akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector <int> botton(N);
  for(int i; i<N; i++){
    cin >> botton.at(i);
  }
  int count;
  int now = botton.at(0);
  for(int i; i<N; i++){
    count++;
    if(now == 2){
      cout << count << endl;
      break;
    }
    if(count == N){
      cout << -1 << endl;
    }
    now = botton.at(now-1);
  }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> a(3 * n);
	rep(i, 3 * n) cin >> a[i];

	sort(all(a));
	reverse(all(a));
	ll ans = 0;
	rep(i, 2 * n)
	{
		if (i & 1)
			ans += a[i];
	}

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


Measured memory_bytes: 4556
_, a, b, c, d = gets.split.map(&:to_i)
s = gets.chomp
if c < d
  if s[b - 1..c].match(/#\.\./) && !s[a..d].match(/##/)
    puts 'Yes'
  else
    puts 'No'
  end
else
  if (s[b - 2..d].match(/\.\.\./) || s[b - 2..d].match(/\.\.\.$/)) && !s[a..c].match(/##/)
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 2428
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a; cin >> a;
	if (a == 3 || a == 5 || a == 7)cout << "YES";
	else cout << "NO";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, r;
    cin >> n >> r;
    cout << (n >= 10 ? r : r + 100 * (10 - n)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,m;
vvi g;

int main(){
	cin>>n>>m;
	g=vvi(n,vi(n));
	int S=1<<n;
	vi dp(S);
	vvi DP(S,vi(n,-1));
	DP[1][0]=0;
	for(int i=0;i<m;i++){
		int u,v,c;
		cin>>u>>v>>c;
		u--;v--;
		g[u][v]=c;g[v][u]=c;
	}
	for(int i=1;i<S;i++) for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) if(i&1<<j&&i&1<<k) dp[i]+=g[j][k];
	for(int i=1;i<S;i++) for(int j=0;j<n;j++) if(DP[i][j]!=-1){
		for(int k=0;k<n;k++) if(!(i&1<<k)&&g[j][k]) DP[i+(1<<k)][k]=max(DP[i+(1<<k)][k],DP[i][j]+g[j][k]);
		int T=S-i-1,T_=T;
		while(T){
			DP[i+T][j]=max(DP[i+T][j],DP[i][j]+dp[T+(1<<j)]);
			T=(T-1)&T_;
		}
	}
	cout<<dp[S-1]-DP[S-1][n-1]<<endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
int m=n,s=0;
while(m)
{
	s+=m%10;
	m/=10;
}
if(n%s==0)ol("Yes");
else ol("No");
return 0;
}



Measured memory_bytes: 256
m,f,r = [],[],[]

while True:
    a,b,c=map(int,input().split())
    if (a==-1) & (b==-1) & (c==-1):
        break
    m.append(a)
    f.append(b)
    r.append(c)

for i in range(len(m)):
    judge = m[i]+f[i]
    if (m[i]<0) or (f[i]<0):
        print('F')
        continue
            
    if (judge >= 80):
        print('A')
    
    elif (judge < 80) & (judge >= 65):
        print('B')
    
    elif (judge < 65) & (judge >= 50):
        print('C')
    
    elif (judge < 50) & (judge >= 30):
        if r[i] >= 50:
            print('C')
        else:
            print('D')
        
    elif judge < 30:
        print('F')


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define int LL
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<endl
#define size(x) ((int)x.size())
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;

void solve() {
  int N; cin>>N;
  vec<int> A(N); times(N, i) cin >> A[i];

  int k = 0;
  times(N, i) k = A[i] - k;
  k /= 2;
  times(N, i) {
    cout << (i ? " " : "") << k * 2;
    k = A[i] - k;
  }
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(6);
  solve();
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<math.h>
#include <iomanip>
#include <cstdio>
using namespace std;
int main(void){
  double a;
  cin>>a;
  cout<< fixed << setprecision(6)<<a*a*M_PI<<" "<<2*a*M_PI<<endl;
  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
constexpr long long  MOD=1000000007;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
// bool visi[300004];
// vector<ll>v[300004];
// ll a[300004],b[300004],c[300004],d[300004];



void solution()
{
    ll q,n,m,i,j,k;
    cin>>n;
    ll a[n+1];
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]%2 && i%2)ans++;
    }
    cout<<ans;
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}

Measured memory_bytes: 3640
#include<iostream>
#include<set>
#include<cstring>
using namespace std;
int b[200010];
int main() {
	int n, a;
	while(cin>> n) {
		memset(b, 0, sizeof(b));
		n--;
		for(int i=0; i<n; i++) {
			cin >> a;
			b[a]++;
		}
		for(int i = 1; i <= n+1; i++)
			cout << b[i]<< endl;
	}
	return 0;
}

Measured memory_bytes: 4384
import sys
from bisect import bisect_left
input=sys.stdin.readline
a,b,q=map(int,input().split())
S=[int(input()) for _ in range(a)]
T=[int(input()) for _ in range(b)]
X=[int(input()) for _ in range(q)]
INF=float('inf')
S=[-INF]+S+[INF]
T=[-INF]+T+[INF]
for x in X:
    s_e_idx=bisect_left(S,x)
    s_e,s_w=S[s_e_idx],S[s_e_idx-1]
    t_e_idx=bisect_left(T,x)
    t_e,t_w=T[t_e_idx],T[t_e_idx - 1]
    d=INF
    for s in [s_w,s_e]:
        for t in [t_w,t_e]:
            d_st=abs(s-x)+abs(t-s)
            d_ts=abs(t-x)+abs(s-t)
            d=min(d,d_st,d_ts)
    print(d)

Measured memory_bytes: 16776
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std; 
#define L 14
#define M 1456527
int v[1000];
vector<int> w(1244); int c; int ans[1000];
int main()
{
     int n,q; cin >> n;
     for (int i = 0; i < n; i++)
         cin >> v[i];
     cin >> q;
     for (int i = 0; i < q; i++)
     {
         int b, e; cin >> b >> e;
         reverse(v + b, v + e);
     }
    for (int i = 0; i < n; i++)cout << (i ? " " : "") << v[i];
    cout << endl;
}


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

int x, y;

int main() {
	cin >> x >> y;
	if(x == 0) {
		if(y >= 0) cout << y << endl;
		else cout << -y+1 << endl;
		return 0;
	}
	if(y == 0) {
		if(x > 0) cout << x+1 << endl;
		else cout << -x << endl;
		return 0;
	}
	if((x > 0)^(y > 0)) {
		if(-y > x) cout << -y-x+1 << endl;
		else cout << y+x+1 << endl;
	}
	else {
		if(x <= y) cout << y-x << endl;
		else cout << x-y+2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _001_FindingMissingCards
{


    class Program
    {
        static Boolean greaterThanLator(string a, string b)
        {
            return Convert.ToInt32(a.Substring(1, 1)) < Convert.ToInt32(b.Substring(1, 1)) ? true : false;
        }
        
        static void Main()
        {
            var n = Convert.ToInt32(Console.ReadLine());
            var aSelection = Console.ReadLine().Split(' ');
            var aBubble = Array.ConvertAll(aSelection, i => i);

            for (int i = 0; i < n ; i++)
            {
                for (int j = n - 1; j > i; j--)
                {
                    if (Program.greaterThanLator(aBubble[j], aBubble[j - 1]))
                    {
                        var tmp = aBubble[j];
                        aBubble[j] = aBubble[j - 1];
                        aBubble[j - 1] = tmp;
                    }
                }
            }

            var minj = 0;
            for (int i = 0; i < n; i++)
            {
                minj = i;
                for (int j = i; j < n; j++)
                {
                    if (Program.greaterThanLator(aSelection[j] , aSelection[minj])) minj = j;
                }
                if (i != minj)
                {
                    var tmp = aSelection[i];
                    aSelection[i] = aSelection[minj];
                    aSelection[minj] = tmp;
                }


            }

            for (int i = 0; i < n - 1; i++)
            {
                Console.Write("{0} ", aBubble[i]);
            }
            Console.WriteLine("{0}", aBubble[n - 1]);

            Console.WriteLine("Stable");

            Boolean stability = true;



            for (int i = 0; i < n - 1; i++)
            {
                if (aBubble[i].Equals(aSelection[i]) == false) stability = false;
                Console.Write("{0} ", aSelection[i]);
            }
            if (aBubble[n - 1].Equals(aSelection[n - 1]) == false) stability = false;
            Console.WriteLine("{0}", aSelection[n - 1]);

            Console.WriteLine(stability ? "Stable" : "Not stable");
        }
    }
}

Measured memory_bytes: 9096
#include<stdio.h>
#include<stdlib.h>

int main(){
  int a, b;
  char str[3];
  gets(str);
  for(int i=0; i<3; i++){
  	if(str[i] == 'A') a++;
    else if(str[i] == 'B') b++;
  }
  if(a == 1 || b == 1)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
using namespace std;
#define MAX_V 500
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to, cap, cost, rev;};
 
int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
 
void add_edge(int from, int to, int cap, int cost)
{
  G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
  G[to].push_back((edge){from, 0, -cost, (int)G[from].size()-1});
}
 
int min_cost_flow(int s, int t, int f)
{
  int res = 0;
  fill(h, h+V, 0);
  while(f > 0)
  {
    priority_queue<P,vector<P>,greater<P>> que;
    fill(dist, dist+V, 1<<28);
    dist[s] = 0;
    que.push(P(0,s));
    while(!que.empty())
    {
      P p = que.top();
      que.pop();
      int v = p.second;
      if(dist[v] < p.first) continue;
      for(int i = 0; i < G[v].size(); i++)
      {
        edge &e=G[v][i];
        if(e.cap > 0 && dist[e.to] > dist[v]+e.cost+h[v]-h[e.to])
        {
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          que.push(P(dist[e.to], e.to));
        }
      }
    }
    if(dist[t] == (1 << 28))
    {
      return -1;
    }
    for(int v = 0; v < V; v++) h[v] += dist[v];
 
    int d = f;
    for(int v = t; v != s; v = prevv[v])
    {
      d = min(d,G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d*h[t];
    for(int v = t; v != s; v = prevv[v])
    {
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}
 
int main()
{
  int e,f,u,v,c,d,i;
  cin >> V;//Vは頂点数（500以下）
  cin >> e >> f;
  for(i = 0; i < e; i++)
  {
    cin >> u >> v >> c >> d;
    add_edge(u,v,c,d);//辺の追加（開始、終了頂点と容量、コスト）
  }
  cout << min_cost_flow(0, V-1, f) << endl;//最小費用流(開始、終了頂点と流量)
  return 0;
}


Measured memory_bytes: 3244
// D - Xor Sum 4
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007
 
ll O[60];
 
int main(){
	int N; cin>>N;
	rp(i,0,N){ ll a; scanf("%lld",&a); for(int j=0; j<60 && a>>j; ++j) O[j]+=a>>j&1; }
	ll ans = 0;
	rp(i, 0, 60) ans = (ans + (O[i]*(N-O[i]) % MOD) * ((1LL<<i) % MOD)) % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
#import numpy as np



def main():

    N,W = map(int,input().split())

    dp = [0] * (W+2)

    for _ in range(N):
        w,v = map(int,input().split())

        for j in range(W+1,w-1,-1):
            dp[j] =max(dp[j-w] +v ,dp[j])

    print(dp[W])
#    print(dp)




if __name__ == "__main__":
    main()

Measured memory_bytes: 65844
#include <stdio.h>
#include <stdlib.h>

#define N 10000

int n;

int Partition(unsigned short* ,int ,int);

int main(){

  unsigned short *A;

  int k=0;
  int i,center;

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++)
    scanf("%hu",&A[i+1]);

  center = Partition(A,1,n);

  for(i=1;i<=n;i++){
    if(i != center)
      printf("%d",A[i]);
    else printf("[%d]",A[i]);
    if(i<n) printf(" ");
  }

  printf("\n");

  return 0;

}

int Partition(unsigned short *A, int p, int r){

  int x,i,j,tmp;
  
  x = A[r];
  i = p-1;

  for(j = p;j<=r-1;j++){
    if(A[j] <= x){
      i = i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

    tmp = A[i+1];
    A[i+1] =  A[r];
    A[r] = tmp;

    return i+1;
}

Measured memory_bytes: 804
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    ll n; cin >> n;
    vector<ll> five;
    five.push_back(5);
    while (five.back() * 5 <= 1e18) {
        five.push_back(five.back() * 5);
    }
    if (n%2 == 0) {
        ll cnt = 0;
        for (ll x : five) {
            cnt += n / (x * 2);
        }
        cout << cnt << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n >= 400 && n < 600) cout << 8 << endl;
    if(n >= 600 && n < 800) cout << 7 << endl;
    if(n >= 800 && n < 1000) cout << 6 << endl;
    if(n >= 1000 && n < 1200) cout << 5 << endl;
    if(n >= 1200 && n < 1400) cout << 4 << endl;
    if(n >= 1400 && n < 1600) cout << 3 << endl;
    if(n >= 1600 && n < 1800) cout << 2 << endl;
    if(n >= 1800 && n < 2000) cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3632
N, A = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]

XX = sum(X) + 1

dp = [[[0 for i in range(XX * 2)] for i in range(N + 3)] for i in range(N + 3)]

dp[0][0][0] = 1

for i in range(N):
    for j in range(N + 1):
        for n in range(XX):
            dp[i + 1][j][n] += dp[i][j][n]
            dp[i + 1][j + 1][n + X[i]] += dp[i][j][n]

ans = 0
for i in range(1,N + 1):
    if i * A < XX:
        ans += dp[N][i][i * A]

print(ans)


Measured memory_bytes: 153608
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;
    S.erase(S.size()-1);

    int ans = 0;
    for (int i = S.size(); i > 0; i--) {
        S.erase(i);
        if (S.size() % 2 == 0) {
            std::string str1, str2;
            str1 = S.substr(0, S.size()/2);
            str2 = S.substr(S.size()/2, S.size()/2);
            if (str1 == str2) {
                ans = S.size();
                break;
            }
        }
        if(S.empty()) {
            break;
        }
    }

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

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        var dic1 = new Dictionary<long, int>(); //hi+ni
        var dic2 = new Dictionary<long, int>(); //hi-ni

        for (int i = 0; i < n; i++) {
            var ni = i + 1;
            var hi = aa[i];

            var d1 = hi + ni;
            if (!dic1.ContainsKey(d1)) dic1[d1] = 0;
            dic1[d1]++;

            var d2 = hi - ni;
            if (!dic2.ContainsKey(d2)) dic2[d2] = 0;
            dic2[d2]++;
        }

        long sum = 0;

        for (int i = 0; i < n; i++) {
            var ni = i + 1;
            var hi = aa[i];

            var d1 = ni - hi;
            if (dic1.ContainsKey(d1)) {
                sum += dic1[d1];
            }

            var d2 = -ni - hi;
            if (dic2.ContainsKey(d2)) {
                sum += dic2[d2];
            }
        }

        return sum/2;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 64164
# -*- coding: utf-8 -*-

n = int(input())

a = list(map(int, input().split()))
ans = 0
tmp = 0
while tmp == 0:
    for i in range(n):
        a[i] = a[i]//2
        if a[i] % 2 == 1:
            tmp += 1
    if tmp >= 1 and ans == 0:
        break
    ans += 1

print(ans)


Measured memory_bytes: 3188
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

/*
    Special functions:
        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

int main(){
    quicken();

    int n; cin >> n;
    int arr[n], brr[n];
    repeat(n) cin >> arr[i];
    repeat(n)
        brr[arr[i]-1] = i+1;

    repeat(n) cout << brr[i] << ' ';
    return 0;
}


Measured memory_bytes: 1664
#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, d, x;
    cin >> n >> d >> x;
    int a;
    int ans = x;
    rep(i,n) {
        cin >> a;
        ans += (d + a - 1)/a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

N,M = LI()
cake = [LI() for _ in range(N)]

ans = 0
for b in range(8):
    b0 = b % 2
    b1 = (b//2) % 2
    b2 = (b//4) % 2
    c = [(x[0]*(b0*2-1) + x[1]*(b1*2-1) + x[2]*(b2*2-1),x) for x in cake]
    c.sort(reverse=True)
    tmp = [0,0,0]
    for i in range(M):
        for j in range(3):
            tmp[j] += c[i][1][j]

    ans = max(ans,abs(tmp[0])+abs(tmp[1])+abs(tmp[2]))

print (ans)



Measured memory_bytes: 45036
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int):
    x = 0
    while H > 0:
        H -= 2 ** x
        x += 1

    ans = 0
    while x >= 0:
        ans = 2*ans + 1
        x -= 1

    print(ans//2)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 29;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

ll f(ll a, ll b, ll c) {
  ll d = b / gcd(b, c) * c;

  return a - a / b - a / c + a / d;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << f(B, C, D) - f(A - 1, C, D) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define LIMIT 1003
using namespace std;
int main()
{
	int h, w;
	int num[LIMIT][LIMIT];
	char tmp[LIMIT];
	int i, j, ans = 0;
	int Bcount = 0,Bh,Bw;

	cin >> h >> w;
	for (i = 1; i <= h; i++) {
		cin >> tmp;
		for (j = 1; j <= w; j++) {
			if (tmp[j-1] == '.') {
				num[i][j] = 1000000;
			}
			else {
				num[i][j] = 0;
				Bcount++;
				Bh = i - 1;
				Bw = j - 1;
			}
		}
	}

	if (Bcount == 1) {
		int a, b, c, d;
		a = Bh + Bw;
		b = Bh + (w - Bw - 1);
		c = (h - Bh - 1) + Bw;
		d = (h - Bh - 1) + (w - Bw - 1);
		a = max(a, b);
		c = max(c, d);
		ans = max(a, c);
		cout << ans << endl;
		return 0;
	}

	while (1) {
		bool check = true;
		for (i = 1; i <= h; i++) {
			for (j = 1; j <= w; j++) {
				if (num[i][j] == ans) {
					num[i - 1][j] = min(num[i-1][j],ans + 1);
					num[i][j - 1] = min(num[i][j-1], ans + 1);
					num[i + 1][j] = min(num[i + 1][j], ans + 1);
					num[i][j + 1] = min(num[i][j+1], ans + 1);
					check = false;
				}
			}
		}
		if(check==true){
			cout << ans-1 << endl;
			return 0;
		}
		else {
			ans++;
		}
	}

	
	return 0;
}


Measured memory_bytes: 4224
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

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

void solve(const int x, const int y, const int type, vector<vector<int>>&field) {
	field[y][x] = type;
	for (int i = 0; i < 4; ++i) {
		if (field[y + dy[i]][x + dx[i]] == -1) {
			solve(x + dx[i], y + dy[i], type, field);
		}
	}
}

int main() {
	while (1) {
		bool ok = true;
		vector<vector<int>>field(14, vector<int>(14));
		for (int i = 0; i < 12; ++i) {
			string st;
			if (cin >> st) {
				for (int j = 0; j < 12; ++j) {
					int num = (st[j] == '1');
					if (num)num = -1;
					field[i + 1][j + 1] = num;
				}
			}
			else {
				ok = false;
				break;
			}
			
		}
		if (!ok)break;
		int type = 1;
		for (int x = 1; x <= 12; ++x) {
			for (int y = 1; y <= 12; ++y) {
				if (field[y][x] == -1) {
					solve(x, y, type, field);
					type++;
				}
			}
		}
		cout << type - 1 << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3144
import itertools

N = int(input())
L = list(map(int, input().split()))

count = 0
triangle_list = itertools.combinations(L, 3)
for triangle in triangle_list:
    if len(set(triangle)) != 3:
        continue
    a, b, c = sorted(triangle)
    if a + b > c:
        count += 1

print(count)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n)){
        int a[(int)1e5+10]={},M=-1;
        for(int i=0;i<n;i++){
        	int t;scanf("%d",&t);
			a[t]++;M=max(M,t);
        }
        int ans=0;
        for(int i=0;i<=M;i++)
            ans=max(ans,a[i]+a[i+1]+a[i+2]);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int a; cin >> a;
        mp[a]++;
    }
    mint x = 2;
    if (n&1) {
        bool ok = true;
        if (mp[0] != 1) ok = false;
        for (int i = n-1; i > 0; i -= 2) {
            if (mp[i] != 2) ok = false;
        }
        if (ok) cout << x.pow(n/2) << endl;
        else cout << 0 << endl;
    } else {
        bool ok = true;
        for (int i = n-1; i >= 1; i -= 2) {
            if (mp[i] != 2) ok = false;
        }
        if (ok) cout << x.pow(n/2) << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 4096
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

int main(void)
{
    ll N,M;
    cin >> N >> M;
    
    vector<pair<ll,ll>> AB(N);

    rep(i,N){
        cin >> AB[i].first >> AB[i].second;
    }


    sort(AB.begin(),AB.end());

    //rep(i,N){
    //    cout << AB[i].first << "," << AB[i].second << endl;
    //}

    ll m = 0;
    ll now = 0;
    ll ret = 0;
    while(m < M){
        if (AB[now].second <= M-m){
            ret += (AB[now].first*AB[now].second);
            m += AB[now].second;
            //cout << now << "," << ret << "," << m << endl;
            now++;
        } else {
            ret += (AB[now].first*(M-m));
            m = M;
            //cout << now << "," << ret << "," << m << endl;
        }
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 1792
/*input
3 3 4
3 3
3 1
1 1
1 2
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll h, w, m;
	cin >> h >> w >> m;
	vector<pair<ll, ll> > row(h), col(w);
	map<pair<ll, ll>, ll> has;
	for(ll i = 1; i <= h; i++) {
		row[i - 1].second = i;
	}
	for(ll i = 1; i <= w; i++) {
		col[i - 1].second = i;
	}
	for(ll i = 0; i < m; i++) {
		ll x, y; cin >> x >> y;
		row[x - 1].first++;
		col[y - 1].first++;
		has[{x, y}] = true;
	}
	sort(row.begin(), row.end(), greater<pair<ll, ll> >());
	sort(col.begin(), col.end(), greater<pair<ll, ll> >());
	ll ans = 0, done = false;
	for(ll i = 0; i < row.size(); i++) {
		if(row[i].first != row[0].first) break;
		for(ll j = 0; j < col.size(); j++) {
			if(col[j].first != col[0].first) {
				break;
			}
			done |= (!has[{row[i].second, col[j].second}]);
			ans = max(ans, row[i].first + col[j].first - 1 + (!has[{row[i].second, col[j].second}]));
			if(done) {
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}




















Measured memory_bytes: 31444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
using namespace __gnu_pbds;
 
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long
#define ull unsigned long long
 
 
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
 
const int  M    =  1000000007;
const int  maxn =  1001   ;
const long long   inf  =  1e18     ;
const long double eps = 1.084202e-19;
 
 
 
void solve(){
    string s ; 
    cin >> s ; 
    if(s[2]==s[3] and s[4]==s[5]){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
}
 
int32_t main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int te;
      te = 1;
      while(te--){
          solve();
          cout<<"\n";
      }
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool visd[5][5];
int a[5][5],b;
int main()
{
	scanf("%d%d%d%d%d%d%d%d%d",&a[1][1],&a[1][2],&a[1][3],&a[2][1],&a[2][2],&a[2][3],&a[3][1],&a[3][2],&a[3][3]);
	cin>>b;
	while(cin>>b)for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)if(a[i][j]==b)visd[i][j]=1;
	if(visd[1][1]&&visd[1][2]&&visd[1][3])puts("Yes");
	else if(visd[2][1]&&visd[2][2]&&visd[2][3])puts("Yes");
	else if(visd[3][1]&&visd[3][2]&&visd[3][3])puts("Yes");
	else if(visd[1][1]&&visd[2][1]&&visd[3][1])puts("Yes");
	else if(visd[1][2]&&visd[2][2]&&visd[3][2])puts("Yes");
	else if(visd[1][3]&&visd[2][3]&&visd[3][3])puts("Yes");
	else if(visd[1][1]&&visd[2][2]&&visd[3][3])puts("Yes");
	else if(visd[1][3]&&visd[2][2]&&visd[3][1])puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
object Main extends App{

  override def main(args : Array[String]) : Unit = {
    Iterator.continually(new Data(io.StdIn.readLine))
      .takeWhile(_.continue).map(_.solve).foreach(println(_))
      
  }
  
  class Data(word : String){
    val continue = word != "-"
    
    val num = if(continue) io.StdIn.readLine.toInt else 0
    val sum = (0 until num).map(_ => io.StdIn.readLine.toInt).reduceOption((z,n)=>z+n)
    
    def solve : String = {
      val len = word.length()
      val index = sum.get % len
      word.substring(index) + word.substring(0,index)     
    }
  }
}

Measured memory_bytes: 43852
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << (a * b) / 2 << endl;
}


Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

A = LI()

a_index = {}
for i in range(N):
    a_index[A[i]] = i+1

sa = sorted(A)

result = []
for v in sa:
    result.append(a_index[v])

print(" ".join(map(str,result)))

Measured memory_bytes: 34404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Mmax = 5000;
const ll INF = 1e9;
int N, M, P, A[Mmax], B[Mmax], C[Mmax];
vector<vector<int>> graph, rgraph;

void dfs(int v, vector<vector<int>> &graph, vector<bool> &reachable){
	for(int u: graph[v]){
		if(reachable[u]) continue;
		reachable[u] = true;
		dfs(u, graph, reachable);
	}
}

int main(){
	cin >> N >> M >> P;
	graph.resize(N);
	rgraph.resize(N);
	for(int i=0; i<M; i++){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		A[i] = a;
		B[i] = b;
		C[i] = c;
		graph[a].push_back(b);
		rgraph[b].push_back(a);
	}

	vector<bool> r0(N), rN(N);
	r0[0] = true;
	rN[N-1] = true;
	dfs(0, graph, r0);
	dfs(N-1, rgraph, rN);

	vector<ll> d(N, INF);
	d[0] = 0;
	bool update = false;
	for(int i=0; i<=N; i++){
		update = false;
		for(int j=0; j<M; j++){
			if(r0[A[j]]&&r0[B[j]]&&rN[A[j]]&&rN[B[j]]&&d[A[j]]+P-C[j]<d[B[j]]){
				d[B[j]] = d[A[j]]+P-C[j];
				update = true;
			}
		}
		if(!update) break;
	}

	if(update){
		cout << -1 << endl;
	} else {
		cout << max(0ll, -d[N-1]) << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int r,c,i=0,j=0;
    int Table[200][200]={};
    scanf("%d %d",&r,&c);
    while(scanf("%d",&Table[i][j])==1){
        j++;
        if(j==c) {
            i++;
            j=0;
        }
        if(i==r) break;
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d ",Table[i][j]);
            Table[i][c]+=Table[i][j];
        }
        printf("%d\n",Table[i][c]);
    }
     for(j=0;j<=c;j++){
        for(i=0;i<r;i++){
            Table[r][j]+=Table[i][j];
        }
        if(j==0){
        printf("%d",Table[r][j]);
        }
        else{
        printf(" %d",Table[r][j]);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n, a;
    cin >> n;
    long long sum = 0;
    for (int i=0; i<n; ++i) {
        cin >> a;
        sum += a;
    }
    cout << sum / n << endl;
    return 0;
}

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

const long long MOD = (long long)1e9 + 7;

int S[2010];
int T[2010];
long long dp[2010][2010];

int main() {
  int N, M;
  std::cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    std::cin >> S[i];
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> T[i];
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      dp[i][j] = 0;
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      if (i > 0) dp[i][j] += dp[i - 1][j];
      if (j > 0) dp[i][j] += dp[i][j - 1];
      if (i > 0 && j > 0) dp[i][j] += MOD - dp[i - 1][j - 1];
      dp[i][j] %= MOD;
      if(S[i] == T[j]){
	dp[i][j] += ((i > 0 && j > 0) ? dp[i - 1][j - 1] : 0) + 1;
	dp[i][j] %= MOD;
      }
    }
  }
  std::cout << dp[N - 1][M - 1] + 1 << std::endl;
  return 0;
}


Measured memory_bytes: 31616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N,A,B;
vector<ll> monsters;
bool check(vector<ll> H, ll val){
  ll cnt1 = 0;
  for (int i = 0; i < H.size(); i++){
    H[i] -= val * B;
  }

  ll diff = A - B;
  for (int i = 0; i < H.size(); i++){
    if (H[i] > 0){
      cnt1 += (H[i] + (diff - 1)) / diff;
      if (cnt1 > val){
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin >> N >> A >> B;
  monsters.resize(N);
  for (auto &val : monsters){
    cin >> val;
  }
  sort(monsters.rbegin(), monsters.rend());
  ll left,right;
  left = 0;
  right = 1LL << 30;
  while (right - left > 1){
    ll med = (right + left) / 2;
    if (check(monsters, med)){
      right = med;
    }else{
      left = med;
    }
  }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end(), greater<int>());
  int count =1;
  for(int i=1;i<N;i++){
    if(A[i] < A[i-1])count++;
  }
  cout << count << endl;
}

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

using namespace std;

int main(int argc, char** argv) {
    int a, b;
    cin >> a >> b;
    int ans = b;
    if (a < 6) ans = 0;
    else if(a < 13) ans /= 2;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max({a*c, a*d, b*c, b*d});
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
 
int a[100010],n;
 
inline int rd()
{
    int x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
inline bool cmp(int x,int y) { return x>y; }
 
int main()
{
    n=rd();
    for (int i=1;i<=n;i++) a[i]=rd();
    sort(a+1,a+n+1,cmp);
    int hh=1;
    while (a[hh+1]>=hh+1) hh++;
    bool ans=1;
    for (int i=hh+1;a[i]==hh;i++) ans^=1;
    ans&=(a[hh]-hh+1)&1;
    puts(ans?"Second":"First");
    return 0;
}

Measured memory_bytes: 768