akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>
//#include <fstream>

using namespace std;

typedef complex<int> xy_t;

int main()
{
//    ifstream fin("input.txt");

    while(1){
        int n;
        cin >> n;
        if(n == 0)break;

        int sample_m;
        cin >> sample_m;
//        scanf("%d", &sample_m);
        vector<vector<xy_t> > sample(8);
        for(int i = 0; i < 8; i++){
            sample[i].resize(sample_m);
        }
        for(int i = 0; i < sample_m; i++){
            // cin >> sample[0][i].real();
            // cin >> sample[0][i].imag();
            int x, y;
            cin >> x >> y;
            sample[0][i] = xy_t(x, y);
//            scanf("%d %d", &sample[0][i].real(), &samle[0][i].imag());
        }

        for(int j = 0; j < sample_m; j++){
            sample[4][j] = sample[0][sample_m-j-1];
        }
        


        for(int i = 1; i < sample_m; i++){
            sample[0][i] -= sample[0][0];
        }
        sample[0][0] = xy_t(0,0);

        for(int i = 1; i < sample_m; i++){
            sample[4][i] -= sample[4][0];
        }
        sample[4][0] = xy_t(0,0);
        


        for(int i = 1; i < 4; i++){
            for(int j = 0; j < sample_m; j++){
                sample[i][j] = sample[i-1][j] * xy_t(0, 1);
            }
        }
        for(int i = 1; i < 4; i++){
            for(int j = 0; j < sample_m; j++){
                sample[i+4][j] = sample[i+3][j] * xy_t(0, 1);
            }
        }
            // cout << "debug" << endl;
            // for(int j = 0; j < sample_m; j++){
            //     cout << sample[i][j].real() << " " << sample[i][j].imag() << endl;
            // }



        vector<int> m(n);
        vector<vector<xy_t> > points(n);
        for(int i = 0; i < n; i++){
            cin >> m[i];
            // scanf("%d", &m[i]);
            points[i].resize(m[i]);
            
            for(int j = 0; j < m[i]; j++){
                // cin >> points[i][j].real();
                // cin >> points[i][j].imag();
                int x, y;
                cin >> x >> y;
                points[i][j] = xy_t(x, y);
                // scanf("%d %d", &points[i][j].real(), &points[i][j].imag());
            }
            
            for(int j = 1; j < m[i]; j++){
                points[i][j] -= points[i][0];
            }
            points[i][0] = xy_t(0,0);
        }


        for(int i = 0; i < n; i++){
            if(m[i] == sample_m){
                vector<bool> flag(8, true);
                for(int j = 0; j < 8; j++){
                    for(int k = 0; k < m[i]; k++){
                        if(sample[j][k] != points[i][k]){
                            flag[j] = false;
                            break;
                        }
                    }
                }
                bool final_flag = false;
                for(int k = 0; k < 8; k++){
                    final_flag = final_flag || flag[k];
                }
                if(final_flag)cout << i+1 << endl;
            }
        }

        cout << "+++++" << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 155

int N;
ll A,B;

struct Info{
	ll nut_value,sweet_value;
};
Info info[NUM];
ll sweet_sum;
ll dp[NUM][NUM];

ll get_max(int index, ll diff){

	ll ret = 0;

	ll left = 0,right = sweet_sum,mid = (left+right)/2;

	while(left <= right){

		if(dp[index][mid] <= diff){

			ret = mid;
			left = mid+1;
		}else{
			right = mid-1;
		}
		mid = (left+right)/2;
	}

	return ret;
}

bool can_get(int index,ll diff,ll tmp_sweet_sum){

	ll eat_value = sweet_sum-get_max(index+1,-(diff+info[index].nut_value));
	ll not_value;

	if(diff > 0){

		not_value = get_max(index+1,diff-1-info[index].nut_value);

	}else{

		not_value = 0;
	}

	return tmp_sweet_sum <= max(0ll,max(eat_value,not_value));
}


int main(){

	scanf("%d %lld %lld",&N,&A,&B);

	sweet_sum = 0;

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&info[i].nut_value,&info[i].sweet_value);
		sweet_sum += info[i].sweet_value;
	}

	for(int i = 0; i <= N; i++){
		dp[i][0] = 0;
		for(int k = 1; k <= sweet_sum; k++){
			dp[i][k] = HUGE_NUM;
		}
	}

	sweet_sum = 0;
	ll left,right,mid,min_diff;

	for(int i = N-1; i >= 0; i--){

		sweet_sum += info[i].sweet_value;

		for(int tmp_sweet = 0; tmp_sweet <= sweet_sum; tmp_sweet++){

			left= -HUGE_NUM,right = HUGE_NUM,mid = (left+right)/2;
			min_diff = HUGE_NUM;

			while(left <= right){
				if(can_get(i,mid,tmp_sweet)){

					min_diff = mid;
					right = mid-1;

				}else{

					left = mid+1;
				}
				mid = (left+right)/2;
			}
			dp[i][tmp_sweet] = min_diff;
		}
	}

	ll ans_A = get_max(0,A-B);
	ll ans_B = sweet_sum-ans_A;

	printf("%lld %lld\n",ans_A,ans_B);

	return 0;
}



