akhauriyash/Code-Regression huggingface dataset:
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    int bx = 0, by = 0;
    int t, x, y;
    int d;
    rep(i, N) {
        cin >> t >> x >> y;
        d = abs(bx - x) + abs(by - y);
        if (d > t) {
            cout << "No" << endl;
            return 0;
        }
        if ((t % 2 == 0 && d % 2 == 1) || (t % 2 == 1 && d % 2 == 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	vint d(n);rep(i, n){cin>>d[i];}
	ll ans = 0;
	rep(i, n-1){
		for(int j = i+1;j < n;j++){
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    string S;
    cin >> S;
    int len = S.size();
    int abc[3] = {0, 0, 0};
    for (int i = 0; i < len; i++) {
        abc[S[i] - 97]++;
    }
    int num = len / 3;
    bool ok = true;
    for (int i = 0; i < 3; i++) {
        if (abc[i] != num && abc[i] != num + 1) {
            ok = false;
        }
    }
    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main(void){
    string S;
    cin >> S;
    for(int tmp = 0; tmp < (1 << 3); tmp++){
        bitset<3> b(tmp);
        int sum = S[0] - '0';
        string ans = {S[0]}; 
        for(int i=0;i<3; i++){
            if(b.test(i)){
                sum += S[i+1] - '0';
                ans += '+';
            }else{
                sum -= S[i+1] - '0';
                ans += '-';
            }
            ans += S[i+1];
        }
        if(sum == 7){
            cout << ans << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np


def dijkstra(cost_matrix, start_node=0):
    node_num = len(cost_matrix)
    distance = np.full(node_num, np.inf)
    distance[start_node] = 0
    unsearched_nodes = [i for i in range(node_num)]
    while unsearched_nodes:
        min_distance = np.inf
        for each_node in unsearched_nodes:
            if distance[each_node] < min_distance:
                min_distance = distance[each_node]
                target_node = each_node
        unsearched_nodes.remove(target_node)
        each_distance = cost_matrix[target_node]
        for i in range(node_num):
            if each_distance[i] != 0:
                distance[i] = min(distance[i], distance[target_node] + each_distance[i])
    return distance.astype(int)


h, w = map(int, input().split())
graph = np.array([np.array(list(map(int, input().split()))) for _ in range(10)])
graph = np.transpose(graph)
dist = dijkstra(graph, start_node=1)


wall_num = []
for i in range(h):
    wall_num += list(map(int, input().split()))



ret = 0
for num in wall_num:
    if num != -1:
        ret += dist[num]


print(ret)

Measured memory_bytes: 12984
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, s, w, q;
        cin >> n >> s >> w >> q;
        if(n == 0)
            return 0;

        vector<int> a(n);
        for(int i=0; i<n; ++i){
            a[i] = (s/7) % 10;
            if(s % 2 == 0)
                s = s / 2;
            else
                s = (s / 2) ^ w;
        }

        if(q == 2 || q == 5){
            int ret = 0;
            int numZero = 0;
            for(int i=0; i<n; ++i){
                if(a[i] == 0)
                    ++ numZero;
                if(a[i] % q == 0)
                    ret += (i+1-numZero);
            }
            cout << ret << endl;
        }else{
            int ret = 0;
            int x = 0;
            int y = 1;
            map<int, int> mii;
            mii.insert(make_pair(0, 1));
            for(int i=n-1; i>=0; --i){
                x += a[i] * y;
                x %= q;

                if(a[i] != 0)
                    ret += mii[x];
                ++ mii[x];

                y *= 10;
                y %= q;
            }
            cout << ret << endl;
        }
    }
}

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

struct Card {
    int value;
    char trump;
};

void trace(struct Card *a, int n) {
    for (int i = 0; i < n - 1; i++) {
        cout << a[i].trump << a[i].value << " ";
    }
    cout << a[n-1].trump << a[n-1].value << endl;
}

void bubbleSort(struct Card *c, int n) {
    for (int i = 0; i < n - 1; i++) {
        for (int j = n - 1; j > i; j--) {
            if (c[j].value < c[j - 1].value) {
                struct Card tmp = c[j];
                c[j] = c[j - 1];
                c[j - 1] = tmp;
            }
        }
    }
}

void selectionSort(struct Card *c, int n) {
    for (int i = 0; i < n - 1; i++) {
        int minoff = i;
        for (int j = i + 1; j < n; j++) {
            if (c[j].value < c[minoff].value) {
                minoff = j;
            }
        }
        if (i != minoff) {
            struct Card tmp = c[i];
            c[i] = c[minoff];
            c[minoff] = tmp;
        }
    }
}

int main() {
    int n;
    struct Card c_1[36], c_2[36];
    cin >> n;
    for (int i = 0; i < n; i++) {
        struct Card tmp;
        cin >> tmp.trump >> tmp.value;
        c_1[i] = tmp;
        c_2[i] = tmp;
    }

    bubbleSort(c_1, n);
    selectionSort(c_2, n);

    trace(c_1, n);
    cout << "Stable" << endl;
    trace(c_2, n);
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (c_1[i].value != c_2[i].value || c_1[i].trump != c_2[i].trump) {
            flag = false;
        }
    }
    if (flag) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }





    return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 3000+5;
const ll mod = 998244353;
ll memo[maxn][maxn];
int N,S,A[maxn];

ll power(ll a,ll b,ll m){
	ll res = 1;
	while(b){
		if(b&1) res = (a*res)%m;
		b >>= 1;
		a = ((a%m)*(a%m))%m;
	}
	return res;
}
ll dp(int pos,int sum){
	if(pos >= N){
		if(sum == S)return power(2,N,mod);
		return 0;
	}
	ll &res = memo[pos][sum];
	if(res != -1)return res;
	res = dp(pos+1,sum);
	ll tmp = ((499122177ll)*(dp(pos+1,min(sum+A[pos],S+1))))%mod;
	res = ((res%mod)+(tmp%mod))%mod;
	return res;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,maxn)forn(j,0,maxn)memo[i][j] = -1;
	cin >> N >> S;
	forn(i,0,N)cin >> A[i];
	ll res = dp(0,0);
	if(res < 0)res += mod;
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

Measured memory_bytes: 74360
#include<iostream>
using namespace std;
int main()
{int n,i;

float f,cnt;
cnt=0;
cin>>n;
if(n==0)
{cout<<cnt;
}
else
{for(i=1;i<=n;++i)
 {if(i%2==1)
  cnt++;
}
f=cnt/n;
cout<<f;

}
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int H,W,K,sy,sx,ans=MAX;
  cin>>H>>W>>K;
  int D[H+2][W+2];
  char A[H+2][W+2];
  bool CAN[H+2][W+2];
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      cin>>A[i][j];
      if(A[i][j]=='S'){
        sy=i;
        sx=j;
      }
      D[i][j]=MAX;
      CAN[i][j]=false;
    }
  }
  
  
  queue<pair<int,int>> Q;
  Q.emplace(sy,sx);
  D[sy][sx]=0;
  
  while(!Q.empty()){
    auto P=Q.front();
    Q.pop();
    for(int i=0; i<4; ++i){
      int ny=P.first+dy[i],nx=P.second+dx[i];
      if(nx<1||nx>W||ny<1||ny>H||A[ny][nx]=='#') continue;
      if(CAN[ny][nx]) continue;
      CAN[ny][nx]=true;
      D[ny][nx]=min(D[ny][nx],D[P.first][P.second]+1);
      Q.emplace(ny,nx);
    }
  }
  
  vector<pair<int,int>> L;
  
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      if(D[i][j]<=K){
        L.PB(MP(i,j));
        if(i==1||i==H||j==1||j==W){
          co(1);
          return 0;
        }
      }
    }
  }
  
  for(int i=0; i<L.size(); ++i){
    int X=L[i].second,Y=L[i].first;
    
    chmin(ans,(X+K-2)/K);
    chmin(ans,(W-X+K-1)/K);
    chmin(ans,(Y+K-2)/K);
    chmin(ans,(H-Y+K-1)/K);
  }
  
  co(ans+1);
  return 0;
}

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

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


Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
const int inf =
 1e9 + 5 ;
 //1e18L + 5;
const int nax = 2e5 + 5;
void min_self(int&a , int b){a=min(a,b);}
void max_self(int&a , int b){a=max(a,b);}
void add_self(int&a , int b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
char ch ;  cin >> ch ; 
cout << char(int (ch ) + 1 ) ; 
	
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

    bool ok = true;

    for (int i = 0; i < n; ++i) {
        if (a[i] % 2 != 0) {
            continue;
        } else {
            if (a[i] % 3 == 0 || a[i] % 5 == 0) {
                continue;
            } else {
                ok = false;
                break;
            }
        }
    }

    if (ok) {
        puts("APPROVED");
    } else {
        puts("DENIED");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<set>
#include <vector>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 9999999
int main()
{
    string s;
    cin>>s;
    vector<char> v;
    set<char> se;
    loop(i,s.size())
    {
        v.push_back(s[i]);
        se.insert(s[i]);
    }
    cout<<(v.size()==se.size() ? "yes" : "no");
    return 0;
}


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

#include <math.h>


int main(){

	int tmp, max;
	int **L, **R, **U, **D;
	int i, j, k, H, W;

	char **S;

	scanf("%d %d", &H, &W);

	S = malloc(sizeof(char *)* H);
	for (i = 0; i < H; i++)
	{
		S[i] = malloc(sizeof(char)* W);
	}

	L = malloc(sizeof(int *)* H);
	for (i = 0; i < H; i++)
	{
		L[i] = malloc(sizeof(int)* W);
	}

	R = malloc(sizeof(int *)* H);
	for (i = 0; i < H; i++)
	{
		R[i] = malloc(sizeof(int)* W);
	}

	U = malloc(sizeof(int *)* H);
	for (i = 0; i < H; i++)
	{
		U[i] = malloc(sizeof(int)* W);
	}

	D = malloc(sizeof(int *)* H);
	for (i = 0; i < H; i++)
	{
		D[i] = malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++)
		scanf("%s", S[i]);


	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			if (S[i][j] == '#'){
				L[i][j] = 0;
			}
			else if (j == 0){
				L[i][j] = 1;
			}
			else{
				L[i][j] = L[i][j - 1] + 1;
			}
		}
	}

	for (i = 0; i < H; i++){
		for (j = W-1; j >= 0; j--){
			if (S[i][j] == '#'){
				R[i][j] = 0;
			}
			else if (j == W-1){
				R[i][j] = 1;
			}
			else{
				R[i][j] = R[i][j + 1] + 1;
			}
		}
	}

		for (j = 0; j < W; j++){
			for (i = 0; i < H; i++){
			if (S[i][j] == '#'){
				U[i][j] = 0;
			}
			else if (i == 0){
				U[i][j] = 1;
			}
			else{
				U[i][j] = U[i-1][j] + 1;
			}
		}
	}

		for (j = 0; j < W; j++){
			for (i = H - 1; i >= 0; i--){
				if (S[i][j] == '#'){
					D[i][j] = 0;
				}
				else if (i == H - 1){
					D[i][j] = 1;
				}
				else{
					D[i][j] = D[i + 1][j] + 1;
				}
			}
		}


		max = 0;

		for (i = 0; i < H; i++){
			for (j = 0; j < W; j++){
				tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
				if (max < tmp)
					max = tmp;
			}
		}
	printf("%d\n", max);

  return 0;
}


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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll h, n; cin >> h >> n;
    ll a, sum = 0;
    rep(i, n){
        cin >> a;
        sum += a;
    }

    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input() for i in range(h)]

