akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	string s,t; cin >> s;
	int N = s.size(); REP(i, N) if (s[i] != 'x') t.push_back(s[i]);
	bool flg = true;
	int M = t.size();
	
	for (int i = 0; i < M / 2; ++i) if (t[i] != t[M - 1 - i]) flg = false;
	if(!flg){
		cout << -1 << endl;
		return 0;
	}
	int l = 0, r = N - 1;
	ll cnt = 0;

	while(l<r){
		if (s[l] == s[r])l++, r--;
		else if (s[l] == 'x'&&s[r] != 'x')l++, cnt++;
		else if (s[l] != 'x'&&s[r] == 'x')r--, cnt++;
		else if (s[l] == 'x'&&s[r] == 'x')l++, r--;
		else if (s[l] != 'x'&&s[r] != 'x'){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
	

	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#define N 1000005
using namespace std;
typedef long long ll;

ll n;
ll M=1e9+7, fac[N]={1,1}, inv[N]={1,1}, fiv[N]={1,1};

int main(void)
{
    int x,y;
    cin >> x >> y;
    int p=(2*x-y)/3;
    int q=(2*y-x)/3;
    if((x+y)%3!=0 || p<0 || q<0)
    {
        cout << 0;
        return 0;
    }
    for(int i=2; i<=N; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
	}
	cout << fac[p+q]*fiv[p]%M*fiv[q]%M;
    return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v(N),v_1(N);
    for(int i = 0; i < N; i++){
        cin >> v[i];
        v_1[i] = v[i];
    }
//    copy(v.begin(),v.end(),v_1);
    int Max, Max_2;
    sort(v.begin(), v.end(),greater<int>());
    Max = v[0];
    /*
    for(int i = 1; i < N; i++){
        if(v[0] != v[i]){
            Max_2 = v[i];
        }
    }
    */
   Max_2 = v[1];

    for(int j = 0; j < N; j++){
        if(v_1[j] == Max){
            cout << Max_2 << endl;
        }else{
            cout << Max << endl;
        }
    }

}

Measured memory_bytes: 3200
package main

import (
	"fmt"
)

func main() {
  var X, Y string 
  fmt.Scanf("%s %s", &X, &Y)
  
  ans := "="
  if X > Y {
    ans = ">"
  }
  if X < Y {
    ans = "<"
  }
 
  fmt.Printf("%s\n",ans)
}

Measured memory_bytes: 1836
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, p1, p2 = map(int, readline().split())
    if N == p1 == p2 == 0:
        return False
    P = p1 + p2
    G = [[] for i in range(P)]
    for i in range(N):
        x, y, a = readline().strip().split()
        x = int(x); y = int(y); d = (a == "no")
        if x == y:
            continue
        G[x-1].append((y-1, d))
        G[y-1].append((x-1, d))
    L = [-1]*P
    ok = 1
    U = []
    for i in range(P):
        if L[i] != -1:
            continue
        que = deque([i])
        L[i] = 0
        cs = [[], []]
        while que:
            v = que.popleft()
            e = L[v]
            cs[e].append(v+1)
            for w, d in G[v]:
                if L[w] != -1:
                    continue
                L[w] = e ^ d
                que.append(w)
        a, b = map(len, cs)
        if a == b:
            ok = 0
            break
        U.append((cs[0], cs[1]))
    if not ok:
        write("no\n")
        return True
    S = [0]*(p1+1)
    S[0] = 1
    SS = [S]
    zeros = [0]*(p1+1)
    M = len(U)
    for c0, c1 in U:
        p = len(c0); q = len(c1)
        T = [0]*(p1+1)
        for i in range(p1+1):
            if S[i]:
                if i+p <= p1:
                    T[i+p] += S[i]
                if i+q <= p1:
                    T[i+q] += S[i]
        SS.append(T)
        S = T
    if S[p1] > 1:
        write("no\n")
        return True
    ans = []
    rest = p1
    for i in range(M-1, -1, -1):
        T0 = SS[i]
        c0, c1 = U[i]
        p = len(c0); q = len(c1)
        if rest - p >= 0 and T0[rest - p]:
            ans.extend(c0)
            rest -= p
        else:
            ans.extend(c1)
            rest -= q
    if ans:
        ans.sort()
        write("\n".join(map(str, ans)))
        write("\n")
    write("end\n")
    return True
while solve():
    ...


Measured memory_bytes: 6328
a,b = map(int,input().split())
s = input()
l = [str(i)for i in range(10)]
ok = True
for i in range(a+b+1):
    if i == a:
        if s[i] != '-':
            ok = False
            break
    else:
        if s[i] not in l:
            ok = False
            break
if ok:
    print('Yes')
else:print('No')
    

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	long long bisq = 1+k;
	int pro = b-a-2;
	if(pro<=0) cout << bisq << "\n";
	else {
		if(bisq>=a) {
			long long x = (k-(a-1))/2;
			x *= pro;
			bisq += x;
		}
		cout << bisq << "\n";
	}
	return 0;
}

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
int n, m, cnt;
char a[9][9];

int main () {
	boost ();
	cin >> n >> m;
	for (int i = 1;i <= n;i ++)
		for (int j = 1;j <= m;j ++) {
			cin >> a[i][j];
			if (a[i][j] == '#') cnt ++;
		}
	if (cnt == n + m - 1) cout << "Possible";
	else cout << "Impossible";

	return 0;
}

        

Measured memory_bytes: 256
#include <iostream>
#include <array>
using namespace std;
typedef long long ll;

constexpr ll bound = 1000'000'000LL * 1000'000'000LL;
array<ll, 100009> a;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if (a.at(i) == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll res = 1;
  for (int i = 0; i < n; i++) {
    if (a.at(i) > bound / res) {
      cout << -1 << endl;
      return 0;
    }
    res *= a.at(i);
  }
  cout << res << endl;
}

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

int main(){

  int n,k,v,u;
  cin>>n;

  double V[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

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


  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<V[i][j];
      if(j!=n-1){
	cout<<" ";
      }
  }
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
using ll=long long;
using namespace std;

int main(){
    int N,D,A;
    cin>>N>>D>>A;

    vector<pair<int,int>> map;
    int a,b;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        map.push_back({a,b});
    }
    sort(map.begin(),map.end());

    ll ans=0;
    queue<pair<ll,ll>> q;//place,plus
    ll subd=0;

    for(int i=0;i<N;i++){
        while(!q.empty() && q.front().first<=map[i].first){
            subd+=q.front().second;
            //cout<<q.front().first<<" "<<q.front().second<<endl;
            q.pop();
        }
        ll hp=map[i].second+subd;
        if(hp>0){
            ll numBom=(hp+A-1)/A;
            ans+=numBom;
            ll damage=numBom*A;
            ll range=map[i].first+2*D;
            subd-=damage;
            q.push({range+1,damage});
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6416
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrepi(i,a,b) for(int i=int(b-1);i>=int(a);i--)

#define all(x) (x).begin(),(x).end()

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 long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w;cin>>h>>w;
  vector<vector<char>>hw(h+1,vector<char>(w+1,'#'));
  vector<vector<ll>>res(h+1,vector<ll>(w+1));

  rep(i,h)rep(j,w)cin>>hw[i+1][j+1];
  repi(i,1,h+1){
    ll ld=0;
    repi(j,1,w+1){
      if(hw[i][j]=='#'){
        ld=-1;
      }
      else {
        res[i][j]+=ld;
      }
      ld++;
      //cout<<res[i][j]<<" ";
    }
    //cout<<endl;
    ll rd=0;
    rrepi(j,1,w+1){
      if(hw[i][j]=='#'){
        rd=-1;
      }
      else {
        res[i][j]+=rd;
      }
      rd++;
    }
  }
  repi(j,1,w+1){
    ll ld=0;
    repi(i,1,h+1){
      if(hw[i][j]=='#'){
        ld=-1;
      }
      else {
        res[i][j]+=ld;
      }
      ld++;
    }
    ll rd=0;
    rrepi(i,1,h+1){
      if(hw[i][j]=='#'){
        rd=-1;
      }
      else {
        res[i][j]+=rd;
      }
      rd++;
    }
  }
  ll r=0;
  rep(i,h)rep(j,w){
    chmax(r,res[i+1][j+1]);
  }
  cout<<r+1<<endl;

  return 0;

}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
int a,c,d,e;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b.at(i);
  rep(i,a-1){
    c=b.at(i);
    d=b.at(i+1);
    e=d%c;
    if(e==0)
      b.at(i+1)=c;
    else{
      b.at(i+1)=c;
      b.at(i)=e;
      i--;
      }
}
  cout<<c<<endl;
}
  

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

int main() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++)
    {
        p[i] = 0;
        cin >> p[i];
    }
    
    int ans = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if ((p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i + 1] > p[i] && p[i] > p[i - 1]))
        {
            ans++;
        }
        
    }
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int n;
  int I[1001],P[1001],Q[1001],R[1001],C[1001];
   
  while(cin >> n ,n){
    for(int i=0;i<n;i++){
      cin >> I[i] >> P[i] >> Q[i] >> R[i];
      C[i] = P[i]*4 + Q[i]*9 + R[i]*4;
    }
    cin >> P[n] >> Q[n] >> R[n] >> C[n];
     
    int ans = 0;
    for(int i=0;i<n;i++){
      if(P[i]<=P[n] && Q[i]<=Q[n] && R[i]<=R[n] && C[i]<=C[n]){
    cout << I[i] << endl;
    ans++;
      }
    }
    if(!ans)cout << "NA\n";
  }
}