Measured memory_bytes: 3408
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stdio.h>

using namespace std;
int main(void)
{
    char sa[100];
    char sb[100];
    char sc[100];

    cin >> sa;
    cin >> sb;
    cin >> sc;

    char *ia = sa;
    char *ib = sb;
    char *ic = sc;

    char x;
    x = ia[0];
    ia++;

    char ans = 'a';
    while(1) {
        switch (x) {
            case 'a' :
                ans = 'a';
                x = *ia;
                if (x == '\0') {
                    break;
                }
                ia++;
                break;
            case 'b' :
                ans = 'b';
                x = *ib;
                if (x == '\0') {
                    break;
                }
                ib++;
                break;
            case 'c' :
                ans = 'c';
                x = *ic;
                if (x == '\0') {
                    break;
                }
                ic++;
                break;
        }
        if (x == '\0') {
            break;
        }
    }

    printf("%c\n", toupper(ans));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int A[101] = {};
int area[101] = {};
int sum1,sum2,i;
int main(){
    int N,M,X;
    cin >> N >> M >> X;
    for(i = 0;i < M;i++){
        cin >> A[i];
        area[A[i]] = 1;
    }
    sum1 = 0;
    sum2 = 0;
    for(i = X; i >= 0;i--){
        sum1 += area[i];
    }
    for(i = X; i < N; i++){
        sum2 += area[i];
    }
    if(sum1 <= sum2){
        cout << sum1 << endl;
    }else{
        cout << sum2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1505;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = (x > y) ? x : y; }
template <typename T> void chkmin(T &x, T y) {x = (x < y) ? x : y; } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN][MAXN];
short l[MAXN][MAXN], r[MAXN][MAXN];
int n, a[MAXN][MAXN], res[MAXN][MAXN];
int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= n; j++)
			if (s[i][j] == '#') a[i][j] = 0;
			else a[i][j] = s[i][j] - '0';
	}
	ll finalans = 0;
	for (int i = n; i >= 1; i--)
	for (int j = n; j >= 1; j--) {
		if (a[i][j] != 0) {
			if (a[i + 1][j] == 0 && a[i][j + 1] == 0) l[j][i] = r[j][i] = j;
			else if (a[i + 1][j] == 0) {
				for (int k = i; k <= n; k++) {
					l[j][k] = l[j + 1][k];
					r[j][k] = r[j + 1][k];
				} l[j][i] = j;
				res[i][j] = res[i][j + 1];
			} else if (a[i][j + 1] == 0) {
				l[j][i] = r[j][i] = j;
				res[i][j] = res[i + 1][j];
			} else {
				short Max = 0; int ans = res[i + 1][j] + res[i][j + 1];
				l[j][i] = j, r[j][i] = r[j + 1][i];
				for (int k = i + 1; k <= n; k++) {
					if (r[j][k] >= l[j + 1][k] && l[j + 1][k] > Max) ans -= res[k][l[j + 1][k]];
					chkmax(Max, r[j][k]);
					chkmax(r[j][k], r[j + 1][k]);
					chkmin(l[j][k], l[j + 1][k]);
				}
				res[i][j] = ans;
			}
			finalans += a[i][j] * res[i][j];
			res[i][j] += a[i][j];
		} else {
			memset(l[j] + i, 0x3f, sizeof(short) * (n - i + 1));
			memset(r[j] + i, 0, sizeof(short) * (n - i + 1));
		}
	}
	cout << finalans << endl;
	return 0;
}

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

using namespace std;

const int INF = 0x3f3f3f3f;

