akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  int a[n];
  int s = 0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    s ^= a[i];
  }
  int ans = s^a[0];
  cout << ans;
  for(int i=1; i<n; i++){
    ans = s^a[i];
    cout << " " << ans;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4340
#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() {
  ll X;
  cin >> X;

  int ans = 0;
  ll amount = 100;
  while(X > amount){
    amount *= 1.01;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#define N 44

int main(){
  int n ,i ,fib[N];

  fib[0]=1;
  fib[1]=1;

  scanf("%d",&n);
  if(n==0 || n==1) printf("1\n");

  else {
    for(i=2;i<=n;i++){
      fib[i]=fib[i-1]+fib[i-2];
    }
    printf("%d\n",fib[i-1]);
  }

  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(100005)
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
using namespace std;
typedef pair<ll, pair<int, int> > pii;

int dp[2][MAXN], n, minor = INF, vet[MAXN], cont = 0;


int solve(int i, int j) {

    if(dp[i][j] != 0) return dp[i][j];

    if(i == 0 && j < minor) return -1;
    if(i == 1 && j < minor) return 1;

    if(i == 1) dp[i][j] = 1;
    else dp[i][j] = -1;

    for(int z = 1; z <= n; z++) {
        if(i == 0 && j >= vet[z]) dp[i][j] = max(dp[i][j], solve(i^1, j-vet[z]));
        else if(i == 1 && j >= vet[z]) dp[i][j] = min(dp[i][j], solve(i^1, j-vet[z]));
    }

    return dp[i][j];
}

int main() {
    FAST;
    int k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> vet[i];
        minor = min(vet[i], minor);
    }
    cout << (solve(0, k) == 1 ? "First" : "Second") << fim;
}



Measured memory_bytes: 7296
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
A = array[1].split(" ").map(&:to_i)

count = 0
ans   = A.dup

while true
  if ans.all?{|a| a % 2 == 0}
    count += 1
    ans = ans.map{|a| a / 2}
  else
    break
  end
end

puts count

Measured memory_bytes: 1916
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
map<ll,int> s;
map<ll,bool> h;
const int maxn=100000+10,maxd=2200;
int id[maxn],pri[maxn],f[maxn],p[maxn][2],sta[maxn];
ll a[maxn],b[maxn];
bool bz[maxn];
int i,j,l,n,m,tot,top,cnt,ans,ca;
ll k,t;
int main(){
    fo(i,2,maxn-10){
        if (!bz[i]) pri[++top]=i,f[i]=i;
        fo(j,1,top){
            if ((ll)i*pri[j]>maxn-10) break;
            bz[i*pri[j]]=1;
            f[i*pri[j]]=pri[j];
            if (i%pri[j]==0) break;
        }
    }
    scanf("%d",&n);
    fo(i,1,n){
        scanf("%lld",&a[i]);
        k=a[i];
        a[i]=b[i]=1;
        fo(j,2,maxd){
            if (k==1) break;
            if (bz[j]) continue;
            t=(ll)j*j*j;
            while (k%t==0) k/=t;
            t=j*j;
            if (k%t==0){
                a[i]*=t;
                b[i]*=j;
            }
            else if (k%j==0){
                a[i]*=j;
                b[i]*=t;
            }
            while (k%j==0) k/=j;
        }
        if (k>1){
            t=ll(sqrt(k));
            if (t*t==k){
                a[i]*=k;
                b[i]*=t;
            }
            else{
                a[i]*=k;
                b[i]*=k*k;
            }
        }
    }
    fo(i,1,n) s[a[i]]++;
    fo(i,1,n)
        if (!h[a[i]]){
            h[a[i]]=1;
            if (a[i]==b[i]) ans++;
            else{
                ans+=max(s[a[i]],s[b[i]]);
                h[b[i]]=1;
            }
        }
    printf("%d\n",ans);
}

Measured memory_bytes: 27392
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        int ans = 700;

        for(int i=0; i<3; i++){
            if(S.substring(i, i+1).equals("o")){
                ans += 100;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

int main()
{
	int k;
	cin >> k;

	if (k % 7 == 0)
		k /= 7;

	if (__gcd(10, k) != 1) {
		cout << -1 << endl;
		return 0;
	}

	long v = 1 % k;
	int len = 1;
	while (v != 0) 
	{
		v = (10 * v + 1) % k;
		len++;
	}
	cout << len << endl;
}



Measured memory_bytes: 3576
program k_th_k
  implicit none
  integer :: n, x(500) = 0, a(250000) = 0, i, j, m, c, k
  integer :: idx(250000) = 0, num(500) = 0
  read(*,*) n
  read(*,*) x(1:n)
  do i = 1, n
    a(x(i)) = i
    idx(x(i)) = i
  end do
  m = 0
  do i = 1, n*n
    if (idx(i) == 0) cycle
    c = 1
    do while (c < idx(i))
      m = m+1
      if (a(m) > 0) cycle
      a(m) = idx(i)
      c = c+1
    end do
  end do
  do i = 1, n*n
    if (idx(i) > 0 .and. idx(i) /= n) then
      k = idx(i)
      j = i
      exit
    end if
  end do
  c = 0
  do while (m < n*n)
    m = m+1
    if (a(m) > 0) cycle
    a(m) = k
    c = c+1
    if (c == n-k) then
      do i = j+1, n*n
        if (idx(i) > 0 .and. idx(i) /= n) then
          k = idx(i)
          j = i
          exit
        end if
      end do
      c = 0
    end if
  end do
  do i = 1, n*n
    num(a(i)) = num(a(i))+1
    if (num(a(i)) == a(i) .and. x(a(i)) /= i) then
      write(*,'(a)') "No"
      stop
    end if
  end do
  write(*,'(a)') "Yes"
  write(*,'(i0)',advance='no') a(1)
  do i = 2, n*n
    write(*,'(x,i0)',advance='no') a(i)
  end do
  write(*,*)
  stop
end program k_th_k

Measured memory_bytes: 2816
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
int main()
{
    ll a,b,c,n,sum=0;
    string s;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum;
}


Measured memory_bytes: 3592
N = int(input())
tree = [{'parent': -1, 'left': -1, 'right': -1, 'sibling': -1} for _ in range(N)]
parent = set(n for n in range(N))

for _ in range(N):
    inp = [int(n) for n in input().split()]
    tree[inp[0]]['left'] = inp[1]
    tree[inp[0]]['right'] = inp[2]

    if inp[1] != -1:
        tree[inp[1]]['parent'] = inp[0]
        tree[inp[1]]['sibling'] = inp[2]
    if inp[2] != -1:
        tree[inp[2]]['parent'] = inp[0]
        tree[inp[2]]['sibling'] = inp[1]
    parent = parent.difference(inp[1:])

root = parent.pop()

def preParse(u):
    if u == -1:
        return 
    print(f' {u}', end = '')
    preParse(tree[u]['left'])
    preParse(tree[u]['right'])

def inParse(u):
    if u == -1:
        return 
    inParse(tree[u]['left'])
    print(f' {u}', end = '')
    inParse(tree[u]['right'])

def postParse(u):
    if u == -1:
        return 
    postParse(tree[u]['left'])
    postParse(tree[u]['right'])
    print(f' {u}', end = '')

print('Preorder')
preParse(root)
print()

print('Inorder')
inParse(root)
print()

print('Postorder')
postParse(root)
print()


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
const ll mod=1e9+7;
int a[N],b[N];
int main()
{
    int n;
    scanf("%d",&n);

    for(int i=1;i<=n+1;i++)
    scanf("%d",&a[i]);

    for(int i=1;i<=n;i++)
    scanf("%d",&b[i]);

    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>b[i])
            sum+=b[i],b[i]=0;
        else
            sum+=a[i],b[i]-=a[i];
            
        if(b[i]>a[i+1])
            sum+=a[i+1],a[i+1]=0;
        else
            sum+=b[i],a[i+1]-=b[i];
            
    }
    printf("%lld\n",sum);
    return 0;
}


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

main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X ;
  int sum = 0;
 // vector<vector<vector<int>>> kei(A,vector<vector<int>>(B,vector<int>(C,0)));
  
  for(int i=0; i<A+1; i++){
  for(int j=0; j<B+1; j++){
  for(int k=0; k<C+1; k++){
 //   kei[i][j][k]=i*500+j*100+k*50;
    if(X==i*500+j*100+k*50){
      sum=sum+1 ;
    }   
  }}}
  
cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    vi  c(26);
    REP(i, 26) cin >> c[i];
    vvl s(d, vl(26));
    REP(i, d) REP(j, 26) cin >> s[i][j];

    vl t(d);
    REP(i, d) cin >> t[i];

    vi last(26);
    ll ans = 0;
    REP(i, d) {
        ans += s[i][t[i] - 1];
        last[t[i] - 1] = i + 1;
        REP(j, 26) {
            ans -= c[j] * ((i + 1) - last[j]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, a, b) for (auto i = (a); i < (b); i++)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))
 
#include <boost/operators.hpp>
 
class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}
 
 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 1e9 + 7;
 
main() {
  modint n, m;
  cin >> n >> m;
  modint re(0), nci(1), mpi(1), mipni(1), m1pi(1);
  rep(i, modint(0), n) mipni *= m - i;
  rep(i, modint(0), n + 1) {
    re += nci * m1pi * mpi * mipni.pow(2);
    nci *= n - i;
    nci /= i + 1;
    mpi *= m - i;
    mipni /= m - i;
    m1pi *= -1;
  }
  cout << re << endl;
}

Measured memory_bytes: 3644
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
#print(s1, s2)
L=[]

for i in range(1, 13):
    L.append(i)


if s1 not in L and s2 not in L:
    print('NA')
elif s1 in L and s2 not in L:
    print('MMYY')
elif s1 not in L and s2 in L:
    print('YYMM')
else:
    print('AMBIGUOUS')


Measured memory_bytes: 9112
n,m = gets.split.map(&:to_i)
a_vec = []
n.times do
  a_vec << gets.split.map(&:to_i)
end

b_vec =[]
m.times do
  b_vec << gets.to_i
end

a_vec.each do |v|
  sum = 0
  m.times do |i|
    sum += (v[i] * b_vec[i])
  end
  puts sum
end


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

int main(){
	int A,B,C,D,L,R;
  	
  	cin >> A >> B >> C >> D;
  	L = A + B;
  	R = C + D;
  
  	if(L > R){
    	cout << "Left" << endl;
    }else if(L == R){
    	cout << "Balanced" << endl;
    }else if(L < R){
    	cout << "Right" << endl;
    } 

}

Measured memory_bytes: 256
readlines.each do |times|
  time_500, time_1000 = times.split.map(&:to_f)
  if time_500 < 35.50 && time_1000 < 71.00
    puts "AAA"
  elsif time_500 < 37.50 && time_1000 < 77.00
    puts "AA"
  elsif time_500 < 40.00 && time_1000 < 83.00
    puts "A"
  elsif time_500 < 43.00 && time_1000 < 89.00
    puts "B"
  elsif time_500 < 50.00 && time_1000 < 105.00
    puts "C"
  elsif time_500 < 55.00 && time_1000 < 116.00
    puts "D"
  elsif time_500 < 70.00 && time_1000 < 148.00
    puts "E"
  else
    puts "NA"
  end    
end

Measured memory_bytes: 6108
#include<iostream>
#include<deque>
#include<vector>
using namespace std;
int H,W,K;
int sx,sy,gx,gy;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
main()
{
	cin>>H>>W>>K;
	cin>>sx>>sy>>gx>>gy;
	sx--,sy--,gx--,gy--;
	vector<string>S(H);
	for(int i=0;i<H;i++)cin>>S[i];
	vector<vector<vector<pair<int,int> > > >D(H,vector<vector<pair<int,int> > >(W,vector<pair<int,int> >(4,make_pair((int)1e9,0))));
	deque<pair<pair<int,int>,int> >P;
	for(int r=0;r<4;r++)
	{
		D[sx][sy][r]=make_pair(1,-K);
		P.push_back(make_pair(make_pair(sx,sy),r));
	}
	while(!P.empty())
	{
		int x=P.front().first.first,y=P.front().first.second;
		int r=P.front().second;
		P.pop_front();
		int nd=D[x][y][r].first;
		int nk=-D[x][y][r].second;
		//cout<<"("<<x<<", "<<y<<", "<<r<<") = "<<nd<<", "<<nk<<endl;
		{
			int tx=x+dx[r],ty=y+dy[r];
			if(nk>0&&tx>=0&&ty>=0&&tx<H&&ty<W&&S[tx][ty]=='.')
			{
				pair<int,int>nxt=make_pair(nd,1-nk);
				if(D[tx][ty][r]>nxt)
				{
					D[tx][ty][r]=nxt;
					P.push_front(make_pair(make_pair(tx,ty),r));
				}
			}
		}
		for(int nr=0;nr<4;nr++)
		{
			int tx=x+dx[nr],ty=y+dy[nr];
			if(tx>=0&&ty>=0&&tx<H&&ty<W&&S[tx][ty]=='.')
			{
				pair<int,int>nxt=make_pair(nd+1,1-K);
				if(D[tx][ty][nr]>nxt)
				{
					D[tx][ty][nr]=nxt;
					P.push_back(make_pair(make_pair(tx,ty),nr));
				}
			}
		}
	}
	int ans=1e9;
	for(int r=0;r<4;r++)ans=min(ans,D[gx][gy][r].first);
	if(ans==(int)1e9)ans=-1;
	cout<<ans<<endl;
}


Measured memory_bytes: 144884
#include <stdio.h>

int main(void)
{

  int i, j, N, A[100], minj, c = 0, temp;

  scanf ("%d", &N);

  for (i = 0; i < N; i++) {
   scanf ("%d", &A[i]);
  }

for (i = 0; i < N; i++) {
   minj = i;
 
 for (j = i; j < N; j++) {
  if (A[j] < A[minj]) {
   minj = j;
}
}
 if(i != minj) {
 temp = A[minj];
 A[minj] = A[i];
 A[i] = temp;
 c++;
}
}
for (i = 0; i < N-1; i++){
 printf("%d ", A[i]);
}
 printf("%d\n%d\n",A[N-1],  c);

return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define M 1000005
#define FI first
#define SE second
#define MP std::make_pair
#define PB push_back
#define mod 998244353
#define base 233
#define INF 1000000000
typedef long long ll;
ll l1, r1, l2, r2;
ll read() {
	ll ans = 0; char c = getchar(); bool flag = 1;
	while (c < '0' || c > '9') flag &= (c != '-'), c = getchar();
	while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
	return flag ? ans : -ans;
}
void Write(ll x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + '0');
	else Write(x / 10), putchar(x % 10 + '0');
	return;
}
ll max(ll x, ll y) {return x > y ? x : y;}
int main() {
	l1 = read(), r1 = read(), l2 = read(), r2 = read();
	Write(max(max(l1 * l2, l1 * r2), max(r1 * l2, r1 * r2)));
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int n, X, Y;
vector<int> adj[2001];
bool visited[2001];
int cnt[2001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> X >> Y;
    for (int i = 1; i <= n - 1; i++) {
        adj[i].push_back(i + 1);
        adj[i + 1].push_back(i);
    }
    adj[X].push_back(Y);
    adj[Y].push_back(X);

    for (int i = 1; i <= n; i++) {
        memset(visited, 0, sizeof(visited));
        queue<pii> q;
        q.push(pii(i, 0));
        visited[i] = true;
        while (!q.empty()) {
            int x = q.front().first;
            int dist = q.front().second;
            q.pop();

            cnt[dist]++;

            for (int nx : adj[x]) {
                // if (nx < i) continue;
                if (!visited[nx]) {
                    q.push(pii(nx, dist + 1));
                    visited[nx] = true;
                }
            }

        }

    }

    for (int i = 1; i < n; i++) {
        cout << cnt[i] / 2 << '\n';
    }

    return 0;
}


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

using namespace std;

#define pb push_back

const int N = 3005;
int n, a[N];
vector<int> gr[N];

bool dfs(int u, bool now) {
    for (int v : gr[u]) {
        if(a[v] < a[u]) {
            bool rem = dfs(v, now ^ 1);
            if(rem ^ now) return (now ^ 1);
        }
    }
    return now;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i < n; ++i) {
        int u, v; cin >> u >> v;
        gr[u].pb(v); gr[v].pb(u);
    }
    for (int i = 1; i <= n; ++i) {
        if(dfs(i, 0) ) cout << i << ' ';
    }

    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
count = 0

tf = True

while tf:
    for i in range(0, len(A)):
        if A[i] % 2 == 1:
            tf = False
        A[i] = A[i] / 2
    if not tf:
        break
    count += 1
print(count)


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

void div(long long N,vector<ll> &num) {
    for (long long i = 2; i * i <= N; ++i) {
        if(N%i!=0) continue;
        while(N%i==0){
            N/=i;
        }
        num[i]++;
    }
    if(N!=1) num[N]++;
}

int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    vector<ll>num(1e6+10,0);
    for(ll i=0;i<n;i++){
        div(a[i],num);
    }
    sort(num.begin(),num.end());
    reverse(num.begin(),num.end());
    ll judge=num[0];
    if(judge>=n) cout << "not coprime" << endl;
    else if(judge>1) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 18676
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import defaultdict, deque
    n = input_int()
    G = defaultdict(dict)
    color = [None] * (n + 1)
    for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
    color[1] = 0
    dq = deque()
    dq.append((1, 0))  # node,cost
    while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
    for c in color[1:]:
        print(c)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 112492
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0)break;
	vector<int> v(n);
	string s = "";
	REP(i,n){
	    cin >> v[i];
	}
	vector< pair<int,int> > pv;
	REP(i,n){
	    int tv = v[i];
	    int count = 0;
	    while(tv==v[i]){
		count++;
		i++;
	    }
	    i--;
	    pv.PB( pair<int,int>(tv,count));
	}
	int ans = 100000000;
	REP(i,pv.size()){
	    FOR(j,1,4){
		int ltemp = -1;
		int rtemp = 1;
		int color = j;
		int tans = 0;
		int sum = 1;
		while(true){
		    if(ltemp+i >= 0 && color == pv[i+ltemp].first){
			sum += pv[i+ltemp].second;
		    }
		    if(rtemp+i < pv.size() && color == pv[i+rtemp].first){
			sum += pv[i+rtemp].second;
		    }
		    if(sum <= 3){
			if(!(ltemp == -1 && rtemp == 1)) tans += pv[i].second;
			tans = n - tans;
			ans = min(ans,tans);
			break;
		    }else{
			if(color == pv[i+ltemp].first) {
			    tans += pv[i+ltemp].second;
			    ltemp--;
			}
			if(color == pv[i+rtemp].first) {
			    tans += pv[i+rtemp].second;
			    rtemp++;
			}
		    }
		    if(i+ltemp>=0){
			color = pv[i+ltemp].first;
		    }else if(i+rtemp<pv.size()){
			color = pv[i+rtemp].first;
		    }
		    sum = 0;
		}
	    }
	}
	cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 1352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{	
	long a, b, c, a2, b2, c2, cnt=0;
	
	scanf("%ld %ld %ld", &a, &b, &c );
	
	while(a%2==0 && b%2==0 && c%2==0){
		
		a2 = a; b2 = b; c2 = c;
		a =  (b2/2) + (c2/2);	
		b =  (a2/2) + (c2/2);
		c =  (a2/2) + (b2/2);
		cnt++;
		
		
		if( (a==b2 || a==c2) && (b==a2 || b==c2) && (c==a2 || c==b2) ) { 
			printf("-1\n"); 
			
		return 0; }
	}
	
	
	printf("%ld\n", cnt);
	
	

	return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    string ans = "NO";
    if(n%2&&k<=(n+1)/2) ans = "YES";
    else if(n%2==0&&k<=n/2) ans = "YES";
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
from collections import deque

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

check = [[1 for _ in range(W)] for _ in range(H)]

def bw(s):
  if s == "#":
    return "."
  else:
    return "#"

def cnt_plus(s, cnt):
  if s == "#":
    c = [cnt[0] + 1, cnt[1]]
  else:
    c = [cnt[0], cnt[1] + 1]
  return c
  
def bfs(i, j):
  stack = deque()
  stack.append(((i, j), S[i][j]))
  check[i][j] = 0
  cnt = [0, 0]
  
  while stack:
    p, s = stack.popleft()
    cnt = cnt_plus(s, cnt)
    ii, jj = p
    bws = bw(s)

    if ii - 1 >= 0 and check[ii - 1][jj]:
      if S[ii - 1][jj] == bws:
        check[ii - 1][jj] = 0
        stack.append(((ii - 1, jj), bws))

    if ii + 1 < H and check[ii + 1][jj]:
      if S[ii + 1][jj] == bws:
        check[ii + 1][jj] = 0
        stack.append(((ii + 1, jj), bws))

    if jj - 1 >= 0 and check[ii][jj - 1]:
      if S[ii][jj - 1] == bws:
        check[ii][jj - 1] = 0
        stack.append(((ii, jj - 1), bws))

    if jj + 1 < W and check[ii][jj + 1]:
      if S[ii][jj + 1] == bws:
        check[ii][jj + 1] = 0
        stack.append(((ii, jj + 1), bws))
  return cnt[0] * cnt[1]

answer = 0
for i in range(H):
  for j in range(W):
    if check[i][j] and S[i][j] == "#":
      answer += bfs(i, j)
print(answer)

Measured memory_bytes: 71644
#include "iostream"

using namespace std;

int main() {

	int num;
	int min;
	int sa = -1000000000;

	cin >> num;

	//????????????????´?
	cin >> min;
	//2????????\??????????´?
	for (int i = 1; i < num; i++) {
		int a;
		cin >> a;

		if (a - min > sa) {
			sa = a - min;
		}
		if (a < min) {
			min = a;
		}

	}

	cout << sa << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 110
#define INF 0x3f3f3f3f
#define MST(vis,x) memset(vis,x,sizeof(vis))
struct Node
{
    int x,y;
}nodea[maxn];
Node nodeb[maxn];
int s1[maxn][maxn];
int judge[maxn];
int n;
int col[maxn];
int row[maxn];
int dfs(int x)
{
    int i,j;
    for(i=1;i<=n;i++)
    {
        if(s1[x][i]&&judge[i]==0)
        {
            judge[i]=true;
            if(!col[i]||dfs(col[i]))
            {
                col[i]=x;
                row[x]=i;
                return 1;
            }
        }
    }
    return 0;
}
int  maxmatch()
{
    int ans=0;
    MST(col,0);
    MST(row,0);
    for(int a=1;a<=n;a++)
    {
        if(!row[a])
        {
            MST(judge,false);
            ans+=dfs(a);
        }
    }
    return ans;
}
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int a=1;a<=n;a++)
            scanf("%d%d",&nodea[a].x,&nodea[a].y);
        for(int b=1;b<=n;b++)
            scanf("%d%d",&nodeb[b].x,&nodeb[b].y);
        MST(s1,0);
        for(int a=1;a<=n;a++)
        {
            for(int b=1;b<=n;b++)
            {
                if(nodea[a].x<nodeb[b].x&&nodea[a].y<nodeb[b].y)
                    s1[a][b]=1;
            }
        }
        int ans=maxmatch();
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  if((k <= LLONG_MAX/d) && x - k*d >= 0){
    cout << x-k*d << endl;
  }else{
    ll c = x/d;
    ll ans = x % d;
    if(c % 2 != k % 2) ans = abs(ans - d);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i, h) cin >> grid[i];
  rep(i, h) {
    rep(j, w) {
      if (grid[i][j] == '#')
        cout << '#';
      else {
        int cnt = 0;
        for (int k = -1; k < 2; k++) for (int l = -1; l < 2; l++) {
          if (!k && !l || i+k < 0 || i+k >= h || j+l < 0 || j+l >= w)
            continue;
          if (grid[i+k][j+l] == '#')
            cnt++;
        }
        cout << cnt;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
require 'date'

table = [["pre-meiji", [   1,  1,  1], [1868,  9,  7]],
         ["meiji"    , [1868,  9,  8], [1912,  7, 29]],
         ["taisho"   , [1912,  7, 30], [1926, 12, 24]],
         ["showa"    , [1926, 12, 25], [1989,  1,  7]],
         ["heisei"   , [1989,  1,  8], [2020,  1,  1]]]
table.map! {|n, d1, d2| [n, Date.new(*d1), Date.new(*d2)]}

$<.readlines.map {|l| Date.new(*l.split.map(&:to_i))}.each do |day|
  table.each do |name, d1, d2|
    if d1 <= day and day <= d2
      if name == "pre-meiji"
        puts "pre-meiji"
      else
        puts "#{name} #{day.year - d1.year + 1} #{day.month} #{day.day}"
      end
    end
  end
end


Measured memory_bytes: 6984
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll l,r;cin>>l>>r;
  ll ans=llINF;
  for(ll i=l;i<=min(l+2019,r-1);i++)
    for(ll j=max(r-2020,l+1);j<=r;j++){
      ans=min(ans,(i*j)%2019);
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1; i<=n; ++i){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3644
N=int(input())
d=dict()
ans=0
for _ in range(N):
  s=input()
  s=tuple(sorted(s))
  if s in d:
    d[s]+=1
  else:
    d[s]=0
for i in d.values():
  ans+=(int(i)**2+int(i))/2
print(int(ans))

Measured memory_bytes: 23648
#include <iostream>
#include <vector>
#include <queue>

struct Node {
	int ID;
	int rep;
	bool visited;
	bool operator<(const Node& rhs) {return this->ID < rhs.ID;}
	bool operator>(const Node& rhs) {return this->ID > rhs.ID;}
	bool operator<=(const Node& rhs) {return this->ID <= rhs.ID;}
	bool operator>=(const Node& rhs) {return this->ID >= rhs.ID;}
	bool operator==(const Node& rhs) {return this->ID == rhs.ID;}
	bool operator!=(const Node& rhs) {return this->ID != rhs.ID;}
};

void BFS(std::vector<int>* adjlist, Node* nodes, std::queue<int> que)
{	
	while (!que.empty()) {
		int id = que.front(); que.pop();
		for (std::vector<int>::iterator it = adjlist[id].begin(); it != adjlist[id].end(); ++it) {
			if (!nodes[*it].visited) { 
				que.push(*it);
				nodes[*it].rep = nodes[id].rep;
				nodes[*it].visited = true;
			}
		}
	}
}

void DFS(std::vector<int>* adjlist, Node* nodes, int id, int rep)
{
	nodes[id].rep = rep;
	nodes[id].visited = true;
	
	for (std::vector<int>::iterator it = adjlist[id].begin(); it != adjlist[id].end(); ++it) {
		if (!nodes[*it].visited) DFS(adjlist, nodes, *it, rep);
	}
}

int main()
{
	int n, m; std::cin >> n >> m;
	
	std::vector<int>* adjlist = new std::vector<int>[n];
	Node* nodes = new Node[n];
	
	std::queue<int> que;
	
	for (int i=0; i<n; i++) {
		nodes[i].visited = false;
	}
	
	for (int i=0; i<m; i++) {
		int x, y;
		std::cin >> x >> y;
		adjlist[x].push_back(y);
		adjlist[y].push_back(x);
	}
	
	//std::sort(nodes, nodes + n);
	
	for (int i=0; i<n; i++) {
		if (!nodes[i].visited) {
			//que.push(i); nodes[i].visited = true; nodes[i].rep = i;
			//BFS(adjlist, nodes, que);
			DFS(adjlist, nodes, i, i);
		}
	}
	
	int q; std::cin >> q;
	
	for (int i=0; i<q; i++) {
		int x, y;
		std::cin >> x >> y;
		if (nodes[x].rep == nodes[y].rep) std::cout << "yes" << std::endl;
		else std::cout << "no" << std::endl;
	}
	
	delete[] adjlist;
	delete[] nodes;
	
	return 0;
}



Measured memory_bytes: 14156
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#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);
    ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;

    bool poss = false;
    ll top = A + (N-1) * D;
    ll bot = A + (N-1) * C;

    while (bot >= (A - (N-1)*D)) {
	//TR(bot); TR(top);

	if (bot <= B && B <= top) {
	    poss = true;
	    break;
	}


	top -= C;
	top -= D;

	bot -= D;
	bot -= C;
    }
    /*
    set<pll> cur_segs = { {A, A}};

    FOR(i, 0, N-1) {
	TR(i);
	set<pll> new_segs;
	for (pll p : cur_segs) {
	    new_segs.insert( {p.xx +C, p.yy + D});
	    new_segs.insert( {p.xx -D, p.yy - C});
	}
	cur_segs = new_segs;
	for (pll p : cur_segs) {
	    TR(p.xx);
	    TR(p.yy);
	}
    }


    TR("end");
    for (pll p : cur_segs) {
	TR(p.xx);
	TR(p.yy);
    }
    for (pll p : cur_segs) {
	if (p.xx <= B && B <= p.yy) {
	    poss = true;
	    break;
	}
    }
    */

    if (poss) cout << "YES" << endl;
    else cout << "NO" << endl;


} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

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

ll N;
vector<vector<ll>> tree;
unordered_map<ll, unordered_map<ll, ll>> to_edge_idx;

void calc_ans(ll now, ll avoid, vector<bool>& visited, vector<ll>& ans) {
    visited[now] = true;
    ll col = 0;
    for (ll to : tree[now]) {
        if (visited[to]) {
            continue;
        }
        if (col == avoid) {
            col++;
        }
        ans[to_edge_idx[now][to]] = col;
        calc_ans(to, col, visited, ans);
        col++;
    }
}

int main() {
    cin >> N;
    tree.resize(N);
    rep(i,0,N-1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
        to_edge_idx[a][b] = i;
        to_edge_idx[b][a] = i;
    }
    ll col_cnt = 0;
    rep(i,0,N) {
        col_cnt = max(col_cnt, (ll)tree[i].size());
    }
    cout << col_cnt << endl;
    vector<ll> ans(N-1);
    vector<bool> visited(N);
    calc_ans(0, -1, visited, ans);
    rep(i,0,N-1) {
        cout << ans[i] + 1 << endl;
    }
}


Measured memory_bytes: 26532
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int vs[200000+10];
int n;
ll ss[200000+10];
ll xs[200000+10];

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
    xs[i+1] = xs[i] ^ vs[i];
    ss[i+1] = ss[i] + vs[i];
  }

  ll res = 0;
  REP(i, n) {
    int left = i;
    int right = n;
    while(left + 1 < right) {
      int md = (left + right) / 2;
      ll s = ss[md+1] - ss[i];
      ll x = xs[md+1] ^ xs[i];
      if(s == x) {
        left = md;
      } else {
        right = md;
      }
    }
    res += left-i+1;
  }
  
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m ,x ,y;
  cin >> n >> m >> x >> y;
  for(int i = 0;i<n;i++){
    int a;
    cin >> a;
    x = max(x,a);
  }
  for(int i =0;i<m;i++){
    int b;
    cin >> b;
    y = min(y,b);
  }
  if( y > x ){
    cout << "No War";
  }
  else{
    cout << "War";
  }
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;
bool pairCompareS(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
int main()
{
    string S;
    cin >> S;
    S += "S";
    ll N = S.size();
    ll tcnt = 0;
    ll scnt = 0;
    ll ans = 0;
    rep(i, N-1) {
        if (S[i] == 'T') tcnt++;
        else scnt++;
        if (S[i] == 'T' && S[i+1] == 'S') {
            ans += max((ll)0, tcnt - scnt);
            scnt = max((ll)0, scnt - tcnt);
            tcnt = 0;
        }
    }
    print(ans + scnt);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
#define mod 1000000007
signed main(){
    int a,b;
    cin>>a>>b;
    cout<<a-b+1<<endl;
    return 0;
}


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

int bingocheck(vector<int> x,vector<int> y, int n)
{
    bool check1 = false;
    bool check2 = false;
    bool check3 = false;
    rep(i,n){
      if(x.at(0)==y.at(i))check1=true;
    }
    rep(i,n){
      if(x.at(1)==y.at(i))check2=true;
    }
    rep(i,n){
      if(x.at(2)==y.at(i))check3=true;
    }
    if(check1&&check2&&check3){
      //cout <<"1"<<endl;
      return 1;
    }

    else return 0;

}


int main(){
  vector<int> a01(3);
  vector<int> a02(3);
  vector<int> a03(3);

  rep(i,3){
    cin >>a01.at(i)>>a02.at(i)>>a03.at(i);
  }
  int n;
  cin>>n;
  vector<int> b;
  rep(i,n){
    int x;
    cin>>x;
    b.push_back(x);
  }
  vector<int> a10{a01.at(0),a02.at(0),a03.at(0)};
  vector<int> a20{a01.at(1),a02.at(1),a03.at(1)};
  vector<int> a30{a01.at(2),a02.at(2),a03.at(2)};
  vector<int> a13{a01.at(0),a02.at(1),a03.at(2)};
  vector<int> a31{a01.at(2),a02.at(1),a03.at(0)};
  bool check =false;

  vector<int> resalt(8);

  resalt.at(0)=bingocheck(a01,b,n);
  resalt.at(1)=bingocheck(a02,b,n);
  resalt.at(2)=bingocheck(a03,b,n);
  resalt.at(3)=bingocheck(a10,b,n);
  resalt.at(4)=bingocheck(a20,b,n);
  resalt.at(5)=bingocheck(a30,b,n);
  resalt.at(6)=bingocheck(a13,b,n);
  resalt.at(7)=bingocheck(a31,b,n);
  int sum = 0;
  rep(i,8){
    sum += resalt.at(i);
  }
  if(sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, r;
    scanf("%d%d", &n, &r);
    printf("%d\n", n >= 10 ? r : r + 100*(10-n));
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <random>
#include <cassert>

using namespace std;

const int N = 2e5;

int n;
vector<int> g[N];
bool used[N];
int lvl[N];
int cnt[2];
int p[N];
int kek[3];

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int v, u;
		cin >> v >> u;
		--v, --u;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	queue<int> q;
	q.push(0);
	used[0] = true;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int u : g[v]) {
			if (!used[u]) {
				q.push(u);
				used[u] = true;
				lvl[u] = lvl[v] + 1;
			}
		}
	}
	for (int v = 0; v < n; ++v) {
		++cnt[lvl[v] % 2];
	}
	kek[0] = 0;
	kek[1] = -2;
	kek[2] = -1;
	if (cnt[0] <= n / 3) {
		for (int v = 0; v < n; ++v) {
			if (lvl[v] % 2 == 0) {
				p[v] = (kek[0] += 3);
			}
			else if ((kek[1] += 3) <= n) {
				p[v] = kek[1];
			}
			else if ((kek[2] += 3) <= n){
				p[v] = kek[2];
			}
			else {
				p[v] = (kek[0] += 3);
			}
		}
	}
	else if (cnt[1] <= n / 3) {
		for (int v = 0; v < n; ++v) {
			if (lvl[v] % 2 == 1) {
				p[v] = (kek[0] += 3);
			}
			else if ((kek[1] += 3) <= n) {
				p[v] = kek[1];
			}
			else if ((kek[2] += 3) <= n) {
				p[v] = kek[2];
			}
			else {
				p[v] = (kek[0] += 3);
			}
		}
	}
	else {
		for (int v = 0; v < n; ++v) {
			if (lvl[v] % 2 == 0 && (kek[1] += 3) <= n) {
				p[v] = kek[1];
			}
			else if (lvl[v] % 2 == 1 && (kek[2] += 3) <= n) {
				p[v] = kek[2];
			}
			else {
				p[v] = (kek[0] += 3);
			}
		}
	}
	for (int v = 0; v < n; ++v) {
		cout << p[v] << ' ';
	}
	cout << '\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 15600
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n;std::cin>>n;
    std::vector<std::vector<int>>a(n,std::vector<int>(n-1));
    for(int i=0;i<n;i++){
        for(int j=n-2;j>=0;j--){
            std::cin>>a.at(i).at(j);
            a.at(i).at(j)--;
        }
    }
    std::vector<int>ckd(n);
    std::deque<std::pair<int,int>>que;
    for(int i=0;i<n;i++){
        int j=a.at(i).back();
        if(!ckd.at(i)&&!ckd.at(j)&&a.at(j).back()==i){
            ckd.at(i)=true;
            ckd.at(j)=true;
            que.emplace_back(i,j);
        }
    }
    int ans=0;
    while(!que.empty()){
        std::deque<std::pair<int,int>>new_que;
        while(!que.empty()){
            auto p=que.front();que.pop_front();
            int i,j;std::tie(i,j)=p;
            ckd.at(i)=false,ckd.at(j)=false;
            a.at(i).pop_back(),a.at(j).pop_back();
            for(int x:{i,j}){
                if(ckd.at(x)||a.at(x).empty())continue;
                int y=a.at(x).back();
                if(!ckd.at(y)&&!a.at(y).empty()&&a.at(y).back()==x){
                    ckd.at(x)=true,ckd.at(y)=true;
                    new_que.emplace_back(x,y);
                }
            }
        }
        que.swap(new_que);
        ans++;
    }
    std::cout<<(std::all_of(a.begin(),a.end(),[](auto&&v){return v.empty();})?ans:-1)<<'\n';
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;
const ll mod = 998244353;

int isp[N], p[N], mu[N], n, tot, a[N], imax;
ll inv[N], f[N], c[N], sum;

void init(int n)
{
    mu[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (!isp[i]) {
            p[++tot] = i;
            mu[i] = -1;
        }
        for (int j = 1; j <= tot && p[j] <= n / i; j++) {
            isp[i * p[j]] = 1;
            if (0 == i % p[j]) {
                mu[i * p[j]] = 0;
                break;
            }
            else mu[i * p[j]] = -mu[i];
        }
    }
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        imax = max(imax, a[i]);
        sum = (sum + a[i]) % mod;
        c[a[i]] += 1;
    }
    init(imax);
    for (int i = 1; i <= imax; i++) {
        for (int j = i; j <= imax; j += i)
            f[i] = (f[i] + c[j] * j) % mod;
        f[i] = (f[i] * f[i]) % mod;
    }
    ll res = 0;
    for (int d = 1; d <= imax; d++) {
        for (int k = 1, t = d; t <= imax; t += d, k++) {
            res = (res + inv[d] * mu[k] % mod * f[t] % mod) % mod;
        }
    }
    res = ((res - sum) % mod + mod) % mod * inv[2] % mod;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 39296
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplitInt();
            Println(ABC[1] + ABC[2] >= ABC[0] ? ABC[1] + ABC[2] - ABC[0] : 0);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268