Measured memory_bytes: 888
N, A, B = map(int,input().split())
if (B-A)%2==0:
  print((B-A)//2)
else:
  a = A-1
  b = N-B
  cnt = 0
  if a <= b:
    A = A-a
    B = B-a-1
    cnt += a+1
    if A==B:
      print(cnt)
    else:
      cnt += (B-A)//2
      print(cnt)
  else:
    A = A+b+1
    B = B+b
    cnt += b+1
    if A==B:
      print(cnt)
    else:
      cnt += (B-A)//2
      print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    cout << (180 * (N-2)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =2*1e5+5;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    char a;
    cin >> a;
    if(isupper(a)) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}

Measured memory_bytes: 3620
//At coder k stones 
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define display(v) f(v.size())cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k; cin>>n>>k;
    int arr[n]; f(n)cin>>arr[i];
    bool dp[k+1] ;   memset(dp,false,sizeof(dp));
    for(int stone = 0 ; stone <=k ; stone++)
    {
        f(n)
        {
            if(stone >= arr[i] && dp[stone-arr[i]]==false)
            {
                dp[stone] = true;
            }
        }
    }
    if(dp[k])cout << "First\n";
    else cout << "Second\n";
    
    return 0;
 }

Measured memory_bytes: 384
#include<stdio.h>
int odd(int x)
{
  if(x%2!=0)
    return 1;
  else
    return 0;
}
int main()
{
  int n,c=0;
  scanf("%d",&n);
  int arr[1000];
  for(int i=0;i<n;i++)
  {
    scanf("%d",&arr[i]);
  }
  for(int i=0;i<n;i++)
  {
    if(odd(i+1) && odd(arr[i])==1)
      c++;
  }
  printf("%d",c);
}


