akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1010
 
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) : x(x),y(y) {}
};
 
int N,X,Y;
vector<int> G[MAX];
 
double getDist(Point &a,Point &b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
void init(){
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
  }  
}
 
void solve(){
  int d[MAX] = {0};
  queue<int> Q; Q.push(0);
  bool can = true;
  
  while(!Q.empty()){
    int v = Q.front(); Q.pop();
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(d[to] == 0){
        d[to] = d[v] + 1;
        if(v > 0 && X > Y){ can = false; }
        Q.push(to);
      }
    }
  }
  
  if(can){
    cout << *max_element(d+1,d+N+1)*X << endl;
  }else{
    cout << "You're always welcome!" << endl;
  }
}
 
int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    init();
    Point sp;
    vector<Point> p;
    cin >> N >> X >> Y;
    cin >> sp.x >> sp.y;
    p.resize(N);
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].x >> p[i].y;
      if(getDist(sp,p[i]) <= 10){
        G[0].push_back(i+1);
      }
    }
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j){ continue; }
        if(getDist(p[i],p[j]) <= 50){
          G[i+1].push_back(j+1);
        }
      }
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)


int A,B;

int main(){
  cin >> A >> B;
  if(A == 1) A = 14;
  if(B == 1) B = 14;

  if(A == B){
    cout << "Draw" << endl;
  }
  if(A > B){
    cout << "Alice" << endl;
  }
  if(A < B){
    cout << "Bob" << endl;
  }
}


Measured memory_bytes: 256
n,a,b = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

cost = 0
last = x[0]

(1...n).each{|i|
    if (x[i]-last)*a < b
        cost += (x[i]-last)*a
    else
        cost += b
    end
    last = x[i]
}

p cost


Measured memory_bytes: 8452
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  var(i64, a, b, c);
  outl(min(c, b / a));

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

int gcd(int a, int b)
{
    if(b==0) return a;
    return gcd(b, a%b);
}
int n, a[N], b[N], pw[N], cnt=1, a0=0, b0=0, ab0=0;
map<pii, int> st;
set<pii> done;
vector<pii> v;
signed main()
{
    pw[0]=1;
    for(int i = 1; i < N; i++)
    {
        pw[i] = (pw[i-1]*2)%MOD1;
    }
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        if(a[i]==0 && b[i]==0)
        {
            ab0++;
            continue;
        }
        if(a[i]==0)
        {
            a0++;
            continue;
        }
        if(b[i]==0)
        {
            b0++;
            continue;
        }
        int g = gcd(abs(a[i]), abs(b[i]));
        a[i]/=g; b[i]/=g;
        if(a[i]*b[i]>0)
        {
            a[i]=abs(a[i]);
            b[i]=abs(b[i]);
        } else{
            a[i]=-abs(a[i]);
            b[i]=abs(b[i]);
        }
        st[{a[i], b[i]}]++;
    }
    for(auto it: st)
    {
        if(done.find(it.F)!=done.end()) continue;
      //  cout << it.F.F << " " << it.F.S << " - " << it.S << " " << st[{it.F.S, -it.F.F}] << endl;
        v.pb({it.S, st[{it.F.S, -it.F.F}]});
        done.insert({it.F.S, -it.F.F});
    }
    for(auto p: v)
    {
        int mult = (pw[p.F] + pw[p.S]) % MOD1;
        mult = (mult - 1 + MOD1)%MOD1;
   //     cout << mult << endl;
        cnt*=mult;
        cnt%=MOD1;
    }
    //cout << a0 << " " << b0 << endl;
    int zero = (pw[a0] + pw[b0] - 1 + MOD1)%MOD1;
    cnt*=zero;
    cnt%=MOD1;
    cnt = (cnt + ab0 -1 + MOD1)%MOD1;

    cout << cnt;
}

Measured memory_bytes: 48404
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
int a;
  cin>>a;
  vector<string> b(a);
  rep(i,a)
    cin>>b[i];
  map<string,bool> c;
  rep(i,a){
  c[b[i]]=1;
  }
  int g=0;
  rep(i,a){
  if(c[b[i]]){
    g++;
    c[b[i]]=0;
  }
  }
  cout<<g;
}