template <class T>
struct Dinic {
  static const int MAXV = 20100;
  struct Edge {
    int v;
    T f;
    int re;
    Edge(int _v, T _f, int _re) : v(_v), f(_f), re(_re) {}
  };
  int n, s, t, level[MAXV];
  vector<Edge> E[MAXV];
  int now[MAXV];
  Dinic(int _n, int _s, int _t) : n(_n), s(_s), t(_t) {}
  void add_edge(int u, int v, T f, bool bidirectional = false) {
    E[u].emplace_back(v, f, E[v].size());
    E[v].emplace_back(u, 0, E[u].size() - 1);
    if (bidirectional) {
      E[v].emplace_back(u, f, E[u].size() - 1);
    }
  }
  bool BFS() {
    memset(level, -1, sizeof(level));
    queue<int> que;
    que.emplace(s);
    level[s] = 0;
    while (not que.empty()) {
      int u = que.front();
      que.pop();
      for (auto it : E[u]) {
        if (it.f > 0 and level[it.v] == -1) {
          level[it.v] = level[u] + 1;
          que.emplace(it.v);
        }
      }
    }
    return level[t] != -1;
  }
  T DFS(int u, T nf) {
    if (u == t) return nf;
    T res = 0;
    while (now[u] < E[u].size()) {
      Edge &it = E[u][now[u]];
      if (it.f > 0 and level[it.v] == level[u] + 1) {
        T tf = DFS(it.v, min(nf, it.f));
        res += tf;
        nf -= tf;
        it.f -= tf;
        E[it.v][it.re].f += tf;
        if (nf == 0) return res;
      } else
        ++now[u];
    }
    if (not res) level[u] = -1;
    return res;
  }
  T flow(T res = 0) {
    while (BFS()) {
      T temp;
      memset(now, 0, sizeof(now));
      while (temp = DFS(s, INF)) {
        res += temp;
        res = min(res, INF);
      }
    }
    return res;
  }
};

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> g(h);
	for (int i = 0; i < h; i++) {
		cin >> g[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (g[i][j] == 'X' && (i == 0 || j == 0 || i == h - 1 || j == w - 1)) {
				cout << "-1\n";
				return 0;
			}
		}
	}
	
	int num = 2 * h * w;
	int inf = 1000;
	const int dx[] = {1, -1, 0, 0};
	const int dy[] = {0, 0, 1, -1};
	auto inside = [&](int i, int j) {
		return 0 <= i && i < h && 0 <= j && j < w;
	};

	Dinic<int> flow(num + 2, num, num + 1);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int k = 0; k < 4; k++) {
				if (inside(i + dx[k], j + dy[k])) {
					int u = 2 * (i * w + j) + 1;
					int v = 2 * ((i + dx[k]) * w + (j + dy[k]));
					flow.add_edge(u, v, inf);
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int in = 2 * (i * w + j);
			int out = 2 * (i * w + j) + 1;
			if (g[i][j] == 'X') {
				flow.add_edge(num, in, inf);
				flow.add_edge(in, out, inf);
			}
			else {
				flow.add_edge(in, out, 1);
			}
			if (i == 0 || i == h - 1 || j == 0 || j == w - 1) flow.add_edge(out, num + 1, inf);
		}
	}
	
	cout << flow.flow() << '\n';
	
	return 0;
}


Measured memory_bytes: 2944
/* Toggling Cases */
#include <stdio.h>

int main()
{
    char ch;
    while(1){
        scanf("%c", &ch);
        if(ch == '\n'){ break; }
        if('a' <= ch && ch <= 'z' ){
            ch = ch -32;
        }
        else if('A' <= ch && ch <= 'Z' ){
            ch = ch +32;
        }
        printf("%c", ch);
    }
    printf("\n");
}


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

string reversed(string s){
  string ss = s;
  reverse(ss.begin(), ss.end());
  return ss;
}