Measured memory_bytes: 1708
// C - /\/\/\/
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<pair<int,int>> E(100000),O(100000);//[value]<count,value>
	rp(i, 0, N/2){
		int e,o; cin>>e>>o; e--;o--;
		// printf("%d %d\n",e+1,o+1);//
		E[e].first++;
		E[e].second = e+1;
		O[o].first++;
		O[o].second = o+1;
	}
	// puts("---");///

	sort(E.rbegin(),E.rend());
	sort(O.rbegin(),O.rend());

	int ans = N - (E[0].second != O[0].second?
			E[0].first + O[0].first:
			max(E[0].first + O[1].first,
					E[1].first + O[0].first)
			);
	cout<< ans <<endl;

	// puts("-----");///
	// rp(i,0,N/2)printf("%d %d\n",E[i].first,E[i].second);puts("--");//
	// rp(i,0,N/2)printf("%d %d\n",O[i].first,O[i].second);puts("--");//

}


Measured memory_bytes: 1792
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int n,a,b;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>a>>b;
	cout<<min(a,b)<<' '<<max(0,a+b-n)<<endl;

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
total = a.inject(:+)
tmp = 4611686018427387903
sumx = 0

0.upto(n - 2) do |i|
  sumx += a[i]
  tmp = [(2 * sumx - total).abs, tmp].min
end

puts tmp

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

using namespace std;
#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

const int N = 1e5+10;

unordered_set<int>  g[N];
unordered_set<int> blk[N];


    int parent[N], sz[N];


void make_set(int v){
    parent[v] = v;
    sz[v] = 1;
}