way = ((1,1),(1,0),(1,-1),(0,1),(0,-1),(-1,1),(-1,0),(-1,-1))
ans = [[0 for j in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = '#'
            continue
        for k in way:
            if not (0 <= i+k[0] < h and 0 <= j+k[1] < w): continue
            if s[i+k[0]][j+k[1]] == '#': ans[i][j] += 1

for i in range(h):
    print(''.join(map(str,ans[i])))

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

    int n;
    cin >> n;
    vi a(n);
    rep(i,0,n)cin >> a[i];
    vi b(n);
    b=a;
    sort(all(b));
    int d = 0;
    rep(i,0,n) {
      if (b[i] != a[i]) d++;
    }

    if (d <= 2) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
}


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

namespace ABC113
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = input[0];
            int M = input[1];

            string[] py;
            List<Tuple<int, int, int>> tupleList = new List<Tuple<int, int, int>>();
            for (int i = 0; i < M; i++)
            {
                py = Console.ReadLine().Split();
                tupleList.Add(Tuple.Create(i, int.Parse(py[0]), int.Parse(py[1])));
            }
            var newList = tupleList.OrderBy(x => x.Item2).ThenBy(x => x.Item3);

            string[] Res = new string[M];
            int prefecture = newList.First().Item2;
            int index = 1;
            foreach (var i in newList)
            {
                if (i.Item2 != prefecture) { index = 1; prefecture = i.Item2; }
                Res[i.Item1] = i.Item2.ToString().PadLeft(6, '0') + index.ToString().PadLeft(6, '0');
                index++;
            }

            foreach (var i in Res)
            {
                Console.WriteLine(i);
            }
        }
    }
}

