akhauriyash/Code-Regression huggingface dataset:
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  int n,m;
  cin>>n>>m;
  if(n<=9 && m<=9){
  cout<<n*m<<endl;
}else{
cout<<-1<<endl;
}
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

vector <ll> o;
vector <ll> e;
vector <ll> a;
vector <ll> b;

void print()
{
    for (ll i = 0; i < a.size(); i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;

    cout << b.size() << endl;
    for (ll i = 0; i < b.size(); i++)
    {
        cout << b[i] << " ";
    }
    cout << endl;
}

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

	ll n , m;
	cin >> n >> m;

	for (ll i = 1; i <= m; i++)
    {
        ll x;
        cin >> x;

        if (x & 1)
        {
            o.pb(x);
        }
        else
        {
            e.pb(x);
        }
    }

    if (o.size() == 0)
    {
        b.pb(1);
        for (ll i = 0; i < (ll)(e.size()) - 1; i++)
        {
            a.pb(e[i]);
            b.pb(e[i]);
        }
        a.pb(e.back());
        b.pb(e.back() - 1);

        print();
        return 0;
    }

    if (o.size() == 1)
    {
        if (n == o[0])
        {
            a.pb(o[0]);
            if (o[0] > 1)
            {
                b.pb(o[0] - 1);
            }
            b.pb(1);
        }
        else
        {
            a.pb(o[0]);
            b.pb(o[0] + 1);
            for (ll i = 0; i < (ll)(e.size()) - 1; i++)
            {
                a.pb(e[i]);
                b.pb(e[i]);
            }
            a.pb(e.back());
            b.pb(e.back() - 1);
        }

        print();
        return 0;
    }

    if (o.size() == 2)
    {
        a.pb(o[0]);
        if (o[0] > 1)
        {
            b.pb(o[0] - 1);
        }

        for (ll i = 0; i < e.size(); i++)
        {
            a.pb(e[i]);
            b.pb(e[i]);
        }
        a.pb(o[1]);
        b.pb(o[1] + 1);

        print();
        return 0;
    }

    cout << "Impossible";
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int D,N,ans=0;cin>>D>>N;
    int m=pow(100,D);
    REP(i,N)ans+=m;
    if(N==100)ans+=m;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n,a,b;

void solve(){
  cin >> n >> a >> b;
  int c=b-a;
  if(c%2==0)cout << "Alice";
  else cout << "Borys";
  cout << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	double a1,b1,e1,a2,b2,e2;
	double x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a1,&b1,&e1,&a2,&b2,&e2) != EOF){
//		x = (e1*b2 - b1*e2) / (a1*b2 - b1*a2);
//		y = (e2*a1 - e1*a2) / (a1*b2 - a2*b1);
		x = e1*b2 / (a1*b2 - b1*a2) - b1*e2 / (a1*b2 - b1*a2);
		y = e2*a1 / (a1*b2 - b1*a2) - e1*a2 / (a1*b2 - b1*a2);

		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

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

int main()
{
	int A, B, C , count = 0;
	cin >> A >> B >> C;
	if (A < B)swap(A, B);
	if (B < C)swap(B, C);
	if (A < B)swap(A, B);
	while (A!=C) {
		if (A < B)swap(A, B);
		if (B < C)swap(B, C);
		if (A < B)swap(A, B);
		while (A != B) {
			B++;
			C++;
			count++;
		}
		while (B > C) {
			C = C + 2;
			count++;
		}
	}
	cout << count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
#define ld long double
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define endl '\n'
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define mod 1000000007
#define MEM(a, b) memset(a, (b), sizeof(a))
#define addmod(a,b,mod) (a%mod + b%mod)%mod
#define submod(a,b,mod) (a%mod - b%mod + mod)%mod
//const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
const int MAX = 1e6;

vector<bool> l(200001), r(200001);
int main(){
    ios_base:: sync_with_stdio(0); 
    cin.tie(0);
    
    ll n, k = 1, a, temp, k2 = 0;
    cin >> n;
    vector<ll> divisor;
	if(n < 6){
		cout << n - 1;
		return 0;
	}
    FOR(i,2,sqrt(n-1) + 1)
    	if((n - 1)%i == 0){
    		if((n-1)/i == i)
    			k++;
    		else
    			k += 2;
		}
	FOR(i,1,int(sqrt(n)) + 1){
		if(n%i == 0){
    		if(n/i == i)
    			divisor.push_back(i);
    		else{
    			if(i != 1)
    				divisor.push_back(i);
    			divisor.push_back(n/i);
			}
		}
	}
	
	FOR(i,0,divisor.size()){
		a = divisor[i]; 
		temp = n;
		while(temp % a == 0)
			temp /= a;
		if(temp%a == 1)
			k2++;
	}
	cout << k + k2;
			
    return 0; 
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define MAX 20
#define MAX2 200

int keisan(int,int);
int a[MAX],b[MAX2],count=0,sum,n;
int main() {
int h,i,j;
int m,key,v;
scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&a[i]);
}
scanf("%d",&m);
for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  v=keisan(0,b[i]);
     if(v==1) printf("yes\n");
     else printf("no\n");
}
  return 0;
}
  int keisan(int x,int y){
    if(y == 0) return 1;
      if(x >= n) return 0;
      return keisan(x + 1,y) || keisan(x + 1,y - a[x]);
  }


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<list>

