akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = map(int, input().split())

def count_time(a):
  c = 0
  while a % 2 == 0:
    c += 1
    a //= 2
  return c

ans = 10**10
for a in A:
  ans = min(ans, count_time(a))

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdbool.h>

int main(void){
	int n,i,j,sum,flag=0,loopf=0;
	scanf("%d",&n);
	for(i=0; i<25; i++){
		for (j=0; j<15; j++)
		{
			sum=4*i+7*j;
			if (sum == n){
				flag=1;
				break;
			}
			else if(sum>n) break;
		}
		if (flag==1) break;
	}
	if(flag==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <complex>

long long int modul = 1000000007;

long long int faktorijel(long long int x)
{
	int h = 1;
	
	for (int i = 1; i <= x; ++i)
		h = ((h % modul) * (i % modul)) % modul;
	
	return h;
}

int main()
{
	long long int n, m;
	std::cin >> n >> m;
	
	if (abs(n - m) > 1)
	{
		std::cout << 0;
		return 0;
	}
	else if (abs(n - m) > 0)
	{
		long long int ans = ((faktorijel(n) % modul) * (faktorijel(m) % modul)) % modul;
		std::cout << ans;
		return 0;
	}
	else
	{
		long long int ans = ((((faktorijel(n) % modul) * (faktorijel(m) % modul)) % modul) * 2) % modul;
		std::cout << ans;
		return 0;
	}
	
}

Measured memory_bytes: 256
N ,W = map(int,input().split())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
dp = [[0 for _ in range(W + 10)] for _ in range(N + 10)]
for i in range(N):
    for w in range(W+1):
        if w+L[i][0] <= W:
            dp[i+1][w+L[i][0]] =max(dp[i][w]+L[i][1], dp[i+1][w+L[i][0]])
        dp[i+1][w] = max(dp[i][w], dp[i+1][w])
ans = 0
for w in range(W+1):
    ans = max(ans,dp[N][w])
print(ans)



Measured memory_bytes: 181640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

template<int char_size, int base>
class Trie {
public:
    explicit Trie() : res(0), node(1, Node()) {}
    void insert(const string& word){
        vector<int> cnt(char_size, 0);
        for(auto& c : word) cnt[c - base]++;
        int nodeId = 0;
        for(const auto& c : word){
            for(int i=0;i<char_size;i++){
                if(cnt[i] > 0 && node[nodeId].next[i] != -1){
                    res += node[node[nodeId].next[i]].accept;
                }
            }
            int b = c - base;
            int& nextId = node[nodeId].next[b];
            if(nextId == -1){
                nextId = node.size();
                node.emplace_back(Node());
            }
            cnt[b]--;
            nodeId = nextId;
        }
        node[nodeId].accept = 1;
    }
    long long getRes() const { return res; }
private:
    long long res;
    struct Node {
        vector<int> next;
        int accept;
        Node() : next(char_size, -1), accept(0) {}
    };
    vector<Node> node;
};

int main(){
    int N; cin >> N;
    vector<string> vs(N);
    for(auto& s : vs){
        cin >> s;
        reverse(s.begin(), s.end());
    }
    sort(vs.begin(), vs.end(), [](const string& a, const string& b){ return a.size() < b.size(); });
    Trie<26, 'a'> trie;
    for(auto& s : vs){
        trie.insert(s);
    }
    cout << trie.getRes() << endl;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int>A){
    
    if(A.size()==n+1){
        int score = 0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]) score+=d[i];
        }
        ans = max(ans, score);
        return;

    }
    A.push_back(A.back());
    while(A.back()<=m) {
        dfs(A);
        A.back()++;
    }
}
int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){

  int sum = 0;
  double sum_v = 0;
  int ave;
  int v,n;
  char ten;
  int cnt = 0;
  while( cin >> v >> ten >> n ){
    sum +=  v * n;
    cnt++;
    sum_v += n;
  }

  cout << sum << endl;
  printf("%.0f\n",sum_v / cnt + 0.5 );

  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int n,k;
    cin>>n>>k;
    int check[101] = {0};
    int d,temp;
    for(int i=0;i<k;i++){
        cin>>d;
        while(d--){
            cin>>temp;
            check[temp] = 1;
        }
    }
    int count=0;
    for(int i=1;i<=n;i++){
        if(!check[i]) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll arr[100004];
// ll st[4 * 100004];
// void build(ll si, ll ss, ll en)
// {
//     if (ss == en)
//     {
//         st[si] = arr[ss];
//         return ;
//     }
//     ll mid = ss + (en - ss) / 2;
//     build(2 * si, ss, mid);
//     build(2 * si + 1, mid + 1, en);
//     st[si] = min(st[2 * si], st[2 * si + 1]);

// }
// ll query(ll si, ll ss, ll en, ll qs, ll qe)
// {
//     if (ss > qe || en < qs)
//         return INT_MAX;
//     if (ss >= qs and en <= qe)
//         return st[si];
//     ll mid = ss + (en - ss) / 2;
//     return min(query(2 * si, ss, mid, qs, qe), query(2 * si + 1, mid + 1, en, qs, qe));
// }
int main()
{

#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output12.txt", "w", stdout);
#endif
    ll n;
    cin >> n;
    if (n % 1000 == 0)
        cout << 0 << "\n";
    else
    {
        ll y = ceil(double(n) / (double)(1000));
        cout << (1000 * y - n) << "\n";
    }
    return 0;

}


Measured memory_bytes: 3716
#include<iostream>
using namespace std;
int main(){
    long a, b, atax, btax;
    cin >> a >> b;
    for (int i = 1; i <= 10000; i++){
        btax = i / 10; atax = (i * 2) / 25;
        if (atax == a && btax == b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=2e5+5;
int m,n,a[N];
bool b[N];

bool solve()
{
	rep(i,1,m-1)
	{
		if(b[m-i+1]==b[m-i])return b[m-i];
		if(b[m+i-1]==b[m+i])return b[m+i];
	}
	return b[m]^((m-1)%2);
}

int main()
{
	//freopen("1.in","r",stdin);
	cin>>m;
	n=m*2-1;
	rep(i,1,n)scanf("%d",a+i);
	int l=1,r=n+1;
	while(l+1!=r)
	{
		int mid=(l+r)/2;
		rep(i,1,n)b[i]=a[i]>=mid;
		if(solve())l=mid;
		else r=mid;
	}
	cout<<l;
}

Measured memory_bytes: 1280
N = int(input())
D = sorted(map(int, input().split()))
M = int(input())
T = sorted(map(int, input().split()))
i = 0
for t in T:
    while D[i] < t:
        i += 1
    if D[i] == t:
        i += 1
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 122836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const string t = "AKIHABARA";
	const int n = s.size(), m = t.size();
	int i = 0, j = 0;
	while(true){
		if(i < n && j < m && s[i] == t[j]){
			++i;
			++j;
		}else if(j < m && t[j] == 'A'){
			++j;
		}else{
			break;
		}
	}
	cout << (i == n && j == m ? "YES" : "NO") << endl;
	return 0;
}



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

int main() {

  int X, Y;
  cin >> X >> Y;

  string ans = "No";

  for (int i = 0; i <= X; i++) {
    int tsuru = i * 2;
    int kame = (X - i) * 4;
    if ((tsuru + kame) == Y) {
      ans = "Yes";
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;

}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    scanf("%d", &n);
    long mn = 1000001, mx = -1000001, sum = 0;
    for(int i = 0; i < n; i++){
        long num;
        scanf("%ld", &num);
        if(mn > num) mn = num;
        if(mx < num) mx = num;
        sum += num;
    }
    printf("%d %d %ld\n", mn, mx, sum);
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    string s;
    cin>>s;
    while(1){
        if(s[0]==s[1]&&s[1]==s[2]){
            break;
        }
        int n = stoi(s);
        n++;
        s = to_string(n);
    }
    cout<<s<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define print(x) printf("%d\n",x)

using namespace std;

pair<int,pair<int,int> > cat[1000];
int catx[1000];
int caty[1000];
int catc[1000];
int esa[1000];
int n,m;
int acc;

bool can(int lim){
  vector<int> e(esa, esa+m);
  while(true){
    if(e.size() <= 1){
      if(lim >= acc)
        break;
      else
        return false;
    }

    int mm = e.size();
    vector<int> counts(mm);
    int ep = 0;
    int next = e[1];
    int maxc = -1;
    int maxp;

    REP(i,n){
      if(ep == mm - 1){
        counts[ep] += catc[i];
      }else{
        if(catx[i] <= e[ep+1]){
#define ABS(x) ((x) < 0 ? -(x) : (x))
          int da = ABS(e[ep  ] - catx[i]);
          int db = ABS(e[ep+1] - catx[i]);
          if(da <= db){
            counts[ep] += catc[i];
          }else{
            counts[ep+1] += catc[i];
          }
        }else{
          while(ep != mm-1 && catx[i] > e[ep+1]) ep++;
          i--;
        }
      }
      if(maxc < counts[ep]){
        maxc = counts[ep];
        maxp = ep;
      }
      if(ep != mm-1 && maxc < counts[ep+1]){
        maxc = counts[ep+1];
        maxp = ep+1;
      }
    }

    //printf("counts: ");
    //REP(i,mm) printf("(%d):%d ",e[i],counts[i]); puts("");
    if(maxc <= lim) break;
    if(maxp == 0 || maxp == mm - 1) return false;
    if(counts[maxp - 1] > lim && counts[maxp + 1] > lim) return false;
    e.erase(e.begin() + maxp);
  }
  return true;
}

int main(){
  while(scanf("%d%d",&n,&m), n+m){
    int tmp;
    REP(i,n) scanf("%d%d%d",&cat[i].f,&cat[i].s.f,&cat[i].s.s);
    REP(i,m) scanf("%d",esa+i);
    if(n == 0){
      puts("0");
      continue;
    }

    sort(cat, cat+n);
    sort(esa, esa+m);
    REP(i,n) catx[i] = cat[i].f;
    REP(i,n) caty[i] = cat[i].s.f * cat[i].s.f;
    REP(i,n) catc[i] = cat[i].s.s;

    int high = acc = accumulate(catc, catc+n, 0);
    int low  = *max_element(catc, catc+n);

    while(high >= low){
      int mid = (high + low) / 2;
      //printf("%d %d %d\n",low,mid,high);
      if(can(mid)){
        high = mid - 1;
      }else{
        low = mid + 1;
      }
    }
    low = max(*max_element(catc, catc+n), low - 2);
    while(!can(low)) low++;
    print(low);
  }
  return 0;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int a,  b;

int main()
{
   // startTime = (double)clock();
    #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);
    
    scanf("%d %d",  &a , &b);
    printf("%d\n" , a * b);

    return 0;
}

Measured memory_bytes: 3780
#include<stdio.h>

#define MAX 100

int main(){
  int i,j;
  int M[MAX][MAX];
  int n,u,k,v;

  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;     //  A[1][1] denaku A[0][0]dekanngaeteiru
    
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",M[i][j]);
    }
    printf("%d\n",M[i][j]);
  }

  return 0;

}



    
    



Measured memory_bytes: 2112
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    static int n,q,l[200000],r[200000];
    char str[200000];

    scanf("%d %d",&n,&q);
    scanf("%s",str);
    for(int i=0;i<q;i++){
        scanf("%d %d",&l[i],&r[i]);
    }

    int csum[200000]={};
    int tmp=0;
    for(int i=0;i+1<n;i++){
        if(str[i]=='A'&&str[i+1]=='C'){
            csum[i]=tmp;
            csum[i+1]=tmp+1;
            tmp++;
        }else{
            csum[i]=tmp;
        }
    }
    csum[n-1]=tmp;
    for(int i=0;i<n;i++){
        //printf("csum[%d]==%d\n",i,csum[i]);
    }


    for(int i=0;i<q;i++){
        printf("%d\n",csum[r[i]-1]-csum[l[i]-1]);
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

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

int n;
int input[10][10], state[10][10], ans[10][10];

void pass(int y, int x) {
    for (int i=0; i<5; ++i) {
        if (0 <= y + dy[i] && y + dy[i] < 10 && 0 <= x + dx[i] && x + dx[i] < 10) {
            state[y + dy[i]][x + dx[i]] = !state[y + dy[i]][x + dx[i]];
        }
    }
    ans[y][x] = !ans[y][x];
}

int main() {
    cin >> n;
    while (n --) {
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                cin >> input[i][j];
            }
        }
        for (int bt=0; bt<(1<<10); ++bt) {
            memcpy(state, input, sizeof(input));
            memset(ans, 0, sizeof(ans));
            for (int j=0; j<10; ++j) {
                if ((bt>>j) & 1) {
                    pass(0, j);
                }
            }
            for (int i=1; i<10; ++i) {
                for (int j=0; j<10; ++j) {
                    if (state[i-1][j] == 1) {
                        pass(i, j);
                    }
                }
            }
            if (accumulate(state[9], state[9] + 10, 0) == 0) break;
        }
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                cout << (j == 0 ? "" : " ") << ans[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=1e9;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    int cnt=0;
    while(a%2==0){
      a/=2;
      cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int x, y, z;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;
}

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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans+=min(a,k);
    k-=min(a,k);
    k-=min(k,b);
    ans-=min(k,c);
    cout<<ans<<endl;
    
    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    set<int> st;
    REP(i, n){
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << (st.size() == n ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a*b>a+b&&a*b>a-b)cout<<a*b;
	else
	if(a*b<a-b&&a+b<a-b)cout<<a-b;
	else
	cout<<a+b;
	return 0;
 } 

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        long[] H = new long[N];
        int[] count = new int[N];
        int maxCount = 0;

        for (int i = 0 ; i < N ; i++) {
            H[i] = scanner.nextLong();
        }

        for (int i = N - 2 ; i >= 0 ; i--) {
            if (H[i] >= H[i + 1]) {
                count[i] = count[i + 1] + 1;
            } else {
                count[i] = 0;
            }
            maxCount = Math.max(maxCount, count[i]);
        }

        System.out.println(maxCount);
    }
}


Measured memory_bytes: 60796
#include<stdio.h>
#define min(x,y) ((x) < (y) ? (x) : (y))
 
int main(){
    int ch,a,b,c,d,e,f,g;
    a=b=c=d=0;
    while((ch=getchar())!=EOF){
                switch(ch){
                        case 'K':a++;
                        break;
                        case 'U':b++;
                        break;
                        case 'P':c++;
                        break;
                        case 'C':d++;
                        break;
                        default:
                        break;
                }
        }
        e=min(a,b);
        f=min(c,d);
        g=min(e,f);
        printf("%d\n",g); 
        return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int main()
{
    const int INF = 10000000;

	cin.tie(0);
	ios::sync_with_stdio(0);

    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N);
    rep(i, N) {
        A[i].resize(M);
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    int ans = INF;
    rep(i, (1<<N)) {
        vector<int> B(M);
        int cost = 0;
        rep(j, N) {
            if (i&(1<<j)) {
                cost += C[j];
                rep(k, M) {
                    B[k] += A[j][k];
                }
            }
        }
        bool ok = true;
        rep(k, M) {
            if (B[k]<X) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = min(ans, cost);
        }
    }

    if (ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
from collections import defaultdict

# def find_distances(edge_dict, node, distances):
#     for end in edge_dict[node]:
#         if distances[end] < 0:
#             distances[end] = distances[node] + 1
#             distances = find_distances(edge_dict, end, distances)

#     return distances


def find_distances(edge_dict, node, V):
    distances = [-1] * V
    stack = [(0, node)]

    while stack:
        dist, node = stack.pop()
        if distances[node] >= 0:
            continue

        distances[node] = dist
        for end in edge_dict[node]:
            stack.append((dist + 1, end))

    return distances

if __name__ == "__main__":
    V, T, A = map(int, input().split())
    T -= 1
    A -= 1
    edge_dict = defaultdict(list)

    for _ in range(V - 1):
        start, end = map(int, input().split())
        edge_dict[start - 1].append(end - 1)
        edge_dict[end - 1].append(start - 1)
    
    dist_T = [-1] * V
    dist_T[T] = 0
    dist_T = find_distances(edge_dict, T, V)

    dist_A = [-1] * V
    dist_A[A] = 0
    dist_A = find_distances(edge_dict, A, V)

    max_dist = 0
    for i in range(V):
        if dist_T[i] <= dist_A[i]:
            max_dist = max(max_dist, dist_A[i])
    
    print(max_dist - 1)


Measured memory_bytes: 44860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			String s = String.valueOf(i);
			int sum1 = 0;
			for (int j = 0; j < s.length(); j++) {
				sum1 += Integer.parseInt(s.substring(j, j + 1));
			}
			if (sum1 >= a && sum1 <= b) {
				sum += i;
			}
		}
		
		System.out.println(sum);
	}
}


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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++)cin >> a[i];
  
  int ans = 0;
  for(int i=0;i<N;i++){
    while(1){
      if(a[i]%2==0){a[i]=a[i]/2;ans++;}
      else break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
//https://agc027.contest.atcoder.jp/tasks/agc027_c

#include<bits/stdc++.h>
const int N = 2e5 + 5;
using namespace std;

queue <int> mq;
vector <int> adj[N];
int n, m, cnt[N][2], num;
string s;
bool dead[N];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cin >> s; s = '.' + s;
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v); cnt[u][s[v]-'A']++;
        adj[v].push_back(u); cnt[v][s[u]-'A']++;
    }
    for (int u = 1; u <= n; u++) {
        if (!cnt[u][0] || !cnt[u][1]) {
            mq.push(u);
            dead[u] = true;
        }
    }
    while (mq.size()){
        int u = mq.front(); mq.pop();
        num++;
        for (auto v : adj[u]){
            if (dead[v]) continue;
            cnt[v][s[u]-'A']--;
            if (!cnt[v][s[u]-'A']){
                mq.push(v);
                dead[v] = true;
            }
        }
    }
    cout << ((num == n) ? "No" : "Yes");
}


Measured memory_bytes: 12564
import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    n,m = getList()
    if n == 1 and m == 1:
        print(1)
        return
    if n == 1:
        print(m - 2)
        return
    if m == 1:
        print(n - 2)
        return

    print((n - 2) * (m - 2))

    return


def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


Measured memory_bytes: 61940
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init (n + 1) @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let bs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let sum = ref 0 in
  for i = 0 to n - 1 do
    for d = 0 to 1 do
      let n = min as_.(i + d) bs.(i) in
      sum := !sum + n;
      as_.(i + d) <- as_.(i + d) - n;
      bs.(i) <- bs.(i) - n
    done
  done;
  Printf.printf "%d\n" !sum



Measured memory_bytes: 6272
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
typedef struct{
	char str[101];
	int pri;
	int no;
}node;
node p[101];
bool cmp(node a,node b)
{
	if(a.str!=b.str)
    return strcmp(a.str,b.str)<0;
    else
    return a.pri<b.pri;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%s",&p[i].str);
		cin>>p[i].pri;
		p[i].no = i+1;
	}
	
	sort(p, p+n, cmp);
	for(int i=0;i<n;i++)
		for(int j=0;j<n-i-1;j++){
		if(strcmp(p[j].str,p[j+1].str)==0 && p[j].pri<p[j+1].pri)
			swap(p[j],p[j+1]);
	}
	for(int i=0;i<n;i++)
	cout<<p[i].no<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	ll int n,x,t,z;
 	cin>>n>>x>>t;
 	z=ceil(n/(ld)x);
 	z*=t;
 	cout<<z;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 3648
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n;
	cin>>n;
	double a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	double sum=0;
	for(ll i=0;i<n;i++)
	{
		sum+=(1/a[i]);
	}
	cout<<setprecision(10)<<1/sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<P> bc(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(all(a));
  for (int i = 0; i < m; i++) cin >> bc[i].second >> bc[i].first;
  sort(all(bc));
  reverse(all(bc));
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (bc[j].second <= 0) j++;
    if (j >= m) break;
    if (bc[j].first > a[i]) {
      a[i] = bc[j].first;
      bc[j].second--;
      }
  }
  cout << accumulate(all(a), 0LL) << endl;
}


Measured memory_bytes: 1408
N, C = [int(_) for _ in input().split()]
X = [0] * N
V = [0] * N
for i in range(N):
    X[i], V[i] = [int(_) for _ in input().split()]


def calc(X, V):
    Vcumsum = [0]
    for v in V:
        Vcumsum += [Vcumsum[-1] + v]
    cumsum = [0] * (N + 1)
    cumsum_r = [0] * (N + 1)
    for i in range(N):
        cumsum[i + 1] = Vcumsum[i + 1] - X[i]
        cumsum_r[i + 1] = Vcumsum[N] - Vcumsum[N - i - 1] - (C - X[-1 - i])
    cumsum_max = [0] * (N + 1)
    cumsum_r_max = [0] * (N + 1)
    for i in range(N):
        cumsum_max[i + 1] = max(cumsum[i + 1], cumsum_max[i])
        cumsum_r_max[i + 1] = max(cumsum_r[i + 1], cumsum_r_max[i])
    res = max(cumsum_max[-1], cumsum_r_max[-1])
    for i in range(N):
        res = max(
            res, cumsum_max[i + 1] + cumsum_r_max[N - i - 1] - X[i],
            cumsum_r_max[i + 1] + cumsum_max[N - i - 1] - (C - X[-1 - i]))
    return res


print(calc(X, V))


Measured memory_bytes: 25388
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("10 2 5");
            WillReturn.Add("6 3 4");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("13 21 6 19");
            WillReturn.Add("11 30 6 15");
            //6
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1");
            WillReturn.Add("1");
            WillReturn.Add("50");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] VArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int[] CArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();

        int Answer=0;
        for (int I = 0; I <= VArr.GetUpperBound(0); I++) {
            if (VArr[I] > CArr[I]) {
                Answer += VArr[I] - CArr[I];
            }
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include <assert.h>
#include<math.h>

int minElement(const float* array, size_t size)
{
    int x=0;
    assert(array != NULL);
    assert(size >= 1);

    float min = array[0];
    for (size_t i = 0; i < size; ++i) {
        if (min > array[i]) {
            min = array[i];
            x = i;
        }
    }

    return x;
}


int main(void){
    int n;
    int a;
    int t;
    int h[1000];
    float b[1000];

    scanf("%d", &n);
    scanf("%d", &t);
    scanf("%d", &a);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }

    for(int i = 0; i < n; i++){
        b[i] = fabsf(a - (t - h[i] * 0.006));
    }

    printf("%d\n", minElement(b, n)+1);
    return 0;
}


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

int main() {
  // ここにプログラムを追記
  string s;
  cin >> s;
  int n[3];
  for(int i=0;i<3;i++){
    if(s[i]=='1') n[i]=1; else n[i]=0;
  }
  cout << n[0]+n[1]+n[2] << endl;
  return 0;
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map &:to_i
c=0
0.upto(n-2){|i|
  (n-1).downto(i+1){|j|
    if a[j] < a[j-1]
      tmp = a[j]
      a[j] = a[j-1]
      a[j-1] = tmp
      c+=1
    end
  }
}
puts a*" "
p c


Measured memory_bytes: 6868
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;

    if(n % 2) {
        cout << 0 << endl;
        return 0;
    }

    ll pow5 = 5, cnt5 = 0;
    while(pow5 < n) {
        cnt5 += n / pow5 / 2;
        pow5 *= 5LL;
    }
    cout << cnt5 << endl;

}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    long count = 0;
    for(int i = 0; i < h; i++)
    {
		  string s = Console.ReadLine();
      for(int j = 0; j < w; j++)
      {
        if(s[j] == '#') count++;
      }
    }
		
		if(count == h+w-1) Console.WriteLine("Possible");
    else Console.WriteLine("Impossible");
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int main(){
  int n;
  cin >> n ;
  int ans = 0;
  ans = n / 3;
  cout << ans << endl;
}


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

bool is_prime(int n) {
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int X;  cin >> X;
    int i = X;
    while (true) {
        if (is_prime(i)) {
            cout << i << endl;
            return 0;
        }
        ++i;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int red = 0, blue = 0;
    for(int i=0; i<n; i++){
        if (s[i] == '0') red++;
        else blue++;
    }

    out(2 * min(red, blue));

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++){
    cout<<"node "<<i+1<<": key = "<<a[i]<<", ";
    if(i) cout<<"parent key = "<<a[(i-1)/2]<<", ";
    if(i*2+1<n) cout<<"left key = "<<a[i*2+1]<<", ";
    if(i*2+2<n) cout<<"right key = "<<a[i*2+2]<<", ";
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
void send(int a,int b,int c,int d){
  printf("%d %d %d %d\n",a,b,c,d);
}
int main(){
  int n;  cin >> n;
  string s; cin >> s;
  int cnt =0;
  vector<int> v;
  int left = 0, ln = 0;
  for(int i=0 ; i<n ; i++){
    if(s[i]=='(') ln++;
    else{
      if(ln == 0) left++;
      else ln--;
    }
  }
  string res = "";
  rep(i,0,left) res +='(';
  res += s;
  rep(i,0,ln) res +=')';
  cout << res << endl;
  return 0;
}


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

int main () {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]]++;
    }
    vector<pair<int, int>> v;
    for (auto x : m) {
        v.push_back(make_pair(x.second, x.first));        
    }
    sort(v.rbegin(), v.rend());
    int ans = n, diff = 0;
    for (int i = 0; i < (int) v.size(); i++) {
        if (diff < k) {
            diff++;
            ans -= v[i].first;
        } else {
            break;
        }
    }
    cout << ans;
    return 0;
} 

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