Measured memory_bytes: 33200
#include <bits/stdc++.h>
#define fname "NAME"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << endl;
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef pair<float, float> ff;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n;
	cin >> n;
	double sum = 0, x;
	REP0(i, n) {
		cin >> x;
		sum += 1/x;
	}
	cout << fixed << setprecision(10) << 1/sum;
	return 0;
}

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

//関数
    
    
//main関数
int main() {
    
    
    //入力
    long N,x;
    cin>>N>>x;
    
    
    //計算
    //出力
    
    
    if(x==1||x==2*N-1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        vector<long> ans(2*N-1);
        ans.at(N-1)=x;
        if(x<N){
            for(int i=0;i<N-1;i++){
                ans.at(i)=N-i-(N-i<=x);
            }
            for(int i=N;i<2*N-1;i++){
                ans.at(i)=3*N-i-1;
            }
        }else if(x==N){
            for(int i=0;i<2*N-1;i++){
                 ans.at(i)=i+1;
            }
        }else{
            for(int i=0;i<N-1;i++){
                ans.at(i)=N-i-1;
            }
            for(int i=N;i<2*N-1;i++){
                ans.at(i)=3*N-i-1-(3*N-i-1<=x);
            }
        }
        
        for(int i=0;i<2*N-1;i++){
            cout<<ans.at(i)<<endl;
        }
    }
    
    
}

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

