akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
struct edge{
  int to,cap,rev;
};
vector<edge> G[1005];
bool used[1005];
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}
int max_flow(int s,int t){
  int flow=0;
  while(1){
    for(int i=0;i<1005;i++) used[i]=false;
    int f=dfs(s,t,12345678);
    if(f==0) return flow;
    flow+=f;
  }
}
int main(){
  int v,e;
  cin>>v>>e;
  for(int i=0;i<e;i++){
    int a,b,c;
    cin>>a>>b>>c;
    add_edge(a,b,c);
  }
  cout<<max_flow(0,v-1)<<endl;
}



Measured memory_bytes: 3212
import sys

def I(): return(int(sys.stdin.readline()))
def S(): return(list(sys.stdin.readline())[:-1])

def main():
    s = S()
    K = I()
    N = len(s)

    for i in range(N):
        if K==0:
            break
        if s[i] != "a" and ord("z")-ord(s[i])<K:
            K -= ord("z")-ord(s[i])+1
            s[i] = "a"
    
    if K>0:
        K %= 26

    s[N-1] = chr(ord(s[N-1])+K)
    return("".join(s))

if __name__ == "__main__":
    print(main())


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100007;
int n, u, v;
vector<int> graph[N];

int ans, d[N];

void dfs(int cur, int par, int dist) {
    d[cur] = dist;
    for(int child : graph[cur]) {
        if(child != par) {
            dfs(child, cur, dist+1);
        }
    }
}

void dfs2(int cur, int par, int dist) {
    if(d[cur] < dist) {
        ans = max(ans, dist);
    }
    for(int child : graph[cur]) {
        if(child != par) {
            dfs2(child, cur, dist+1);
        }
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> u >> v;
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(u, 0, 0);

    dfs2(v, 0, 0);

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


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string s; int k; cin >> s >> k;
    vector<string> vec;
    rep(i, s.size())
    {
        Rep(j, 1, k + 1)
        {
            string tmp = s.substr(i, j);
            vec.push_back(tmp);
        }
    }
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec[k - 1] << endl;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(a, b);
    Int(c);
    if (a <= c && c <= b) 
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
import sys

I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6

def getroot(A, id):
    if A[id][P] > -1:
        return getroot(A,A[id][P])
    return A[id][I]

def preorder(N,id,A):
    if id < 0:
        return
    A.append(id)
    preorder(N,N[id][L],A)
    preorder(N,N[id][R],A)

def inorder(N,id,A):
    if id < 0:
        return
    inorder(N,N[id][L],A)
    A.append(id)
    inorder(N,N[id][R],A)

def postorder(N,id,A):
    if id < 0:
        return
    postorder(N,N[id][L],A)
    postorder(N,N[id][R],A)
    A.append(id)


def main():

    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    nlist = list(istr.splitlines())
    
    nodes = [[i, -1, -1, -1, -1, 0, 0] for i in range(num)]

    for nstr in nlist:
        i = list(map(int,nstr.split()))
        n = nodes[i[I]]
        n[I] = i[I]
        if i[L] > -1:
            n[L] = i[L]
            nodes[n[L]][P] = i[I]
            nodes[n[L]][B] = i[R]
        if i[R] > -1:
            n[R] = i[R]
            nodes[n[R]][P] = i[I]
            nodes[n[R]][B] = i[L]
#        print("set n:{} {} {}".format(n[I],n,i))

    r = getroot(nodes, 0)
#    setd(nodes,r, 0)

    pre = [""]
    ino = [""]
    pos = [""]

    preorder(nodes,r,pre)
    inorder(nodes,r,ino)
    postorder(nodes,r,pos)

    print("Preorder")
    print(" ".join(map(str,pre)))
    print("Inorder")
    print(" ".join(map(str,ino)))
    print("Postorder")
    print(" ".join(map(str,pos)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 7876
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		long k = saori.saorihayami();
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("1")){
				if(i+1 == k){
					System.out.println(1);
					return;
				}
			} else {
				System.out.println(s[i]);
				return;
			}
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32596
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, 0, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    REP(i, 0 ,n-1){
        if(a.at(i) == a.at(i+1)){
            p("NO");
            return 0;
        }
    }
    p("YES");
}

Measured memory_bytes: 1024
def main():
  s=input()
  l=len(s)
  mod = 10**9+7
  dp=[[0]*13 for _ in range(l+1)]
  dp[0][0]=1 #初期値設定
  for i in range(l):
    if s[i]!="?":
      for k in range(13):
        dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
    else:
      for j in range(10):
        for k in range(13):
          dp[i+1][(k*10+j)%13]+=dp[i][k]%mod

  print(dp[-1][5]%mod)

if __name__ == "__main__":
    main()


Measured memory_bytes: 61916
#include <stdio.h>

int main(void){
	int i, x, y, tmp;

	for(i=0; i<10000; i++){
		scanf("%d%d", &x, &y);
		if(x == 0 && y == 0)
			break;
		else if(x>y){
			tmp = x;
			x = y;
			y = tmp;
			printf("%d %d\n", x, y);
		}else
			printf("%d %d\n", x, y);
	}	

	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h+2, vector<char>(w+2,'#'));

  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      cin >> grid[i][j];
    }
  }

  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
}

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

