akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100
#define MAX_K 100000

int n,k;
int a[MAX_N];
int dp[2][MAX_K + 1];

int rec(int turn, int k){
    if(dp[turn][k] != -1) return dp[turn][k];
    if(k < a[0]) return dp[turn][k] = (turn == 1) ? 0 : 1;
    if(turn){
        REP(i,n){
            if(k - a[i] < 0) continue;
            if(rec((turn == 1) ? 0 : 1, k - a[i]) == 1) return dp[turn][k] = 1;
        }
        return dp[turn][k] = 0;
    }else{
        REP(i,n){
            if(k - a[i] < 0) continue;
            if(rec((turn == 1) ? 0 : 1, k - a[i]) == 0) return dp[turn][k] = 0;
        }
        return dp[turn][k] = 1;
    }
}

signed main(){
    cin >> n >> k;
    REP(i,n){
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    if(rec(true, k) == 1) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;

const int N = 1001;
char a[N][N];
int H, W;
int F[N][N];

int dp(int x, int y) {
	if (x==1 and y==1) return 1;
	if (x<1 or y<1) return 0;
	if (a[x][y]=='#') return 0;
	if (F[x][y] > -1) return F[x][y];
	int ans = dp(x-1,y)+dp(x,y-1);
	ans %= MOD;
	F[x][y] = ans;
	return ans;
}

int main()
{
	//IN;OUT;
	FASTIO;
	cin >> H >> W;
	for (int i=1; i<=H; i++) 
		for (int j=1; j<=W; j++) {
			cin >> a[i][j];
			F[i][j] = -1;
		}
	cout << dp(H,W);
	return 0;
}
//965601742

Measured memory_bytes: 5248
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#define INF 1000000000
#define MN 200005
using namespace std;
int a, b, c;
int main() {
	scanf("%d%d%d", &a, &b, &c);
	int MAX=a;
	MAX = MAX < b ? b : MAX;
	MAX = MAX < c ? c : MAX;
	int sum = MAX * 3 - a - b - c;
	if (sum % 2 == 0) printf("%d", sum / 2);
	else printf("%d", sum / 2 + 2);
	return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){ans++;}
    }
    cout<<ans;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    if (a==b){
        cout << "a == b" << endl;
        return 0;
    }
    if (a>b){
        cout << "a > b" << endl;
        return 0;
    }
    if (a<b){
        cout << "a < b" << endl;
        return 0;
    }
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(){

  int n, x, i, j, k, count=0, total;

  while(1){
    scanf("%d %d", &n, &x);
    
    count=0;
    
    if(n == 0 && x == 0)break;
    
    for(i = 1; i <= n; i++){
      for(j = i + 1; j <= n; j++){
	for(k = j + 1; k <= n; k++){
	  total = i + j + k;
	  if(x == total){
	    count++;
	  }
	}
      }
    }
    printf("%d\n", count);
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________
	int k;
	string s;
	cin >> k >> s;
	int n = s.length();
	if (n <= k)
	{
		cout << s << en;
	}
	else
	{
		zip(i, 0, k)
		{
			cout << s[i];
		}
		cout << "..." << en;
	}



	return 0;
}


Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
A = (S1 >= 1 and S1 <= 12)
B = (S2 >= 1 and S2 <= 12)
if(A and B):
  print('AMBIGUOUS')
elif(A and not B):
  print('MMYY')
elif(not A and B):
  print('YYMM')
else:
  print('NA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

i64 dp[101][101010];

int main() {
    int n, W;
    cin >> n >> W;

    for (int i = 0; i < n; i++) {
        int v, w;
        cin >> w >> v;
        for (int j = 0; j < 101010; j++) {
            if (j - w >= 0) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    i64 ans = 0;
    for (int j = 0; j <= W; j++) {
        ans = max(ans, dp[n][j]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 79104
#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 n,k; cin>>n>>k;
    if(n%k==0) cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

string s;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> s;
	lint N = SZ(s);
	lint minv = 100;
	REP(anf, 26) {
		char c = 'a' + anf;
		lint cnt = 0, maxv = 0;
		REP(i, N) {
			if (s[i] != c) {
				cnt++;
			}
			else {
				chmax(maxv, cnt);
				cnt = 0;
			}
		}
		chmax(maxv, cnt);
		chmin(minv, maxv);
	}
	cout << minv << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cal(x,y) (x=x>y?x:y)
using namespace std;
const int N=350;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int f[N][N][N],n,k;
char s[N];
int main(){
    scanf("%s%d",s+1,&k);
    n=strlen(s+1);
    int ans=0;
    for (int i=1; i<=n; ++i)
	for (int j=n; j>=i; --j)
	    for (int l=k; ~l; --l){
		cal(f[i+1][j][l],f[i][j][l]);
		cal(f[i][j-1][l],f[i][j][l]);
		cal(f[i+1][j-1][l],f[i][j][l]+(s[i]==s[j]));
		if (l) cal(f[i+1][j-1][l-1],f[i][j][l]+1);
	    }
    for (int i=1; i<=n; ++i)
	for (int j=0; j<=k; ++j){
	cal(ans,f[i+1][i-1][j]*2-1);
	cal(ans,f[i+1][i][j]*2);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 145024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>

int main(){
    int n;
    scanf("%d",&n);
    int a[n+1][n+1];
    int i,j;
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)a[i][j]=0;
    for(i=1;i<=n;i++){
        int q,k;
        scanf("%d %d",&q,&k);
        for(j=1;j<=k;j++) {
            int p;
            scanf("%d",&p);
            a[q][p]=1;
        }
    }
    int time=0;
    std::stack<int>S;
    int ans[n+1][3];
    
    
    
    S.push(1);
    time++;
    ans[1][1]=time;
    
    int color[n+1];
    color[1]=1;
    for(i=2;i<=n;i++)color[i]=0;//0??????????¨????
    int lastcheck=0;
    
    while(lastcheck==0){
        while(S.size()>=1){
            int flag=0;//flag=0??????pop
            for(i=1;i<=n;i++){
                if(i!=S.top()&& a[S.top()][i]==1 &&color[i]==0){
                    S.push(i);
                    color[i]=1;
                    time++;
                    ans[i][1]=time;
                    flag=1;
                    break;
                }
            }
            if(flag==0){
                time++;
                ans[S.top()][2]=time;
                S.pop();
            }
        }
        lastcheck=1;
        for(i=1;i<=n;i++)if(color[i]==0){
            lastcheck=0;
            break;
        }
        if(lastcheck==0){
            S.push(i);
            time++;
            ans[i][1]=time;
            color[i]=1;
        }
    }
    
    
    for(i=1;i<=n;i++){
        printf("%d %d %d\n",i,ans[i][1],ans[i][2]);
    }
    return 0;
}

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

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=200000 +10, M=(ll)1e9+1 ;
const int mod =998244353 ,sz=5 ;

ll dig(ll x){
    return float(log10(x))+1;
}
void work(){
    ll n;
    cin >> n;
//    cout << dig(5) << " " << dig(10) << dig(1563) << "\n";
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(dig(i)&1)
            ans++;
    }
    cout << ans;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
//    cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
int r, g;
cin >> r >> g;

cout << (2*g-r) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[105][5], flag = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i][1] >> a[i][2];
    if (i >= 3) {
      if (a[i][1] == a[i][2] && a[i - 1][1] == a[i - 1][2] &&
          a[i - 2][1] == a[i - 2][2]) {
        flag = 1;
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n,f[130],a[130];
string st;
int main(){
    cin>>n;
    memset(f,127,sizeof(f));
    for(int i=1; i<=n; i++){
        cin>>st;
        memset(a,0,sizeof(a));
        for(int j=0; j<st.size(); j++)
        a[st[j]]++;
        for(int j=97; j<=122; j++)
        f[j]=min(a[j],f[j]);
    }
    for(int i=97; i<=122; i++){
        for(int j=1; j<=f[i]; j++)
        cout<<char(i);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{ll from,to,cost;};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m,p;
    cin>>n>>m>>p;
    vector<edge> g(m);
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[i]={a,b,-(c-p)};
    }
    vector<ll> dist(n,inf);
    dist[0]=0;
    rep(_,2*n){
        for(auto e:g){
            if(dist[e.from]!=inf){
                chmin(dist[e.to],dist[e.from]+e.cost);
            }
        }
    }
    vector<bool> flag(n,false);
    rep(_,2*n){
        for(auto e:g){
            if(dist[e.from]!=inf){
                if(chmin(dist[e.to],dist[e.from]+e.cost)){
                    flag[e.from]=flag[e.to]=true;
                }
            }
            if(flag[e.from]) flag[e.to]=true;
        }
    }
    if(!flag[n-1]) cout<<max(0ll,-dist[n-1])<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 384
for _ in range(20000):
    a, op, b = input().split()
    if op == '+':
        print(str(int(a) + int(b)))
    elif op == '-':
        print(str(int(a) - int(b)))
    elif op == '*':
        print(str(int(a) * int(b)))
    elif op == '/':
        print(str(int(a) // int(b)))
    elif op == '?':
        break


Measured memory_bytes: 5600
n,x = map(int,input().split())
a = list(map(int,input().split()))
if x==0:
    print(sum(a))
else:
    eat = 0
    for i in range(n-1):
        tmp = 0
        if a[i]+a[i+1]>x:
            tmp = a[i]+a[i+1]-x
            eat += tmp
            if tmp>a[i+1]:
                tmp -= a[i+1]
                a[i+1] = 0
                a[i] -= tmp
            else:
                a[i+1] -= tmp
    print(eat)
    #print(a)
            

Measured memory_bytes: 20100
# .....
# ..#.#
# ..#..
from collections import deque

H,W=[int(s) for s in input().split()]
maze=[input() for _ in range(H)]

point=[set() for _ in range(H*W)]
n=0
numcount=0
for h in range(H):
  for w in range(W):
    if maze[h][w]=='#':
      numcount+=1
      n+=1
      continue
    if h>0 and maze[h-1][w]=='.':
      point[n].add(n-W)
    if h<H-1 and maze[h+1][w]=='.':
      point[n].add(n+W)
    if w>0 and maze[h][w-1]=='.':
      point[n].add(n-1)
    if w<W-1 and maze[h][w+1]=='.':
      point[n].add(n+1)
    n+=1
#print(point)
def dfs(n):
  reach=deque([n])
  check=[-1 for _ in range(H*W)]
  check[n]=0
  while reach:
    v=reach.popleft()
    for e in point[v]:
      if not(e in reach) and check[e]==-1:
        reach.append(e)
        check[e]=check[v]+1
  return(max(check))

n=0
ans=set()
for h in range(H):
  for w in range(W):
    if maze[h][w]=='.':
      ans.add(dfs(n))
    n+=1
print(max(ans))

Measured memory_bytes: 3436
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const ll NMAX=50,MOD=1e9+7;
ll n,a[NMAX][NMAX],m[NMAX][NMAX],tmp[NMAX][NMAX];
ll k;

int multmod(int x,int y,int mod){
	
	int res=0;
	
	while(y!=0){
		//cout << x << ' ' << y << endl;
		if(y%2==1){
			res=(res+x)%mod;
		}
		x=(x+x)%mod;
		y/=2;
	}
	
	return res;
}

inline void multiplier(ll a[NMAX][NMAX],ll b[NMAX][NMAX],ll mod){
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			tmp[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				tmp[i][j]=(tmp[i][j]+a[i][k]*b[k][j])%mod;
			}
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			a[i][j]=tmp[i][j];
		}
	}
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> n >> k;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin >> a[i][j];
		}
		m[i][i]=1;
	}
	//fast_exp m=a^k
	
	while(k!=0){
		
		if(k%2==1){
			
			//m<-m*a
			multiplier(m,a,MOD);
			k--;
		}
		
		multiplier(a,a,MOD);
		k/=2;
	}
	
	int somme=0;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			somme=(somme+m[i][j])%MOD;
			//cout << m[i][j] << ' ';
		}
		//cout << endl;
	}
	
	cout << somme << '\n';
					
		
		
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll A, B;
    cin>>A>>B;
    vector<vector<ll>> X(100, vector<ll>(100, 0));
    rep(i, 50){
        rep(j, 100){
            X[i][j]=1;
        }
    }
    A--; B--;
    rep(i, 50){
        rep(j, 100){
            if(i%2&&j%2){
              	if(A==0)break;
                X[i][j]=0;
                A--;
            }
        }
        if(A==0)break;
    }
    for(ll i=99; i>=50; i--){
        rep(j, 100){
            if(i%2&&j%2){
              	if(B==0)break;
                X[i][j]=1;
                B--;
            }
        }
      	if(B==0)break;
    }
  	cout<<100<<" "<<100<<endl;
    rep(i, 100){
        rep(j, 100){
            if(X[i][j]==0)cout<<'.';
            if(X[i][j]==1)cout<<'#';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      char[][] s = new char[n][n];
      char[][] t = new char[m][m];
      boolean count = true;
      for(int i = 0;i < n;i++)s[i] = sc.next().toCharArray();
      for(int i = 0;i < m;i++)t[i] = sc.next().toCharArray();
      if(n==1){
      	if(s[0][0]==t[0][0])System.out.println("Yes");
        else System.out.println("No");
      }else{
      for(int i = 0;i < n-m;i++){
      	for(int j = 0;j < n-m;j++){
        	for(int k = 0;k < m;k++){
            	for(int l = 0;l < m;l++){
                	if(s[l+i][j+k]!=t[k][l])count = false;
                }
            }
            if(count){
              System.out.println("Yes");
              return;
            }
            else count = true;
        }
      }
      System.out.println("No");}
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126D3
{
    class Program
    {
        struct edge
        {
            public int to;
            public int length;
        }
        static List<edge>[] Tree;
        public static bool[] ans;
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Tree = new List<edge>[N + 1];
            for (int i = 0; i <= N; i++)
            {
                Tree[i] = new List<edge>();
            }
            ans = new bool[N+1];//頂点　1～N　0は使わない
            for (int i = 1; i <= N - 1; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int v = int.Parse(input[1]);
                edge e = new edge();

                e.length = int.Parse(input[2]);
                e.to = v;
                Tree[u].Add(e);// Tree[2]←{(5,2)  (3,10)}次の頂点と距離のリスト
                e.to = u;
                Tree[v].Add(e);// Tree[5]←{(2,2)}反対向きの辺
            }
            DFS(1, -1, false);
            for (int i = 1; i <=N; i++)
            {
                Console.WriteLine(ans[i] ? "1":"0");
            }
        }
        static void DFS(int v,int p,bool c)
        {
            ans[v] = c;
            foreach (var item in Tree[v])
            {
                if (item.to!=p)
                {
                    DFS(item.to, v, item.length % 2 == 0 ? c : !c);
                }
            }
        }
    }
}


Measured memory_bytes: 33392
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;

  ans += A * (N / (A + B));
  N %= (A + B);
  ans += min(A, N);

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


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

#ifdef LOCAL
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define dbgv(x) cerr << #x << " = " << x << endl
#define dbga(arr, len) {cerr << #arr << " = "; for (int _ = 0; _ < len; _++)\
cerr << arr[_] << " "; cerr << endl;}
#define dbgi(it) {cerr << #it << " = "; for (const auto& _ : it)\
cerr << _ << " "; cerr << endl;}
#else
#define dbg(...) (void)0
#define dbgv(x) (void)0
#define dbga(arr, len) (void)0
#define dbgi(it) (void)0
#endif

using ll = long long;
using dbl = long double;
using pii = pair<int, int>;

const int N = 100500;

bool can[N];

void solve() {
    can[0] = true;
    for (int i = 0; i < N; ++i) {
        if (!can[i]) {
            continue;
        }
        for (int j = 100; j <= 105; ++j) {
            int to = i + j;
            if (to >= N) {
                continue;
            }
            can[to] = true;
        }
    }

    int x;
    scanf("%d", &x);
    printf("%d\n", can[x] ? 1 : 0);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    dbg("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  int a, b, x, y;
  scanf("%d%d%d%d", &a, &b, &x, &y);
  printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A;
  B = N % 500;
  //cout << A << "," << B << endl;
  if (A >= B) {
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

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

B = [0]
for a in A:
    b = (B[-1] + (a-1)) % K
    B.append(b)

ans = 0
dic = {}
for i, b in enumerate(B):
    if b in dic:
        dic[b].append(i)
    else:
        dic[b] = deque()
        dic[b].append(i)
    
    while len(dic[b]) > 0 and dic[b][0] <= i - K:
        dic[b].popleft()
    ans += len(dic[b])-1
    

print(ans)

Measured memory_bytes: 166780
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long M, long C, long[] B, long[][] A) {
    return iota(N)
        .map!(i => zip(A[i], B).map!(t => t[0] * t[1]).sum + C)
        .filter!"a > 0"
        .count;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long M;
    M = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    long[] B = new long[](cast(size_t) (M));
    foreach (i; 0 .. cast(size_t) (M)) {
        B[i] = input.front.to!long;
        input.popFront;
    }

    long[][] A = new long[][](cast(size_t) (N), cast(size_t) (M));
    foreach (i; 0 .. cast(size_t) (N)) {
        foreach (j; 0 .. cast(size_t) (M)) {
            A[i][j] = input.front.to!long;
            input.popFront;
        }
    }

    static if (is(ReturnType!solve == void))
        solve(N, M, C, B, A);
    else
        solve(N, M, C, B, A).writeln;
}


Measured memory_bytes: 380
n, a, b = map(int, input().split())

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
    else:
        print(a)
else:
    ans = a*NumberOfRotations
    if a > n - ((a+b)*NumberOfRotations):
        print(ans+surplus)
    else:
        print(ans+a)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
sum = 0
for item in a:
    sum += item
ave = sum / n
ans = [200, 0]
for i in range(n):
    if abs(a[i]-ave) < ans[0]:
        ans[0] = abs(a[i]-ave)
        ans[1] = i
print(ans[1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
const int MAXN=2000;
//arr 1 adalah arr invers
//versi adalah jenis yang mana yang mau diambe
int par[MAXN+5],kompterbesar,size[MAXN+5],n,m,arr[2][MAXN+5][MAXN+5],versi[MAXN+5]={},ans,beda[MAXN+5],jauh[MAXN+5];
vector <int> edgelist;
void resetdisjoint(){				//yang akan dibagi jadi komponen itu yang menurun
	kompterbesar=1;
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
		size[i]=1;
	}
}
int finds(int u){
	if(par[u]!=u)
		par[u]=finds(par[u]);
	return par[u];
}
void gabung(int u,int v){
	u=finds(u);
	v=finds(v);
	if(u==v)
		return;
	if(size[u]<size[v])
		swap(u,v);
	//yang jadi parent itu yang punya size lebih besar dan dipasikan u
	size[u]+=size[v];
	par[v]=u;
	
	//update komponen terbesar
	kompterbesar=max(kompterbesar,size[u]);
}
void updateans(int calonans){
	ans=max(ans,calonans);
}
void buatarrinvers(){
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			arr[1][i][j]=arr[0][i][j]^1;
}
void tentukanversi(int kolom){		//menentukan bentuk invers atau tidak yang di pake
	versi[1]=0;
	for(int i=2;i<=n;i++)
	{
		versi[i]=0;
		if(arr[versi[i]][i][kolom]!=arr[versi[i-1]][i-1][kolom])
			versi[i]=1;
	}
}
void updatebeda(int kolom){			//memperbaiki nilainya beda sama yang diatasnya
	for(int i=2;i<=n;i++)
	{
		if(beda[i]<=kolom)
			beda[i]=kolom+1;
		while(beda[i]<=m&&(arr[versi[i-1]][i-1][beda[i]]==arr[versi[i]][i][beda[i]]))
			beda[i]++;
	}
}
void isijauh(int kolom){			//isi jauh nya beda sama dia
	for(int i=2;i<=n;i++)
		jauh[i]=beda[i]-kolom;
}
bool cmpbeda(int a,int b){			//menentukan urutan edgelist sort dari yang paling jauh
	return (jauh[a]>jauh[b]);
}
int main()
{
	scan(n,m);
	ans=max(n,m);
	for(int i=1;i<=n;i++)			//baca input;
	{
		char input[m];
		scanf("%s",&input);
		for(int j=0;j<m;j++)			//0-based jadi 1-based
			arr[0][i][j+1]=(input[j]=='#')?1:0;
	}
	
	edgelist.resize(n-1);			//inisialisasi edgelist
	for(int i=0;i<edgelist.size();i++)
		edgelist[i]=i+2;
	
	buatarrinvers();
	memset(beda,-1,sizeof(beda));			//posisi beda pertamanya anggap dulu tidak ada
	for(int i=1;i<=m;i++)			//proses
	{
		tentukanversi(i);			//buat mereka angka depannya sama
		resetdisjoint();
		updatebeda(i);
		isijauh(i);
		sort(all(edgelist),cmpbeda);
		/*for(int i=1;i<=n;i++)
			cout<<versi[i]<<endl;
		cout<<endl<<endl;
		cout<<"ohahahage "<<beda[2]<<endl;*/
		for(auto v:edgelist)
		{
			gabung(v,v-1);
			updateans(kompterbesar*jauh[v]);
		}
	}
	cout<<ans<<endl;
}

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

int exgcd(int a,int b,int &x,int &y){
	while(b){
		int t{a/b};
		swap(a-=t*b, b);
		swap(x-=t*y, y);
	}
	return a;
}
int exgcd(int a,int b){
	int x{1},y{0};
	return exgcd(a,b,x,y);
}

int inverse(int a,int mod){
	int x{1},y{0};
	exgcd(a,mod,x,y);
	return (x%mod+mod)%mod;
}

int main() {
	int x,y; cin>>x>>y;
	cout << exgcd(x,y) <<endl;
}


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

int main()
{
	long long a = 0, b = 0;
	char op;
	cin >> a >> op >> b;
	if (op=='+')
	{
		cout << a + b;
	}
	else if (op == '-')
	{
		cout << a - b;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    #define N 100
    // Your code here!
    char buf[N] = {};
    char str1[N*2] = {};
    char str2[N];
    
    int i = 0;
    int j = 0;
    int cnt = 0;
    int flg = 0;
    
    scanf( "%s %s" , buf , str2 );
    
    while ( buf[i] != '\0' ) {
        cnt++;
        i++;
    }
    i = 0;    
    while( buf[i] != '\0' ){
        str1[i] = buf[i];
        str1[ i + cnt ] = buf[i];
        i++;  
    }
    //printf("%s\n",str1);
    for( i = 0 ; i < cnt * 2 && flg == 0; i++ ){
        for( j = 0; j < cnt+1 ; j++ ){
            if( str2[j] == '\0' ){
                flg = 1;
                //printf("%d-%d o %c == %c\n" , i,j,str1[i+j],str2[j]);
                break;
            }else if( str1[i+j] != str2[j] ){
                //printf("x %c != %c\n" , str1[i+j],str2[j]);
                break;
            }
            //printf("%d-%d △ %c == %c\n" , i,j,str1[i+j],str2[j]);
        }
        j = 0;
        //printf("%d---\n",i);
    }
    

    if ( flg == 1 ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
}



Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int main()
{
  int n,k;
  scanf("%d",&n);
  int count=0;
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&k);
    if(i%2==1 && k%2==1)
    count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> as = vector<int>(N);
  for (int i = 0; i < N; i++) {
    cin >> as.at(i);
  }
  int c = 1;
  for (int i = 0; i < N; i++) {
    if (as.at(i) % 2 == 0) {
      if (as.at(i) % 3 == 0 || as.at(i) % 5 == 0) {
        c = c * 1;
      } else {
        c = c * 0;
      }
    }
  }
  if (c == 1) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <numeric>

using namespace std;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    auto r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int a, ans;
  cin >> ans >> ans;
  while (cin >> a) ans = gcd(ans, a);
  cout << ans << endl;
}


Measured memory_bytes: 3568
#!/usr/bin/env python
import sys

def _i(): return int(sys.stdin.readline().strip())

n = _i()
nmin = n//100
mod = n%100
m = 0
for i in range(5,0,-1):
    num = mod // i
    m += num
    mod-= num*i
#
if nmin>=m: print(1)
else: print(0)


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int	nqp[200001] = {0};
long long ans[200001] = {0};

int main()
{
	int		a,b,c,i,j,k,n,q,p,x;
	
	scanf("%d %d", &n, &q);
	
	for(i=1;i<n;i++) {
		scanf("%d %d", &a, &b);
		nqp[b] = a;
	}
	for(k=1;k<=q;k++) {
		scanf("%d %d", &p, &x);
		ans[p] += x;
	}
	for(i=2;i<=n;i++) {
		j = i;
		if (nqp[j]!=0) {
			ans[i] += ans[nqp[j]];
		}
	}
	for(i=1;i<=n;i++) {
		printf("%lld",ans[i]);
		if (i==n) printf("\n");
		else printf(" ");
	}

	return 0;
}


Measured memory_bytes: 4608
l = list(map(int, input().split()))
n = l[1]
ans = []
anss = []
for i in range (0,n):
  m = list(map(int, input().split()))
  ans.append(m[0])
  anss.append(m[1])

if min(anss)-max(ans)+1 > 0:
  print(min(anss)-max(ans)+1)
if min(anss)-max(ans)+1 <= 0:
  print(0)

Measured memory_bytes: 11256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int a[] = {0,1,2,3,5,7,8,9};
void solve(int n){
  if(!n) return;
  solve(n/8);
  cout << a[n%8];
}
int main(void){
  int n;
  while(cin >> n && n){
    solve(n);
    cout << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll c ; cin >> c ;
	vll a(n),b(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) >> b.at(i) ;
	vll mxr(n+1,0),mxl(n+1,0),sum(n+1,0) ;
	for(int i=0;i<n;i++) sum.at(i+1) = sum.at(i)+b.at(i) ;
	for(int i=0;i<n;i++){
		mxr.at(i+1) = sum.at(i+1)-2*a.at(i) ;
		mxl.at(i+1) = (sum.at(n)-sum.at(i))-2*(c-a.at(i)) ;
	}
//	for(int i=0;i<=n;i++) cout << mxl.at(i) << endl ;
	for(int i=1;i<=n;i++){
		mxr.at(i) = max(mxr.at(i),mxr.at(i-1)) ;
		mxl.at(n-i) = max(mxl.at(n-i),mxl.at(n-i+1)) ;
	}
	for(int i=0;i<n;i++) mxl.at(i) = mxl.at(i+1) ; mxl.at(n) = 0 ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		ll sub1 = sum.at(i+1)-a.at(i) ;
		ll sub2 = sum.at(n)-sum.at(i)-(c-a.at(i)) ;
		ll sub3 = mxl.at(i+1)+sub1 ;
		ll sub4 = mxr.at(i)+sub2 ;
		ans = max(ans,max(max(sub1,sub2),max(sub3,sub4))) ;
	}
//	for(int i=0;i<n;i++){
//		cout << sum.at(i+1) << " " << mxr.at(i+1) << " " << mxl.at(i+1) << endl ;
//	}
	cout << ans << endl ;
}


Measured memory_bytes: 4224
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> prime(0);//i番目の素数
vector<bool> is_prime(0);//iは素数か
//n以下の素数の数
int hurui(int n){
    is_prime.resize(n+1,true);
    is_prime[0]=0; is_prime[1]=0;
    int p=0;
    REP(i,2,n+1){
        if(is_prime[i]){
            prime.emplace_back(i);
            p ++;
            for(int j=2*i; j<=n; j +=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    hurui(1000);//168個
    set<int> onazi;

    int cnt=0;
    bool pw=true,sw=true;

    for(auto x: prime){
        cnt=0;
        rep(i,n){
            if(a[i]%x==0){
                cnt ++;
                while(a[i]%x==0){
                    a[i] /=x;
                }
            }
        }
        if(cnt<=1) continue;
        else if(cnt<n){
            pw=false;
        }
        else if(cnt==n){
            pw=false;
            sw=false;
            break;
        }
    }

    cnt=0;
    rep(i,n){
        if(a[i]==1) cnt++;
        else onazi.insert(a[i]);
    }
    int x=onazi.size();
    if(cnt==0 && x==1){
        sw=false;
        pw=false;
    }
    else if(cnt+x<n){
        pw=false;
    }
    if(pw && sw) cout<<"pairwise coprime"<<endl;
    else if(sw) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}/*
./problem.exe
*/

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(pair<pii,int> (itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, x[100100], y[100100], w[100100], r;
map<pii,int> p;


signed main() {
	cin >> n;
	rep(i,n) {
		cin >> x[i] >> y[i] >> w[i];
		p[{x[i],y[i]}] = w[i];
	}
	rep(i,n) {
		int t = w[i] + p[{x[i]+1,y[i]}];
		chmax(r, (t + p[{x[i],y[i]+1}] + p[{x[i]+1,y[i]+1}]));
		chmax(r, (t + p[{x[i],y[i]-1}] + p[{x[i]+1,y[i]-1}]));
	}
	cout << r << " / 1" << ln;
}


Measured memory_bytes: 41900
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_e
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define sc(x) scanf("%lld",&x);
#define int long long
#define fi first
#define se second
#define endl '\n'
#define P pair<int,int>
#define fi first
#define se second
 
 
 
int A[200004];
int B[200005];
map<int,int> mp;
signed main()
{
	    int n;sc(n)
		        for(int i=1;i<=n;i++){sc(A[i])B[i]=A[i]-i;mp[B[i]]++;}
	        int a = 0;
		 
		for(int i=1;i<=n;i++){
			        a += mp[-(A[i]+i)];
				 
				    }
		    cout<<a;
		        return 0;
}


Measured memory_bytes: 29356
package main

import (
	"fmt"
)

func main() {

	var A, B, T int
	fmt.Scan(&A, &B, &T)

	bisket := 0
	for i := 1; i <= T; i++ {
		if i%A == 0 {
			bisket += B
		}
	}

	fmt.Println(bisket)
}


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

int main(){
int H,W;
  cin>>H>>W;
  vector<vector<string>> X(H,vector<string>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>X.at(i).at(j);
    }
  }
  char a;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(X.at(i).at(j)=="snuke"){
        a = j+'A';
        cout<<a<<i+1<<endl;
      }
    }
  }
}

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

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> H(N);
    int ans = 1;

    for (int i = 0; i < N; ++i) {
        std::cin >> H[i];
    }

    for (int i = 1; i < N; ++i) {
        bool f = true;
        for (int j = 0; j < i; ++j) {
            if (H[i] < H[j]) f = false;
        }
        if (f) ++ans;
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, ans = 0;
  cin >> N;
  vi A(N);
  REP(I, N) cin >> A.at(I);
  REP(i, N) {
    if ((i+1) % 2 == 1 && A.at(i) % 2 == 1) ans++;
  }
  cout << ans << endl;
}

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

int main() {
    int k;
    int a,b;
    cin >> k;
    cin >> a >> b;
    for (int i=a; i<=b; i++) {
        if (i%k==0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int MX = 1e5 + 1;
vector<int> adj[MX + MX + 6];
int vis[MX + MX + 6];
int X, Y;

void dfs(int u) {
    if (vis[u])return;
    vis[u] = true;
    if (u > MX)Y++;
    else X++;

    for (int nxt : adj[u])
        dfs(nxt);
}

int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vii v(n);
    for (auto &p : v) {
        cin >> p.sc >> p.fr;
    }

    sort(ALL(v));
    long long cur = 0;
    for (auto p : v) {
        cur += p.sc;
        if (cur > p.fr) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>  
using namespace std;  
  
// üÍ  
int a, b;  
  
void solve()  
{  
    int res = 0;  
  
    a += b;  
  
    for (; a; a /= 10)  
        res++;  
  
    cout << res << endl;  
}  
  
int main()  
{  
    while (cin >> a >> b)  
        solve();  
  
    return 0;  
} 

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
map<ll,ll> mp;
map<ll,ll> WA;
int main()
{
	ll n,m;
	cin>>n>>m;
	ll sum = 0;
	FOR(i,0,m)
	{
		ll a;
		string s;
		cin>>a>>s;
		if(s == "AC")
		{
			if(mp[a]!=1)
			{
				sum+=WA[a];
			}
			mp[a] = 1;
		}
		else
		{
			WA[a]++;
		}
	}
	cout<<mp.size()<<" "<<sum<<endl;
	return 0;
}


Measured memory_bytes: 15960