using namespace std;

template <typename T>
class dinic{
private:
	unordered_map<int,unordered_map<int,T>> mp;
	unordered_map<int,int> level;
	unordered_set<string> visited;
public:
	void add_edge(int from, int to, T cap){
		mp[from][to] = cap;
		mp[to][from] = 0;
	}

	void bfs(int s){
		level.clear();
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while(!q.empty()){
			int v = q.front();q.pop();
			for(auto x:mp[v]){
				if(x.second > 0 && !level.count(x.first)){
					level[x.first] = level[v] + 1;
					q.push(x.first);
				}
			}
		}
	}

	T dfs(int v, int t, T f){
		if(v == t){
			return f;
		}
		for(auto x:mp[v]){
			if(visited.count(to_string(v) + ":" + to_string(x.first))) continue;
			visited.insert(to_string(v) + ":" + to_string(x.first));
			if(x.second > 0 && level.count(x.first) && level[v] < level[x.first]){
				T d = dfs(x.first, t, min(f, x.second));
				if(d > 0){
					mp[v][x.first] -= d;
					mp[x.first][v] += d;
					return d;
				}
			}
		}
		return 0;
	}

	T max_flow(int s, int t){
		T flow = 0;
		while(1){
			bfs(s);
			if(!level.count(t)) return flow;
			visited.clear();
			T f;
			while((f = dfs(s, t, 10000000)) > 0){
				flow += f;
			}
		}
	}
};