struct job {
	string name;
	long time;
};

int main() {
	int n, q;
	cin >> n >> q;
	queue<job>l;
	for (int i = 0; i < n; i++){
		job j;
		cin >> j.name >> j.time;
		l.push(j);
	}
	int time = 0;
	while (l.size()){
		job j = l.front();
		l.pop();
		if (j.time <= q) {
			time += j.time;
			cout << j.name << ' ' << time << endl;
		}
		else{
			time += q;
			j.time -= q;
			l.push(j);
		}
	}
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9

struct LCA{//lowest common ancestor
	int MAX_LOG_V = 50;
	vector<vector<int> > g;
	vector<vector<int> > parent;
	int root = 0,V;
	vector<int> depth;
	LCA(){}
	LCA(int V):V(V){init();}
	void init(){
		for(int i=0;i<g.size();i++)g[i].clear();
		g.clear();
		for(int i=0;i<parent.size();i++)parent[i].clear();
		parent.clear();
		depth.clear();
		g.resize(V);
		parent.resize(MAX_LOG_V,vector<int>(V) );
		depth.resize(V);
	}
	void dfs(int v,int p,int d){
		parent[0][v] = p;
		depth[v] = d;
		for(int i=0;i<g[v].size();i++)if(g[v][i] != p) dfs(g[v][i],v,d+1);
	}
	void construct(){
		dfs(root,-1,0);
		for(int k=0;k+1<MAX_LOG_V;k++)
		    for(int i=0;i<V;i++)
			if(parent[k][i]<0) parent[k+1][i] = -1;
			else parent[k+1][i] = parent[k][parent[k][i]];
	}
	int lca(int u,int v){
		if(depth[u] > depth[v]) swap(u,v);
		for(int k=0;k<MAX_LOG_V;k++)
		    if( (depth[v]-depth[u]) >> k&1)
			v = parent[k][v];
		if(u==v) return u;
		for(int k=MAX_LOG_V-1;k>=0;k--)
		    if(parent[k][u] != parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		    }
		return parent[0][u];
	}
	void add_edge(int u,int v){ 
	    g[u].push_back(v);
	    g[v].push_back(u);
	}
};

int main(){
	int n;
	cin>>n;
	LCA t(n);
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int c;
			cin>>c;
			t.add_edge(i,c);
		}
	}
	t.construct();
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int u,v;
		cin>>u>>v;
		cout<<t.lca(u,v)<<endl;
	}
	return 0;
}



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

    int main() {
        
        long long n;
        cin >> n;
        
        long long ct=0,st=0,at=0,rt=0;
        
       while(n--){
             string s;
            cin>> s;
        
            if(s=="AC")
                ct++;
                
           else if(s=="WA")
                st++;
            
           else if(s=="TLE")
                at++;
           else if(s=="RE")
                rt++;
                
        
        }
        
        
   cout<<"AC x "<<ct<<endl;
     cout<<"WA x "<<st<<endl;
       cout<<"TLE x "<<at<<endl;
         cout<<"RE x "<<rt<<endl;
 
        
       return 0; 
        
        }