using namespace std;
/*
方針
*/
int K;
const long long INF = 1e18;
long long dist[100010];
void bfs(){
  deque<int> q;
  q.push_back(1);
  while(!q.empty()){
    int current = q.front();
    q.pop_front();

    if(dist[current] < dist[current * 10 % K]) {
      dist[current * 10 % K] = min(dist[current],dist[current * 10 % K] );
      q.push_front(current * 10 % K);
    }


    if(dist[current + 1 % K] > dist[current] + 1){
      dist[current + 1 % K] = dist[current] + 1;
      if(current + 1 % K != 0) q.push_back(current + 1 % K);
    }
    //cout <<"current :"<< current << endl;
    //for(int i = 0; i <= K; i++) cout << dist[i%K] << " ";
    //cout << endl;

  }
}
int main(){

  cin >> K;
  for(int i = 0; i <= K; i++) dist[i] = INF;
  dist[1] = 1;
  bfs();
  //for(int i = 0; i <= K; i++) cout << dist[i%K] << " ";
  //cout << endl;
  cout << dist[0] << endl;

  return 0;
}


Measured memory_bytes: 1280
N, Q = [int(nq) for nq in input().split()]
S = input()
AC = []
for s in range(len(S)-1):
    if S[s:s+2] == "AC":
        AC.append(1)
    else:
        AC.append(0)
CS = [0]*len(AC)
CS[0] = AC[0]
for i in range(len(AC)-1):
    CS[i+1] = CS[i] + AC[i+1]
for q in range(Q):
    l, r = [int(lr) for lr in input().split()]
    if l == 1:
        print(CS[r-2])
    else:
        print(CS[r-2] - CS[l-2])

Measured memory_bytes: 8540
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <set>
#include <map>

using namespace std;