int main() {
  string s;
  cin >> s;

  if(s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  
  
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll D,N;
  cin>>D>>N;
  if(D==0){
    if(N!=100){
      cout<<N<<endl;
    }
    else{
      cout<<101<<endl;
    }
  }
  else if(D==1){
    if(N!=100){
      cout<<100*N<<endl;
    }
    else{
      cout<<10100<<endl;
    }
  }
  else if(D==2){
    if(N==100){
      N++;
    }
    cout<<10000*N<<endl;
  }
}


Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
long long res;
char a[100][100];
bool b[100][100];
int main(){
	//freopen("RE081_B.inp","r",stdin);
	cin>>n;
	res=1;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int j=1;j<=n;j++)
		for(int i=1;i<=2;i++)
			if(not b[i][j]){
				if (i==1){
					if (a[i][j]==a[i+1][j]){
						b[i][j]=true;
						b[i+1][j]=true;
						if(j-1>0&&a[i][j-1]==a[i+1][j-1]) res=(res*2)%1000000007;
						else if(j-1<=0) res=(res*3)%1000000007;
					}
					else if(a[i][j]==a[i][j+1]){
						b[i][j]=true;
						b[i][j+1]=true;
						if(j==1||a[i][j-1]!=a[i+1][j-1]) res=(res*3)%1000000007;
						else if(j>1) res*=2;
						
						
					}
				}
				else if(i==2){
					b[i][j]=true;
					b[i][j+1]=true;
					if(j==1) res=(res*2)%1000000007;
				}
			}
	cout<<res;
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

vll vx;

void precalc(){
	vx.pb(0);
	ll x=0,s=1;
	while(x<=1000000000000001LL){
		x+=(s*26LL);
		vx.pb(x);
		s*=26LL;
	}
}

void solve(){
	ll n;
	cin>>n;
	auto it = lower_bound(all(vx),n)-vx.begin();
	string ans(it,'a'); int pos = it-1;
	ll aux = n-(vx[it-1]+1);
	while(aux){
		ll xd=(aux%26);
		ans[pos]+=xd;
		--pos;
		aux/=26;
	}
	cout<<ans<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	precalc();
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3672
while True:
    n,m= map(int,input().split())
    if n==0 and m==0:
        break
    hajime= {}
    owari= {}
    for _ in range(n):
        a,b,c= input().split()
        hajime[a]= int(c)- int(b)
        owari[a]= int(c)

    for _ in range(m):
        year= int(input())
        for a in hajime:
            flag= True
            if hajime[a]< year and year<= owari[a]:
                flag= False
                print(a,year- hajime[a])
                break
        if flag:
            print("Unknown")



Measured memory_bytes: 5840
from collections import Counter

values_nr = int(input())
idx___value = [int(x) for x in input().split()]

value_counter = Counter()
for value in idx___value:
    value_counter[value] += 1
    value_counter[value + 1] += 1
    value_counter[value - 1] += 1

print(max(value_counter.values()))


Measured memory_bytes: 19996
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int d[6] = {1,10,100,1000,10000,100000};

int calc(int a, int l)
{
	map<int, int> cnt;
	for (int i = l-1; i>=0; i--) {
		cnt[a / d[i]]++;
		//debug(a/d[i]);
		a %= d[i];
	}
	map<int, int> cmax, cmin;
	cmax = cnt; cmin = cnt;

	int b = 0, c = 0;
	for (int i = l-1; i>=0; i--) {
		for (int j = 9; j>=0; j--) {
			if (cmax[j]) {
				b += j * d[i];
				cmax[j]--;
				break;
			}
		}
	}
	for (int i = l-1; i>=0; i--) {
		rep(j,0,10) {
			if (cmin[j]) {
				c += j * d[i];
				cmin[j]--;
				break;
			}
		}
	}
	//printf("b=%d c=%d\n",b,c);

	return b-c;
}

int main()
{
	while(1) {
		int a, l;
		cin >> a >> l;
		if (!a && !l) break;
		Vi u;
		u.pb(a);
		rep(i,0,20) {
			a = calc(a, l);
			auto it = find(all(u), a);
			if (it == u.end()) {
				u.pb(a);
			} 
			else {
				int j = 0;
				while (1) {
					if (u[j] == a) break;
					j++;
				}
				//for(auto x: u) cout << x << " "; cout << endl;
				cout << j << " " << a << " " << i+1-j << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	
	int n;
	
	while(cin>>n)
	{
		
		string str;
		
		while(n--)
		{
			cin>>str;
			
			if(str=="AC")
				cnt1++;
			else if(str=="WA")
				cnt2++;
			else if(str=="TLE")
				cnt3++;
			else if(str=="RE")
				cnt4++;
		}
		
		cout<<"AC x "<<cnt1<<endl; 
		cout<<"WA x "<<cnt2<<endl;
		cout<<"TLE x "<<cnt3<<endl;
		cout<<"RE x "<<cnt4<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,X;
int L[110];
int main(){
  cin>>N>>X;
  rep(i,N) cin>>L[i];
  int res=0;
  int D=0;
  while(D<=X&&res<N){
    D+=L[res++];
  }
  if(res==N){
    if(D>X) prin(res);
    else prin(++res);
  }
  else prin(res);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (void)
{
  int x,i,j,k,n,ans;
  cin>>x;
  n=1;
  j=0;
  ans=0;
  if(x==1)
  {
    cout<<"1";
    return 0;
  }
  
  for(i=2;i<x;i++)
  {
    while(1)
    {
      if(n<=x)
      {
        n=n*i;
        j++;
      }
      else 
      {
        n=n/i;
      //  cout<<n<<endl;
        if(j>2&&n>ans)
        {
          ans=n;
        }
        n=1;
        j=0;
        break;
      }
    }
    
  }
  
  cout<<ans;

}

Measured memory_bytes: 3524
#include<cstdio>
using namespace std;
#define re register int
int n,m,to[200003],ne[200003],he[100003],tot=1,res,st[100003],ed[100003],du[100003];
bool vis[100003];
inline void rea(re&dd)
{
	dd=0;re ch=getchar();
	while(ch<48||ch>57)ch=getchar();
	while(ch>=48&&ch<=57)dd=(dd<<3)+(dd<<1)+(ch^48),ch=getchar();
}
inline void dfs(re u,re fa)
{
	vis[u]=1;
	for(re i=he[u];i;i=ne[i])
	if(vis[to[i]]&&to[i]!=fa)
	++du[u],st[++res]=u,ed[res]=to[i];
	for(re i=he[u];i;i=ne[i])
	if(!vis[to[i]])dfs(to[i],u);
	if(u==1)return;
	if(du[u]&1)++du[u],st[++res]=u,ed[res]=fa;
	else ++du[fa],st[++res]=fa,ed[res]=u;
}
int main()
{
	rea(n),rea(m);
	if(m&1)return putchar(45),putchar(49),0;
	for(re i=1,u,v;i<=m;++i)
	{
		rea(u),rea(v);
		to[++tot]=v,ne[tot]=he[u],he[u]=tot;
		to[++tot]=u,ne[tot]=he[v],he[v]=tot;
	}
	dfs(1,0);
	for(re i=1;i<=res;++i)printf("%d %d\n",st[i],ed[i]);
 	return 0;
}


Measured memory_bytes: 6784
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,m;
void solve()
{
    cin>>n>>m;ll ar[m];
    for(ll i=0;i<m;i++)
        cin>>ar[i];
    ll dp[m+1];
    dp[0]=0;
    for(int i=1;i<m;i++)
        dp[i]=dp[i-1]+ar[i]-ar[i-1];
    dp[m]=dp[m-1]+ar[0]+n-ar[m-1];
    ans=dp[m-1];
    for(int i=1;i<m;i++)
    {
        ans=min(ans,dp[m]-ar[i]+ar[i-1]);
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  string s; cin >>s;
  int w; cin >>w;
  for (int i=0; i<s.size(); i+=w){
    cout <<s[i];
  }
  cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 60;
const double EPS = 1e-10;

struct edge {
  int from, to, cost;
  edge() {}
  edge(int t, int c) : from(-1), to(t), cost(c) {}
  edge(int f, int t, int c) : from(f), to(t), cost(c) {}
};

edge es[2010];
int dis[1010];
int N, M;

void bellmanford(int s) {
  fill(dis, dis+1010, INF);
  dis[s] = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = 0; j < M; j++) {
      edge e = es[j];
      if (dis[e.from] != INF && dis[e.to] > dis[e.from] + e.cost) {
        dis[e.to] = dis[e.from] + e.cost;
      }
    }
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  REP(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    es[i] = edge(a, b, -c);
  }
  bellmanford(0);
  REP(i, M) {
    edge e = es[i];
    if (dis[e.from] != INF && dis[e.to] > dis[e.from] + e.cost) {
      dis[e.to] = dis[e.from] + e.cost;
      if (e.to == N-1) {
        cout << "inf" << endl;
        return 0;
      }
    }
  }
  cout << -dis[N-1] << endl;

  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import bisect
n,m,k=map(int,input().split())
a=list(accumulate([0]+list(map(int,input().split()))))
b=list(accumulate(list(map(int,input().split()))))
ans=0
for i in range(n+1):
  if a[i]>k:break
  j=bisect.bisect_right(b,k-a[i])
  ans=max(i+j,ans)
print(ans)

Measured memory_bytes: 124120
#include <iostream>
#include <vector>
#include <cmath>

using ll = long long;
#define rep(i,n) for(int i = 0;i < (n);++i)
constexpr ll INF {3000000000000};

ll search(int left, int right, std::vector<std::vector<ll>>& dp, const std::vector<ll>& a, bool is_first) {
  if (dp[left][right] != INF && dp[left][right] != -INF) return dp[left][right];
  if (left == right) {
    if (is_first == true) return a[left];
    else return -a[left];
  }
  if (is_first == true) {
    ll c = a[left] + search(left+1, right, dp, a, false);
    dp[left][right] = std::max(dp[left][right], c);
    c    = a[right] + search(left, right-1, dp, a, false);
    dp[left][right] = std::max(dp[left][right], c);
  } else {
    ll c = - a[left] + search(left+1, right, dp, a, true);
    dp[left][right] = std::min(dp[left][right], c);
    c    = - a[right] + search(left, right-1, dp, a, true);
    dp[left][right] = std::min(dp[left][right], c);
  }
  return dp[left][right];
}

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::vector<ll> a(N);
  rep(i,N) std::cin >> a[i];

  std::vector<std::vector<ll>> dp(N+1, std::vector<ll>(N+1, INF));
  rep(i,N+1) {
    rep(j,N+1) {
      if ((N+i+j) % 2 == 1) {
        dp[i][j] = -INF;
      } else {
        dp[i][j] = INF;
      }
    }
  }
  std::cout << search(0, N-1, dp, a, true) << '\n';
}


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

using namespace std;

int main()
{
    int Tc;
    cin >> Tc;
    while (Tc--) {
        int N;
        cin >> N;
        vector<int> a(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        int mu = 0, md = 0;
        for (int i = 1; i < N; i++) {
            mu = max(mu, a[i] - a[i-1]);
            md = max(md, a[i-1] - a[i]);
        }
        cout << mu << " " << md << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx = INT_MAX;
ll mn = INT_MIN;
ll INF = 1e18+10;
ll MOD = 1e9+7;
const ll maxs = (1<<11);
const ll lg = 22; 
ll fast(ll base , ll expo){ ll res = 1; while(expo>=1){ if(expo%2) res *= base; base *= base; expo /= 2; } return res; }

void init(){
    mx = INT_MIN; mn = INT_MAX; INF = 1e18+10;
}

void code_idhr_h(){
    ll N; cin>>N;
    map<string , ll> MAP;
    while(N--){
        string S; cin>>S;
        MAP[S]++;
    }
    cout<<"AC x "<<MAP["AC"]<<endl;
    cout<<"WA x "<<MAP["WA"]<<endl;
    cout<<"TLE x "<<MAP["TLE"]<<endl;
    cout<<"RE x "<<MAP["RE"]<<endl;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    //pre();
    while(T--){
        init();
        code_idhr_h();
    }
    return 0;
}

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

using namespace std;

int stone[262145];

int dp(int a, int b){
    if(a + 1 == b){
        return stone[a];
    }
    else{
        int x, y;
        x = dp(a, (a+b)/2);
        y = dp((a+b)/2, b);
        if (x==y){
            return x;
        }
        else{
            return(abs(x-y));
        }
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < pow(2,n); i++){
        cin >> stone[i];
    }
    cout << dp(0, pow(2,n));
    return 0;
}


Measured memory_bytes: 1280
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

//------------------------------------------------------
ll n,m,k;
void input(){
    cin>>n>>m>>k;
}
void src(){
    bool f=false;
    rep(i,n+1){
        rep(j,m+1){
            if(i*(m-j)+j*(n-i) == k){f=true;break;}
        }
            if(f){break;}
    }
    Yes(f);
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

const int max_n = 200222, inf = 1000000000;

int n, m, d[max_n], u[max_n], v[max_n];
int w[max_n], p[max_n];
vector<int> g[max_n];
int col[max_n];

bool cmp(int a, int b) {
    return d[a] < d[b];
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &d[i]);
        p[i] = i;
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &u[i], &v[i]);
        --u[i];
        --v[i];
        g[u[i]].push_back(i);
        g[v[i]].push_back(i);
        w[i] = inf;
    }
    sort(p, p + n, cmp);
    for (int I = 0; I < n; ++I) {
        int i = p[I];
        if (col[i]) {
            continue;
        }
        for (int num : g[i]) {
            const int to = i ^ u[num] ^ v[num];
            if (d[to] <= d[i]) {
                if (col[to]) {
                    col[i] = 3 - col[to];
                    w[num] = d[i];
                } else {
                    col[i] = 1;
                    col[to] = 2;
                    w[num] = d[i];
                }
                break;
            }
        }
        if (!col[i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        printf("%c", " WB"[col[i]]);
    }
    puts("");
    for (int i = 0; i < m; ++i) {
        printf("%d\n", w[i]);
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 H, W, N;
  cin >> H >> W >> N;
  using P = pair<int, int>;
  vector<P> ab;
  set<P> s;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    ab.emplace_back(a, b);
    s.emplace(a, b);
  }
  set<P> ans[10];
  rep(i, N) {
    int a, b;
    tie(a, b) = ab[i];
    for (int j = -2; j <= 2; j++) {
      for (int k = -2; k <= 2; k++) {
        int x = a + j, y = b + k;
        if (x < 0 || y < 0 || x >= H - 2 || y >= W - 2) continue;
        int cnt = 0;
        for (int l = 0; l <= 2; l++) {
          for (int m = 0; m <= 2; m++) {
            if (s.count(P(x + l, y + m))) cnt++;
          }
        }
        ans[cnt].insert(P(x, y));
      }
    }
  }
  i64 zero = (H - 2) * (W - 2);
  reps(i, 9) zero -= ans[i].size();
  cout << zero << '\n';
  reps(i, 9) cout << ans[i].size() << '\n';
}


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




int N;
int W[300];
//-----------------------------------------------------------------
int dp1[300][300];
int dp2[300];
int sol() {
	// clear
	rep(i, 0, 300) rep(j, 0, 300) dp1[i][j] = false;
	rep(i, 0, 300) dp2[i] = 0;

	// dp1
	rep(L, 0, N - 1) {
		int R = L + 1;
		if (abs(W[L] - W[R]) <= 1) dp1[L][R] = true;
	}
	for (int len = 4; len <= N; len += 2) rep(L, 0, N) {
		int R = L + len - 1;
		if (N <= R) break;

		// ok + ok
		for (int C = L + 2; C < R; C += 2) if (dp1[L][C - 1] && dp1[C][R]) dp1[L][R] = true;
		// ? + ok + ?
		if (dp1[L + 1][R - 1]) if (abs(W[L] - W[R]) <= 1) dp1[L][R] = true;
	}

	// dp2
	rep(R, 1, N) {
		dp2[R] = max(dp2[R], dp2[R - 1]);
		rep(L, 0, R) {
			if (dp1[L][R]) {
				if (L == 0)
					dp2[R] = max(dp2[R], R - L + 1);
				else
					dp2[R] = max(dp2[R], dp2[L - 1] + R - L + 1);
			}
		}
	}

	return dp2[N - 1];
}
//-----------------------------------------------------------------
int main() {
	while (cin >> N) {
		if (N == 0) return 0;
		rep(i, 0, N) scanf("%d", &W[i]);
		cout << sol() << endl;
	}
}

Measured memory_bytes: 3480
#include <stdio.h>
#include <stdlib.h>

int main() {
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if (abs(c-a)<=d || abs (b-a)<=d && abs (c-b)<=d) {
		printf("Yes");
	} else {
		printf("No");
	}
}

Measured memory_bytes: 1728
//https://beta.atcoder.jp/contests/abc053/tasks/abc053_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int Apla = -1,Zpla = -1;
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s[i] == 'A' && Apla == -1) Apla = i;
        if(s[i] == 'Z' && Zpla < i && Apla != -1) Zpla = i;
    }
    cout << Zpla - Apla + 1 << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int ans = 0;
    REP(i,N-1) if (S[i] == S[i+1]) ans++;
    
    ans += K*2;
    if (ans > N-1) ans = N-1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int ans = 0;
	if (K <= A){
		ans = K;
	} else if (A + B >= K){
		ans = A;
	} else {
		ans = A;
		int hoge = K - (A + B);
		ans = ans - hoge;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i = 0; i < values.length; i++) {
                values[i] = i + 1;
            }
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                int c = values[a];
                values[a] = values[b];
                values[b] = c;
            }
            for(int i = 0; i < values.length; i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26268
import sys
import heapq
input = sys.stdin.readline

def main():
    while True:
        w, h = map(int, input().split())
        if w == 0:
            break
        board = [input().strip().split() for i in range(h)]
        check = [[[False, False] for i in range(w)] for j in range(h)]
        q = []
        for y in range(h):
            for x in range(w):
                if board[y][x] == "S":
                    # 0: 右足   1: 左足
                    check[y][x][0] = True
                    check[y][x][1] = True
                    heapq.heappush(q, (0, 0, x, y))
                    heapq.heappush(q, (0, 1, x, y))
        ok = False
        while len(q) > 0:
            cost, foot, x, y = heapq.heappop(q)
            if foot == 0:# 次は左足
                nexts = [(x+1, y-2), (x+1, y-1), (x+1, y), (x+1, y+1), (x+1, y+2), (x+2, y-1), (x+2, y), (x+2, y+1), (x+3, y)]
            else:# 次は右足
                nexts = [(x-3, y), (x-2, y-1), (x-2, y), (x-2, y+1), (x-1, y-2), (x-1, y-1), (x-1, y), (x-1, y+1), (x-1, y+2)]
            # 足を動かす
            next_foot = (foot + 1) % 2
            for nx, ny in nexts:
                if 0 <= nx and nx < w and 0 <= ny and ny < h:
                    if board[ny][nx] == "T":
                        print(cost)
                        ok = True
                        break
                    if (not check[ny][nx][next_foot]) and board[ny][nx] != "X":
                        check[ny][nx][next_foot] = True
                        heapq.heappush(q, (cost + int(board[ny][nx]), next_foot, nx, ny))

            if ok:
                break
        
        if not ok:
            print(-1)




if __name__ == "__main__":
    main()


Measured memory_bytes: 5936
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0062
"""

import sys


def solve(data):
    work = data[:]
    while len(work) != 1:
        # print(work)
        temp = []
        for i in range(len(work)-1):
            temp.append((work[i] + work[i+1]) % 10)
        work = temp[:]
    return work[0]


if __name__ == '__main__':
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        data = [int(x) for x in list(line.strip())]
        result = solve(data)
        print(result)

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	set<int> st;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		st.insert(a);
	}
	if (st.size() % 2 == 1) {
		cout << (int)st.size() << endl;
	}
	else {
		cout << (int)st.size() - 1 << endl;
	}
}


Measured memory_bytes: 4992
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private int N;
    private int Ma;
    private int Mb;
    private int[] a;
    private int[] b;
    private int[] c;
 
    private Map<String, Integer> memo = new HashMap<>();
 
    private void solve(Scanner sc) {
        N = sc.nextInt();
        Ma = sc.nextInt();
        Mb = sc.nextInt();
        a = new int[N];
        b = new int[N];
        c = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
 
        int r = calc(0, 0, 0);
        if (r == Integer.MAX_VALUE) {
            _out.println(-1);
        } else {
            _out.println(r);
        }
    }
    private int calc(int d, int ma, int mb) {
        String key = d + "/" + ma + "/" + mb;
        if (memo.containsKey(key)) {
            return memo.get(key);
        }
        if (d >= N) {
            if (d == N && ma > 0 && mb > 0 && ma % Ma == 0 && mb % Mb == 0 && ma / Ma == mb / Mb) {
                return 0;
            }
            return Integer.MAX_VALUE;
        }
 
        int r1 = calc(d + 1, ma, mb);
        int r2 = calc(d + 1, ma + a[d], mb + b[d]);
        if (r2 != Integer.MAX_VALUE) {
            r2 = r2 + c[d];
        }
        int r = Math.min(r1, r2);
        memo.put(key, r);
        return r;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

// 解説見た。再帰を使ったdfs
vector<int> to[200000];
vector<int> ans;

void dfs(int v,  int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  ans.resize(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] +=  x;
  }

  dfs(0);

  rep(i, n) cout << ans[i] << endl;
  return 0;
}


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

using namespace std;

int main() {
    string S; cin >> S;
    int cnt1 = 0;
    int cnt2 = 0;
    for(int i = 0; i < S.length(); i++) {
        if(S[i] - '0' == i % 2) cnt1++;
        else cnt2++;
    }

    cout << min(cnt1, cnt2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    int c[10][10];
    int A[H][W];
    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)
            cin >> c[i][j];
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> A[i][j];

    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(A[i][j] != -1){
                ans += c[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();
		if(h % a != 0) {
			System.out.println(h / a + 1);
		}else {
			System.out.println(h / a);
		}
		sc.close();
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long L[n+1];
    L[0] = 2;
    L[1] = 1;
    for(int i=2;i<n+1;i++){
        L[i] = L[i-1] + L[i-2];
    }

    cout << L[n] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,m,l,r,lmax=1,rmin,ans=0;
	scanf("%d %d",&n,&m);
	rmin=n;
	for(int i=0;i<m;i++){
		scanf("%d %d",&l,&r);
		if(lmax<l) lmax=l;
		if(rmin>r) rmin=r;
	}
	if(rmin-lmax+1>0) printf("%d\n",rmin-lmax+1);
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 128