Measured memory_bytes: 3632
#include <stdio.h>
#define MAX 250

int q(int);
int l(int);
int r(int);

int main(void) {

	int i, n, h[MAX];
	scanf("%d", &n);

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

	for (i = 1; i <= n; i++) {

		printf("node %d: key = %d, ", i, h[i]);

		if (q(i) != 0) {
			printf("parent key = %d, ", h[q(i)]);
		}

		if (l(i) != 0 && l(i) <= n) {
			printf("left key = %d, ", h[l(i)]);
			if (r(i) != 0 && r(i) <= n) {
				printf("right key = %d, ", h[r(i)]);
			}
		}

		printf("\n");
	}
	return 0;
}

int q(int a) {
	return a / 2;
}

int l(int a) {
	return 2 * a;
}

int r(int a) {
	return 2 * a + 1;
}


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

bool f(int k) {
	int len = 0;
	while (k) {
		len++;
		k /= 10;
	}
	return len%2 == 1;
}

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

	int ans = 0;
	for (int k = 1; k <= n; k++) {
		ans += f(k);
	}

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



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),res=n*2;
		String s=sc.next(),t=sc.next();
		
		for(int i=0;i<n;i++) {
			if(s.substring(i, n).equals(t.substring(0, n-i))) {
				res-=n-i;
				break;
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21972
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define inv (mod+1)/3
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;while(t--)
ll zero=0;
ll one=1;
ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return(a.second<=b.second);}

//https://www.youtube.com/watch?v=k4V3Mo61fJM

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    ll x,y;cin>>x>>y;y/=2;
    cout<<x+y;
    return 0;
}


Measured memory_bytes: 256
s = input().split()

w = int(s[0])
h = int(s[1])
n = int(s[2])

max_x = w
max_y = h
min_x = 0
min_y = 0

x = []
y = []
a = []

for num in range(n):
    v = input().split()
    x.append(int(v[0]))
    y.append(int(v[1]))
    a.append(int(v[2]))

for num in range(n):
    if a[num] == 1:
        if x[num] > min_x:
            min_x = x[num]
    elif a[num] == 2:
        if x[num] < max_x:
            max_x = x[num]
    elif a[num] == 3:
        if y[num] > min_y:
            min_y = y[num]
    else:
        if y[num] < max_y:
            max_y = y[num]

y_length = max_y - min_y
if y_length < 0:
    y_length = 0
x_length = max_x - min_x
if x_length < 0:
    x_length = 0
answer = x_length * y_length

print(answer)
        




Measured memory_bytes: 9256
#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

char s[1000000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> s;
	size_t N = strlen(s);
	uint64_t count = 0;
	for (size_t i = 0; i < N; i++)
	{
		count += N-1;
		if (s[i] == 'U') {
			count += i;
		}
		else {
			count += (N-1-i);
		}
	}
	std::cout << count << std::endl;

	return 0;
}
#endif


#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int64_t N,MIN,MAX;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>MIN>>MAX;
	if (N == 1 &&(MIN<MAX)) { std::cout << 0 << std::endl; return 0; }
	if (MAX<MIN) { std::cout << 0 << std::endl; return 0; }
	--N;
	std::cout << ((MAX*N + MIN) - (MIN*N + MAX) + 1) << std::endl;

	return 0;
}
#endif


Measured memory_bytes: 888
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut m = HashMap::new();
    for _ in 0..N {
        let S: String = sc.get();
        *m.entry(S).or_insert(0) += 1;
    }
    for c in &["AC", "WA", "TLE", "RE"] {
        if let Some(t) = m.get(&c.to_string()) {
            println!("{} x {}", c, t);
        } else {
            println!("{} x {}", c, 0);
        }
    }
}