int find_set(int v){
    if(v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_set(int a, int b){
    a = find_set(a);
    b = find_set(b);

    if(a != b){
        if(sz[a] < sz[b])
            swap(a, b);
        parent[b] = a;
        sz[a] += sz[b];
        sz[b] = 0;
    }
}

bool same(int x, int y){
    return find_set(x) == find_set(y);
}

int size(int x){
    return sz[find_set(x)];
}
int main(){
    IOS

    int n, m, k;
    cin>> n>>m>>k;

    for(int i = 1; i <= n; i++){
        make_set(i);
    }

    vector<int> count(N,0);
    
    for(int i = 0; i < m; i++){
        int x, y;
        cin>>x>>y;
        count[x]++, count[y]++;
        union_set(x,y);
    } 
 
    for(int i = 0; i < k; i++){
      int x, y;
      cin>>x>>y;
        if(same(x,y)){
            count[x]++, count[y]++;
        }
     }

     for(int i =1 ; i <= n; i++){
         cout<<size(i)-count[i]-1<<" ";
     }
     cout<<"\n";
}


Measured memory_bytes: 12928
class Node:
    def __init__(self, id_num):
        self.id = id_num
        self.parent = None
        self.children = []
    def get_type(self):
        if self.parent is None:
             return 'root'
        if self.children == []:
             return 'leaf'
        else:
             return 'internal node'
             
def get_depth(node, nodes):
    depth = 0
    parent = node.parent
    while parent is not None:
        depth += 1
        parent = nodes[parent].parent
    return depth
 
n = int(input())
nodes = {}
for i in range(n):
    input_line = list(map(int , input().split(' ')))
    id = input_line[0]
    children = input_line[2:]
    if id not in nodes:
        node = Node(id)
        node.children = children
        nodes[id] = node
    else:
        nodes[id].children = children
    for ch in children:
        if ch not in nodes:
            ch_node = Node(ch)
            nodes[ch] = ch_node
            nodes[ch].parent = id
        else:
            nodes[ch].parent = id
for id in sorted(nodes):
    node = nodes[id]
    parent = node.parent
    if node.parent is None:
         parent = -1
    depth = get_depth(node, nodes)
    type = node.get_type()
    print('node {}: parent = {}, depth = {}, {}, {}'.format(id, parent, depth, type, node.children))


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

int main() {

    int x;
    cin >> x;

    int count = 0;

    if(x==1) cout << 0 << endl;
    if(x==0) cout << 1 << endl;

    return 0;

}

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

int main(){
  int i,n,num[1000001];
  while(1){
  cin >> n;
  if(n==0)break;
  for(i = 0; i < 1000001; i++){
    num[i]=0;
  }
  
  for(i = 0;i < n; i++){
    cin >> num[i];
  }
  
  int cnt=0;

  for(i = 0; i < n; i++){
    for(int j = 0; j < n-1; j++){
      if(num[j] > num[j+1]){
	cnt++;
	swap(num[j],num[j+1]);
      }
    }
  }
  cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 5060
package main
import "fmt"
func main(){
    var n, c, total, minus int
    fmt.Scan(&n)
    v := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&v[i])
    }
    for i := 0; i < n; i++ {
        fmt.Scan(&c)
        minus = v[i] - c
        if total < total + minus {
            total += minus
        } else {
            continue
        }
    }
    fmt.Println(total)
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> ans(N);
    rep(i, N) ans[A[i] - 1] = i + 1;
    rep(i, N) cout << ans[i] << endl;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007

ll n,k,ans;
int main(){
	scanf("%lld%lld",&n,&k);
		ll t=n/k;
		ans=t*t*t;
	if(k%2==0){
		ll t=(n+k/2)/k;
		ans+=t*t*t;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
//minpro2019_b.cpp
//Sat Feb  9 20:56:01 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int machi[4];
	fill(machi,machi+4,0);

	for (int i=0;i<3;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		machi[a]++;
		machi[b]++;
	}

	int count[2];
	fill(count,count+2,0);
	for (int i=0;i<4;i++){
		if (machi[i]==1){
			count[0]++; 
		}else if (machi[i] == 2){
			count[1]++;
		}
	}
//	cout << count[0] << " " << count[1] << endl;
	if (count[0]==2 && count[1]==2){
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}
//	printf("%.4f\n",ans);
}

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


int main()
{
	int n, T,cost=0,costMin=10001;
	cin >> n >> T;
	vector<int>c(n), t(n);
	for (int i = 0; i < n; i++)cin >> c[i] >> t[i];

	for (int i = 0; i < n; i++) {
		if (t[i] <= T) {
			cost = c[i];
			costMin = min(cost, costMin);
		}
	}
	if (costMin == 10001)return cout << "TLE" << endl,0;
	cout << costMin << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const double INF = 1e12;
const double EPS = 1e-10;
typedef complex<double> P;
namespace std {bool operator < (const P& a, const P& b) {return real(a)!=real(b)?real(a)>real(b):imag(a)>imag(b);}}
bool cmp(P a,P b) {return atan2(a.imag(),a.real())<atan2(b.imag(),b.real());}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
struct C {
  P p; double r;
};
double D(P a, P b) {
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

void Main() {
  vector<C> a(1111);
  rep(i,2) {
    double x,y;
    cin >> x >> y;
    a[i]=(C){P(x,y),0};
  }
  int n;
  R n;
  rep(i,n) {
    double x,y,z;
    cin >> x >> y >> z;
    a[i+2]=(C){P(x,y),z};
  }
  n+=2;
  double d[n];
  fill(d,d+n+2,INF);
  vector<P> v[n];
  rep(i,n) {
    REP(j,i+1,n) {
      double d=D(a[i].p,a[j].p);
      double t=a[i].r+a[j].r;
      d=max(0.0,d-t);
      v[i].pb(P(j,d));
      v[j].pb(P(i,d));
    }
  }
  d[0]=0;
  priority_queue<P> que;
  que.push(P(0,0));
  while(!que.empty()) {
    P p=que.top();que.pop();
    int x=p.imag();
    double cc=p.real();
    if(d[x]<cc) continue;
    rep(i,v[x].size()) {
      P q=v[x][i];
      int y=q.real();
      double c=q.imag();
      if(d[y]>d[x]+c) {
        d[y]=d[x]+c;
        que.push(P(d[y],y));
      }
    }
  }
  pd(d[1]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 20756
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int n,k;
int main(){
  cin >> n >> k;
  int ans;
  for(int i=1;i<=n;i++){
    int t;
    cin >> t;
    if(t==1) ans =i;
  }
  cout << (n-1+k-2)/(k-1) << endl;
  return 0;
}


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

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int check(string s, int p, int len) {
  int r = p + len/2;
  int l = r-1;
  if (len&1) r++;
  while (l >= p) {
    if (s[l] != s[r]) {
      return 0;
    }
    l--, r++;
  }
  return 1;
}

int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  int res = check(s, 0, n);
  res &= check(s, 0, (n-1)/2);
  res &= check(s, (n+3)/2-1, n-(n+3)/2+1);
  puts(res ? "Yes" : "No");
  return 0;
}

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

int n, W;
int v[101], w[101];
int a[101][10001];

void solve() {
    a[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (j >= w[i] && a[i-1][j - w[i]] + v[i] > a[i-1][j]) {
                a[i][j] = a[i-1][j-w[i]] + v[i];
            } else {
                a[i][j] = a[i-1][j];
            }
        }
    }
}

int main() {
    cin >> n >> W;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i] >> w[i];
    }

    for (int i = 0; i < 101; ++i) {
        for (int j = 0; j <= W; ++j) {
            a[i][j] = 0;
        }
    }

    solve();
    cout  << a[n][W] << endl;

    return 0;
}



Measured memory_bytes: 7036
import itertools
import math
n = int(input())
point = []
for _ in range(n):
    x,y = map(int,input().split())
    point.append([x,y])
mati = "1"
root1 = 0
kazu = 0
for i in range(2,n+1):
    i = str(i)
    mati += i
for x in itertools.permutations(mati):
    root2 = 0
    kazu += 1
    for y in range(n-1):
        a = int(x[y])-1
        b = int(x[y+1])-1
        root2 += math.sqrt((point[a][0]-point[b][0])**2 + (point[a][1]-point[b][1])**2)
    root1 += root2
print(root1/kazu)

Measured memory_bytes: 42732
class Main{
    public static void main(String[] a){
        int x , y;
        for(x = 1; x < 10; x++){
            for(y = 1; y < 10; y++){
                int A = x * y;
                System.out.println(x + "x" + y + "=" + A);
            }

        }
    }
}



Measured memory_bytes: 24036
"use strict";
const main = input => {
    const a = Number(input[0].split(' ')[0]);
    const b = Number(input[0].split(' ')[1]);
    const c = Number(input[0].split(' ')[2]);
    console.log(Math.floor(b/a)>c?c:Math.floor(b/a));
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
// AUTHOR:: MOHAMMAD FAISAL
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int * arr = new int[n];
  for(int i=0;i<n;i++)
    cin >> arr[i];
  sort(arr,arr+n);
  long sum = 0;
  for(int i=0;i<n;i++)
  {
    if(i==n-1)
      sum+=(arr[i]/2);
    else 
      sum+=arr[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
;; ----

(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
            vars
            (mapcar (constantly '(read))
                vars)))
       ,@body)))

;; --- solution B

(defun calc (p q)
  (apply #'+ (loop
		for x in p
		for y in q
		collect (* (- x y)
		(- x y)))))

(defsolver sol-b (n d)
  (let ((l
	 (loop for i below n
	    collect (loop for j below d collect (read))))
	(squares
	 (loop for i below (* d 40 40) collect (* i i)))
	(ll))
    (loop for i below n do
	 (loop for j below n
	    when (< i j)
	    do
	      (push
	       (calc (nth i l)
		     (nth j l))
	       ll)))
    (princ (count-if #'(lambda (x)
			 (member x squares))
		     ll))))

(sol-b)

Measured memory_bytes: 15972
import java.util.*;

public class Main {
    public static long gcd(long x, long y) {
        if (y == 0) {
            return x;
        } else {
            return gcd(y, x - (x / y) * y);
        }
    }

    public static long quotient(long n, long k) {
        return n >= 0 ? n / k : n / k - 1;
    }

    public static void main(String[] args) {
        // read inputs
        Scanner in = new Scanner(System.in);
        final int N = in.nextInt();
        long[] as = new long[N], bs = new long[N], cs = new long[N], ds = new long[N];
        for (int i = 0; i < N; i++) {
            as[i] = in.nextLong();
            bs[i] = in.nextLong();
            cs[i] = in.nextLong();
            ds[i] = in.nextLong();
        }

        // solve
        for (int i = 0; i < N; i++) {
            final long a = as[i], b = bs[i], c = cs[i], d = ds[i];
            if (b > d) {
                System.out.printf("No\n");
            } else {
                if (Math.min(a, c) >= b) {
                    System.out.printf("Yes\n");
                } else if (a < b) {
                    System.out.printf("No\n");
                } else { // a >= b && c < b
                    final long gcdBD = gcd(b, d);
                    final long a0 = a % b;
                    final long num = a0 + (quotient(c - a0, gcdBD) + 1) * gcdBD;
                    if (num < b) {
                        System.out.printf("No\n");
                    } else {
                        System.out.printf("Yes\n");
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 26432
import math
N = int(input())
A = list(map(int, input().split()))
now = 1000
stack = 0
for i in range(0, N-1):
    if stack != 0: #売る
        now += stack*A[i]
        stack = 0
    if A[i] < A[i+1]: #買う
        stack = math.floor(now/A[i])
        now -= stack*A[i]
    
now += stack*A[N-1] #最終日　全部売る
stack = 0
print(now)

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

int main(){
  int n,k;
  cin>>n>>k;
  vector <int> v(n);
  rep(i,n)cin>>v[i];

   int ans=0;
  for (int i=0;i<=min(n,k);i++){
    for(int j=0;j<=min(k-i,n-i);j++){
      vector<int>vn;
      if (i>0){
      rep(i1,i)vn.emplace_back(v[i1]);
    }if (j>0){
      rep(j1,j)vn.emplace_back(v[n-j1-1]);
    }
      sort(vn.begin(),vn.end());
      reverse(vn.begin(),vn.end());
      int w=1;
      while(i+j+w<=k && vn.size()>0){
       if (vn.back()>=0)  break;
       if (vn.back()<0) {
          w++; vn.pop_back();
        }
      }
      int temp=0;
      for (auto t:vn)temp+=t;
      //cout<<i<<'i'<<j<<'j'<<temp<<endl;
      ans=max(ans,temp);

    }
  }
  cout<<ans;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,k,p;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&k,&p);
    if(k%p)
      printf("%d\n",k%p);
    else
      printf("%d\n",p);
  }
  return 0;
}

Measured memory_bytes: 596
n ,q = map(int, input().split())
ntlist = []
for i in range(n):
    nt = list(map(str, input().split()))
    ntlist.append(nt)
tp = 0
while (len(ntlist)):
    nt = ntlist.pop(0)
    if (int(nt[1])> q):
        nt[1] = int(nt[1]) - q
        tp += q
        ntlist.append(nt)
    else:
        tp += int(nt[1])
        nt[1] = 0
        print(nt[0], tp)



Measured memory_bytes: 14296
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		int count=0;
		int first=0;
		int second=0;
		int nokori=n;
		int a[300];
		lp(i,300){
			a[i]=0;
		}
		int ans=0;
		char firsts;
		lp(i,n){
			char memo;
			cin>>memo;
			a[memo]++;
			if(a[memo]>first) {
				if(firsts!=memo) second=first;
				first=a[memo];
				firsts=memo;
			}
			else if(a[memo]>second){
				second=a[memo];
			}
			nokori--;
			if(first>second+nokori&&ans==0){
				ans=n-nokori;
			}
		}
		if(first==second){
			cout<<"TIE"<<endl;
		}
		else cout<<firsts<<" "<<ans<<endl;
		
	}

return 0;
}


Measured memory_bytes: 2996
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
mod = 998244353

dp = [0] * (n + 1)
acc = [0] * (n + 1)
dp[1], acc[1] = 1, 1
for i in range(2, n + 1):
    for l, r in lr:
        dp[i] += acc[max(i - l, 0)]
        dp[i] -= acc[max(i - (r + 1), 0)]
    dp[i] %= mod
    acc[i] = (dp[i] + acc[i - 1]) % mod
print(dp[n])


Measured memory_bytes: 76608
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,M;
int p[SIZE];
ll K;

int par[SIZE]; //親
int rnk[SIZE]; //木の深さ

//初期化(n要素0オリジン)
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

//xの根を求める
int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

//x,yの属する集合を併合
void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y)return;

	if(rnk[x] < rnk[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rnk[x] == rnk[y])rnk[x]++;
	}
}

vector<P> c[SIZE]; //子 番号・値

int main()
{
	scanf("%d%d",&N,&M);
	init(N+1);
	int x,y;
	for(int i=1;i<=N;i++)scanf("%d",&p[i]);
	for(int i=0;i<M;i++){
		scanf("%d%d",&x,&y);
		unite(x,y);
	}
	for(int i=1;i<=N;i++){
		c[find(p[i])].push_back(P(i,p[i]));
	}
	int ans=0;
	for(int i=1;i<=N;i++){
		if(c[i].size()==0)continue;
		//c[i]
		set<int> S;
		for(int j=0;j<c[i].size();j++){
			S.insert(c[i][j].first);
			S.insert(c[i][j].second);
		}
		ans += c[i].size()*2-S.size();
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 9332
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
using namespace std;
signed main() {
		int n, k;
		cin >> n >> k;
		if (n%k == 0)cout << 0 << endl;
		else cout << 1 << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.readline

H,W=map(int,input().split())
A=[0 for i in range(0,H)]
B=[0 for i in range(0,H)]
for i in range(0,H):
    A[i]=list(map(int,input().split()))
for i in range(0,H):
    B[i]=list(map(int,input().split()))

C=[[0 for i in range(0,W)] for j in range(0,H)]
for i in range(0,H):
    for j in range(0,W):
        C[i][j]=abs(A[i][j]-B[i][j])

dp=[[0 for i in range(0,W)] for i in range(0,H)]
if C[0][0]!=0:
    dp[0][0]=pow(2,6400+C[0][0])+pow(2,6400-C[0][0])
else:
    dp[0][0]=pow(2,6400)
for i in range(0,H):
    for j in range(0,W):
        ans1=0
        ans2=0
        if i!=0:
            ans1=(dp[i-1][j]<<C[i][j])|(dp[i-1][j]>>C[i][j])
        if j!=0:
            ans2=(dp[i][j-1]<<C[i][j])|(dp[i][j-1]>>C[i][j])
        if (i,j)!=(0,0):
            dp[i][j]=ans1|ans2

ans=100
for i in range(0,80+1):
    test=100
    if dp[H-1][W-1]>>(6400+i) &1 ==1:
        test=i
    if ans>test:
        ans=test

print(ans)


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


int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0; i < M; ++i) {
		cin >> B[i];
	}
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> A[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int sum = 0;
		for (int j = 0; j < M; ++j) {
			sum += A[i][j] * B[j];
		}
		sum += C;
		if (sum > 0) ++ans;
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, s[MAXN], par[MAXN];
vector<int> a[MAXN], b;

void dfs(int u, int p) {
    s[u] = 1;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v != p) {
            par[v] = u;
            dfs(v, u);
            s[u] += s[v];
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].emplace_back(v);
        a[v].emplace_back(u);
    }
    dfs(1, 0);
    int r = n;
    while (r != 1) {
        b.emplace_back(r);
        r = par[r];
    }
    b.emplace_back(1);
    reverse(ALL(b));
    int V = b[(SZ(b)-1)/2+1];
    if (s[1] - s[V] > s[V]) cout << "Fennec";
    else cout << "Snuke";
    return 0;
}

Measured memory_bytes: 14972
/*#pragma GCC optimize("O3")*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
//#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	char c[m][n];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> c[j][i];
	long long dp[m][n];
	dp[0][0]=1;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(j || i)
			{
				dp[j][i]=0;
				if(c[j][i]=='.')
				{
					if(j-1 >= 0)
						dp[j][i]+=dp[j-1][i];
					if(i-1 >= 0)
						dp[j][i]+=dp[j][i-1];
					dp[j][i]%=MOD2;
				}
			}
		}
	}
	cout << dp[m-1][n-1] << '\n';
}
//size

Measured memory_bytes: 12440
#include <iostream>

using namespace std;
int x, y;

void solve() {
	switch (x)
	{
	case 1:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 2:
		if (y == 2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 3:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 4:
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout <<"Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 5:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 6:
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 7:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 8:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 9:
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 10:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 11:
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	case 12:
		if (y == 3 || y == 5 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		break;
	}
}

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

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    string ym = "YYMM", my = "MMYY", amb = "AMBIGUOUS", na = "NA";
    if((s[0] == '0' && '1' <= s[1] && s[1] <= '9') || (s[0] == '1' && '0' <= s[1] && s[1] <= '2')){
        if((s[2] == '0' && '1' <= s[3] && s[3] <= '9') || (s[2] == '1' && '0' <= s[3] && s[3] <= '2')){
            cout << amb << endl;
            return 0;
        }
    }

    if((s[0] == '0' && '1' <= s[1] && s[1] <= '9') || (s[0] == '1' && '0' <= s[1] && s[1] <= '2')){
        cout << my << endl;
        return 0;
    }
    if((s[2] == '0' && '1' <= s[3] && s[3] <= '9') || (s[2] == '1' && '0' <= s[3] && s[3] <= '2')){
        cout << ym << endl;
        return 0;
    }

    cout << na << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int  n,k,m,l;
    cin>>n;
    vector<int> v;
    for(int i=0; i<n; i++)
    {
        cin>>k;
        v.push_back(k);
    }
    sort(v.begin(),v.end());
    l=n/2;
    m=v[l]-v[l-1];
    cout<<m;

    return 0;



}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x, m; cin >> n >> x >> m;
    vector<ll> rem(2 * m + 10);
    ll start = 0, shuki = 0;
    map<ll, ll> mp;
    rem[0] = x;
    mp[x] = 1;
    rep (i, 1, 2 * m + 1) {
        rem[i] = ((rem[i - 1] % m) * (rem[i - 1] % m)) % m;
        if (int k = mp[rem[i]]; k != 0) {
            start = i + 1;
            shuki = i + 1 - k;
            break;
        }
        mp[rem[i]] = i + 1;
    }
    // rep (i, start) eprintf("%lld%c", rem[i], " \n"[i + 1 == start]);
    eprintf("%lld, %lld\n", start, shuki);
    if (n <= start) {
        ll ans = 0;
        rep (i, n) ans += rem[i];
        cout << ans << "\n";
    } else {
        ll ans = 0;
        rep (i, start) ans += rem[i];
        ll k = (n - start) / shuki, r = (n - start) % shuki;
        rep (i, shuki) ans += k * rem[start - shuki + i - 1];
        rep (i, start - shuki, start - shuki + r) ans += rem[i];
        cout << ans << "\n";
    }

    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 7944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  string s;
  int N;
  cin >> N;
  cin >> s;
  bool f = true;
  
  if(N % 2 != 0) f = false;
  else{
    if(s.substr(0,N/2) == s.substr(N/2,N/2)) f = true;
    else f = false;
  }
  cans(f);
}




Measured memory_bytes: 256
import math
import sys
A, B = map(int, input().split())

def gcd(a, b):
  if b > a:
    a, b = b,a
  a, b = b, a % b
  if b == 0:
    return a
  else:
    return gcd(a, b)

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
  divisors.append(N // divisors[-1])
  return divisors

N = gcd(A, B)
if N == 1:
  print (1)
  sys.exit()

D = make_divisors(N)
L = []
for i in D[1:]:
  for j in L:
    if i % j == 0:
      break
  else:
    L.append(i)
print (len(L)+1)

Measured memory_bytes: 3188