akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<vector>
#include<climits>
using namespace std;
#define MAXN 400000
#define INF INT_MAX
vector< pair<int,int> > G[MAXN+5];
int n,m,u,v,w;
int dist[MAXN+5];
priority_queue < pair<int,int> > Q;
map<int,int> AC_color[MAXN+5];
void Dij(int s)
{
	Q.push({0,s});
	dist[s]=1;
	while(!Q.empty())
	{
		int x=Q.top().second,Bd=-Q.top().first;
		Q.pop();
		for(int i=0;i<G[x].size();i++)
		{
			int xnext=G[x][i].first;
			int Co=G[x][i].second;
			int NB=Bd;
			if(!AC_color[x].count(Co))NB++;
			if(dist[xnext]>NB)
			{
				AC_color[xnext].clear();
				AC_color[xnext][Co]=1;
				dist[xnext]=NB;
				Q.push({-NB,xnext});
			}
			if(dist[xnext]==NB)AC_color[xnext][Co]=1;
		}
	}
}
int main()
{
	fill(dist+1,dist+MAXN+1,INF);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&u,&v,&w);
		G[u].push_back({v,w});
		G[v].push_back({u,w});
	}
	Dij(1);
	if(dist[n]!=INF)printf("%d",dist[n]);
	else printf("-1");
	//system("pause");
}


Measured memory_bytes: 45684
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    cin >> a >> b;
    if(a + b < 10){
        cout << a + b << endl;
    }else{
        cout << "error" << endl;
    }
}


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

namespace cplib {
    template <typename T>
    void warshall_floyd(std::vector<std::vector<T>> &dist) {
        int n = dist[0].size();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    dist[j][k] = std::min(dist[j][k], dist[j][i] + dist[i][k]);
                }
            }
        }
    }
}

int main() {
    int h, w;
    std::cin >> h >> w;

    int n = h * w;
    auto enc = [w](int i, int j){
        return i * w + j;
    };
    std::vector<char> s(n);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> s[enc(i, j)];
        }
    }

    const int inf = 1e9;
    std::vector<std::vector<int>> dist(n, std::vector<int>(n, inf));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int pos = enc(i, j);
            if (s[pos] == '.') {
                dist[pos][pos] = 0;
                int next1 = enc(i + 1, j), next2 = enc(i, j + 1);
                if (i + 1 < h and s[next1] == '.') {
                    dist[pos][next1] = 1;
                    dist[next1][pos] = 1;
                }
                if (j + 1 < w and s[next2] == '.') {
                    dist[pos][next2] = 1;
                    dist[next2][pos] = 1;
                }
            }
        }
    }

    cplib::warshall_floyd(dist);

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (dist[i][j] != inf) {
                ans = std::max(ans, dist[i][j]);
            }
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    string S;
    cin >> S;
    map<char,int>count;
    for(char x : S) count[x] = 1;
    bool flag = false;
    if(count['N'] and count['W'] and count['S'] and count['E']) flag = true;
    else if(count['N'] and count['S'] and !(count['W']) and !(count['E'])) flag = true;
    else if(count['W'] and count['E'] and !(count['N']) and !(count['S'])) flag = true;

    if(flag) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
inf = 10 ** 20
n,m = map(int,input().split())
c = [int(i) for i in input().split()]
dp = [inf for _ in range(n + 1)]
dp[0] = 0
for coin in c:
    for j in range(n + 1):
        if j - coin >= 0:
            dp[j] = min(dp[j], dp[j - coin] + 1)
print(dp[n])



Measured memory_bytes: 7640
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24;
}


Measured memory_bytes: 256
/*
  AOJ 0279
  Title:
  @kankichi573
*/
#include <stdio.h>

int N;
int k;
int f0,f1;

main()
{
        int i;


        while(EOF!=scanf("%d",&N) && N)
        {
                f0=0;f1=0;
                for(i=0;i<N;i++)
                {
                        scanf("%d ",&k);
                        if(k==0)
                                f0++;
                        if(k==1)
                                f1++;
                }
                if(f0+f1==N)
                        printf("NA\n");
                else
                        printf("%d\n",N-f0+1);
        }
        return(0);
}