Measured memory_bytes: 25092
#include <bits/stdc++.h>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0)
	{
		cout << (a + b) / 2;
	}
	else
	{
		cout << (a + b) / 2 + 1;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;
#define int long long
const int N = 666666 , inf = 999999999999999;
struct str{
	int x,y;
}st[N];
int a[N],b[N];

signed main(){
	int n;
	cin>>n;
	int mx=0,nx=inf;
	int res=0;
	for(int i=1;i<=n;i++){
		cin>>st[i].x>>st[i].y;
		a[i]=st[i].x+st[i].y;
		b[i]=st[i].x-st[i].y;
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	cout<<max(-1*a[1]+a[n],-1*b[1]+b[n]);
	return 0;
}

Measured memory_bytes: 9908
import java.util.Scanner;
 
public class Main {
	
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] x = new int[N][D];
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < D; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int count = 0;
		for(int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++) {
				double sum = 0;
				for(int d=0;d<D; d++) {
				int	xd=x[i][d]-x[j][d];
					sum += xd*xd;
					//System.out.println(x[i][d]);
					//System.out.println(x[j][d]);
				}
			
			double dist = Math.sqrt(sum);  //Math.sqrt() 関数は、数値の平方根を返す
			//System.out.println(dist);
			if (dist == Math.floor(dist)) { //distが整数だったら countに+1する
				count++;
			}
			}
		}
		System.out.println(count);
	   
	}
}

Measured memory_bytes: 21716
N=input()
K=int(input())
M=len(N)
dp=[[[0]*(K+1) for i in (0,1)] for j in range(M+1)]
dp[0][0][0]=1

for i in range(M):
   for smaller in (0,1):
      for no_zero_number in range(K+1):
         for x in range(10):
            #print("############")
            #print("i:",i)
            #print("smaller:",bool(smaller))
            #print("no_zero:",no_zero_number)
            #print("x:",x)
            if smaller==0 and x>int(N[i]):
               continue
            if x==0:
               dp[i+1][smaller or x<int(N[i])][no_zero_number]+=dp[i][smaller][no_zero_number]
            else:
               if no_zero_number+1>K:
                  continue
               else:
                  dp[i+1][smaller or x<int(N[i])][no_zero_number+1]+=dp[i][smaller][no_zero_number]
            #print(dp)
#print(dp)
print(dp[M][1][K]+dp[M][0][K])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{
    int n;
    cin >> n;
    map<string , int> m;
    rep(i,n)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;

    cout << "WA x " << m["WA"] << endl;

    cout << "TLE x " << m["TLE"] << endl;

    cout << "RE x " << m["RE"] << endl; 
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;




int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> sum(n + 1);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum[i + 1] = (sum[i] + a);
	}
	map<ll, int>m;
	m[0]++;
	ll cnt = 0;
	for (int i = 1;i <=n;i++) {
		
		if (i >= k) {

			int s1 = (sum[i - k] - (i - k)) % k;
			m[s1]--;
		}
		int s = (sum[i] - i) % k;
		cnt += m[s];
		m[s]++;
		
		
		
	}


	cout << cnt << endl;
}



Measured memory_bytes: 14336
p = [1] * (100000 + 1)
p[0], p[1] = 0, 0
for i in range(2, int(100000 ** 0.5) + 1):
    if not p[i]:
        continue
    for j in range(2 * i, 100000 + 1, i):
        p[j] = 0

while 1:
    try:
        n = int(input())
        bp, ap = 0, 0
        for i in range(n)[::-1]:
            if p[i] == 1:
                bp = i
                break
        for i in range(n+1, 2 * n + 1):
            if p[i] == 1:
                ap = i
                break
        print(bp, ap)
    except:
        break



