akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(void){
    int N;
    cin>>N;
    
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    sort(A.begin(),A.end(),greater<ll>());
    
    ll sum=1;
    ll check=false;
    for(int i=1;i<A.size();i++){
        if(A[i-1]==A[i]){
            if(check){sum*=A[i];break;}
            sum*=A[i];
            check=true;
            i++;
        }
    }
    
    if(check)cout<<sum<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,x,y;cin>>n>>x>>y;
    x--;y--;
    vi ans(n-1);
    rep(i,n){
        REP(j,i+1,n){
            ll res=j-i;
            chmin(res,abs(x-i)+abs(y-j)+1);
            chmin(res,abs(x-j)+abs(y-i)+1);
            ans[res-1]++;
        }
    }
    for(ll x:ans)out(x);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n, t;
    cin >> n >> t;
    int r = 0, u = 0;
    for (int i = 0; i < n; i++) {
        int s;
        cin >> s;
        u += t;
        if (s < r) u -= r - s;
        r = s + t;
    }

    cout << u << endl;

    return 0;
}

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

int main() {
	int H, W;
while(1){
cin>>H>>W;
if(H==0&&W==0) break;
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(i==0||i==H-1||j==0||j==W-1){
cout<<"#";

}else{cout<<".";}

}
cout<<"\n";
}
cout<<endl;
}

// your code goes here
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

//KULASIS
public class Main{