Measured memory_bytes: 616
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
vector<int>vec;
map<int,int>cnt;
int ses=0;
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        int x;
        cin>>x;
        cnt[x]++;
    }
    for(auto x:cnt)
    {
        if(x.si>=2)vec.pb(x.fi);
        if(x.si>=4)ses=max(ses,(x.fi*x.fi));
    }
    sort(vec.begin(),vec.end());
    if(vec.size()<2)
    {
        cout<<ses<<endl;
        return 0;
    }
    int a=vec.back();
    vec.pop_back();
    int b=vec.back();
    ses=max(ses,a*b);
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 9876
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin>>N;
	int a[N];
	for(int i=0; i<N; i++){
		cin>>a[i];
	}
	int cnt=0;
	for(int i=0; i<N; i++){
	cnt++;
	while(i+1<N&&a[i]==a[i+1]){i++;}
	if(i==N-1)break;
	if(a[i]<a[i+1]){
		while(i<N-1&&a[i]<=a[i+1]){
			i++;
		}
	}
	else{
		while(i<N-1&&a[i]>=a[i+1]){
			i++;
		}
	}
}
	cout<<cnt<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////

int main(){
	int N,X;
	int ans = 0;
	SCD2(N,X);
	
	int m[N];
	ARSCD(m,N);
	sort(m,m+N);
	
	REP(i,N){
		if (X >= m[i]){
			X = X - m[i];
			ans = ans + 1;
		}
	}
	
	ans = ans + (X / m[0]);
	
	PRINTD(ans);
	
}










Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

S = input()

if S.islower():
    print('a')
else:
    print('A')


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

int main() {
	long h, w;
	cin >> h >> w;

	long res = 0;

	res = (h * w + 1) / 2;
	if (min(h, w) == 1) {
		res = 1;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,k;cin>>n>>k;
    ll x[n],y[n];
    string c[n];
    rep(i,0,n-1){
        cin>>x[i]>>y[i]>>c[i];
        x[i]=x[i]%(2*k);
        y[i]=y[i]%(2*k);
    }
    ll desk[4*k+1][4*k+1];
    rep(i,0,4*k){
        rep(j,0,4*k){
            desk[i][j]=0;
        }
    }
    rep(i,0,n-1){
        if(c[i]=="B"){
            desk[x[i]+k+1][y[i]+k+1]++;
            desk[x[i]+2*k+1][y[i]+2*k+1]++;
            desk[x[i]+2*k+1][y[i]+k+1]--;
            desk[x[i]+k+1][y[i]+2*k+1]--;
            
            desk[x[i]+1][y[i]+1]++;
            desk[x[i]+k+1][y[i]+k+1]++;
            desk[x[i]+k+1][y[i]+1]--;
            desk[x[i]+1][y[i]+k+1]--;
        }else{
            desk[x[i]+k+1][y[i]+1]++;
            desk[x[i]+2*k+1][y[i]+k+1]++;
            desk[x[i]+k+1][y[i]+k+1]--;
            desk[x[i]+2*k+1][y[i]+1]--;
            
            desk[x[i]+1][y[i]+k+1]++;
            desk[x[i]+k+1][y[i]+2*k+1]++;
            desk[x[i]+1][y[i]+2*k+1]--;
            desk[x[i]+k+1][y[i]+k+1]--;
        }
    }
    
    
    rep(i,0,4*k){
        rep(j,1,4*k){
            desk[i][j]=desk[i][j-1]+desk[i][j];
        }
    }
    
    
    rep(j,0,4*k){
        rep(i,1,4*k){
            desk[i][j]=desk[i-1][j]+desk[i][j];
        }
    }
    
    ll a_d[2*k][2*k];
    ll ans=0;
    rep(i,0,2*k-1){
        rep(j,0,2*k-1){
            a_d[i][j]=0;
            for(ll ii=i;ii<=4*k;ii+=2*k){
                for(ll jj=j;jj<=4*k;jj+=2*k){
                    a_d[i][j]+=desk[ii][jj];
                }
            }
            ans=max(ans,a_d[i][j]);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 164608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SequenceDecomposing solver = new SequenceDecomposing();
        solver.solve(1, in, out);
        out.close();
    }

    static class SequenceDecomposing {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(in.next());
            }

            List<Long> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                long aa = a[i];
//            int pos = Collections.binarySearch(list, aa, new LowerBoundComparator<>());
                int pos = arraySearch(list, aa);
                if (pos < 0) {
                    pos = ~pos;
                }
                if (pos == 0) {
                    list.add(0, aa);
                } else {
                    list.set(pos - 1, aa);
                }
            }
            out.println(list.size());

        }

        public int arraySearch(List<Long> list, long target) {
            int left = -1;
            int right = list.size();
            while (left + 1 < right) {
                int mid = (left + right) / 2;
                if (list.get(mid) < target) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            return left + 1;
        }

    }
}