Measured memory_bytes: 6252
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,len;
int a[100005],f[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	f[++len]=a[1];
	for(int i=2;i<=n;i++){
		if(f[len]>=a[i]) f[++len]=a[i];
		else{
			int l=1,r=len;
			while(l<=r){
				int mid=(l+r)>>1; 
				if(f[mid]>=a[i]) l=mid+1;
				else r=mid-1;
			} 
			f[l]=max(f[l],a[i]);
		}
	}
	printf("%d",len);
	return 0;
} 

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>g;
vector<edge>edges;
//vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000];
string str, ss;
bool f[200][200];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
vector<LL>v[26];
int main() {
	cin >> str;
	cin >> ss;
	rep(i, str.size()) {
		v[str[i] - 'a'].push_back(i);
	}
	rep(i, str.size()) {
		v[str[i] - 'a'].push_back(str.size() + i);
	}
	rep(i, 26)v[i].push_back(INF);
	LL cur = -1;
	for (LL i = 0; i < ss.size(); i++) {
		auto it = lower_bound(v[ss[i]-'a'].begin(), v[ss[i]-'a'].end(), cur+1)-v[ss[i]-'a'].begin();
		if (v[ss[i] - 'a'][it] == INF) {
			cout << -1 << endl;
			return 0;
		}
		ans += v[ss[i] - 'a'][it] - cur;
		cur = v[ss[i] - 'a'][it] % str.size();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2800
n = int(input())
xy = [[int(item) for item in input().split()] + [i] for i in range(n)]
xsort = sorted(xy, key=lambda x : x[0])
ysort = sorted(xy, key=lambda x : x[1])

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1] * (n)
        self.rank = [0] * (n)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

edge = []
for i in range(1, n):
    xdif = abs(xsort[i-1][0] - xsort[i][0])
    ydif = abs(ysort[i-1][1] - ysort[i][1])
    edge.append([xsort[i-1][2], xsort[i][2], xdif])
    edge.append([ysort[i-1][2], ysort[i][2], ydif])
edge.sort(key=lambda x : x[2])

UF = UnionFind(n)
cost = 0
for e in edge:
    if not UF.same_check(e[0], e[1]):
        UF.union(e[0], e[1])
        cost += e[2]

print(cost)

Measured memory_bytes: 58628
#include<bits/stdc++.h>
using namespace std;
int p[200][200];
main()
{
	int m,n;
    scanf("%d%d",&m,&n);
    if(abs(m-n)<=1)
    printf("Brown");
    else
    printf("Alice");
    // for(int is = 0;is <= 30;is++)
    // {
    //     for(int j = is;j >= 0;j--)
    //     {
    //         int i=is-j;
    //         int ck=0;
    //         if(i==2 && j==0)
    //         {}
    //         printf("%d %d\n",i,j);
    //         if(i <= 1 && j <= 1 && (i!=j || j==0))
    //         {
    //             //printf("%d %d\n",i,j);
    //             p[i][j]=1;
    //             continue;
    //         }
    //         else
    //         {
    //             for(int ii = 1;ii*2 <= i;ii++)
    //             {
    //                 ck=max(ck,p[i-2*ii][j+ii]);
    //             }
    //             for(int jj = 1;jj*2 <= j;jj++)
    //             {
    //                 //if(i==2 && j==0)
    //                 //printf("%d %d\n")
    //                 ck=max(ck,p[i+jj][j-2*jj]);
    //             }
    //         }
    //         if(ck==0)
    //         p[i][j]=1;
    //         else
    //         p[i][j]=0;
    //     }
    // }
    // for(int i = 0;i <= 30;i++)
    // {
    //     for(int j = 0;j <= 30;j++)
    //     {
    //         if(p[i][j]==1)
    //         printf("P ");
    //         else
    //         printf("N ");
    //     }
    //     printf("\n");
    // }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
using namespace std;
int main(){
    int N;  cin>>N;
    for(int i=0;i<=N/4;++i){
        if((N-i*4)%7==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(int(a*b))
    elif op=='/':
        print(int(a/b))
    elif op=='?':
        break
    else:
        break
    



Measured memory_bytes: 5596
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const int MOD=1e9+7;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

map<int, int> mp;

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) {
    int x; cin >> x;
    mp[x] = i+1;
  }

  for(auto &e: mp) cout << e.second << " ";  
  cout << endl;
  return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  
  string S;
  cin >> S;

  if(S.at(K-1)=='A'){
    S.at(K-1)='a';
  }
  if(S.at(K-1)=='B'){
    S.at(K-1)='b';
  }
  if(S.at(K-1)=='C'){
    S.at(K-1)='c';
  } 
  cout << S << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int res = 0;
    if(2 * c < a + b){
        res = min(2 * c * min(x,y) + a * (x - min(x,y)) + b * (y - min(x,y)), 2 * c * max(x,y));
    }else{
        res = a * x + b * y;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int dp[100002];

int main() {

    int n;

    cin >> n;

    int a,b;

    for(int i=0;i<n;i++){
        cin >> a >> b;
        for(int j=a;j<=b;j++){
            dp[j]++;
        }
    }

    int ans = 0;

    for(int i=2;i<=100001;i++){
        if(dp[i]>=i-1) {
            ans = i-1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3396
#include <stdio.h>

void p(int A[], int n){
    int i;
    for (i = 0; i < n; i++) {
        if (i != 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}

int main(){
    int n, A[100], i, j, swap, c;
    scanf("%d", &n);
    for (i = 0; i < n;i++) scanf("%d", A + i);
    for (i = 1; i < n; i++) {
        j = n;
        while (i < j--) {
            if (A[j] < A[j - 1]) {
                swap = A[j];
                A[j] = A[j - 1];
                A[j - 1] = swap;
                c++;
            }
        }
    }
    p(A, n);
    printf("%d\n", c);
    
    return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int main(void){
	int rectangle=0, diamond=0, in[3];
	while(scanf("%d,%d,%d",&in[0],&in[1],&in[2])==3){
		if(in[0]==in[1]) diamond++;
		if(in[0]*in[0]+in[1]*in[1]==in[2]*in[2]) rectangle++;
	}
	printf("%d\n%d\n",rectangle,diamond);
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
)

const Inf = math.MaxInt64 / 10

func main() {
	N := ReadInt()
	a := ReadInts(3 * N)

	sum := 0
	h := Heap{}
	leftSum := make([]int, 3*N)
	for i := 0; i < 3*N; i++ {
		h.push(a[i])
		sum += a[i]
		if len(h) > N {
			sum -= h.pop()
		}
		if len(h) == N {
			leftSum[i] = sum
		} else {
			leftSum[i] = -Inf
		}
	}

	sum = 0
	h = Heap{}
	rightSum := make([]int, 3*N)
	for i := 3*N - 1; i >= 0; i-- {
		h.push(-a[i])
		sum += a[i]
		if len(h) > N {
			sum -= -h.pop()
		}
		if len(h) == N {
			rightSum[i] = sum
		} else {
			rightSum[i] = Inf
		}
	}

	ans := -Inf * 5
	for i := 0; i < 3*N-1; i++ {
		ans = Max(ans, leftSum[i]-rightSum[i+1])
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

type HeapElement = int
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i] < h[j] }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 17152
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int P = 700;
		for(var i=0;i<=2;i++){
			if(str.Substring(i,1) == "o"){
				P += 100;
			}
		}
		Console.WriteLine(P);
	}
}

Measured memory_bytes: 11092
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = A[0] * A[1]

if len(A) > 2:
    for k in A[2:]:
        lcm_a = lcm_a * k

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007








int main()
{	
	
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n=Int,x=Int;
    int arr[n+1];
    For(n)arr[i]=Int;
    int cnt=1,ans=0;
    for(int i=0;i<n;i++)
    {
    	ans=ans+arr[i];
    	if(ans<=x) cnt++;
    }
    cout<<cnt<<endl;
    
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

long long x;
long long now = 100;

int main(){
	cin >> x;
	int cnt = 0;
	while(now < x){
		now = (long long)(1.01 * now);
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

#define N_MAX 201010
ll f[N_MAX],rf[N_MAX];

ll pow(ll x,ll n){  // xのn乗 (mod m)
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }else{
            res = (((res * res) % mod) * x) % mod;
        }
    }
    return res;
}

void init(){
    f[0] = 1;
    for(int i = 1; i < N_MAX; i++){
        f[i] = (i * f[i-1]) % mod;
    }
    for(int i = 0; i < N_MAX; i++){
        rf[i] = pow(f[i],mod-2);
    }
}

ll com(ll n, ll k){
    ll a = f[n];
    ll b = rf[k];
    ll c = rf[n-k];

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main()
{
    ll n,k; cin >> n >> k;
    init();
    for(int i = 1; i <= k; i++){
        ll ans;
        if(n-k+1 >= i){
            ans = com(n-k+1,i) * com(k-1,i-1);
        }else{
            ans = 0;
        }
        ans %= mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

using ll = long long;

static const int MAX = 100000;
vector<vector<int>> G;
int color[MAX];

void input_graph(int m) {
    int s, t;
    rep(i, m) {
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
}

void init_graph(int n) {
    rep(i, n) {
        vector<int> vec;
        G.push_back(vec);
    }
}
void bfs(int s, int color_id) {
    queue<int> que;
    que.push(s);
    color[s] = color_id;
    while(que.size() > 0) {
        int u = que.front();
        que.pop();
        rep(i, G[u].size()) {
            int v = G[u][i];
            if(color[v] == -1) {
                que.push(v);
                color[v] = color_id;
            }
        }
    }
}

void color_assign(int n) {
    int color_id = 1;
    rep(i, n) { color[i] = -1; }
    rep(i, n) {
        if(color[i] == -1) {
            bfs(i, color_id++);
        }
    }
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, m, q, s, t;
    cin >> n >> m;
    init_graph(n);
    input_graph(m);
    color_assign(n);
    cin >> q;
    rep(i, q) {
        scanf("%d %d", &s, &t);
        if(color[s] == color[t]) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }
}


Measured memory_bytes: 8684
l, r = map(int, input().split())

minVal = -1
for i in range(l, r):
    for j in range(i+1, r+1):
        modVal = (i * j) % 2019
        if minVal == -1 or minVal > modVal:
            minVal = modVal
            if minVal == 0:
                break
    if minVal == 0:
        break
print(minVal)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e9+7;
int S,ans;
int len(int x){
	return (int)log10(x)+1;
}
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(ll)x*x%M)
		if (y&1)ans=(ll)ans*x%M;
	return ans;
}
signed main(){
	scanf("%d",&S);
	int sum=0;long long ans=0;
	for (int i=1,j=1;i<1e7;i++){
		if (i!=1)sum-=len(i-1);
		while (sum<S)sum+=len(j),j++;
		if (sum==S)ans++;
	}
	for (int i=8,nowcnt=90000000;i<=S;i++,nowcnt=10ll*nowcnt%M)
		ans+=(S-1)/i-S/(i+1);
	for (int i=1;i*i<=S;i++)
		if (S%i==0){
			if (i>7)ans+=9ll*ksm(10,i-1)-S/i+1;
			if (i*i!=S&&S/i>7)ans+=9ll*ksm(10,S/i-1)-i+1;
		}
	printf("%lld\n",(ans%M+M)%M);
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
n,t = list(map(int, input().split(' ')))

cost = 1001
for i in range(n):
    c,ti = list(map(int, input().split(' ')))
    if ti <= t:
        cost = min(cost, c)

if cost > 1000:
    print('TLE')
else:
    print(cost)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;

int main(){
    int N;
    cin>>N;
    int k=0;
    int C[N-1],S[N-1],F[N-1];
    for(int i=0;i<N-1;i++){
        cin>>C[i]>>S[i]>>F[i];
    }
    while(k<N-1){
        int t=0;
        for(int j=k;j<N-1;j++){
            if(S[j]>t){
                t=S[j];
            }else if(t%F[j]==0){

            }else{
                t = t+F[j]-t%F[j];
            }
            t+=C[j];
        }
        cout<<t<<endl;
        k++;
    }
    cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
        int x, y;
        cin >> x >> y;
        if (x < y)
                swap(x, y);
        while (y > 0) {
                int d = x % y;
                x = y;
                y = d;
        }
        cout << x << endl;
        return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a,b,c,d;
	int total,m,s;

	cin >> a >> b >> c >> d;
	
	total = a + b + c + d;
	
	m = total / 60;
	s = total - (m * 60);

	printf("%d\n%d\n",m,s);

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;

int N, W;
int w[102], v[102];
long long dp[102][100005];

long long dfs(int pos, int can) {
	if(dp[pos][can]) return dp[pos][can];
	if(pos == N+1) return dp[pos][can] = 0;
	else if(can < w[pos]) return dp[pos][can] = dfs(pos+1, can);
	else return dp[pos][can] = max(dfs(pos+1, can), dfs(pos+1, can-w[pos])+v[pos]);
}

int main() {
	scanf("%d %d", &N, &W);
	for(int i = 1;i <= N; i++) {
		scanf("%d %d", &w[i], &v[i]);
	}
	printf("%lld\n", dfs(1, W));
}

Measured memory_bytes: 75776
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  int K[M], S[M][N]; bool P[M];
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> S[i][j]; S[i][j]--;
    }
  }
  for (int i = 0; i < M; i++) cin >> P[i];
  int count = 0;
  for (int s = 0; s < (1<<N); s++) {
    bool allOn = true;
    for (int i = 0; i < M; i++) {
      bool isOn = !P[i];
      for (int j = 0; j < K[i]; j++) {
        if ((s >> S[i][j]) & 1) isOn = !isOn;
      }
      if (!isOn) allOn = false;
    }
    if (allOn) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  cout << max((ll)0, a - k) << " " << 
    (a - k >= (ll)0 ? b : max((ll)0, a + b - k)) << endl;
}

Measured memory_bytes: 3540
import * as fs from 'fs';

//in
//
//out
//
const main = (inp: string) => {
    const weather: { [s: string]: string } = {
        Sunny: 'Cloudy',
        Cloudy: 'Rainy',
        Rainy: 'Sunny'
    };

    console.log(weather[inp]);

};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    string s; cin >> s;
    vector<int> a(4);
    vector<char> op(3);
    rep(i, 4) a[i] = s[i] - '0';

    for(int bit=0; bit<(1<<3); bit++){
        int count = a[0];
        for(int i=0; i<3; i++){
        if(bit &(1<<i)){op[i]='+'; count+=a[i+1];}
        else {op[i]='-'; count-=a[i+1];}
        }
        if(count==7) break;
    }

    cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {  
  int a = 0, b = 0, x = 0, r = 0;  
  cin >> a >> b;
  r = (a + b) % 2;
  x = (a + b) / 2 + r;
  cout << x << endl;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  long double a;
  cin >> a;
  cout << 2.0*a*3.14159265358979;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (k >= a) {
        cout << 0 << " " << ((b - (k - a)) <= 0 ? 0 : (b - (k - a)));
    } else {
        cout << a - k << " " << b;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; (i) < ((int)(n)); ++(i))
const ll MOD = 1000000007;
int main() {
    ll ans = 1;
    int N, K;
    cin >> N >> K;
    vector<ll> pos, neg;
    rep(i, N) {
        ll x;
        cin >> x;
        if(x >= 0)
            pos.push_back(x);
        else
            neg.push_back(x);
    }
    sort(pos.begin(), pos.end(), greater<ll>());
    sort(neg.begin(), neg.end());
    int p = pos.size(), n = neg.size();
    if(n == 0) {
        rep(i, K) ans = (ans * pos[i]) % MOD;
    } else if(p == 0) {
        if(K % 2 == 0)
            rep(i, K) ans = (ans * neg[i]) % MOD;
        else {
            rep(i, K) ans = (ans * neg[N - 1 - i]) % MOD;
            ans = (ans + MOD) % MOD;
        }
    } else if(K == N) {
        rep(i, p) ans = (ans * pos[i]) % MOD;
        rep(i, n) ans = (ans * neg[i]) % MOD;
        ans = (ans + MOD) % MOD;
    } else {
        int count = 0;
        int i = 0, j = 0;
        while(count < K) {
            if(i < p - 1 && j < n - 1) {
                ll x = pos[i] * pos[i + 1];
                ll y = neg[j] * neg[j + 1];
                if(x > y || count == K - 1) {
                    ans = (ans * pos[i]) % MOD;
                    count++;
                    i++;
                } else {
                    ans = (ans * (y % MOD) % MOD) % MOD;
                    j += 2;
                    count += 2;
                }
            } else if(j == n - 1) {
                ans = (ans * pos[i]) % MOD;
                count++;
                i++;
            } else {
                if(count < K - 1) {
                    ans = (ans * (neg[j] * neg[j + 1] % MOD) % MOD) % MOD;
                    j += 2;
                    count += 2;
                } else {
                    ans = (ans * pos[i]) % MOD;
                    count++;
                    i++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5508
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,m;
  cin >> n>>m;
  
  int ac = 0;
  int wa = 0;
  vector<bool> p(n,false);
  vector<int> q(n,0);
  
  rep(i,m){
  int x;
  string s;
  cin>>x>>s;
    if(!p[x-1]){
      if(s=="AC") {
      ac++;
      wa+=q[x-1];
      p[x-1]=true;
      }
      if(s=="WA") {
      q[x-1]++;
      }
    }
  }
  
  cout << ac << " " << wa << endl;
  
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

/*
const int MAX=1000;
vector<vector<int> > memo(MAX,vector<int>(MAX));
vector<vector<int> > done(MAX,vector<int>(MAX));
int dfs(vector<vector<int> > vi,int i,int j,int sum);

int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int m,n;
	while(cin>>m>>n&&m!=0&&n!=0){
		vector<vector<int> > ice(m,vector<int>(n));
		int ans=0;
		for(int i=0; i<MAX; ++i){
			for(int j=0; j<MAX; ++j){
				memo[i][j]=0;
				done[i][j]=0;
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				cin >> ice[j][i];
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				if(ice[i][j]==1) {
					ans=max(ans,dfs(ice,i,j,0));
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

int dfs(vector<vector<int> > vi,int i,int j,int sum){
	if(done[i][j]==1) return memo[i][j];
	if(i+1>=vi.size()&&j+1>=vi[i].size()&&i-1<0&&j-1<0&&vi[i+1][j]==0&&vi[i][j+1]==0&&vi[i-1][j]==0&&vi[i][j-1]==0) return sum;
	done[i][j]=1;
	++sum;
	if(i+1<vi.size()) memo[i][j]=dfs(vi,i+1,j,sum+1);
	if(j+1<vi[i].size()) memo[i][j]=dfs(vi,i,j+1,sum+1);
	if(i-1>=0) memo[i][j]=dfs(vi,i-1,j,sum+1);
	if(j-1>=0) memo[i][j]=dfs(vi,i,j-1,sum+1);
	return memo[i][j]; 
}
*/

int main(){
	int n;
	vector<int> memo;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		a[i]=t;
	}

	if(n==2){
		for(int i=1; i<=min(a[0],a[1]); ++i){
			if(a[0]%i==0&&a[1]%i==0) memo.push_back(i);
		}
	} else if(n==3){
		for(int i=1; i<=min(a[0],min(a[1],a[2])); ++i){
			if(a[0]%i==0&&a[1]%i==0&&a[2]%i==0) memo.push_back(i);
		}
	}

	for(unsigned int i=0; i<memo.size(); ++i){
		cout << memo[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1216
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
s=int(input())
print(a[s-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, ans=0;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i=0; i<N; i++) {
    cin >> A[i];
  }
  vector<int64_t> B(N);
  B[0]=0;
  for (int64_t i=1; i<N; i++) {
    if (A[i]>=A[i-1]+B[i-1]) {
      B[i]=0;
    }
    else {
      B[i]=A[i-1]+B[i-1]-A[i];
    }
  }
  for (int64_t i=0; i<N; i++) {
    ans=ans+B[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  string N;
  int A,B;
  cin>>N>>A>>B;
  int count=0;
  int n=stoi(N);
  for(int i=1;i<n+1;i++){
    int num=0;
    string NN=to_string(i);
    for(int j=0;j<NN.size();j++){
        num+=(NN.at(j)-'0');
    }
    if(num>=A&&num<=B){
      count+=i;
    }
  }
  cout<<count<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	for(int64 ii = 1;ii < 50000;ii++)
	{
		if(nn < (int64)((long double)ii * 1.08))
		{
			puts(":(");
			return 0;
		}
		else if(nn == (int64)((long double)ii * 1.08))
		{
			cout << ii << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
// Mujhe jod mat kisi aur ke usool se .. Hype Game
// Baat karun sirf apne liye, Aur mujhe maharani se nafrat hai
// Hm intezaar kre , hmpe nahi janchta... 

#include<bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll                  long long
#define all(x)              x.begin(), x.end()
#define le(x)               cout << #x << ' ' << x << '\n'
#define lex(a, n)           cout << #a << " : "; loop(i, 0, n) cout << a[i] << ' '; xd
#define xd                  cout << '\n'
#define fi                  first
#define se                  second
#define pb                  push_back
#define vl                  vector<ll> 
#define show(x)             cout << #x << " : "; for(auto i : x) cout << i << ' '; xd
#define Google              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Trip()              Google;  int T; cin >> T; while(T-- )
#define fl(i, a, b)       for(int i = a; i < b; ++i )
#define rep(i, b, a)        for(int i = b - 1; i >= a; --i)

const ll N = 1e7, M = 1e9+7ll, inf = M;

int main()
{
        Google;
        int n; cin >> n;
        vector<int> a(n, 0);
        fl(i, 0, n) cin >> a[i];        
        //Op Task -> try to obtain lics dp
        int c = 0 ;
        for(int i = 0; i < n; ++i ) 
            if( a[i] == (c + 1)) 
                c++ ;
        cout << (c ? n - c : -1);

        


}
/*
// set<int> s;
        // fl(i, 0, n) {
        //     cin >> a[i];
        //     if(a[i] == 1) 
        //         s.insert(1);
        // }
        // if(s.empty())
        //     return cout << -1, 0;
        // fl(i, 0, n) {
        //     if(a[i] == *s.rbegin() + 1) 
        //         s.insert(a[i]);
        // }
        // cout << n - s.size() << " ";
   10
    3 1 4 1 5 9 2 6 5 3     
    ispe lis 3 4 5 9 aagaya to problem.
// vector<int> lis(vector<int> const& a) {
//     int n = a.size();
//     vector<int> d(n, 1), p(n, -1);
//     for (int i = 0; i < n; i++) {
//         for (int j = 0; j < i; j++) {
//             if (a[j] < a[i] && d[i] < d[j] + 1) {
//                 d[i] = d[j] + 1;
//                 p[i] = j;
//             }
//         }
//     }

//     int ans = d[0], pos = 0;
//     for (int i = 1; i < n; i++) {
//         if (d[i] > ans) {
//             ans = d[i];
//             pos = i;
//         }
//     }

//     vector<int> subseq;
//     while (pos != -1) {
//         subseq.push_back(a[pos]);
//         pos = p[pos];
//     }
//     reverse(subseq.begin(), subseq.end());
//     return subseq;
// }

*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

vector<int> v[100010];
bool vis[100010];
int ans, n, m, dist[100010];

int dfs(int u)
{
    vis[u] = 1;
    int sum = 1, maxv = 0;
    for (int i = 0; i < v[u].size(); i++)
    {
        int val;
        if (dist[v[u][i]] == 0)
            val = dfs(v[u][i]);
        else
            val = dist[v[u][i]];
        maxv = max(maxv, val);
    }
    sum += maxv;
    dist[u] = sum;
    return sum;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    for (int i = 1; i <= n; i++)
    {
        if (!vis[i])
        {
            ans = max(ans, dfs(i));
        }
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	string s;
	cin >> s;
	ll a = 0, b = 0;
	rep(i, s.size()) {
		if (s[i] == '0') ++a;
		else ++b;
	}
	cout << min(a, b) * 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;

int main(){
  int X;
  cin>>X;
  if(X>=400&&X<=599){
    cout<<"8"<<endl;
  }
  else if(X>=600&&X<=799){
    cout<<"7"<<endl;
  }
  else if(X>=800&&X<=999){
    cout<<"6"<<endl;
  }
  else if(X>=1000&&X<=1199){
    cout<<"5"<<endl;
  }
  else if(X>=1200&&X<=1399){
    cout<<"4"<<endl;
  }
  else if(X>=1400&&X<=1599){
    cout<<"3"<<endl;
  }
  else if(X>=1600&&X<=1799){
    cout<<"2"<<endl;
  }
  else{
    cout<<"1"<<endl;
  }
}

Measured memory_bytes: 3612
import java.util.Scanner;
     
    public class Main {
      public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();

        System.out.println(A.substring(0, 1).toUpperCase() + B.substring(0, 1).toUpperCase() + C.substring(0, 1).toUpperCase());
      }
    }


Measured memory_bytes: 39324