	int[] f(int x){
		int[] r = new int[4];
		int k = 0;
		while(x>0){
			r[k++] = x%4;
			x/=4;
		}
		return r;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int[] p = {0, 60, 70, 80};
		int[][] k = new int[256][];
		for(int i=0;i<256;i++)k[i]=f(i);
		int T = sc.nextInt();
		while(T--!=0){
			int[][] a = new int[5][5];
			for(int i=0;i<5;i++)for(int j=0;j<5;j++)a[i][j]=sc.nextInt()-1;
			int[] dp = new int[256];
			for(int i=0;i<256;i++){
				for(int j=0;j<5;j++){
					int s = a[0][j];
					if(s==-1)continue;
					if(j<4)s+=k[i][j];
					if(j>0)s+=k[i][j-1];
					dp[i] += p[s%4];
				}
			}
			for(int n=1;n<4;n++){
				int[] next = new int[256];
				//niÚÌóÔ
				for(int i=0;i<256;i++){
					int max = 0;
					//n-1iÚÌóÔ
					for(int j=0;j<256;j++){
						int sum = 0;
						for(int v=0;v<5;v++){
							if(a[n][v]==-1)continue;
							int s = a[n][v];
							if(v<4)s+=k[i][v]+k[j][v];
							if(v>0)s+=k[i][v-1]+k[j][v-1];
							sum += p[s%4];
						}
						max = Math.max(max, dp[j]+sum);
					}
					next[i] = max;
				}
				dp = next;
			}
			int res = 0;
			for(int i=0;i<256;i++){
				int sum = 0;
				for(int j=0;j<5;j++){
					if(a[4][j]==-1)continue;
					int s = a[4][j];
					if(j<4)s+=k[i][j];
					if(j>0)s+=k[i][j-1];
					sum += p[s%4];
				}
				res = Math.max(res, dp[i]+sum);
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#import <Foundation/Foundation.h>
int main() {
	int n;
	scanf("%d",&n);
	int *a = (int*)malloc(sizeof(int)*n);
	int *b = (int*)malloc(sizeof(int)*n);
	int *c = (int*)malloc(sizeof(int)*(n-1));
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	for(int i=0;i<n;i++){
		scanf("%d",b+i);
	}
	for(int i=0;i<n-1;i++){
		scanf("%d",c+i);
	}
	int prev=-2;
	int sum=0;
	for(int i=0;i<n;i++){
		int j=a[i]-1;
		sum += b[j];
		if(j-prev==1){
			sum+=c[prev];
		}
		prev=j;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 6228
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

vector<pair<int, int>> Pfact(int num) {
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= num; i++) {
        int cnt = 0;
        while (num % i == 0) {
            cnt++;
            num /= i;
        }
        if (cnt) res.emplace_back(i, cnt);
    }
    if (num != 1) res.emplace_back(make_pair(num, 1));
    return res;
}

  
int main() {
  int N;
  cin >> N;
  map<int,int> mp;
  srep(x,1,N+1){
    vector<pair<int, int>> res = Pfact(x);
    for(auto i: res) {
      mp[i.first] += i.second;
    }
  }
  ll ans = 1;
  for(auto x: mp) {
    ans *= (ll)(x.second + 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}



int main(){
  ll n,m; cin >> n >> m;
  vector<ll> dp(n+1); vector<bool> isbreak(n+1);
  
  rep(i,m){
    ll x; cin >> x;
    isbreak[x] = true;
  }
  
  if(n == 1){
    if(isbreak[1]) cout << 0 << endl;
    else cout << 1 << endl;
  }
  else{
    
  if(isbreak[1] && isbreak[2]){
    cout << 0 << endl;
    return 0;
  }
  else if(isbreak[1] && !isbreak[2]){
    dp[1] = 0; dp[2] = 1;
  }
  else if(!isbreak[1] && isbreak[2]){
    dp[1] = 1; dp[2] = 0;
  }
    else{
      dp[1] = 1; dp[2] = 2;
    }
    
    
    for(ll i=3; i <= n; i++){
      if(isbreak[i]){
        continue;
      }
      else{
        dp[i] = dp[i-1] + dp[i-2];
        dp[i] = mod(dp[i]);
      }
    }
    
    cout << dp[n] << endl;
  }
  
}
  

Measured memory_bytes: 1024
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		string s = Console.ReadLine();
		int counter = 0;
		for(int i=0;i!=3;i++){
			if(s.Substring(i,1)=="7"){counter++;}
		}
		if(counter==0){
			Console.WriteLine("No");
		}else{
			Console.WriteLine("Yes");
		}
		
	}
}

Measured memory_bytes: 25864
S=list(input())

def kai(str):
    return 1 if str == str[::-1] else 0

buf=kai(S)

count=0

if buf==True:
    print(0)
else:
    if len(S)%2==0:
        tmp=S[0:int(len(S)/2)]
        tmp2=S[int(len(S)/2):len(S)+1]
        for a,b in zip(tmp,tmp2[::-1]):
            if a!=b:
                count+=1
    else:
        tmp=S[0:int(len(S)/2)]
        tmp2=S[int(len(S)/2)+1:len(S)+1]
        for a,b in zip(tmp,tmp2[::-1]):
            if a!=b:
                count+=1

if count!=0:
    print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
     
    #define INF (1LL << 31 - 1)
    #define MOD int(1e9+7)
    #define repi(i,j,n) for(int i = (j); i < (n); ++i)
    #define rep(i,n) repi(i,0,n)
    #define fi first
    #define se second
     
    inline void init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
     
    string s;
     
    int main() {
        cin >> s;
        cout << s.substr(0, s.size() - 8) << endl;
        return 0;
    }

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

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;

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

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;                  //   | grep -v ' .* '  1300111 ~2^20.31
using vl = vector<ll>;                   //                    10300777 ~2^23.30
using vvl = vector<vl>;                  //                   100400999 ~2^26.58
using pll = pair<ll,ll>;                 //                  1300400999 ~2^30.28
using vpll = vector<pll>;                //                 10200500333 ~2^33.25
using vb = vector<bool>;                 //                100200400777 ~2^36.54
using vs = vector<string>;               //               1200300700111 ~2^40.13
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //              10200300500777 ~2^43.21
const ld eps = 1e-9;                     //             100200300400777 ~2^46.51
#define sz(c) ll((c).size())             //            1200300400600999 ~2^50.09
#define all(c) begin(c),end(c)           //           10200300400600111 ~2^53.18
#define mp make_pair                     //          100200300400600333 ~2^56.48
#define mt make_tuple                    //         1200300400500800999 ~2^60.06
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	ll n; cin >> n;
	vector<ld> ps(n);
	FOR(i,0,n) cin >> ps[i];

	vector<ld> dp(n+1, 0.0);
	dp[0] = 1 - ps[0];
	dp[1] = ps[0];

	FOR(i,1,n) {
		vector<ld> old = dp;

		dp[0] = old[0] * (1 - ps[i]);
		dp[i+1] = old[i] * ps[i];
		FOR(j,1,i+1) {
			dp[j] = old[j-1] * ps[i] + old[j] * (1 - ps[i]);
		}
	}

	ld res = 0.0;
	FOR(i,n/2 + 1,n+1) {
		res += dp[i];
	}

	cout << setprecision(11) << res << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a,b,c;

int main(){
    cin >> a >> b >> c;
    if(a==b&&b==c&&a==c){
        cout << 1 << endl;
    }else if(a==b||b==c||a==c){
        cout << 2 << endl;
    }else cout << 3 << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <algorithm>

using namespace std; 

int main()
{
	int n, *a, *b;
   long long c;

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

   c=0;
	for(int i=0; i<n; i++){
		if(a[i] <= b[i]){
          c = c+a[i];
          b[i]=b[i]-a[i];
          a[i]=0;
          if(a[i+1]<=b[i]){
             c = c+a[i+1];
             b[i]=b[i]-a[i+1];
             a[i+1]=0;
          }
          else{
             c= c+b[i];
             a[i+1]=a[i+1]-b[i];
             b[i]=0;
          }
      }
      else{
             c= c+b[i];
             a[i]=a[i]-b[i];
             b[i]=0;      
      }
	}      

   cout << c << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define mp make_pair
int main()
{
	std::ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if((a+b)==15)cout<<"+"<<endl;
	else if((a*b)==15)cout<<"*"<<endl;
	else cout<<"x"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200010;
ll a[N],b[N],k,x,s; // a b=-a
int n;
int les(ll* arr,int L,int R,ll y) {
    int M,B=-1;
    while(L<=R) {
        M=(L+R)>>1;
        if(arr[M]<y) B=M,L=M+1;
        else R=M-1;
    }
    return B;
}
int lar(ll *arr,int L,int R,ll y) {
    int M,B=-1;
    while(L<=R) {
        M=(L+R)>>1;
        if(arr[M]>y) B=M,R=M-1;
        else L=M+1;
    }
    return B;
}
ll ceild(ll a,ll b){
    if(a%b==0) return a/b;
    return a/b+1;
}
ll floord(ll a,ll b){
    if(a%b==0||a>0&&b>0||a<0&&b<0) return a/b; 
    return a/b-1;
    // return (ll)ceil((db)a/(db)b);
}
int check(ll val) {
    ll ls=0,lr=0,eq;
    int tmp;
    // cout<<ls<<" "<<lr<<endl;
    for(int i=1;i<=n;i++) {
        // printf("a[%d]=%lld\n",i,a[i]);
        if(a[i]>0){
            tmp=les(a,i+1,n,ceild(val,a[i]));
            if(tmp!=-1) ls+=(ll)(tmp-i);
            // printf("+less tmp : %d ls:%d\n",tmp,ls);
            tmp=lar(a,i+1,n,floord(val,a[i]));
            if(tmp!=-1) lr+=(ll)(n-tmp+1);
            // printf("+large tmp : %d lr:%d\n",tmp,lr);
        }
        else if(a[i]<0){
            tmp=lar(a,i+1,n,floord(val,a[i]));
            if(tmp!=-1) ls+=(ll)(n-tmp+1);
            // printf("-less tmp : %d ls:%d\n",tmp,ls);
            tmp=les(a,i+1,n,ceild(val,a[i]));
            if(tmp!=-1) lr+=(ll)(tmp-i);
            // printf("-large tmp : %d lr:%d\n",tmp,lr);
        }
        else {
            if(val>0)ls+=(ll)(n-i);
            if(val<0)lr+=(ll)(n-i);
        }
    }
    eq=s-lr;
    // cout<<ls<<" _ "<<eq<<" _ "<<lr<<endl;
    if(k<=ls) return 1;// less
    if(k<=eq) return 2;// eq
    return 3;//large
}
int main() {
    scanf("%d%lld",&n,&k);
    s=(n-1ll)*n/2ll;
    for(int i=1;i<=n;i++) {
        scanf("%lld",&x);
        a[i]=x;
    }
    sort(a+1,a+n+1);
    ll L=-1e18,R=1e18,M,ans;
    while(L<=R) {
        M=(L+R)>>1;
        int d=check(M);
        // cout<<L<<" "<<R<<" "<<M<<" "<<d<<endl;
        if(d==2) {ans=M;break;}
        else if(d==1) R=M-1;
        else L=M+1,ans=M;
        // system("pause");
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];
    vector<bool> v(k+1,false);
    rep(i,k+1){
        rep(j,n){
            if(i == a[j]) v[i] = true;
            if(i >= a[j] && !v[i-a[j]]) v[i] = true; 
        }
    }
    if(v[k]) puts("First");
    else puts("Second");
    //rep(i,k+1) cout << v[i] << " ";
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

current = 0
prev = 0
_min = min(h)
_max = max(h)

for i in range(n):
  current = h[i]

  if i == 0:
    prev = current

  if i == 0 and current > 1:
    prev = current - 1

  if current > prev:
    prev = current - 1
  
  if current < prev:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 14396
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 340;
int mod = 1e9 + 7;
int a[N][N], s[N], b[N],c[N];
int ans[N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) if (s[j] == '#'){
            a[i][j] = 1;
            b[j]++;
            c[i]++;
        }
        else a[i][j] = 0;
    }
    int cnt = 1;
    int l = 0;
    int r = 0;
    while(b[r] == 0) r++;
    int f1 = 1;
    while(r < m){
        while(b[r + 1] == 0 && r + 1 < m) r++;
        int h = 0;
        int w = 0;
        int u = 0;
        int f2 = 1;
        for (int i = l; i <= r; i++) if (b[i] != 0) w = i;
        while (a[h][w] == 0) h++;
        while(h < n){
            while (a[h + 1][w] == 0 && h + 1 < n) h++;
            for (int i = u; i <= h; i++){
                for (int j = l; j <= r; j++) ans[i][j] = cnt;
            }
            cnt++;
            h++;
            u = h;
            f2 = 0;
        }
        f1 = 0;
        r++;
        l = r;
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int h;
    in(h);
    vector<int> vec(h);
    in(vec);
    rep(i,h){
        printf("node %d:",i+1);
        printf(" key = %d,",vec[i]);
        if(i>=1)printf(" parent key = %d,",vec[(i-1)/2]);
        if(2*i+1<h)printf(" left key = %d,",vec[2*i+1]);
        if(2*i+2<h)printf(" right key = %d,",vec[2*i+2]);
        printf(" \n");
    }
}


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

int main(){
  int n = 0;
  cin >> n;
  vector<int64_t> memo(n+1);
  memo[0] = 2;
  memo[1] = 1;
  for(int i = 2; i <= n; i++){
    memo[i] = memo[i-2]+memo[i-1];
  }
  cout << memo[n] << endl;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>
using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
ll amida_list[10];

ll Amida(ll x){
	if (x==1) amida_list[x] = 1;
	else if (x==2) amida_list[x] = 2;
	else amida_list[x] = Amida(x-1) + Amida(x-2);
	return amida_list[x];
}
 

ll dp[101][9]; // メモ化テーブル


int main() {
	// 入力
	ll H,W,K;
	cin >>H>>W>>K;
 
	// 解法
	Amida(8);
	amida_list[0] = 1;
	// printf("amida: ");
	// for (ll i=1 ; i<=8; ++i){
	// 	printf("%lld ", amida_list[i]);
	// }
	// printf("\n");
	ll waru = 1000000007;
	memset(dp, 0, sizeof(dp)); // 一旦すべて0に
	dp[0][K] = 1;
	for (ll i=1 ; i<=H; ++i){
		for (int j=1; j<=W; ++j){
			if (j==1){ //左端
				ll tmp;
				tmp =   dp[i-1][j]*amida_list[W-1] 
				      + dp[i-1][j+1]*amida_list[W-2];
				tmp = tmp%waru;
				dp[i][j] = tmp;
			} 
			else if (j==W){ // 右端
				ll tmp;
				tmp =   dp[i-1][j-1]*amida_list[W-2] 
				      + dp[i-1][j]*amida_list[W-1];
				tmp = tmp%waru;
				dp[i][j] = tmp;
			} 
			else{
				ll tmp;
				tmp =   dp[i-1][j-1]*(amida_list[j-2]*amida_list[W-j])
				      + dp[i-1][j]*(amida_list[j-1]*amida_list[W-j])
				      + dp[i-1][j+1]*(amida_list[j-1]*amida_list[W-j-1]);
				tmp = tmp%waru;
				dp[i][j] = tmp;
			}
		}
	}
	
	// for (ll i=0 ; i<=H; ++i){
	// 	for (ll j=1 ; j<=W; ++j){
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }
	//出力
	// cout << dp[H][1]%waru << endl;
	if (W==1) cout<<1<<endl;
	else cout << dp[H][1] << endl;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(s.length() <= n)
  {
      cout<<s;
  }
  else if(s.length() > n)
  {
      string s2 = s.substr(0,n);
      s2.push_back('.');
      s2.push_back('.');
      s2.push_back('.');

      cout<<s2;

  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//#include <vector>
//#include <cmath>
std::vector<long long> div(long long n) {
	std::vector<long long> v(1, 1);
	if (n == 1) return v;
	for (long long i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) v.push_back(i);
	}
	if (sqrt(n) == (long long)sqrt(n)) {
		for (long long i = v.size() - 2; i >= 0; i--) v.push_back(n / v[i]);
	}
	else {
		for (long long i = v.size() - 1; i >= 0; i--) v.push_back(n / v[i]);
	}
	return v;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<ll> v = div(n);
	ll ans = 0;
	for (auto x : v) {
		ll m = n / x - 1;
		if (x < m) ans += m;
	}
	cout << ans << endl;
}

//n = m * x + x (x < m)
//n = x * (m + 1) (x < m)


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    ll sum = 0;
    for(int i=0;i<n;i++)cin>>a[i],sum += a[i];
    vector<ll> res;
    for(int i=1;i*i<=sum;i++)if(sum%i==0)res.push_back(i),res.push_back(sum/i);
    ll ans = 1;
    for(ll i=0;i<res.size();i++){
	ll tmp = 0;
	for(ll j=0;j<n;j++)tmp+= a[j],tmp%=res[i];
	if(tmp == 0){
	    vector<ll> e(n);
	    for(ll j=0;j<n;j++){
		e[j] = a[j]%res[i];
	    }
	    sort(e.begin(),e.end());
	    vector<ll> ep,em;
	    ep = e;
	    em = e;
	    for(ll j=0;j<n;j++){
		em[j] -=res[i];
	    }
	    for(ll j=1;j<n;j++) ep[j] += ep[j-1];
	    for(ll j=n-2;j>=0;j--) em[j] += em[j+1];
	    bool flag = false;
	    for(ll j=0;j<n-1;j++){
		if(ep[j]+em[j+1] == 0){
		    if(ep[j] <= k){
			flag = true;
		    }
		    break;
		}
	    }
	    if(flag)ans = max(ans,res[i]);
	}
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
long long  a[maxn];
long long  b[maxn<<1];
int c[maxn<<1];
long long sum;
    int n,m;
void f(int i) {
    if(a[i]>a[i-1]) {
        sum+=a[i]-a[i-1];
        b[a[i-1]+1]+=a[i-1]+1;
        b[a[i]+1]-=a[i-1]+1;
        c[a[i-1]+1]++;
        c[a[i]+1]--;
    } else {
        sum += m-a[i-1]+a[i];
        b[a[i-1]+1] += a[i-1]+1;
        b[a[i]+1] += m-a[i-1]-1;
        b[1] -= m-a[i-1]-1;
        c[1]++;
        c[a[i-1]+1]++;
        c[a[i]+1]--;
    }
}
int main() {
//    freopen("in.txt","r",stdin);
    sum=0;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; ++i)
        scanf("%lld",&a[i]);
    for(int i=2; i<=n; ++i) {
        f(i);
    }
    for(int i=1; i<=m; ++i) {
        c[i]+=c[i-1];
        b[i]+=b[i-1];
    }
    long long  ma=0;
    for(int x=1; x<=m; ++x) {
        if(c[x]) {
            ma=max(ma,1ll*x*c[x]-b[x]);
        }
    }
    printf("%lld\n",sum-ma);
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=1e5+5;
int n,a[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline bool cmp(int a,int b){ return a > b; }

int main(){
	n=rd();
	go(i,n+1,1) a[i]=rd();
	sort(a+1,a+n+1,cmp);
	int i=0;
	while(a[i+1] >= i+1) i++;
	int j=i;
	while(a[j+1] >= i && j+1 <= n) j++;
	if((j-i)%2 || (a[i]-i)%2) puts("First");
	else puts("Second");
	return 0;
}//Faze


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int n=A+B-C-D;
  if(n>0){
    cout<<"Left"<<endl;
  }
  else if(n==0){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;

class C2
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int x1 = h[2] - h[0], y1 = h[3] - h[1];

		var q = int.Parse(Console.ReadLine());
		var r = new int[q].Select(_ => Read())
			.Select(v =>
			{
				int x2 = v[0] - h[0], y2 = v[1] - h[1];
				return
					x1 * y2 > x2 * y1 ? "COUNTER_CLOCKWISE" :
					x1 * y2 < x2 * y1 ? "CLOCKWISE" :
					x1 * x2 < 0 || y1 * y2 < 0 ? "ONLINE_BACK" :
					Math.Abs(x1) < Math.Abs(x2) || Math.Abs(y1) < Math.Abs(y2) ? "ONLINE_FRONT" :
					"ON_SEGMENT";
			});
		Console.WriteLine(string.Join("\n", r));
	}
}



Measured memory_bytes: 18508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int x, y; cin >> x >> y;

  cout << x + y/2 << endl;

  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n), b(n);
	rep(i,n) cin >>a[i] >>b[i];
	vector<VI> dt(n, VI(3,0)), et=dt;
	rep(i,n){
				dt[i] = {a[i]+ b[i],   max(a[i],b[i]) ,i};
		et[i] = {b[i],  a[i]  ,i};
	}
	sort(all(dt));
	sort(all(et));
	//for(auto x :dt) printf("%d:%d:%d, ",x[0],x[1],x[2]); puts("");
	//for(auto x :et) printf("%d:%d:%d, ",x[0],x[1],x[2]); puts("");
	
	VI usd(n);
	ll ans = 0;
	rep(i,n){
		while(usd[dt.back()[2]]) dt.pop_back();
		auto cr=dt.back();
		ans += i%2==0? a[cr[2]]: -b[cr[2]];
		usd[cr[2]]=1;
	
	}
	
	cout <<  ans <<"\n";
	return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    int    q;
    double x1, x2, x3, x4, y1, y2, y3, y4, slope1, slope2, naiseki;

    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
              &x4, &y4);
        if (x1 == x2 && x3 == x4) {
            printf("2\n");
        } else if (x1 == x2 && x3 != x4) {
            if (y3 == y4)
                printf("1\n");
            else {
                printf("0\n");
            }
        } else if (x1 != x2 && x3 == x4) {
            if (y1 == y2)
                printf("1\n");
            else {
                printf("0\n");
            }
        } else {
            slope1  = (y2 - y1) / (x2 - x1);
            slope2  = (y4 - y3) / (x4 - x3);
            naiseki = (x2 - x1) * (x4 - x3) + (y2 - y1) * (y4 - y3);
            if (fabs(slope1 - slope2) < 0.00000001) {
                printf("2\n");
            } else if (fabs(naiseki) < 0.00000001) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3244
icase=0
if icase==0:
    s=list(input())
    acgt={"A","C","G","T"}
    sc=[0]*len(s)
    if s[0] in acgt:
        sc[0]=1
    for i in range(1,len(s)):
        if s[i] in acgt:
            sc[i]=sc[i-1]+1
    print(max(sc))
        

Measured memory_bytes: 3060
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e6 + 5;

int n, l[1005];
int sum;

int main() {
    
    cin >> n;
    n *= 2;
    for (int i = 1; i <= n; i++) {
    	cin >> l[i];
    }
    sort (l + 1, l + 1 + n);
    for (int i = 1; i <= n; i += 2) {
    	sum += l[i];
    }
	cout << sum;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

const int MAX_N = 100020;
ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD-2);
    }
}

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

    calc(100010);

    int n, k; cin>>n>>k;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    sort(a.begin(), a.end());

    vector<ll> pbase(n, 0);
    for(int i=0; i<n; i++){
        pbase[i] = comb(i, k - 1);
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += pbase[i] * a[i];
        ans %= MOD;
        ans -= (pbase[n - i - 1] * a[i]) % MOD;
        ans += MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
import java.util.*

fun main(args: Array<String>) {
    val num = Scanner(System.`in`).nextInt()

    val h = (num / 3600)
    val m = (num - (h * 3600)) / 60
    val s = (num - (h * 3600) - (m * 60))

    println("$h:$m:$s")
}


Measured memory_bytes: 27248
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int T=30000;
int calc(int n,int k) {
    if(n<k) return 0;
    if(n%k==0) return n/k;
    int t=(n/k+1);
    if(t>T) return calc(n-t,k);
    int x=(n%k)/t;
    if((n-x*t)%k) x++;
    return calc(n-x*t,k);
}
int n,ans;
int main() {
    rd(n);
    for(int i=1;i<=n;++i) {
        int a,k; rd(a),rd(k);
        ans^=calc(a,k);
    }
    if(ans) printf("Takahashi");
    else printf("Aoki");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m;
bool G[1000][1000];
map<P,bool> used;
vector<bool> visited;
vector<int> color;
vector<P> unko;
int w_=1,l=1;
bool isbipartite=true;

void dfs(int s){
    rep(i,n){
        if (!G[s][i]) continue;
        //cout << s << " " << t << " " << color[t] << endl;
        if (color[i]==-1){
            l+=1;
            color[i]=1-color[s];
            if (color[i]==0) w_+=1;
            //cout << t << " " << color[t] << endl;
            dfs(i);
        }else if(color[i]==color[s]){
            isbipartite=false;
        }
    }
}

void solve(){
    cin >> n >> m;
    visited.resize(n,false);
    color.resize(n,-1);
    rep(i,n){
        G[i][i]=0;
        rep(j,i){
            G[i][j]=1;
            G[j][i]=1;
        }
    }
    rep(i,m){
        int x,y;
        cin >> x >> y;
        G[x-1][y-1]=0;
        G[y-1][x-1]=0;
    }

    //cout << " " << endl;
    rep(i,n){
        if (color[i]==-1){
            color[i]=0;
            w_=1,l=1;
            dfs(i);
            //cout << w_ << " " << l << endl;
            unko.push_back(P(w_,l-w_));
        }
    }

    if (!isbipartite){
        cout << -1 << endl;
        return;
    }
    int u=unko.size();
    bool dp[1000][1000]={false};
    dp[0][0]=true;
    rep(i,u){
        per(j,n+1){
            if (!dp[i][j]) continue;
            dp[i+1][j]=false;
            dp[i+1][j+unko[i].first]=true;
            dp[i+1][j+unko[i].second]=true;
        }
    }

    ll a = -1;
    ll mindif = n;
    rep(i,n+1){
        if (!dp[u][i]) continue;
        if (mindif > abs(i - n/2)) mindif = abs(i - n/2), a = i;
    }
    long long b = n-a;
    cout << a*(a-1)/2 + b*(b-1)/2 << endl;
    
    
}


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

Measured memory_bytes: 1920
from itertools import combinations
from collections import defaultdict
N = int(input())
names = [input() for _ in range(N)]

d = defaultdict(int)
for name in names:
    tmp = name[0]
    if tmp in 'MARCH':
        d[tmp] += 1

keys = d.keys()
if len(keys) < 3:
    print(0)
else:
    cnt = 0
    for a, b, c in combinations(keys, 3):
        cnt += d[a] * d[b] * d[c]
    print(cnt)


Measured memory_bytes: 10120
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))//数组(结构体)清零 
#define ll long long
int A(int a,int b){if(a<b||a<1||b<0)return 0;int k=1;while(b--){k*=a--;}return k;}//数学中的Aab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
int C(int a,int b){if(a<b||a<1||b<0)return 0;b=min(a-b,b);int k=A(a,b),t=1;while(--b)k/=++t;return k;}//数学中的Cab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
int HW(char*HWa,int HWl,int HWr){if(HWr<HWl)swap(HWl,HWr);for(int i=0;i<(HWr-HWl)/2+1;i++)if(HWa[HWl+i]!=HWa[HWr-i])return 0;return 1;}//传递字符串名,判断区间l r,如果是回文字符串就返回1,否则返回0 
int SS(int a){if(a>4&&((a-1)%6)&&((a+1)%6))return 0;for(int i=2;i<=sqrt(a);i++)if(a%i==0)return 0;return 1;}//判断一个数是不是质数，是1 否0；请确保a>1; 
/*记得如果改int为long long,就把printf与scanf中相应的%d也改成%lld*/
int a1;
int main()
{
	int n,k,i,M=0,t,now,last;
	cin>>k>>n>>a1;
	last=a1;
	for(i=1;i<n;i++)
	{
		scanf("%d",&now);
		t=now-last;
		if(t>M)M=t;
		last=now;
	}
	t=a1+k-last;
	if(t>M)M=t;
	cout<<k-M;
	return 0;
}

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

int main() {
int N;
cin >> N;
for ( int i=0 ;i <N ; i++){
string s ;
cin >> s;
if (s=="Y"){
cout << "Four" << endl;
return 0;
}
}
cout << "Three" << endl;
return 0;
}

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

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A>=B){
    cout << "delicious" << endl;
  }
  else if(B<=A+X){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
int a, b;

void solve() {
	cin >> a >> b;
	cout << max({a + b, a - b, a * b}) << endl;
	return;
}

int main(int args, char* argv[]) {
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
int read(){char c=getchar();int d=0,f=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());return d*f;}
char Read(){char c=getchar();while(c<'0'||c>'9')c=getchar();return c;}
typedef pair<int,int>PII;
typedef long long LL;
const int N=100000;
const int mod=1e9+7;
int n,dp[N+1],a[N+1],t[N+1][3],tt[N+1],p[10];
char s[N+1];
int main(){
	scanf("%s",s+1); n=strlen(s+1);
	ref(i,1,n)a[i]=(s[i]=='a'?1:2);
	ref(i,1,n)(a[i]+=a[i-1])%=3;
	def(i,n,1){
		ref(j,0,2)t[i][j]=t[i+1][j]; t[i][a[i]]=i;
		tt[i]=tt[i+1]; if(i<n&&s[i]==s[i+1])tt[i]=i+1;
	}
	dp[0]=1;
	ref(i,0,n-1)if(dp[i]){
		p[0]=0;
		p[++p[0]]=i+1;
		if(tt[i+1])ref(j,0,2) if(j!=a[i]&&j!=a[i+1])p[++p[0]]=t[tt[i+1]][j];
		if(tt[i+1]&&a[n]!=a[i]){ p[++p[0]]=n; ref(j,1,p[0]-1)if(p[j]==n)p[0]--; }
		ref(j,1,p[0])(dp[p[j]]+=dp[i])%=mod;
		if(i&&i!=n-1&&!tt[i+1]){
			int S=(s[i]!=s[i+1])?(mod+dp[i]-dp[i-1]):dp[i];
			S=1LL*S*((n-i-1)/2)%mod;
			(dp[n]+=S)%=mod;
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 2688
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    int n, k, ans;
    cin >> n >> k;
    ans = 0;

    while (n > 0) {
        n = n / k;
        ans++;
    }

    cout << ans << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, k, a[100000];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	bool ans = false;
	LL x = a[0];
	inc(i, n) { x = gcd(x, a[i]); }
	LL ma = 0;
	inc(i, n) { setmax(ma, a[i]); }
	
	ans = (k <= ma && k % x == 0);
	
	cout << (ans ? "" : "IM") << "POSSIBLE" << endl;
	
	return 0;
}


Measured memory_bytes: 1024