using namespace std;



int main(){
    int N, L, i=1, j;
    bool flag;
    string input;
    string a;
    list<string> s;
    list<string>::iterator itr;
    
    cin >> N >> L;
    cin >> input;
    s.push_front(input);
    while (i != N){
        cin >> input;
        flag = false;
        for (itr=s.begin(); itr!=s.end(); itr++){
            a = *itr;
            j = 0;
            while (input[j] <= a[j]){
                if (input[j] < a[j] || j == L-1){
                    s.insert(itr, input);
                    flag = true;
                    break;
                }
                j++;
            }
            if (flag == true){
                break;
            }      
        }
        if (flag == false){
            s.push_back(input);
        }
        i++;
    }

    for (itr=s.begin(); itr!=s.end(); itr++){
        cout << *itr;
    }

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(void){
    int h, w, c[10][10], b=0;
    cin>>h>>w;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>c[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]);
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin>>a;
            if(a>=0){
                b+=c[a][1];
            }
        }
    }
    cout<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

vector<int> z_algorithm(string &s) {
    vector<int> res(s.size());
    res[0] = s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
        while (i+j < s.size() && s[j] == s[i+j]) j++;
        res[i] = j;

        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (k < j && k + res[k] < j) {
            res[i+k] = res[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i,n) {
        string tmp = s.substr(i);
        vint x = z_algorithm(tmp);
        int mx = 0;
        rep(j,x.size()) {
            mx = max(mx,min(j,x[j]));
        }
        ans = max(ans,mx);
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    string str;
    vector<int> vec;
    
    cin >> str;

    for (int i=0; i < (int)str.length(); i++) {
        for (int j=0; j < (int)str.length() - i; j++) {
            if (str[i+j] != 'A' && str[i+j] != 'C' && str[i+j] != 'G' && str[i+j] != 'T') {
                vec.push_back(j);
                break;
            }
            if (i+j == (int)str.length()-1) {
                vec.push_back(j+1);
                break;
            }
        }
    }
    sort(vec.begin(), vec.end());

    cout << vec.back() << endl;
    
   /* for(auto itr = vec.begin(); itr != vec.end(); ++itr) {
        cout << *itr ;
    }*/
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int a, b, tmp, ans;
        int i, j;
        scanf("%d%d", &a, &b);
        int m[a];
        for(i=0;i<a;i++){
                scanf("%d", &m[i]);
        }

        for(i=0;i<a;i++){
                for(j=0;j<a;j++){
                        if(m[i]<m[j]){
                                tmp = m[i];
                                m[i] = m[j];
                                m[j] = tmp;
                        }
                }
        }
        tmp = 0;
        for(i=0;i<a;i++){
                tmp = tmp + m[i];
        }

        b = b - tmp;
        ans = (b / m[0]) + a;

        printf("%d\n", ans);
        return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  int a[n],b[m];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<m; i++) cin >> b[i];
  sort(b,b+m,greater<int> ());
  int j=0;
  int d[n],max=0,ans;
  fill(d,d+n,0);
  for(int i=0; i<n; i++) {
    while(b[j]>=a[i]) {
      d[i]++;
      j++;
      if(d[i]>max) {
	max=d[i];
	ans=i;
      }
    }
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>

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

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int factorial(int k){
    int rel = 1;
    while(k != 1){
        rel *= k;
        k--;
    }
    return rel;
}

int combi(int n){
    int rel = 0;
    rep(i, n){
        rel += (n-1)-i;
    }
    return rel;
}

int main() {
    int n; cin >> n;
    vector<int> x(n), y(n);
    rep(i, n){
        cin >> x[i];
        cin >> y[i];
    }
    int k = ((n - 1) * factorial(n)) / combi(n);
    long double ans = 0;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            ans += (sqrt(pow((x[i]-x[j]),2) + pow((y[i]-y[j]),2)) * k) / factorial(n);
        }
    }
    cout << setprecision(9) << ans << endl;
}




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

int vis[1010][1010];
char ch[1010][1010];

int main() {
	memset(vis, -1, sizeof(vis));
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int x, y;
	cin >> x >> y;
	
	queue<pair<int, pair<int, int> > > q;
	for(int i = 1; i <= x; i++) {
		for(int j = 1; j <= y; j++) {
			cin >> ch[i][j];
			
			if(ch[i][j] == '#') {
				vis[i][j] = 0;
				q.push(make_pair(0, make_pair(i, j)));
			}
		}
	}
	
	int ans = 0;
	while(!q.empty()) {
		int val = q.front().first;
		int tarX = q.front().second.first;
		int tarY = q.front().second.second;
		q.pop();
		
		ans = max(ans, val);
		if(tarX < x && vis[tarX + 1][tarY] == -1) {
			vis[tarX + 1][tarY] = val + 1;
			q.push(make_pair(val + 1, make_pair(tarX + 1, tarY)));
		}
		
		if(tarX > 1 && vis[tarX - 1][tarY] == -1) {
			vis[tarX - 1][tarY] = val + 1;
			q.push(make_pair(val + 1, make_pair(tarX - 1, tarY)));
		}
		
		if(tarY < y && vis[tarX][tarY + 1] == -1) {
			vis[tarX][tarY + 1] = val + 1;
			q.push(make_pair(val + 1, make_pair(tarX, tarY + 1)));
		}
		
		if(tarY > 1 && vis[tarX][tarY - 1] == -1) {
			vis[tarX][tarY - 1] = val + 1;
			q.push(make_pair(val + 1, make_pair(tarX, tarY - 1)));
		}
	}
	
	cout << ans << "\n";
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S;
    cin >> S;

    ll ans = 0;
    rep (i, N-2) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main()
{
	int a,b;
	cin >> a >> b;
	if(a > 0 && a <= 9 && b > 0 && b <= 9)
		cout << a * b << endl;
	else 
		cout << -1 << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	while(1){
		int n;
		map<ll,ll> mp;
		scanf("%d",&n);
		if(n==0) break;
		list<pll> lt;
		for(int i=0;i<n;i++){
			char c;
			cin>>c;
			if(c=='W'){
				int x,y;
				scanf("%d%d",&x,&y);
				auto it=lt.begin();
				mp[x]=y;
				while(it!=lt.end()){
					if(it->first==-1){
						int t=it->second;
						if(y>=t){
							it->first=x;
							y-=t;
						}
						else{
							it=lt.insert(it,make_pair(x,y));
							it++;
							it->second=t-y;
							y=0;
						}
					}
					if(y==0) break;
					it++;
				}
				if(y) lt.push_back(make_pair(x,y));
			}
			if(c=='D'){
				auto it=lt.begin();
				int x;
				scanf("%d",&x);
				int t=mp[x];
				while(it!=lt.end()){
					if(it->first==x){
						it->first=-1;
						t-=it->second;
						if(t==0) break;
					}
					it++;
				}
			}
			if(c=='R'){
				int x;
				scanf("%d",&x);
				auto it=lt.begin();
				bool B=0;
				while(it!=lt.end()){
					int t=it->second,y=it->first;
					if(t<=x) x-=t;
					else{
						printf("%d\n",y);
						B=1;
						break;
					}
					it++;
				}
				if(!B) printf("-1\n");
			}
		}
		printf("\n");
	}
}


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

#define MOD 1000000007

int n;

long long memo[120][10][10][10];

long long dfs(int i, int one, int two, int three){
    if(i == n) return 1;
    if(memo[i][one][two][three] != -1) return memo[i][one][two][three];

    long long ans = 0;
    for(int f = 1;f <= 4;f++){
        if(one == 1 && two == 2 && f == 3) continue;
        if(one == 1 && three == 2 && f == 3) continue;
        if(two == 1 && three == 2 && f == 3) continue;
        if(two == 2 && three == 1 && f == 3) continue;
        if(two == 1 && three == 3 && f == 2) continue;
        ans = (ans + dfs(i+1, two, three, f)) % MOD;
    }

    return memo[i][one][two][three] = ans;
}

int main(){
    cin >> n;
    memset(memo, -1, sizeof(memo));
    cout << dfs(0, 0, 0, 0) << endl;;
    return 0;
}


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

int main(){
  int N;cin>>N;
  vector<long long> L(N+1);
  L.at(0)=2;L.at(1)=1;
  for(int i=2;i<N+1;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout<<L.at(N)<<endl;
}


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

using namespace std; 

int main(){ 
  string n;
  cin>>n;
  int ans=0;
  if(n[0]=='2') ans+=1;
  if(n[1]=='2') ans+=1;
  if(n[2]=='2') ans+=1;
  if(n[3]=='2') ans+=1;
  cout<<ans;

} 

Measured memory_bytes: 256
// E - Red and Green Apples
#include <bits/stdc++.h>
using namespace std;
int in(){int x;cin>>x;return x;}

int main(){
	int X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
	priority_queue<int> P,Q,R,T;
	while(A--) P.push(in());
	while(B--) Q.push(in());
	while(C--) R.push(in());
	while(X--){ T.push(P.top()); P.pop(); }
	while(Y--){ T.push(Q.top()); Q.pop(); }
	long long ans = 0;
	while(T.size()){
		int t = T.top(), r = R.top(); T.pop(); R.pop();
		if(t < r) swap(t,r);
		R.push(r);
		ans += t;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 2552
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	long long n;
	cin>>n;
	long long ans=n-1;
	for(long long i=1;i*i<=n;++i){
		if(n%i!=0){
			continue;
		}
		ans=min(ans,i-2+(n/i));
	}
	cout<<ans;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int d, n;
    cin >> d >> n;
    int ans = 0;
    int num = 0;
    if(d == 0){
        num = 1;
    }else if(d == 1){
        num = 100;
    }else{
        num = 10000;
    }
    int i = 1;
    while(n--){
        ans = i * num;
        i++;
        if(i == 100) i++;
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;

typedef unsigned long long ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

int add(int x, int y) { return ((x % MOD)  + (y % MOD)) % MOD;             }
int mul(int x, int y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;   }
int sub(int x, int y) { return add(x, -y + MOD);                           }

int n, c[MAXN][4];

int maxGain(int x, int y) {
	int res = 1;
	for(int i = 1; i <= 3; ++i) {
		if(i == y) continue;
		res = max(res, c[x][i]);
	}
	return res;
}

int dp[MAXN][4];

int solve(int x, int last) {
	if(dp[x][last] != -1) return dp[x][last];
	if(x == n) return maxGain(x, last);
	int maxx = -1;
	for(int i = 1; i <= 3 ; ++i) {
		if(i == last) continue;
		maxx = max(maxx, c[x][i] + solve(x + 1, i));
	}
	return dp[x][last] = maxx;
}

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

	cin >> n;

	for(int i = 1; i <= n ; ++i) {
		cin >> c[i][1] >>  c[i][2] >> c[i][3];
	}	

	memset(dp, -1, sizeof(dp));

	cout << solve(1, -1) << endl;

	return 0;
}




Measured memory_bytes: 11136
S = input()

def MM(S):
    for i in range(1, 13):
        if S == format(str(i).zfill(2)):
            return True
    return False

b0 = MM(S[:2])
b1 = MM(S[2:])

if b0:
    if b1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b1:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(100000)

n, m = map(int, input().split())
a = list(map(int, input().split()))
memo = {}
matches = [100, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def doit(n):
    if n == 0:
        return ""
    if not n in memo:
        ret = None
        for d in a:
            m = matches[d]
            if n - m >= 0 and doit(n - m) is not None:
                r = max(doit(n - m) + str(d), str(d) + doit(n - m))
                if ret is None or len(r) > len(ret) or len(r) == len(ret) and r > ret:
                    ret = r
        memo[n] = ret
    return memo[n]

print(doit(n))

Measured memory_bytes: 32748
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int h, w, k; cin >> h >> w >> k;
    vvi a(h, vi(w));
    FOR(i, 0, h - 1) {
        FOR(j, 0, w - 1) {
            char c; cin >> c;
            a[i][j] = (c == '#');
        }
    }
    int ans = 0;
    FOR(i, 0, (1 << h) - 1) FOR(j, 0, (1 << w) - 1) {
        // cout << i << ' ' << j << endl;
        int tt = 0;
        FOR(k, 0, h - 1) FOR(l, 0, w - 1) {
            if (!(i & (1 << k)) && !(j & (1 << l))) tt += a[k][l];
        }
        if (tt == k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int i,n;
  int D[1000000];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&D[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,D[i]);
    if(i/2>=1){
      printf("parent key = %d, ",D[i/2]);
    }
    if(i*2<=n){
      printf("left key = %d, ",D[i*2]);
    }
    if(i*2+1<=n){
      printf("right key = %d, ",D[i*2+1]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())

int32_t main()
{
    io
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
map<int,int>m;
for(int i=0;i<n;i++)
{
  m[a[i]]++;
}
map<int,int>mm,nn;int cc=0,dd=0;
for(auto it:m)
{
  int pp=it.second;
  mm[it.first]=pp*(pp-1)/2;cc+=mm[it.first];
  pp--;
  nn[it.first]=pp*(pp-1)/2;dd+=nn[it.first];
}
for(int i=0;i<n;i++)
{
  int ans=0;
  cout<<cc-mm[a[i]]+nn[a[i]]<<endl;

}
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> contests = {111, 222, 333, 444, 555, 666, 777, 888, 999};
  
  for(int contest : contests)
  {
    if(contest >= N)
    {
      cout << contest << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

typedef struct node{
    lld a, b;
}node;

int cmpAsc(const void* a, const void* b){
    lld x = ((node*)a)->a, y = ((node*)b)->a;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    lld k;
    scanf("%d %lld", &n, &k);
    node a[n];
    rep(i, 0, n){
        scanf("%lld %lld", &a[i].a, &a[i].b);
    }
    qsort(a, n, sizeof(node), cmpAsc);
    int x = 0;
    while(k > 0){
        k -= a[x].b;
        if(k>0){
            x++;
        }
    }
    printf("%lld", a[x].a);

    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
const int MAXN = 2*1e5;
ll t[4*MAXN+1];
vector<ll>h,a;
void build(int v,int l,int r)
{
	if(l == r)t[v] = 0;
	else{
		int mid = (l+r)/2;
		build(2*v,l,mid);
		build(2*v+1,mid+1,r);
		t[v] = max(t[2*v],t[2*v+1]);
	}
}
void upd(int v,int tl,int tr,ll val,ll pos)
{
	if(tl == tr)t[v] = val;
	else{
		int tm = (tl+tr)/2;
		if(pos <= tm){
			upd(2*v,tl,tm,val,pos);
		}else{
			upd(2*v+1,tm+1,tr,val,pos);
		}
		t[v] = max(t[2*v],t[2*v+1]);
	}
}
ll get(int v,int l,int r,int tl,int tr)
{
	if(tl == l && tr == r)return t[v];
	if(l > r)return -INF;
	int tm = (tl+tr)/2;
	return max(get(2*v,l,min(r,tm),tl,tm),
	           get(2*v+1,max(l,tm+1),r,tm+1,tr));
}
int main()
{
   int n;
   cin>>n;
   a.resize(n);
   h.resize(n);
   for(ll&x:h)cin>>x;
   for(ll&x:a)cin>>x;
   for(int i=0;i<n;i++){
	   if(h[i] == 1){
		   upd(1,1,n,a[i],1);
		   continue;
	   }
	   else{
		ll r = get(1,1,h[i]-1,1,n);
		upd(1,1,n,r+a[i],h[i]);
	   }
   }
   cout<<t[1];
}


Measured memory_bytes: 10496
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<vector>
#define pb push_back
#define eb emplace_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 10000007
#define inf 1000000000000000000
#define MOD 1000000007
using namespace std;

const int nax = 305;
double p[nax][nax][nax], ev[nax][nax][nax];
void solve(){
	int n;
    scanf("%d", &n);
    vector<int> cnt(4);
    for(int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c >= 0; --c) {
        for(int b = n; b >= 0; --b) {
            for(int a = n; a >= 0; --a) {
                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a + b + c > n) {
                    continue;
                }
                double p_waste = (double) (n - (a + b + c)) / n;
                double ev_waste = p_waste / (1 - p_waste) + 1;
                ev[a][b][c] += ev_waste * p[a][b][c];
                if(a != 0) {
                    double p_go = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * p_go;
                    ev[a-1][b][c] += ev[a][b][c] * p_go;
                }
                if(b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_go;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_go;
                }
                if(c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_go;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 438528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

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

    int mcnt = 0;
    int cnt = 0;
    rep(i, 3) {
        if (S.at(i) == 'R') {
            cnt++;
            mcnt = max(mcnt, cnt);
        } else {
            mcnt = max(mcnt, cnt);
            cnt = 0;
        }
    }

    cout << mcnt << endl;
}

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

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

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}


int main(){

    int N, M;
    cin >> N >> M;
    vector<int> X(N, 1000000);
    //int a[100000], b[100000];
    int a, b, imin, imax;

    for(int i = 0; i < M; i++){
        cin >> a >> b;
        a--;
        b--;
        imin = min(a, b);
        imax = max(a, b);
        if(X[imin] > imax) X[imin] = imax;
    }



    int sum = 0;
    int min_tmp = 1000000;
    for(int i = 0; i < N - 1; i++){
        if(X[i] < min_tmp) min_tmp = X[i];
        if(i + 1 == min_tmp){
            sum++;
            min_tmp = 1000000;
        }
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 768
def main():
    n = int(input())
    As = list(map(int, input().split()))

    ans = 1
    if 0 in As:
        print(0)
        exit()

    for i in range(n):
        ans *= As[i]
        if ans > 10**18:
            ans = -1
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84772
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,m,c=input2()
B=input_array()
A=[input_array() for _ in range(n)]

count=0

for a in A:
	tmp=c
	for i in range(m):
		tmp+=a[i]*B[i]

	if tmp>0:
		count+=1
print(count)

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

const int MAX_N = 200005;

int N, num, u, v, L, R;
long long ans, w, A[MAX_N], pref[MAX_N][2];
priority_queue<pair<long long, pair<int, int>>> pq;
set<int> unused;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}

	for (int i = 1; i <= N; i++)
	{
		pq.push({ A[i], {i, i + 1} });
	}

	for (int i = 0; i <= N + 2; i++)
	{
		unused.emplace(i);
	}

	for (int i = 1; i <= N + 2; i++)
	{
		pref[i][0] = pref[i - 1][0];
		pref[i][1] = pref[i - 1][1];
		pref[i][i & 1] += A[i];
	}

	while (num < N / 2)
	{
		w = pq.top().first;
		u = pq.top().second.first;
		v = pq.top().second.second;
		pq.pop();
		if (unused.find(u) != unused.end() && unused.find(v) != unused.end())
		{
			unused.erase(u);
			unused.erase(v);
			num++;
			ans += w;
			L = *prev(unused.lower_bound(u));
			R = *unused.lower_bound(v);
			if (1 <= L && R <= N + 1)
			{
				pq.push({ (pref[R - 1][L & 1] - pref[L - 1][L & 1]) - (pref[R - 1][(L & 1) ^ 1] - pref[L - 1][(L & 1) ^ 1]), {L, R} });
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20308
n = int(input())
aL = sorted(list(map(int, input().split(" "))))
# aL = sorted(list(set(aLP)))

dp = [False for _ in range(1000001)]

d = {}
for a in aL:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans = 0
for a in aL:
    if dp[a]:
        continue
    if d[a] > 1:
        c = 1
        while a * c <= 1000000:
            dp[a * c] = True
            c += 1
        continue
    ans += 1

    c = 1
    while a * c <= 1000000:
        dp[a * c] = True
        c += 1

print(ans)


Measured memory_bytes: 44620
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

K,N=map(int, input().split())
A = list(map(int, input().split()))

## Logic

A.append(A[0]+K)

tmp = 0
for i in range(0,N):
    tmp = max(tmp,A[i+1]-A[i])
print(K-tmp)


Measured memory_bytes: 103368
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 998244353;


        signed main() {
      int n,k;
      cin>>n>>k;
      int l[n];
      for(int i=0;i<n;i++)cin>>l[i];
      sort(l,l+n);
      for(int i=0;i<k-1;i++)l[n-2-i]+=l[n-1-i];
      cout<<l[n-k];

        


      }


        


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[10][10];
	int i,j,e,r,t;
	while((scanf("%s",a[0]))!=EOF){
		for(i=1;i<8;i++){
			scanf("%s",a[i]);
		}
		t=0;
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(a[i][j]=='1'){
					e=i;
					r=j;
					t=1;
					break;
				}
			}
			if(t==1)break;
		}	
		if(e<7&&j<7){
			if(a[e][r]=='1'&&a[e][r+1]=='1'&&a[e+1][r]=='1'&&a[e+1][r+1]=='1')printf("A\n");
		}
		if(e<5){
			if(a[e][r]=='1'&&a[e+1][r]=='1'&&a[e+2][r]=='1'&&a[e+3][r]=='1')printf("B\n");
		}
		if(r<5){
			if(a[e][r]=='1'&&a[e][r+1]=='1'&&a[e][r+2]=='1'&&a[e][r+3]=='1')printf("C\n");
		}
		if(e<6&&r>0){
			if(a[e][r]=='1'&&a[e+1][r-1]=='1'&&a[e+1][r]=='1'&&a[e+2][r-1]=='1')printf("D\n");
		}
		if(e<7&&r<6){
			if(a[e][r]=='1'&&a[e][r+1]=='1'&&a[e+1][r+1]=='1'&&a[e+1][r+2]=='1')printf("E\n");
		}
		if(e<6&&r<7){
			if(a[e][r]=='1'&&a[e+1][r]=='1'&&a[e+1][r+1]=='1'&&a[e+2][r+1]=='1')printf("F\n");	
		}
		if(a[e][r]=='1'&&a[e][r+1]=='1'&&a[e+1][r-1]=='1'&&a[e+1][r]=='1')printf("G\n");		
	}
	return 0;	
}

Measured memory_bytes: 0
#include<stdio.h>
  
int main(){
  int x,y,i;
  while(1){
    scanf("%d %d",&x,&y);
    if(x>y){
    i=x;
    x=y;
    y=i;
    }
    else if(x==0&&y==0)
      break;
    printf("%d %d\n",x,y);
 
  }
    return 0;
}

Measured memory_bytes: 2592
N,D = map(int,input().split(' '))
X = []
count = 0
for i in range(N):
  s = tuple(map(int,input().split(' ')))
  X.append(s)

for i in range(0,N):
  for j in range(i+1,N):
    a = 0
    for k in range(D):
      a += (X[i][k]-X[j][k])**2
    b = a**0.5
    if b.is_integer():
      count += 1
print(count)
      

Measured memory_bytes: 3188
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i >> (s-1) & 1:
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)


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

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

class RollingHash {
 private:
  using u64 = std::uint_fast64_t;

  const u64 mod = (1ULL << 61) - 1;
  std::vector<u64> hashes, pows;

  inline u64 add(u64 a, u64 b) const {
    a += b;
    if (a >= mod) a -= mod;
    return a;
  }

  inline u64 sub(u64 a, u64 b) const {
    if (a < b) a += mod;
    a -= b;
    return a;
  }

  inline u64 mul(u64 a, u64 b) const {
    u64 ah = a >> 31, al = a & ((1ULL << 31) - 1), bh = b >> 31,
        bl = b & ((1ULL << 31) - 1), m = ah * bl + al * bh,
        v = (ah * bh << 1) + (m >> 30) + ((m & ((1ULL << 30) - 1)) << 31) +
            al * bl;
    v = (v & ((1ULL << 61) - 1)) + (v >> 61);
    return v;
  }

 public:
  RollingHash(const std::string &S, u64 base = 10007)
      : hashes((int)S.size() + 1, 0), pows((int)S.size() + 1, 0) {
    int sz = (int)S.size();
    pows[0] = 1;
    for (int i = 0; i < sz; i++) {
      pows[i + 1] = mul(pows[i], base);
      hashes[i + 1] = add(mul(hashes[i], base), S[i]);
    }
  }

  u64 slice(int l, int r) const {
    return sub(hashes[r], mul(hashes[l], pows[r - l]));
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  RollingHash rh(S);

  auto f = [&](int d) -> bool {
    map<u64, int> mp;
    for (int i = 0; i + d < N + 1; i++) {
      u64 x = rh.slice(i, i + d);
      if (mp.count(x)) {
        if (i - mp[x] >= d) return true;
      } else {
        mp[x] = i;
      }
    }
    return false;
  };

  int lo = 0, hi = N + 1;
  while (lo < hi) {
    int mi = (lo + hi + 1) >> 1;

    if (f(mi)) {
      lo = mi;
    } else {
      hi = mi - 1;
    }
  }
  cout << lo << '\n';
  return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> s(n);
  int sum = 0, ans = 0;
  rep(i,n) {
    cin >> s[i];
    sum += s[i];
  }
  if (sum % 10 != 0) {
    ans = sum;
  } else {
    sort(s.begin(),s.end());
    int cs=0;
    rep(i,n) {
      if (s[i] % 10 != 0) {
        ans = sum - s[i];
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a<b) {
        printf("a < b\n");
    }
    else if(a>b) {
        printf("a > b\n");
    }
    else {
        printf("a == b\n");
    }

    return 0;
}



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

int main(){
  string a;
  cin >> a;
  for(int i=0;i<a.size();i++){
  if(a.at(i)=='9')
    a.at(i)='1';
  else
    a.at(i)='9';
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char const* argv[])
{
    int a, b, c, t;
    scanf("%d%d%d", &a, &b, &c);

    if (a > b) {
        t = a;
        a = b;
        b = t;
    }

    if (b > c) {
        t = b;
        b = c;
        c = t;
        if (a > b) {
            t = a;
            a = b;
            b = t;
        }
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}


Measured memory_bytes: 2056
import sys


class AlgSegmentTreeMin:
    def __init__(self, n, default_value):
        self.Nelem = n
        self.default_value = default_value
        self.size = 1 << (n.bit_length())
        self.data = [default_value] * (2 * self.size)

    def build(self, raw_data):
        for i, x in enumerate(raw_data):
            self.data[self.size + i] = x
        for i in range(self.size - 1, 0, -1):
            x = self.data[i + i]
            y = self.data[i + i + 1]
            self.data[i] = min(x, y)

    def update(self, i, x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i + i]
            y = self.data[i + i + 1]
            self.data[i] = min(x, y)
            i >>= 1

    def get_value(self, left, right):
        left += self.size
        right += self.size + 1
        x = self.default_value
        while left < right:
            if left & 1:
                y = self.data[left]
                x = min(x, y)
                left += 1
            if right & 1:
                right -= 1
                y = self.data[right]
                x = min(x, y)
            left >>= 1
            right >>= 1
        return x


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    stree = AlgSegmentTreeMin(n, 10 ** 15)
    stree.update(0, 0)
    lrc = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    lrc.sort()
    for l, r, c in lrc:
        l -= 1
        r -= 1
        tm = stree.get_value(l, r)
        stree.update(r, min(tm + c, stree.get_value(r, r + 1)))
    mt = stree.get_value(n-1, n)
    print(mt if mt != stree.default_value else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 98268
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
//#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

signed main (){
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int A=0,B=0;
    rep(i,0,s.size()){
        if(s[i]=='c')cout<<"No"<<endl;
        else if(s[i]=='a'){
            if(A+B<a+b){
                cout<<"Yes"<<endl;
                A++;
            }else cout<<"No"<<endl;
        }else {
            if(A+B<a+b && B<b){
                cout<<"Yes"<<endl;
                B++;
            }else cout<<"No"<<endl;
        }
    }
    


    
}
/*
1-21-2
*/


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;

int main(){
    int n, a, mi, count;
    ll ans;
    mi = INF;
    ans = 0;
    count = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        mi = min(mi,abs(a));
        ans += abs(a);
        if(a<0) count++;
    }
    if(count%2==1) ans -= 2*mi;
    cout << ans << endl;
}

Measured memory_bytes: 256