Measured memory_bytes: 2188
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, H: int, M: int):
    angle = abs(H / 12 + (M / 60)/ 12 - M / 60) * 2 * math.pi
    print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle)))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(A, B, H, M)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n, m, x; cin >> n >> m >> x;
  vector<bool> a(n+1,false);
  REP(i, m){
    ll b;
    cin >> b;
    a[b] = true;
  }
  ll l = 0;
  ll r = 0;
  REP(i, x){
    if(a[i]) l++;
  }
  FOR(i, x, n+1){
    if(a[i]) r++;
  }

  cout << min(l, r) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.00000000001)
#define side 1e9
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[200005];
void power()
{
    powe[0]=1;
    REP(i,1,200005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
struct node
{
	vll adj;
    ll dist;
   // ll max_depth;
    ll cwgd;
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll A[n];
    REP(i,0,n)
    {
        cin>>A[i];
    }
    ll dp[n][n];         //dp[i][j] :  answer for best play starting with player 1 if the array was only from ith index to jth index i<=j
    REP(i,0,n)
    {
        dp[i][i] = A[i];
    } 
    for(ll i=n-2;i>=0;i--)
    {
        REP(j,i+1,n)
        {
            dp[i][j] = max(A[j] - dp[i][j-1], A[i] - dp[i+1][j]);
        }
    }
    cout<<dp[0][n-1]<<"\n";
    return 0;
}






Measured memory_bytes: 70528
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>

using namespace std;

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

    if(n <= 999) printf("ABC");
    else printf("ABD");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	int N, sum = 0, num = 0, dig;
	cin >> N;
	num = N;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	cout << ((N%sum == 0) ? "Yes" : "No");

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m=15;
	string s;
	cin>>s;
	n=s.size();
	for(int i=0;i<n;i++)
	if(s[i]=='x')
	m--;
	if(m>=8)
	cout<<"YES";
	else
	cout<<"NO";
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define INF 1e18
#define int long long

struct sp {
    int idx, p;
    string s;
    bool operator<(const sp& another) const {
        if(s != another.s) return s < another.s;
        return p > another.p;
    }
};

signed main() {
    int n; cin >> n;
    vector<sp> vec(n); for(int i = 0; i < n; i++) {
        vec[i].idx = i + 1;
        cin >> vec[i].s >> vec[i].p;
    }

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

    for(int i = 0; i < n; i++) {
        cout << vec[i].idx << endl;
    }

    return 0;
}


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

int main(){
  signed long long int A, B,C ,D;
  cin >> A >> B >> C >> D;
  
  //最小公倍数を求める
  auto c = C; auto d = D;
  if(c < d) {swap(c,d);}
  auto r =c % d;
  while( r != 0){
    c = d;
    d = r;
    r = c % d;
  }
  signed long long int CD =  C * D / d;
  //cout << CD << endl;
    
  //Cで割り切れる
  signed long long int dC = (signed long long int)(B / C ) - (signed long long int)((A-1)/ C);
  //Dでわりきれる
  signed long long int dD = (signed long long int)(B / D) - (signed long long int)((A-1)/ D);
  //CとDで割り切れる
  signed long long int dCD = (signed long long int)(B / CD ) - (signed long long int)((A-1)/ CD);
  //cout << dC<<" " << dD<<" " << dCD << endl;

  signed long long int ans = ( B - A + 1 ) - dC - dD + dCD;
  
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 256
INF=10000

def prim():
    mincost=[INF]*n
    used=[False]*n
    mincost[0]=0
    res=0
    while True:
        v=-1
        for u in range(n):
            if  not used[u] and (v==-1 or mincost[u]<mincost[v]):
                v=u
        if v==-1:
            break
        used[v]=True
        res+=mincost[v]
        for u in range(n):
            mincost[u]=min(mincost[u],cost[v][u])
    return res

while True:
    n,m=map(int,raw_input().split())
    if n==m==0:break
    cost=[[INF]*n for i in range(n)]
    for i in range(m):
        a,b,d=map(int,raw_input().split())
        cost[a][b]=d
        cost[b][a]=d
    print prim()

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x;
  string s;
  rep(i,x){
    std::cin >> s;
    if(s=="AC")y++;
    else if(s=="WA")z++;
    else if(s=="TLE")w++;
    else n++;
  }
  std::cout << "AC x "<<y << '\n';
  std::cout << "WA x " <<z<< '\n';
  std::cout << "TLE x " <<w<< '\n';
  std::cout << "RE x " <<n<< '\n';
}


Measured memory_bytes: 3560
#include <cstdio>
#include <algorithm>
#include <cstring>
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)

#define maxn 110
int w[maxn], v[maxn], f[maxn * 10][maxn];
int main()
{
	int n, W, w1; scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d%d", &w[i], &v[i]);
		i == 1 ? w1 = w[1] : 0;
		w[i] -= w1;
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i, W -= w1)
	{
		if (W < 0) break;
		memset(f, -63, sizeof (f));
		f[0][0] = 0;
		for (int j = 1; j <= n; ++j)
			for (int jj = i; jj; --jj)
				for (int k = 0; k <= 3 * i; ++k)
					cmax(f[k + w[j]][jj], f[k][jj - 1] + v[j]);
		for (int k = 0; k <= W && k <= 3 * i; ++k)
		{
			cmax(ans, f[k][i]);
//			printf("%d %d\n", i, f[k][i]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

signed main(){
  
  string s;
  cin>>s;
  
  for(int i=0;i<=2;i++){
    if( s[i] == s[i+1] ){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  
  cout<<"Good"<<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> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

struct TmpDist{
    ll vertex;
    ll dist;
    TmpDist(ll vertex, ll dist): vertex(vertex), dist(dist) {}
    bool operator< (const TmpDist& right)const{
        return dist > right.dist;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;

vector<ll> dijkstra(Graph &G, ll r){
    ll V = G.size();
    vector<ll> dist(V, INFLL);
    priority_queue<TmpDist> pq;
    vector<bool> check(V, false);
    TmpDist init(r, 0);
    pq.push(init);
    while(!pq.empty()){
        TmpDist td = pq.top();pq.pop();
        ll now = td.vertex;
        if(!check[now]){
            check[now] = true;
            dist[now] = td.dist;
            for (int i=0;i<G[now].size();i++){
                if(dist[G[now][i].dst] > td.dist + G[now][i].weight){
                    TmpDist tdCandidate(G[now][i].dst, td.dist + G[now][i].weight);
                    pq.push(tdCandidate);
                }
            }
        }
    }
    return dist;
}

int main(){
    ll V, E, r;
    cin >> V >> E >> r;
    Graph G(V);
    ll s, t, w;
    for(int i=0;i<E;i++){
        cin >> s >> t >> w;
        Edge e(t, w);
        G[s].push_back(e);
    }

    vector<ll> dist = dijkstra(G, r);
    for (int i=0;i<V;i++){
        if(dist[i] == INFLL) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 21584
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N=1e5+5;
int a[N];
void work()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	int mx1=0,mx2=0;
	for(int i=1;i<=n;i++){
		if(a[i]==a[i+1]){
			if(a[i]>mx1)mx2=mx1,mx1=a[i];
			else if(a[i]>mx2)mx2=a[i];
			i++;
		}
	}
	long long ans=(long long)mx1*mx2;
	printf("%lld\n",ans);
}

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


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin>>str;
	int size = str.size();
	vector<int> hist(26,0);
	for(int i=0;i<size;++i){
		hist[ str[i]-'a']++;
	}
	if( size<26 ){
		cout << str;
		for(int i=0;i<26;++i){
			if( hist[i] == 0 ){
				cout << (char)('a'+i);
				break;
			}
		}
		cout << endl;
	}else{//26文字
		string org = str;
		if( next_permutation(str.begin(),str.end()) ){
			for(int i=0;i<size;++i){
				cout << str[i];
				if( str[i] > org[i] ){
					break;
				}
			}
			cout << endl;
		}else{
			cout << -1 << endl;
		}
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N){
        cin >> X.at(i);
    }
    int ans = 1e+9;
    rep2(i, 1, 101){
        int a = 0;
        rep(j, N){
            a += pow((i - X.at(j)), 2);
        }
        if(a < ans){
            ans = a;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var (
		n int
		a []int
	)
	fmt.Scan(&n)

	a = make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}


	for _, v := range a {
		if v % 2 == 0 && v % 3 != 0 && v % 5 != 0 {
			fmt.Println("DENIED")
			os.Exit(0)
		}
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n),y(n),h(n);
    rep0(i, n)cin >> x[i] >> y[i] >> h[i];
    rep0(i, 101){
        rep0(j, 101){
            ll H;
            rep0(k, n){
                if(h[k] != 0){
                    H = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    break;
                }
            }
            bool f = true;
            rep0(k, n){
                if(max((H - abs(i - x[k]) - abs(j - y[k])),(ll)0) != h[k]){
                    f = false;
                    break;
                }
            }
            if(f){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<long long> H(N+1, 0);
    vector<int> A(M, 0);
    vector<int> B(M, 0);
    vector<int> s(N+1, 1);
    for(int i=1; i<=N; i++){
        cin >> H[i];
    }
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
    }

    int cnt = N;

    for(int i=0; i<M; i++){
        if(H[A[i]] > H[B[i]]){
            if(s[B[i]] != 0){
                cnt = cnt -1;
            }
            s[B[i]] = 0;
        }
        else if(H[A[i]] < H[B[i]]){
            if(s[A[i]] != 0){
                cnt = cnt -1;
            }
            s[A[i]] = 0;
        }
        else if(H[A[i]] == H[B[i]]){
            if(s[A[i]] != 0){
                cnt = cnt -1;
            }
            if(s[B[i]] != 0){
                cnt = cnt -1;
            }
            s[A[i]] = 0;
            s[B[i]] = 0;
        }
        else{
            /* nothing */
        }
    }

    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 4664
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

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

	}
}

*/

ll c(ll n) {
	ll ans = 0;
	for (ll i = 2; i <= n; i++) {
		if (n / i == n % i) { ans += i; }
	}
	return ans;
}


ll f(ll n) {
	ll ans = 0;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ll high = n / i;
			ll low = 0;
			ll left;

			while (high - low > 1) {
				left = (high + low) / 2;

				//cout << n / left << " " << n % left << endl;

				if (n / left == n % left) { ans += left; break; }

				if (n / left > n % i) {
					low = left;
				}
				else {
					high = left;
				}
			}
		}
	}
	return ans;
}

int main(void) {
	ll n; cin >> n;


	cout << f(n) << endl;
	




}

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

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long mod = n % 1000;
            Console.WriteLine(mod != 0 ? (1000-mod) : 0);
        }
    }
}

Measured memory_bytes: 27152
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int n,w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
    rep(i,n){
        ll f,g;
        cin >> f >> g;
        rep(j,w+1)  dp.at(i+1).at(j)=dp.at(i).at(j);
        rep(j,w){
            if (j+f>w) break;
            dp.at(i+1).at(j+f)=max(dp.at(i+1).at(j+f),dp.at(i).at(j)+g);
        }
    }
    ll ans=0;
    rep(i,w+1) ans=max(ans,dp.at(n).at(i));
    cout << ans << endl;
}


Measured memory_bytes: 80256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
function main()
  l,r,d=parse.(Int,split(readline()))
  ans=0
  for i=l:r
    if i%d==0; ans+=1;end
  end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 173304
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

def move(i,string):
  lis = []
  for e in string:
    if e == "." :
      lis.append(".")
    elif e == "\n":
      lis.append("\n")
    else:
      if ord(e)+i > 122:
        lis.append( chr(ord(e)+i-26) )
      else:
        lis.append( chr(ord(e)+i ) )
  st = "".join(lis)
  if st in ["the","that","this"]:
    return True
  else:
    return False

def move2(i,string):
  lis = []
  for e in string:
    if e == "." :
      lis.append(".")
    elif e == "\n":
      lis.append("")
    elif e == " ":
      lis.append(" ")
    else:
      if ord(e)+i > 122:
        lis.append( chr(ord(e)+i-26) )
      else:
        lis.append( chr(ord(e)+i ) )
  st = "".join(lis)
  return st

for s in sys.stdin:
  flag = False
  i = 0
  d = map(str , s.split())
  for i in range(26):
    for e in d:
      if move(i,e):
        flag = True
        break
    if flag:
      break
  print move2(i,s)

Measured memory_bytes: 4272
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long sum = (long) Math.pow(3, N);
		long odd = 1;

		for(int i=0;i<N;i++) {
			int a = sc.nextInt();

			if(a % 2 == 0) {
				odd *= 2;
			}
		}

		System.out.println(sum - odd);
	}

}


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

int main(){
  int n[10];

  for(int i=0; i<10; i++) {
    cin >> n[i];
  }
  sort(n, n+10);

  for(int j=0; j<3; j++) {
    cout << n[9-j] << "\n";
  }
  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>

using namespace std;

using ll = long long;
vector<string> split(string src, string del = "")
{
	vector<string> result;

	if (del == "")
	{
		for (char s : src)
		{
			result.push_back(string{s});
		}
		return result;
	}

	int start = 0;
	int last = src.find_first_of(del);

	while (start < src.length())
	{
		string sub(src, start, last - start);

		result.push_back(sub);

		start = last + 1;
		last = src.find_first_of(del, start);
		if (last == string::npos)
		{
			last = src.size();
		}
	}

	return result;
}

string join(vector<string> els, string con = "")
{
	string result = "";

	for (auto itr = els.begin(); itr != els.end(); itr++)
	{
		result += *itr;
		if (itr + 1 != els.end())
		{
			result += con;
		}
	}

	return result;
}

int main()
{
	string input;
	cin >> input;

	cout << (join(split(input, ","), " ")) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


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

  long long int a, b, a1, b1, x;

  cin >> a >> b >> x;

  b1 = b/x;
  a1 = a/x;

  if(a != 0 && a%x != 0) cout << b1-a1 << endl;
  if(a != 0 && a%x == 0) cout << b1-a1+1 << endl;
  if(a == 0) cout << b1+1 << endl;

  return 0;
}


Measured memory_bytes: 256
// author:-*mdragneell*

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=3001;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll cache[N][N][2];
ll n,m,a[N];

ll sol(ll i,ll j,ll player)
{
		if(i>j) return 0;
		if(cache[i][j][player]!=-1)
			return cache[i][j][player];

		if(player==0)
			return cache[i][j][player]=max(a[i]+sol(i+1,j,player^1),a[j]+sol(i,j-1,player^1));
		else
			return cache[i][j][player]=min(-a[i]+sol(i+1,j,player^1),-a[j]+sol(i,j-1,player^1));

}

int main()
{
		ll i,j;
		cin>>n;

		memset(cache,-1,sizeof(cache));

		for(i=0;i<n;i++)
				cin>>a[i];
		cout<<sol(0,n-1,0)<<endl;

}


Measured memory_bytes: 141184
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll f(ll n, ll x) { return (n >= 0) ? n / x + 1 : 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll a, b, x; cin >> a >> b >> x;
    cout << f(b, x) - f(a-1, x) << endl;
    return 0;
}

Measured memory_bytes: 256
def binary_search(arr, num):
  left = 0
  right = len(arr)-1
  while right-left > 0:
    mid = (left+right) // 2
    if arr[mid] > num:
      right = mid
    else:
      left = mid + 1
  if arr[left] > num:
    return left
  else:
    return len(arr)

def main():
  n, m, k = map(int , input().split())
  a_books = list(map(int , input().split()))
  b_books = list(map(int , input().split()))
  b_cum_sum = [0] * (m+1)
  for i in range(m):
    b_cum_sum[i+1] = b_cum_sum[i] + b_books[i]
  current = 0
  ans = 0
  for i in range(n+1):
    if i > 0:
      current += a_books[i-1]
    if current > k:
      break
    rest = k - current
    index = binary_search(b_cum_sum, rest)
    ans = max(ans, i+index-1)
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 40504