int main(){
	dinic<int> g;
	int v,e;
	cin >> v >> e;
	for(int i=0;i<e;i++){
		int u,v,c;
		cin >> u >> v >> c;
		g.add_edge(u,v,c);
	}
	cout << g.max_flow(0,v-1) << endl;
	return 0;
}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

bool prime[siz];
map<int,int> mp;
vector<int> vtp;

void sieve()
{
	prime[0] = prime[1] = true;
	for(int i = 2 ; i < siz ; i++)
	{
		if(prime[i] == false)
		{	
			vtp.push_back(i);
			for(int j = 2*i ; j < siz ; j += i)
			{
				prime[j] = true;
			}
		}
	}
}


bool pairwise_coprime()
{
	for(int i = 0 ; i < vtp.size() ; i ++)
	{
		int cnt = 0;
		int val = vtp[i];
		if(prime[val] == true)
		{
			continue;
		}

		for(int j = val ; j <= 1e6 ; j+= val)
		{
			cnt += mp[j];
		}

		if(cnt > 1)
		{
			return false;
		}
	}

	return true;
}

signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		int n;
		cin>>n;
		int a[n];
		sieve();
		for(int i = 0 ; i < n ; i ++)
		{
			cin>>a[i];
			mp[a[i]]++;
		}

		bool setwise = false;

		int g = 0;
		for(int i = 0 ; i < n ; i++)
		{
			g = __gcd(g,a[i]);
		}

		if(g == 1)
		{
			setwise = true;
		}
		bool pairwise = pairwise_coprime();
		if(!pairwise and setwise)
		{
			cout<<"setwise coprime";
			continue;
		}

		if(pairwise)
		{
			cout<<"pairwise coprime";
			continue;
		}

		cout<<"not coprime";
	}
}