int main(){

    int n;
    cin >> n;

    int ans = 0;
    for(int i=0; i<n; i++)
    {
        int a;
        cin >> a;

        while(a % 2 == 0)
        {
            ans++;
            a /= 2;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  map<int,int> water;
  for(int i=0;i*100*a<=f;i++){//a増やすやつをi回やる
    for(int j=0;j*100*b<=f-i*a;j++){//b増やすやつをj回やる
      water[i*100*a+j*100*b] ++;
    }
  }
  map<int,int> sugar;
  for(int i=0;i*c<=f;i++){//c増やすやつをi回やる
    for(int j=0;j*d<=f-i*c;j++){//d増やすやつをj回やる
      sugar[i*c+j*d] ++;
    }
  }
  int ans1 = 0;
  int ans2 = 0;
  int dens = 0;
  for(auto w : water){
    for(auto s : sugar){
      int wat = w.first;
      int sug = s.first;
      if(wat == 0) continue;
      if(wat + sug <= f && sug <= e*wat/100){
        double tmp = (double)10000*sug/(wat+sug);
        if(tmp >= dens){
          ans1 = wat + sug;
          ans2 = sug;
          dens = tmp;
          //cout << ans1 << " " << ans2 << " " << e*wat/100 << " " << dens << endl;
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 384
S = input()
S1 = S[0:int((len(S)-1)/2)]
S2 = S[int((len(S)+1)/2):len(S)]
L = []
for i in range(int((len(S)-1) / 2)):
    if S[i] != S[-i-1]:
        L.append('No')
        break
    else:
        L.append('Yes')
for j in range(round((len(S1)-1) / 2)):
    if S1[j] != S1[-j-1]:
        L.append('No')
        break
    else:
        L.append('Yes')
for k in range(round((len(S2)+1) / 2)):
    if S2[k] != S2[-k-1]:
        L.append('No')
        break
    else:
        L.append('Yes')
if set(L) == {'Yes'}:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 2010

using namespace std;

int n,m,q;
int a[N][N];
int b[N][N],c[N][N];

inline int read(){
	char c=getchar();
	while(c<'0'||c>'1') c=getchar();
	return c-'0';
}

inline int calc(int a[N][N],int x1,int y1,int x2,int y2){
	if(x1>x2||y1>y2) return 0;
	return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
}

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=read();
	for(int i=2;i<=n;i++)
		for(int j=1;j<=m;j++)
			b[i][j]=a[i][j]&a[i-1][j];
	for(int i=1;i<=n;i++)
		for(int j=2;j<=m;j++)
			c[i][j]=a[i][j]&a[i][j-1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			c[i][j]=c[i][j]+c[i-1][j]+c[i][j-1]-c[i-1][j-1];
	}
	while(q--){
		int x1,x2,y1,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",calc(a,x1,y1,x2,y2)-calc(b,x1+1,y1,x2,y2)-calc(c,x1,y1+1,x2,y2));
	}
}

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

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

  ll x;
  cin >> x;

  ll a = 0, b = 0;
  bool check = true;

  while (check)
  {
    for (ll i = -65; i < a; i++)
    {
      if((ll)pow(a, 5) - (ll)pow(i, 5) == x)
      {
        check = false;
        b = i;
      }
    }
    if(!check) break;
    a++;
  }
  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 4072
/*
	Code written by Talant I.D.
*/

#include <bits/stdc++.h> 

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define mp make_pair
#define mt make_tuple
#define mod int(1e9+7)
#define eps double(1e-9)
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod ll(998244353)
#define fr first
#define sc second

inline bool isvowel(char ch){
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y');
}

inline bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n%i == 0) return false;
	return true;
}

const int N = 3001;
double dp[N][N];
vector <double> prob;

int main(){
	do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, i, j;
	cin >> n;
	prob.resize(n+1);
	for(i = 1; i <= n; i++){
		cin >> prob[i];
	}
	dp[1][1] = prob[1];
	dp[1][0] = 1-prob[1];
	for(i = 2; i <= n; i++){
		for(j = 0; j < i; j++){
			dp[i][j+1]+=dp[(i-1)][j] * prob[i];
			dp[i][j]+=dp[(i-1)][j] * (1-prob[i]);
			
		}
	}
	
	double sum = 0;
	for(i = n/2+1; i <= n; i++){
		sum += dp[n][i];
	}
	cout << precision(10) << sum;
	
	return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void solve(){
	int x,n;
	cin>>x>>n;
	int arr[n];
	bool vis[200]={false};
	int mn=-1;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		vis[arr[i]]=true;
	}
	int min_val=INT_MAX;
	int d1=0,d2=0;
	int a1=INT_MAX,a2=INT_MAX;
	for(int i=x;x>=0;i--){
		if(vis[i]==false){
			d1=x-i;
			a1=i;
			break;
		}
	}
	for(int i=x;i<=105;i++){
		if(vis[i]==false){
			d2=i-x;
			a2=i;
			break;
		}
	}
	if(d1<d2){
		cout<<a1<<"\n";
	}
	else if(d2<d1){
		cout<<a2<<"\n";
	}
	else{
		cout<<min(a1,a2)<<"\n";
	}
	return ;
}

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

    #ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t=1;

	while(t--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 3652
#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(){
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int c = 0, d = 0;
  rep(i, s.size()){
    if(s.at(i) == 'c') cout << "No" << endl;
    else if(s.at(i) == 'a'){
      if(c+d < a+b){
        cout << "Yes" << endl;
        c++;
      }else{
        cout << "No" << endl;
      }
    }else{
      if(c+d < a+b && d < b){
        cout << "Yes" << endl;
        d++;
      }else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3744
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }
const int NIL = -1;
const int INF = (1ll << 31) - 1;
struct SegmentTree {
	int n;
	vector<int>d, lazy;
	SegmentTree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
		lazy.assign(2 * n, NIL);
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != NIL) {
			d[k] = lazy[k];
			if (r - l > 1) {
				lazy[2 * k] = lazy[2 * k + 1] = lazy[k];
			}
			lazy[k] = NIL;
		}
	}
	void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		else if (a <= l&&r <= b) {
			lazy[k] = x;
			eval(k, l, r);
		}
		else {
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
			d[k] = min(d[2 * k], d[2 * k + 1]);
		}
	}
	int find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return INF;
		else if (a <= l&&r <= b)return d[k];
		else return min(find(a, b, 2 * k, l, (l + r) / 2), find(a, b, 2 * k + 1, (l + r) / 2, r));
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int s, t; cin >> s >> t;
			cout << seg.find(s, t + 1) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4948
#include<iostream>
//#include<vector>

int main(){
	int k,a,b;
	std::cin>>k>>a>>b;


	for (int i = a; i <=  b; i++) {
		if (i%k==0) {
			std::cout << "OK" << std::endl;
			exit(0);
		}
	}

	
	std::cout << "NG" << std::endl;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int main ()
{
	int a , b , k ;
	scanf("%d%d%d",&a,&b,&k);
	int i ;
	for ( i=1 ; i<=k ; i++ ) 
	{
		if ( i&1 ) a>>=1,b+=a;
		else b>>=1,a+=b;
	}
	printf("%d %d\n",a,b);
	return 0 ;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

a.sort()
ans1 = a[n-1]
minabs = 10**9+1
x = a[n-1]//2

for i in range(n-1):
    y = abs(a[i]-x)
    if a[n-1]%2 == 0:
        if minabs > y:
            ans2 = a[i]
            minabs = y
    else:
        if minabs > min(y,y-1):
            ans2 = a[i]
            minabs = y
  
print(ans1,ans2)


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

int main() {
  char s;
  cin >> s;
  if(isupper(s)){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<n;i++){
		int p=n-i;
		int j=1;
		for(;j*j<p;j++){
			if(p%j==0) ans+=2;
		}
		if(j*j==p) ans++;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine();
            var word = Console.ReadLine();

            //target = target + target.Substring(0, word.Length - 1);
            //var find = target.Contains(word);
            //Console.WriteLine(find ? "Yes" : "No");

            var index = 0;
            for (var h = 0; h < (target.Length + word.Length); ++h)
            {
                index = 0;
                for (var i = 0; i < word.Length; ++i)
                {
                    var charIndex = (h + i) % target.Length;
                    if (target[charIndex] != word[index])
                    {
                        break;
                    }
                    ++index;
                }

                if (index == word.Length)
                {
                    break;
                }
            }

            Console.WriteLine((index == word.Length) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 19528
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };

ll G[30][30];
int limit[30][30];
int n, m;
ll dp[18][1 << 18];
const ll INF = 1e18;



int main() {
	cin >> n >> m;

	rep(i, n)rep(j, n)if(i!=j)G[i][j] = INF;
	rep(i, m) {
		int a, b, c, t;
		cin >> a >> b >> c;
		//a--; b--;
		G[a][b]= c;
	}

	rep(i, n)rep(j, 1 << n)dp[i][j] = INF;


	dp[0][0] = 0;

	rep(i,1<<n){
	rep(from, n) {
		rep(to, n){
			if (i & (1 << to))
				continue;
				dp[to][i | (1 << to)] = min(dp[to][i | (1 << to)], dp[from][i]+G[from][to]);
			}
		}
	}

	cout << (dp[0][(1 << n) - 1]==INF? -1:dp[0][(1<<n)-1]) << endl;
	return 0;
}



Measured memory_bytes: 7000
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  string s;
  cin>>s;
  char x=s.at(0);
  int sum=0;
  for(int i=1;i<s.size();i++){
    if(x!=s.at(i)){
      sum++;
      x=s.at(i);
    }
  }
  cout<<sum<<endl;
  



}




Measured memory_bytes: 512
#include<stdio.h>

int main(){
    int x,y;
    do{
    scanf("%d",&x);
    scanf("%d",&y);
    
    if(x == 0 && y == 0){
        break;
    }
    if(x > y){
       x = x - y;
       y = x + y;
       x = y - x;
    }
    printf("%d"" ""%d\n",x,y);
    }while(x != 0 || y!= 0);
  
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class Dinic{//max flow
public:
    int n;
    vector<vector<edge> >G;//[MAX];
    vi level,iter;//[MAX];
    Dinic(int size){
        n=size;
        G=vector<vector<edge> >(n);
    }
    void add_edge(int from, int to, int cap){
        edge q={to,cap,int(G[to].size())};
        G[from].push_back(q);
        q={from,0,int(G[from].size()-1)};
        G[to].push_back(q);
    }
    int getmaxflow(int s,int t) {//from s to t,ford_fulkerson
        int flow=0;
        while(1){
            bfs(s);
            if(level[t]<0)return flow;
            iter=vi(n);
            int f;
            while((f=dfs(s,t,INF))>0)flow+=f;
        }
    }
private:
    void bfs(int s){
        level=vi(n,-1);
        queue<int>q;
        level[s]=0;
        q.push(s);
        while(!q.empty()){
            int v=q.front();q.pop();
            for(int i=0;i<G[v].size();i++){
                edge &e=G[v][i];
                if(e.cap>0&&level[e.to]<0){
                    level[e.to]=level[v]+1;
                    q.push(e.to);
                }
            }
        }
    }
    int dfs(int v,int t, int f) {
        if(v==t)return f;
        for(int &i=iter[v];i<G[v].size();i++){
            edge &e=G[v][i];
            if(level[v]>=level[e.to]||e.cap<=0) continue;
            int d =dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
        return 0;
    }
};

signed main(){
    int v,e;
    cin>>v>>e;
    Dinic yebi(v+1);
    rep(i,e){
        int a,b,c;cin>>a>>b>>c;
        yebi.add_edge(a,b,c);
    }
    cout<<yebi.getmaxflow(0, v-1)<<endl;
}



Measured memory_bytes: 3188
#include<cstdio>
#include<cmath>
using namespace std;
int d[100010][5],s[100010][5],n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d%d",&d[i][0],&d[i][1],&d[i][2]);
	for(int i=1;i<=n;i++){
		int a;
		if(s[i-1][1]<s[i-1][2])a=s[i-1][2];
		else a=s[i-1][1];
		s[i][0]=a+d[i][0];
		if(s[i-1][0]<s[i-1][2])a=s[i-1][2];
		else a=s[i-1][0];
		s[i][1]=a+d[i][1];
		if(s[i-1][1]<s[i-1][0])a=s[i-1][0];
		else a=s[i-1][1];
		s[i][2]=a+d[i][2];
	}
	if(s[n][1]>s[n][2])s[n][2]=s[n][1];
	if(s[n][0]>s[n][2])s[n][2]=s[n][0];
	printf("%d",s[n][2]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    // cnt[num][oe] : numがいくつあるか，oeは偶数奇数番目の要素かどうか
    ll cnt[100001][2] = {};
    rep(i, n)
    {
        ll v;
        cin >> v;
        cnt[v][i % 2]++;
    }
    // res[oe][fs] : 奇数か偶数かどうか，一番大きい数，２番目に大きい数
    ll res[2][2] = {};
    rep(i, 2)
    {
        // 全探索
        for (ll j = 1; j <= 100000; j++) {
            // 1番大きい数を更新している
            if (cnt[j][i] > cnt[res[i][0]][i]) {
                res[i][1] = res[i][0];
                res[i][0] = j;
            }
            // ２番目に大きい数を更新している
            else if (cnt[j][i] > cnt[res[i][1]][i]) {
                res[i][1] = j;
            }
        }
    }
    // 一番大きい数が奇数と偶数で違うときは奇数，偶数ごとにそれぞれの一番大きい数にする
    if (res[0][0] != res[1][0]) {
        cout << n - cnt[res[0][0]][0] - cnt[res[1][0]][1] << endl;
    } else {
        // それ以外のときはどちらかを１番多いものに変え，もう一方を２番目に多いものに帰る
        cout << n - max(cnt[res[0][0]][0] + cnt[res[1][1]][1], cnt[res[0][1]][0] + cnt[res[1][0]][1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	sa = input()
	if s == sa[:-1]:
		print('Yes')
	else:
		print('No')
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9144
local n = io.read("*n")
local wmax = 0
local score = 0
local ws, vs = {}, {}
local samesum = 0
for i = 1, n do
  local a, b = io.read("*n", "*n")
  if a < b then
    score = score + b
    wmax = wmax + b - a
  elseif a == b then
    samesum = samesum + b
  else
    table.insert(ws, a - b + 1)
    table.insert(vs, b)
  end
end
if 0 < wmax then
  score = score + samesum
end

local mma, mmi = math.max, math.min
local dpret = 0
local dpmin = 0
local tn = #ws
for i = 1, tn do
  local w, v = ws[i], vs[i]
  dpret = dpret + v
  dpmin = i == 1 and v or mmi(dpmin, v)
end
print(score + dpret - dpmin)


Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    int p,q,r;
    int a[3];
    for(int i=0;i<3;i++)
        cin>>a[i];
    
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
}

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

long long int min(long long int a, long long int b){
  return (a<b) ? a : b;
}

long long int max(long long int a, long long int b){
  return (a>b) ? a : b;
}
int main(){
  int n,k,q;
  cin >> n;
  vector<long long int> a(n);
  long long int res=0;
  long long int allxor=0;
  long long int j;
  for(long long int i=0; i<n; i++){
    cin >> a[i];
  }
  for(long long int i=0; i<n; i++){
    allxor ^= a[i];
  }
  for(long long int i=0; i<n; i++){
    a[i] &= ~allxor;
  }
  long long int rank=0;
  for(long long int i=59; i>=0; i--){
    for(j=rank; j<n; j++){
      if(a[j] & (1LL << i)) break;
    }
    if(j==n){
      continue;
    }
    if(j>rank) a[rank]^=a[j];
    for(j=rank+1; j<n; j++){
      a[j] = min(a[j], a[j]^a[rank]);
    }
    rank++;
  }
  long long int x = 0;
  for(long long int i=0; i<n; i++){
    x = max(x, x^a[i]);
  }
  res = (x*2) + allxor;
  cout << res << endl;
  //for(long long int i=0; i<n; i++){
  //  cout << a[i] << endl;
  //}
  return 0;
}


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

int main() {
    int n; cin >> n;
    map<int, int> sides;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (sides.count(a)) sides[a]++;
        else sides[a] = 1;
    }

    long long side1 = -1, side2 = -1;
    for (auto it = sides.rbegin(); it != sides.rend(); it++) {
        if (it->second >= 4) {
            if (side1 < 0) {
                side1 = (long long)it->first;
                side2 = (long long)it->first;
                break;
            } else if (side2 < 0) {
                side2 = (long long)it->first;
                break;
            }
        } else if (it->second >= 2) {
            if (side1 < 0) side1 = (long long)it->first;
            else if (side2 < 0) side2 = (long long)it->first;
            else break;
        }
    }

    if (side1 < 0 || side2 < 0) cout << 0 << endl;
    else cout << side1 * side2 << endl;
}


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

for i in range(N-1):
    minj = i
    for j in range(i+1,N):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        A[i],A[minj] = A[minj],A[i]
        count+=1
print(*A)
print(count)


Measured memory_bytes: 5604
# B - Judge Status Summary


def main(n, s):
    result_table = {
        'AC': 0,
        'WA': 0,
        'TLE': 0,
        'RE': 0
    }
    for i in s:
        result_table[i] += 1
    return result_table


if __name__ == "__main__":
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    results = main(n, s)
    for key, value in results.items():
        print(f"{key} x {value}")


Measured memory_bytes: 16244