Measured memory_bytes: 60924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5+5;

int n;
set<int> a[MAXN][2];
map<pii, int> m;
set<pii> s;

void rem(int u, int v, int x) {
    if (u > v)
        swap(u, v);
    m[pii(u, v)]--;
    if (m[pii(u, v)] < 2)
        s.erase(pii(u, v));
    a[u][x].erase(v);
    a[v][x].erase(u);
}

void add(int u, int v, int x) {
    if (u > v)
        swap(u, v);
    m[pii(u, v)]++;
    if (m[pii(u, v)] >= 2)
        s.insert(pii(u, v));
    a[u][x].insert(v);
    a[v][x].insert(u);
}

void merge(int u, int v) {
    rem(u, v, 0);
    rem(u, v, 1);

    if (a[u][0].size()+a[u][1].size() > a[v][0].size()+a[v][1].size())
        swap(u, v);
    set<int> s0 = a[u][0];
    set<int> s1 = a[u][1];

    for (int w : s0) {
        rem(u, w, 0);
        add(v, w, 0);
    }

    for (int w : s1) {
        rem(u, w, 1);
        add(v, w, 1);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n-1; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        add(u, v, 0);
    }

    for (int i = 0; i < n-1; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        add(u, v, 1);
    }

    for (int i = 0; i < n-1; ++i) {
        if (s.empty()) {
            cout << "NO\n";
            return 0;
        }

        pii t = (*s.begin());
        merge(t.first, t.second);
    }

    cout << "YES\n";
}

Measured memory_bytes: 43904
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};