Measured memory_bytes: 75104
S = input()
T = input()


from collections import Counter


s_dict, t_dict = {}, {}

for i in range(len(S)):
    if S[i] in s_dict.keys():
        if s_dict[S[i]] != T[i]:
            print("No")
            exit()
    else:
        s_dict[S[i]] = T[i]

    if T[i] in t_dict.keys():
        if t_dict[T[i]] != S[i]:
            print("No")
            exit()
    else:
        t_dict[T[i]] = S[i]

print("Yes")


Measured memory_bytes: 3812
//
//AtCoder Beginner Contest 173
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int H ,W ,K;
    cin >> H >> W >> K;

    string t[H];
    REP(h, H) cin >> t[h];

    int ans=0;
    REP(bh, (1<<H)){
        REP(bw, (1<<W)){
            int b=0;
            REP(h,H){
                if ((bh>>h)&1) continue;
                REP(w,W){
                    if ((bw>>w)&1) continue;
                    if (t[h][w]=='#') b++;
                }
            }
            if (b==K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
l = [[0, 0] for i in range(n)]
for i in range(n):
  a, b = map(int, input().split())
  l[i][0] = b
  l[i][1] = a

l.sort()

sum_ = 0
for i in range(n):
  sum_ += l[i][1]
  if sum_ > l[i][0]:
    print('No')
    exit()
else:
  print('Yes')
  

Measured memory_bytes: 35616
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

NOW=[0]*(K+1)
NOW[0]=1#そこまでi個使ったときの場合の数


for i in range(N):
    NEXT=[0]*(K+1)
    NOWSUM=[0]
    for n in NOW:
        NOWSUM.append(NOWSUM[-1]+n)
        
    for j in range(K+1):
        NEXT[j]=(NEXT[j]+NOWSUM[j+1]-NOWSUM[max(0,j-A[i])])%mod

    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K])

Measured memory_bytes: 121320
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
 
int main() {
 
	std::string n = {};
	int ans = 0, a = 0, i = 0;
	bool flug = false;
 
	std::cin >> n;
 
	ans += (n.size() - 1) * 9;
 
	if (n[i] == '0') { a = 0; }
	else if (n[i] == '1') { a = 1; }
	else if (n[i] == '2') { a = 2; }
	else if (n[i] == '3') { a = 3; }
	else if (n[i] == '4') { a = 4; }
	else if (n[i] == '5') { a = 5; }
	else if (n[i] == '6') { a = 6; }
	else if (n[i] == '7') { a = 7; }
	else if (n[i] == '8') { a = 8; }
	else if (n[i] == '9') { a = 9; }
 
	if (n.size() == 1) {
		std::cout << n[0] << std::endl;
		return 0;
	}
 
	if (n[n.size()-1] == '9' && n[n.size() - 2] && n[n.size()-3] != '0') {
		ans += a;
	}
	else { ans += a - 1; }
 
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256