int main() {
	int n;
	while (cin >> n, n) {
		vector<string> vs(n);
		vector<set<int>> alp(26);
		string ans = "yes";
		REP(i, n)
			cin >> vs[i];
		REP(i, n-1) {
			int si1=vs[i].length();
			int si2 = vs[i+1].length();
			REP (j,min(si1,si2)) {
				if (vs[i][j] == vs[i + 1][j])
					continue;
				if (alp[vs[i + 1][j] - 'a'].find(vs[i][j] - 'a') != alp[vs[i + 1][j] - 'a'].end()) {
					ans = "no";
					goto res;
				}
				alp[vs[i][j] - 'a'].insert(vs[i + 1][j]-'a');
				REP(k, 26) {
					if (alp[k].find(vs[i][j] - 'a') != alp[k].end()) {
						if (alp[vs[i + 1][j] - 'a'].find(k) != alp[vs[i + 1][j] - 'a'].end()) {
							ans = "no";
							goto res;
						}
						alp[k].insert(vs[i + 1][j] - 'a');
					}
				}
				break;
			}
			if (si1 > si2&&vs[i].substr(0, vs[i + 1].length()) == vs[i + 1]) {
				ans = "no";
				goto res;
			}
		}
	res:
		cout << ans << endl;
	}
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <fstream>
#include <iostream>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define maxim INT_MAX
#define fi first
#define se second
#define INF 1e16
#define mod 1000000007
/* 1. If you can't keep solution in mind, then visualize it on a paper.
 * 2. Try to identify the type of problem - DP, Greedy, Graph, Constructive,
 * 	  Prefix/Suffix, Difference Array, BIT/Segment Tree, etc.
 * 3. Look at the problems from different perspectives - reverse the problem,
 * 	  add instead of delete (maybe?)
 * 4. Divide difficult solutions into cases and/or sequences.
 * 5. Use math rules to solve Nested Summation.
 * 6. Optimisation problems are generally solved with DP, greedy, binary search or brute-force.
 * 7. Try fixing a solution then proving we can't do better or worse than that.
 * ------------------------------------------------------------------
 */
int main()
{
   ll n;
   cin>>n;
   double ar[n];
   double ans=1;
   for(ll i=0;i<n;i++)
   {
       cin>>ar[i];
   }
   vector<vector<double>> v(n+1, vector<double>(n+1));
   v[0][0]=1.000000000;
   for(ll i=1;i<=n;i++)
   {
       for(ll j=0;j<=n;j++)
       {
           if(j==0)
            v[i][j]=(1-ar[i-1])*v[i-1][j];
           else
            v[i][j]=(ar[i-1]*v[i-1][j-1])+(1-ar[i-1])*v[i-1][j];
       }
   }
   cout<<fixed<<setprecision(10)<<accumulate(v[n].begin()+(n/2)+1,v[n].end(),0.0);

}


Measured memory_bytes: 73804
#include <iostream>
using namespace std;
int a[11],c[11];
int q;
int main()
{
	int k;
	cin>>k;
	q--;
	for(int i1=0;i1<=9;i1++)
	{
		a[1]=i1;
		if(a[1]!=0)
			c[1]=1;
	for(int i2=max(0,i1-1);i2<=(c[1]==0?9:min(9,i1+1));i2++)
	{
		a[2]=i2;
		if(a[2]!=0)
			c[2]=1;
	for(int i3=max(0,i2-1);i3<=(c[2]==0?9:min(9,i2+1));i3++)
	{
		a[3]=i3;
		if(a[3]!=0)
			c[3]=1;
	for(int i4=max(0,i3-1);i4<=(c[3]==0?9:min(9,i3+1));i4++)
	{
		a[4]=i4;
		if(a[4]!=0)
			c[4]=1;
	for(int i5=max(0,i4-1);i5<=(c[4]==0?9:min(9,i4+1));i5++)
	{
		a[5]=i5;
		if(a[5]!=0)
			c[5]=1;
	for(int i6=max(0,i5-1);i6<=(c[5]==0?9:min(9,i5+1));i6++)
	{
		a[6]=i6;
		if(a[6]!=0)
			c[6]=1;
	for(int i7=max(0,i6-1);i7<=(c[6]==0?9:min(9,i6+1));i7++)
	{
		a[7]=i7;
		if(a[7]!=0)
			c[7]=1;
	for(int i8=max(0,i7-1);i8<=(c[7]==0?9:min(9,i7+1));i8++)
	{
		a[8]=i8;
		if(a[8]!=0)
			c[8]=1;
	for(int i9=max(0,i8-1);i9<=(c[8]==0?9:min(9,i8+1));i9++)
	{
		a[9]=i9;
		if(a[9]!=0)
			c[9]=1;
	for(int i10=max(0,i9-1);i10<=(c[9]==0?9:min(9,i9+1));i10++)
	{
		a[10]=i10;
		if(a[10]!=0)
			c[10]=1;
		q++;
		if(q==k)
		{
			for(int i=1;i<=10;i++)
				if(c[i]!=0)
					cout<<a[i];
			cout<<endl;
			return 0;
		}
	}
	}
	}
	}
	}
	}
	}
	}
	}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
long n,t;
long a[200000],b[200000];
long i;
scanf("%ld",&n);
for(i=0;i<n;i++){
scanf("%ld",&a[i]);
}
for(i=0;i<n;i++){
if(i%2==0) {
b[i/2]=a[n-1-i];
}else{
b[n-1-i/2]=a[n-1-i];
}
}
for(i=0;i<n;i++){
printf("%ld ",b[i]);
}
return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

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

  int num_queries;
  cin >> num_queries;


  priority_queue<int, vector<int>, less<int>> pq_less;
  priority_queue<int, vector<int>, greater<int>> pq_greater;

  int64 base = 0;
  int64 median = INT64_MIN;
  int64 absolute_sum = 0;
  for (int i = 0; i < num_queries; i++) {
    int command;
    cin >> command;
    if (command == 1) {
      int64 a, b;
      cin >> a >> b;

      base += b;

      if (pq_less.size() == 0 || a <= pq_less.top()) {
        pq_less.push(a);
        if (DEBUG) cout << "PUSH TO LESS" << endl;
      } else {
        pq_greater.push(a);
        if (DEBUG) cout << "PUSH TO GREATER" << endl;
      }
      // cout << "DEBUG 1" << endl;

      if (pq_less.size() >= pq_greater.size() + 2) {
        int64 x = pq_less.top();
        pq_less.pop();
        pq_greater.push(x);
        if (DEBUG) cout << "MOVE TO GREATER: " << x << endl;
      }
      if (pq_greater.size() >= pq_less.size() + 1) {
        int64 x = pq_greater.top();
        pq_greater.pop();
        pq_less.push(x);
        if (DEBUG) cout << "MOVE TO LESS: " << x << endl;
      }

      int64 new_median = pq_less.top();
      if (DEBUG) cout << "NEW MEDIAN" << new_median << endl;
      if (median != INT64_MIN) {
        absolute_sum += abs(a - median);
        if ((pq_less.size() + pq_greater.size()) % 2 == 1) {
          absolute_sum -= abs(median - new_median);
        }
      }
      median = new_median;
    } else {
      // Output
      cout << median << " " << absolute_sum + base << endl;
    }
  } 

}


Measured memory_bytes: 3452
tmp=input()
n=int(tmp)
l=len(tmp)
k=int(input())
if k==1:
    ans=9*(l-1)
    last=int(tmp[0])
    ans+=last
    print(ans)
    exit()
if k==2:
    c=l-2
    ans=(9**2)*((c*(c+1))//2)
    num=0
    for i in range(1,l):
        for head_i in range(9,0,-1):
            for tail_i in range(9,0,-1):
                cal=str(head_i)
                cal+="0"*len(tmp[1:i])
                cal+=str(tail_i)
                cal+="0"*len(tmp[i+1:])
                if int(cal)<=n:
                    num+=1
    
    ans+=num
    print(ans)
    exit()


c=0
for i in range(3,l):
    c+=(i-1)*(i-2)//2
ans=(9**3)*c
num=0
for i in range(1,l):
    for j in range(i+1,l):
        for f_i in range(1,10):
            if f_i<int(tmp[0]):
                num+=81
                continue
            for s_i in range(1,10):
                for t_i in range(1,10):
                    cal=f_i*(10**(l-1))+s_i*(10**(l-1-i))+t_i*(10**(l-1-j))
                    if cal<=n:
                        num+=1
ans+=num
print(ans)

Measured memory_bytes: 44084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int n;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    cin>> n;
    cout << n*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
using ll = long long;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    rep(i,b)cout<<a;
  }
  else rep(i,a){
    cout<<b;
  }
  

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, a, YJSNPI[10][100];
	char c;

	cin >> n;

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

		cin >> c >> a;
		if (c == 'S')
			YJSNPI[0][a] = a;
		else if (c == 'H')
			YJSNPI[1][a] = a;
		else if (c == 'C')
			YJSNPI[2][a] = a;
		else if (c == 'D')
			YJSNPI[3][a] = a;

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

		if (YJSNPI[0][i] != i)
			cout << 'S' << " " << i << endl;

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

		if (YJSNPI[1][i] != i)
			cout << 'H' << " " << i << endl;

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

		if (YJSNPI[2][i] != i)
			cout << 'C' << " " << i << endl;

		}
		for (int i = 1; i <= 13; i++)
		{
		if (YJSNPI[3][i] != i)
			cout << 'D' << " " << i << endl;
		}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>


auto print = [](auto x){ std::cout << x; };
auto println = [](auto x){ std::cout << x << std::endl; };
auto read = [](auto x){ std::cin >> x; return x;};

int main ()
{
  auto lowercase = [](std::string str){
                     for (auto &c : str)
                       c = std::tolower(c);
                     return str;
                   };


  std::string word;
  word = read(word);
  word = lowercase(word);

  std::string str;
  auto count = 0;
  str = read(str);
  while ((str != "END_OF_TEXT"))
    {
      str = lowercase(str);
      if (word == str)
        count ++;
      str = read(str);
    }
  println(count);
}



Measured memory_bytes: 3216
import math
from itertools import permutations

N = int(input())
p = [[int(_) for _ in input().split()] for _ in range(N)]

s = 0
cnt = 0
for a in permutations(p):
    for i in range(1, len(a)):
        s += math.sqrt((a[i-1][0]-a[i][0]) **2 + (a[i-1][1]-a[i][1]) **2)
    cnt +=1
print(s/cnt)

# for i in range(N-1):
#     for j in range(i+1,N):
#
#         cnt +=1
# print(s,cnt)
# print(s/cnt)






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

int main() {
    int n;
    cin >> n;
    vector<ll> x(n), l(n);
    vector<pair<ll, ll>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> l[i];
        p[i] = make_pair(x[i] + l[i], x[i] - l[i]);
    }
    sort(p.begin(), p.end());
    ll ans = 0, t = -1e18;
    for (int i = 0; i < n; i++) {
        if (t <= p[i].second) {
            ans++;
            t = p[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}

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


int main() {
    int N; cin>>N;
    map<string,int>mp;
    ll ans=0;
    rep(i,N){
        string S;
        cin>>S;
        sort(S.begin(),S.end());
        mp[S]++;
        ans+=mp[S]-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11264
import sys
input = sys.stdin.readline


def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


def solve(N, A, B):
    ans = 0
    for i in range(1, N+1):
        n = i
        d = 0
        while n > 0:
            d += n % 10
            n //= 10
        if A <= d <= B:
            ans += i
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9164
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  d,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  //l:array[0..6] of Integer = (1,2,4,8,16,32,64);
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(b);
    Read(c);
    Readln(d);

    sum:=(b+d-abs(b-d))div 2 - (a+c+abs(a-c))div 2;
    Writeln((sum+0+abs(sum-0))div 2);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  LL N,K;
  cin >> N >> K;
  if((N+1)/K>=2){
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N, K;
  string S;
  cin >> N >> S >> K;
  char target;
  target = S.at(K-1);
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == target) {
      cout << target;
    } else {
      cout << '*';
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;

int flag(int mask,int i){
   if(mask&(1<<i))return true;
   else return false;
}

int main(){
   int n; cin>>n;
   string s; cin>>s;
   int vec[n];

   REP(i,n){
      if(s[i]=='E')vec[i]=1;
      else vec[i]=0;
   }

   ll ans =n+1;
   // 累積和
   ll SUM[n+1];//Eを向いてるひとの数
   SUM[0]=0;

   REP(i,n){
   if(vec[i]==1)SUM[i+1]=SUM[i]+1;
   else SUM[i+1]=SUM[i];
   }
 
  REP(i,n){ //0,....n-1番目の人がリーダーのとき
    ll manzoku=SUM[i];
    manzoku+=n-i-1-(SUM[n]-SUM[i+1]);
    //i+１番目からn－１番目までの人（n-i-1）
    ll human=n-1-manzoku;
    if(human<ans)ans=human;
    
  }
  cout<<ans<<endl;
} 

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int INF = 1e9;
int main() {	
	ll N, C;
	cin >> N >> C;
	vector<ll>x(N + 2), v(N + 2);
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> v[i];
	}
	x[0] = 0;
	x[N + 1] = C;
	ll cal = 0;
	vector<vector<ll>>dp(2, vector<ll>(100010));
	for (int i = 1; i <= N; i++) {
		cal -= x[i] - x[i - 1];
		cal += v[i];
		dp[0][i] = max(dp[0][i - 1], cal);
	}
	cal = 0;
	for (int i = N; i >= 1; i--) {
		cal -= x[i + 1] - x[i];
		cal += v[i];
		dp[1][i] = max(dp[1][i + 1], cal);
	}
	ll maxcal = 0;
	for (int i = 0; i <= N; i++) {
		cal = dp[0][i] + dp[1][i + 1] - x[i];
		maxcal = max(maxcal, cal);
		cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
		maxcal = max(maxcal, cal);
	}
	cout << maxcal << endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int k; cin >> k;
	string s; cin >> s;

	
	if (k >= s.size()) {
		cout << s << endl;	
	}else {
		cout << s.substr(0,k) << "..." <<  endl;	
	}
	

	return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
using namespace std;

const int w=20003;

char s[10005];
int x,y,_x,len,p,sum,q,now=1;
bool ws[2][2][40009];

int main(){
    int i;
    scanf("%s%d%d",s+1,&x,&y);
	len=strlen(s+1);
	x+=w;
	y+=w;
    while(now<=len&&s[now]=='F'){
    	now++;
		_x++;
	}
    ws[0][0][w+_x]=1;
	ws[1][0][w]=1;
    while(now<=len){
        now++;
		sum=0;
		p^=1;
		q^=p;
        while(now<=len && s[now]=='F'){
        	sum++;
			now++;
		}
        for(int i=w-len;i<=w+len;++i)
            ws[p][q][i]=ws[p][q^1][i+sum]|ws[p][q^1][i-sum];
    }
    if((p==1 && ws[0][q^1][x] && ws[1][q][y]) || (p==0 && ws[0][q][x] && ws[1][q][y]))
		puts("Yes");
    else
		puts("No"); 
    return 0;
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Fri 03/07/2020
 * 22:13:35.27
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int d;
    cin >> d;
    if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 25) cout << "Christmas" << endl;
    return 0;
}


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

namespace TYC
{
	typedef long long ll;
	const int N = 605, mod = 1e9 + 7;

	int n, K, A[N], B[N], Mark[N], Cnt[N][N], G[N], F[N][N];

	inline bool check(const int l, const int r)
	{
		for (int i = 1; i <= K; i++)
			if ((l <= A[i] && A[i] <= r) != (l <= B[i] && B[i] <= r))
				return true;
		return false;
	}

	void work()
	{
		scanf("%d%d", &n, &K);
		n <<= 1;
		for (int i = 1; i <= K; i++)
		{
			scanf("%d%d", &A[i], &B[i]);
			if (A[i] > B[i])
				swap(A[i], B[i]);
			Mark[A[i]] = Mark[B[i]] = 1;
		}
		for (int l = 1; l <= n; l++)
			for (int r = l; r <= n; r++)
				for (int i = l; i <= r; i++)
					Cnt[l][r] += !Mark[i];
		G[0] = 1;
		for (int i = 2; i <= n; i += 2)
			G[i] = int((ll)(i - 1) * G[i - 2] % mod);
		int ans = 0;
		for (int l = 1; l <= n; l++)
			for (int r = l; r <= n; r++)
				if (!check(l, r))
				{
					F[l][r] = G[Cnt[l][r]];
					for (int p = l; p < r; p++)
						F[l][r] = int((F[l][r] - (ll)F[l][p] * G[Cnt[p + 1][r]] % mod + mod) % mod);
					ans = int((ans + (ll)F[l][r] * G[Cnt[1][n] - Cnt[l][r]] % mod) % mod);
				}
		printf("%d\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	vector<int> v;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		v.push_back(x);
	}
	int min=v[0];
	 int c=1;
	for(int i=1;i<v.size();i++)
	{
		if(v[i]<=min)
		{
			c++;
			min=v[i];
		}
	//	else{
	//		min=v[i];
	//	}
	}
	cout<<c;
}
		

Measured memory_bytes: 1400
def solve(N):
    if N%2==1:
        return 0
    N2=(N-N%10)//10
    count_zero=N2
    x=5
    while N2>=x:
        count_zero+=N2//x
        x*=5
    return count_zero
    
        
    

N=int(input())
print(solve(N))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> VI;
typedef long long ll;

int main() {
	ll x;
	cin >> x;
	ll sol = (x/11)*2;
	x %= 11;
	if (x > 6) sol += 2;
	else if (x > 0) sol += 1;
	cout << sol;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)
N = int(input())
d = [0]*N
G = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    d[a-1]+=1
    d[b-1]+=1
    G[a-1].append((i, b-1))
    G[b-1].append((i, a-1))
K = max(d)
ans = [0]*(N-1)
def dfs(v, p, c):
    if G[v] == [p]:
        return 
    nc = 1
    for i, nv in G[v]:
        if nv == p:
            continue
        if nc == c:
            nc+=1
        ans[i] = nc
        dfs(nv, v, nc)
        nc+=1
    return
dfs(0, -1, -1)
print(K)
print(*ans, sep = '\n')
        




Measured memory_bytes: 75192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int h[200],n,f;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];

    bool water = true;
    while(water){
        water=false;
        int sl = 0;
        for(int i=1;i<=n+1;i++){
            if(h[i]>0){
                h[i]--;
                sl++;
                water=true;
            }
            else{
                if(sl>0){
                    f++;
                    sl=0;
                }
            }
        }
    }
    cout<<f<<endl;
}


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

vector<vector<ll>> g;
vector<ll> depth;

bool flag = false;

void dfs(int pos, int dep){
	if(depth[pos] >= 0) {
		if(depth[pos] != dep) flag = true;
		return ;
	}
	depth[pos] = dep;
	for(auto x:g[pos]) dfs(x,dep^1);
}

int main(){
	ll n; cin >> n;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	vector<vector<ll>> dist(n, vector<ll>(n, MAX));
	g.resize(n);
	rep(i,n)rep(j,n){
		if(s[i][j] == '1'){
			g[i].push_back(j);
			dist[i][j] = 1;
		}
	}

	// 二部グラフ判定
	depth.resize(n, 0);
	rep(i,n) depth[i] = -1;
	dfs(0,0);
	if(flag) {
		puts("-1");
		return 0;
	}

	// warshall_floyd法
	rep(i,n) dist[i][i] = 0;
	rep(k,n)rep(i,n)rep(j,n) dist[i][j] = 
							min(dist[i][j],dist[i][k] + dist[k][j]);
	
	ll ans = 0;
	rep(i,n) ans =
max(ans, *max_element(dist[i].begin(),dist[i].end()));
	
	cout << ans + 1 << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<pair<string,int>>st(n);
	for (int i = 0; i < n; i++)cin >> st.at(i).first >> st.at(i).second;
	string x;
	cin >> x;
	bool sk = false;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (st.at(i).first == x)sk = true;
		else if (sk == true) ans += st.at(i).second;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

int main() {
	int N;
	cin >> N;
	map<int,int>mp;
	FOR(i,1, N+1) {
		int a;
		cin >> a;
		mp[i] = a;
	}
	int ans = 0;
	for (auto x : mp) {
		if (x.first == mp[x.second])ans++;
	}
	ans /= 2;
	cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int w = h / a + ((h % a == 0) ? 0: 1);
        System.out.println(w);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define fast  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long int
using namespace std;
const int N=1e5+1;
ll n, w, values[N], Weight[N];
ll dp[101][N];
ll calc(int i, ll W){
    if(W>w)return -1e17;
    if(i==n){
        if(W>w){
            return -1e17;
        }
        return 0;
    }
    if(dp[i][W]!=-1)return dp[i][W];
 	dp[i][W]=-1e17;
  	dp[i][W]=max(calc(i+1,W),dp[i][W]);
    dp[i][W]=max(calc(i+1, W+Weight[i])+values[i],dp[i][W]);
    return dp[i][W]=max(calc(i+1,W),calc(i+1, W+Weight[i])+values[i]);
}
int main()
{
    fast;
    cin>>n;cin>>w;
    for(int i=0;i<n;i++){
        cin>>Weight[i]>>values[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<calc(0,0);
    return 0;
}


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

int main(){
  int A, B, C, P, Ans;
  cin >> A >> B >> C;
  
  P = A - B;
  if(P < C){
    Ans = C - P;
    cout << Ans << endl;
  }else{
    cout << "0" << endl;
  }
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

template<typename T>
T extgcd(T a, T b, T &x, T &y){
  T d = a;
  if(b != 0){
    d = extgcd(b, a%b, y, x);
    y -=(a/b) * x;
  }else{
    x = 1;
    y = 0;
  }
  return d;
}

template<typename T>
T mod_inverse(T a, T mod){
  T x, y;
  extgcd(a, mod, x, y);
  return (mod + x%mod)%mod;
}

template<typename T>
pair<T, T> linear_congruence(const vector<T> &A,
                            const vector<T> &B,
                            const vector<T> &M){
  T x = 0, m = 1;
  for(int i=0;i<(int)A.size();i++){
    T a = A[i] * m, b = B[i] - A[i]*x, d = __gcd(M[i], a);
    if(b%d!=0) return make_pair(0, -1);
    T t=b/d*mod_inverse(a/d, M[i]/d)%(M[i]/d);
    x = x + m * t;
    m *= M[i]/d;
  }
  return make_pair((x%m + m)%m, m);
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  vector<int> ps(n),qs(n);
  for(int i=0;i<n;i++) cin>>ps[i],ps[i]--;
  for(int i=0;i<n;i++) cin>>qs[i],qs[i]--;

  using ll = __int128_t;
  vector<ll> A,B,M;

  vector<int> used(n,0);
  for(int i=0;i<n;i++){
    if(used[i]) continue;
    int pos=i;
    vector<int> vs,ws;
    while(!used[pos]){
      vs.emplace_back(pos);
      ws.emplace_back(ps[pos]);
      used[pos]=1;
      pos=qs[pos];
    }
    {
      auto as=vs,bs=ws;
      sort(as.begin(),as.end());
      sort(bs.begin(),bs.end());
      if(as!=bs) drop(-1);
    }
    int m=vs.size();
    for(int j=0;j<m;j++)
      ws.emplace_back(int(ws[j]));

    const int DEBUG = 0;
    if(DEBUG){
      for(int j=0;j<m;j++) cout<<vs[j]<<" ";
      cout<<endl;
      for(int j=0;j<m;j++) cout<<ws[j]<<" ";
      cout<<endl;
    }

    for(int j=0;j<m;j++){
      if(ws[j]!=vs[0]) continue;
      for(int k=0;k<m;k++)
        if(ws[j+k]!=vs[k]) drop(-1);

      //cout<<1<<" "<<j<<" "<<m<<endl;
      A.emplace_back(1);
      B.emplace_back(j);
      M.emplace_back(m);
    }
  }

  auto res=linear_congruence(A,B,M);
  if(res.second<0) drop(-1);
  cout<<(long long)(res.first)<<endl;
  return 0;
}



Measured memory_bytes: 3224
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = readLine >>= main'
    where
        main' [n, m] = readContents n >>= print . solve m

solve :: Int -> [[Int]] -> Int
solve m = count m 0 . sortBy cmpf 
    where
        cmpf = comparing head
        
        count 0 acc _ = acc
        count n acc ([a, b] : xs)
            | n < b = acc + n * a
            | otherwise = count (n - b) (acc + a * b) xs

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 54652