akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var c = new int[3,3];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    c[i, j] = cin.nextInt();
                }
            }

            if (c[0,0] + c[1,1] + c[2,2] == c[0,1] + c[1,2] + c[2,0] && c[0,1] + c[1,2] + c[2,0] == c[0,2] + c[1,0] + c[2,1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

string N;
ll dp[1000005][2];
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    cin >> N;

    dp[0][1] = 1;
    REP(i, (int)N.size()) {
        int now = (int)(N[i] - '0');
        dp[i + 1][0] = min(dp[i][0] + now, dp[i][1] + (10 - now));
        dp[i + 1][1] = min(dp[i][0] + now + 1, dp[i][1] + (10 - 1 - now));
    }

    cout << dp[N.size()][0] << endl;

    return 0;
}


Measured memory_bytes: 17028
import sys
S=sys.stdin.readlines()
N,A,B=map(int,S[0].split())
H=[int(S[i+1]) for i in range(N)]
L,R=0,10**9
M=0
Z=0
A-=B
while R>L:
  M=(L+R)//2
  Z=0
  for i in range(N):
    Z+=max((H[i]-B*M+A-1)//A,0)
  if Z>M:
    L=max(L+1,M)
  else:
    R=M
print(R)

Measured memory_bytes: 57948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1LL<<60;
const int INF = 1LL<<17;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll bit[500500];
ll n;
#define N 500010
// ll sum(ll i){
//     ll res=0;
//     while(0<i){
//         res += bit[i];
//         i -= i&-i;
//     }
//     return res;
// }
// void add(ll i, ll x){
//     while(i<=n){
//         bit[i] += x;
//         i += i&-i;
//     }
// }

void add(int i,int x){
    for(;i<N;i+=i&-i)bit[i]+=x;
}
int sum(int i){
    int res=0;
    for(;i>0;i-=i&-i)res+=bit[i];
    return res;
}
ll rsum(ll l, ll r){
    return sum(r)-sum(l-1);
}
vector<vector<ll>> qr(N), qri(N);
vector<ll> a(N), c(N), res(N);
int main(){
    ll q;   cin >> n >> q;


    rep(i, n) cin >> c[i+1];
    
    rep(i, q){
        ll a, b;    cin >> a >> b;
        qr[b].push_back(a);
        qri[b].push_back(i);
    }

    FOR(i, 1, n+1){
        if(a[c[i]]>0) add(a[c[i]], -1);
        add(i, 1);
        a[c[i]] = i;
        rep(j, qr[i].size()){
            res[qri[i][j]] = rsum(qr[i][j], i);
        }
    }
    rep(i, q) cout << res[i] << endl;
}


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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  string S;
  int N;
  
  cin >> S;
  if(S=="RSS" || S=="SRS" || S=="SSR" || S=="RSR"){
    N=1;
  }else if(S=="RRS" || S=="SRR"){
    N=2;
  }else if(S=="RRR"){
    N=3;
  }else{
    N=0;
  }
  
  cout << N;
  
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const int INF = 1<<28;
int n,m,s,g1,g2;
void warshall_floyd(vector<vector<int> > &cost){
  for(int i = 0;i < n;i++){
	for(int j = 0;j < n;j++){  
	  for(int k = 0;k < n;k++){	  
		cost[j][k] = min(cost[j][k],cost[j][i] + cost[i][k]);
	  }
	}
  }
}
int main(){
  while(cin >> n >> m >> s >> g1 >> g2 &&n){
	vector<vector<int> > cost = vector<vector<int> >(n,vector<int>(n,INF));
	for(int i =0;i < n;i++)cost[i][i] = 0;
	for(int i = 0;i < m;i++){
	  int from,to,c;
	  cin >> from >> to >> c;
	  cost[from-1][to-1] = c;
	}
	warshall_floyd(cost);
	s--;g1--;g2--;
	int ans = INF;
	for(int j = 0;j < n;j++){
	  ans = min(ans,(cost[s][j]+cost[j][g1]+cost[j][g2]));
	}
	cout << ans << endl;
//	cout << min(min(cost[s][g1]+cost[s][g2],cost[s][g1]+cost[g1][g2]),cost[s][g2]+cost[g2][g1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(void){
	scanf("%d",&n);
	printf("0\n");
	fflush(stdout);
	string str;
	cin >> str;
	if(str=="Vacant"){
		return 0;
	}else{
		int vi=0;
		if(str=="Male")vi=1;
		int l=1,r=n;
		while(l<r){
			int mid=(l+r)/2;
			printf("%d\n",mid);
			fflush(stdout);
			cin >> str;
			if(str=="Vacant"){
				return 0;
			}
			int mi=0;
			if(str=="Male")mi=1;
			if(mid%2==0){
				if(vi==mi)l=mid+1;
				else r=mid-1;
			}else{
				if(vi!=mi)l=mid+1;
				else r=mid-1;
			}
		}
		printf("%d\n",l);
		fflush(stdout);
		cin >> str;

	}
	return 0;
}

Measured memory_bytes: 852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException, Exception{
		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
		int n = getInt(st);
		int ans = n*n*n;
		anser(ans);

	}

	private static int getInt(BufferedReader st) throws Exception, IOException {
		int num = Integer.parseInt(st.readLine());
		return num;
	}

	private static void anser(int num) {
		System.out.println(num);
	}

}

Measured memory_bytes: 19412
#include<iostream>
using namespace std;
#include<map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(b-a<=10)
	{
		int answer=0;
		int j;
		for(j=a;j<=b;j++)
		    answer^=j;
		cout<<answer<<endl;
	}
	else
	{
		int answer=0;
		while(b%4!=3)
		{
			answer^=b;
			b--;
		}
		while(a%4!=0)
		{
			answer^=a;
			a++;
		}	
		cout<<answer<<endl;
	}
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int x = ni();
        int n = ni();
        if (n == 0) {
            out.println(x);
            out.close();
            return;
        }
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = ni();
        }
        int diff = Integer.MAX_VALUE;
        int target = arr[0];
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(arr[i]);
            int currDiff = Math.abs(x - arr[i]);
            if (currDiff < diff) {
                diff = currDiff;
                target = arr[i];
            }
        }
        int offset = 1;
        while(true) {
            int left = target - offset;
            int right = target + offset;
            if (!set.contains(left)) {
                out.println(left);
                break;
            }
            if (!set.contains(right)) {
                out.println(right);
                break;
            }
            offset++;
        }

        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 25436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long int llint;
string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
#define sort_all(v) sort(v.begin(),v.end())
#define sum_all(v) accumulate(v.begin(),v.end())

int main(void)
{
    int N;
    cin >> N;
    auto AB = vector<vector<int>>(N,vector<int>(2));
    loop(i,N)
        loop(j,2)
            cin >> AB[i][j];

    auto compare = [](vector<int>& x, vector<int>& y) { return x[1] < y[1]; };
    sort(AB.begin(),AB.end(),compare);

    llint totaltime = 0;
    loop(i,N) {
        totaltime += AB[i][0];
        if(totaltime > AB[i][1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N;
    ll X;
    cin >> N >> X;

    ll x[N];
    cin >> x[0];
    ll ans = abs(x[0]-X);

    
    if (N>1)
    {
        rep(i,N-1)
        {
            cin >> x[i+1];
            ans = __gcd(ans, abs(x[i+1]-X));
        }
    }
    
    cout << ans << endl;
}

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

static const int LEN = 100005;

typedef struct pp{
    char name[10];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail+1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head+1) % LEN;
    return x;
}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    cin >> n >> q;
    // 全てのプロセスをキューに順番に追加する
    for(i=1;i<=n;i++){
        cin >> Q[i].name >> Q[i].t;
    }
    head = 1, tail = n+1;

    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if (u.t>0){
            enqueue(u);
            }else{
                cout << u.name << " " << elaps << "\n";
            } 
    }
}



Measured memory_bytes: 4656
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<ll> lis;
bool vis[maxn];
bool pos;

int main(){
       
 
  ll t = 1;

  //cin>>t;

  while(t--){
    

     double r, pi = 3.1415926535;
     cin>>r;
     cout<<2*pi*r;     
  }     
        
}


Measured memory_bytes: 3740
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

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

T lcm(T)(T a, T b) {
    return a * (b / gcd(a, b));
}

void main() {
    readint;
    auto xs = readints;
    auto ans = xs.reduce!lcm;
    writeln(ans);
}


Measured memory_bytes: 2496
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] w = new String[n];
		HashMap<String, Integer> hm = new HashMap<>();
		for(i=0;i<n;i++) {
			w[i] = sc.next();
			if(hm.containsKey(w[i])) {
				hm.put(w[i], hm.get(w[i])+1);
			} else {
				hm.put(w[i], 1);
			}
		}
		sc.close();
		boolean f=true;
		ArrayList<Integer> list = new ArrayList<>(hm.values());
		Collections.sort(list, Comparator.reverseOrder());
		if(list.get(0)>1) {
			f=false;
		} else {
			for(i=0;i<n-1;i++) {
				if(w[i].charAt(w[i].length()-1) != w[i+1].charAt(0)) {
					f=false;
					break;
				}
			}
		}
		out.println(f?"Yes":"No");
	}
}


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

namespace ABC123C
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            var lst = new List<long>();

            long n = long.Parse(Console.ReadLine());
            for (int i = 0; i < 5; i++)
            {
                long a = long.Parse(Console.ReadLine());

                lst.Add(a);

            }
 
            lst.Sort((x, y) => x.CompareTo(y));
            long ans = 0;
            if (lst.First() < n)
            {

                if (n % lst.First() == 0)
                {
                    ans = n / lst.First() + 4;
                }
                else
                {
                    ans = n / lst.First() + 5;
                }
            }
            else
            {
                ans = 5;
            }
            Console.WriteLine(ans);
        }


    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	long long x[n],y[n],z[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>z[i];
	}
	long long a[8][n];
	int db[8]={1,1,1,-1,1,-1,-1,-1};
	int dt[8]={1,1,-1,1,-1,1,-1,-1};
	int dp[8]={1,-1,1,1,-1,-1,1,-1};
	long long ans=-1000000000000000000;
	for(int i=0;i<8;i++){
		for(int j=0;j<n;j++){
			a[i][j]=x[j]*db[i]+y[j]*dt[i]+z[j]*dp[i];
		}
		sort(a[i],a[i]+n);
		reverse(a[i],a[i]+n);
		long long sum=0;
		for(int j=0;j<m;j++){
			sum+=a[i][j];
		}
		ans=max(ans,sum);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 384
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int c[] = new int[N+1];

		for(int k=0;k<N+1;k++){
			c[k] = 0;
		}
		for(int n=0;n<M;n++){
			int t = sc.nextInt();
			c[t] = 1;
		}

		int up=0;
		int down=0;

		for(int n=0;n<X;n++){
			down += c[n];
		}
		for(int n=X+1;n<N+1;n++){
			up += c[n];
		}

		System.out.println(Math.min(down,up));


	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,m,p;
int vis[2525],can[2525],dis[2525];
struct node {
	int u,v,w;
} e[5005];
vector<int>G[2525],Q[2525];
void dfs1(int x) {
	vis[x]=1;
	for(unsigned i=0; i<G[x].size(); i++) {
		if(!vis[G[x][i]])dfs1(G[x][i]);
	}
}
void dfs2(int x){
	can[x]=1;
	for(unsigned i=0; i<Q[x].size(); i++) {
		if(!can[Q[x][i]])dfs2(Q[x][i]);
	}
}
long long bellman_ford() {
	memset(dis,-125,sizeof(dis));
	dis[1]=0;
	for(int i=1; i<=n; i++) {
		p=0;
		for(int j=1; j<=m; j++)
		if(dis[e[j].u]+e[j].w>dis[e[j].v]&&vis[e[j].u]&&vis[e[j].v])dis[e[j].v]=dis[e[j].u]+e[j].w,p=1;
		if(!p)break;
		if(i==n)return -1;
	}
	return max(0,dis[n]);
}
int main() {
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1; i<=m; i++) {
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);e[i].w-=p;
		G[e[i].u].push_back(e[i].v);Q[e[i].v].push_back(e[i].u);
	}
	dfs2(n),dfs1(1);
	for(int i=1; i<=n; i++)vis[i]&=can[i];
	printf("%lld",bellman_ford());
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N;
	cin>>N;
	
	cout<<N*N*N<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int T,X;
	double ans;

	cin >> T >> X;

	ans = (double)T / X;

	printf("%6f", ans);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

LL n,A,B;
LL a[N];
bool judge(LL x){
    LL temp=x*B;
    LL sub=A-B;
    LL sum=0;
    for(LL i=n;i>=1;i--){
        if(a[i]>temp){
            if((a[i]-temp)%sub)
                sum+=(a[i]-temp)/sub+1;
            else
                sum+=(a[i]-temp)/sub;
        }
    }
    if(sum<=x)
        return true;
    return false;
}
int main() {
    while(scanf("%lld%lld%lld",&n,&A,&B)!=EOF)
{
    LL right=0;
    for(LL i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        right+=a[i]/B+1;
    }
    sort(a+1,a+1+n);

    LL left=1;
    while(left<right){
        LL mid=(left+right)>>1;
        if(judge(mid))
            right=mid;
        else
            left=mid+1;
    }
    printf("%lld\n",left);
}
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
int a,b,c;
scanf ("%d %d %d",&a,&b,&c);
	if (a+b==c||b+c==a||a+c==b){
		printf("Yes\n");
			}else{
		printf("No\n");
		}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int N=1e5;

struct res {bool take,no;};
V<int> adj[N];

res dp(int u, int par) {
    V<res> ch;
    for (int v : adj[u]) if (v != par)
        ch.pb(dp(v,u));
    int numTake=0;
    for (res r : ch)
        numTake += r.take;
    res me;
    me.no = (numTake == S(ch));
    me.take = false;
    for (res r : ch) {
        if (r.no && (numTake - r.take == S(ch)-1))
            me.take = true;
    }
    return me;
}

signed main() {
    int n; cin>>n;
    F(i,n-1) {
        int a,b; cin>>a>>b;
        a--, b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    res root = dp(0,-1);
    if (root.take) P("Second");
    else P("First");
}

Measured memory_bytes: 6272
#include <iostream>

using namespace std;

int main() {
  int x, a, b;
  cin >> x;
  cin >> a;
  cin >> b;

  if (b-a <= x) {
    if (a - b >= 0) {
      cout << "delicious" << endl;
    } else {
      cout << "safe" << endl;
    }
  } else {
    cout << "dangerous" << endl;
  }
}


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

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

struct modint {
    static const int MOD = 998244353;

    int v;
    modint(const int _v = 0): v(_v % MOD) {
        if (v < 0) v += MOD;
    }

    bool operator==(const modint& other) const {
        return v == other.v;
    }

    modint& operator+=(const modint& other) {
        v += other.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }

    modint& operator-=(const modint& other) {
        v -= other.v;
        if (v < 0)
            v += MOD;
        return *this;
    }

    modint& operator*=(const modint& other) {
        v = 1LL * v * other.v % MOD;
        return *this;
    }

    modint& operator/=(const modint& other) {
        *this *= other.inv();
        return *this;
    }

    modint operator+(const modint& other) const {
        return modint(v) += other;
    }

    modint operator-(const modint& other) const {
        return modint(v) -= other;
    }

    modint operator*(const modint& other) const {
        return modint(v) *= other;
    }

    modint operator/(const modint& other) const {
        return modint(v) /= other;
    }

    static modint pow(modint b, ll e) {
        modint res = 1;
        for (ll p = 1; p <= e; p <<= 1) {
            if (p & e)
                res *= b;
            b *= b;
        }

        return res;
    }

    modint pow(ll e) const {
        return pow(*this, e);
    }

    modint inv() const {
        return pow(MOD - 2);
    }

    friend ostream& operator<<(ostream& os, modint m) {
        return os << m.v;
    }
};

constexpr int MAXN = 1e5;
modint fact[MAXN], tcaf[MAXN];

void gen_fact() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i - 1] * i;
    }

    tcaf[MAXN - 1] = modint(1) / fact[MAXN - 1];
    for (int i = MAXN - 2; i >= 0; --i) {
        tcaf[i] = tcaf[i + 1] * (i + 1);
    }
}

modint choose(int n, int k) {
    assert(n >= 0);
    if (k < 0 or n < k)
        return 0;

    return fact[n] * tcaf[k] * tcaf[n - k];
}

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

    int n;
    cin >> n;

    modint ans = modint::pow(3, n);
    modint cur = 0;
    modint term = 1;
    modint p = 2;
    // n choose k * 2^k for k in range()
    for (int k = n; k > n / 2; --k) {
        cur += term * p;
        // going from n!/k!(n-k)! to n!/(k-1)!(n-k+1)!
        // multiply by k/(n-k+1)
        term /= (n - k + 1);
        term *= k;
        p += p;
    }

    cout << ans - cur << '\n';
 
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
void rec(int zan,int cur){
	if(cur == 0 || zan == 0) return;
	if((cur-1)*cur/2 < zan){
		cout<<cur<<endl;
		zan-=cur;
	}
	rec(zan,cur-1);
}
int main(){
	cin>>n;
	rec(n,10000);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
int main()
{
	LL a,b;
	scanf("%lld%lld",&a,&b);
	LL c,d;
	c=a%b;d=abs(c-b)%b;
	printf("%lld\n",min(c,d));
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char ** argv) {
    int a, b;
    for (int q = 0;; q++){
        scanf("%d%d", &a, &b);
        if (a == 0) break;
        if (q != 0) puts("");
        auto is_uruu = [](int y){
            if (y % 400 == 0) return true;
            return y % 4 == 0 && y % 100 != 0;
        };
        int na = true;
        for (int i = a; i <= b; i++){
            if (is_uruu(i)){
                na = false;
                printf("%d\n", i);
            }
        }
        if (na) puts("NA");
    }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;

  int cont=0;
  for(int a=0;a<=A;a++){
    for(int b=0;b<=B;b++){
      for(int c=0;c<=C;c++){
        if(500*a+100*b+50*c==X){
          cont++;
        }
      }
    }
  }

  cout<<cont<<"\n";
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n+1];
  for (int i=1;i<=n;i++){
    a[i]=0;
  }
  for (int x=1;x<=sqrt(n);x++){
    for (int y=1;y<=sqrt(n);y++){
      for (int z=1;z<=sqrt(n);z++){
        int ans;
        ans=x*x+y*y+z*z+x*y+y*z+z*x;
        if (ans<=n) a[ans]++;
      }
    }
  }
  for (int i=1;i<=n;i++){
    cout<<a[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans,m;
string s[111111];
signed main(){
	cin>>n;
	rep(i,n)cin>>s[i];
	int a=0,w=0,t=0,r=0;
	rep(i,n){
		if(s[i]=="AC")a++;
		if(s[i]=="WA")w++;
		if(s[i]=="TLE")t++;
		if(s[i]=="RE")r++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
}

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    list<int> List;   //?????????
    int CommandNum;     //????????°
    string Command;
    int Number;
    
    List.clear();
    
    cin >> CommandNum;
    
    for(int i = 0; i < CommandNum; i++){
        cin >> Command;
        if(Command == "insert"){    //??????????????\
            cin >> Number;
            List.push_front(Number);
        } else if(Command == "delete"){ //????????????????????????
            cin >> Number;
            list<int>::iterator it = find(List.begin(), List.end(), Number);
            if(it != List.end())    List.erase(it);
        } else if(Command == "deleteFirst"){    //????????????
            List.pop_front();
        } else{ //????°???????
            List.pop_back();
        }
    }
    
    for(list<int>::iterator it = List.begin(); it != List.end(); it++){
        if(it != List.begin())   cout << " ";
        cout << *it;
    }
    cout << endl;
}

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

int main() {
	int n;
	cin>>n;string st;
	string s[n][3];int h;
	for(int i=0;i<n;i++)
	{
	    cin>>s[i][0]>>h;
	    s[i][1]=to_string(h);
	    s[i][2]=to_string(i+1);
	}
/**	for(int i=0;i<n;i++)
	cout<<s[i][0]<<" "<<s[i][1]<<" "<<s[i][2]<<endl;*/
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<n-1;j++)
	    {
	        int k=s[j][0].compare(s[j+1][0]);
	        if(k==0)
	        {
	            if(stoi(s[j][1])<stoi(s[j+1][1]))
	            {
	                st=s[j][2];
	                s[j][2]=s[j+1][2];
	                s[j+1][2]=st;
	                st=s[j][0];
	                s[j][0]=s[j+1][0];
	                s[j+1][0]=st;
	                st=s[j][1];
	                s[j][1]=s[j+1][1];
	                s[j+1][1]=st;
	            }
	        }
	        else if(k>0)
	        {
	                st=s[j][2];
	                s[j][2]=s[j+1][2];
	                s[j+1][2]=st;
	                st=s[j][0];
	                s[j][0]=s[j+1][0];
	                s[j+1][0]=st;
	                st=s[j][1];
	                s[j][1]=s[j+1][1];
	                s[j+1][1]=st;
	        }
	    }
	}
	/**for(int i=0;i<n;i++)
	cout<<s[i][0]<<" "<<s[i][1]<<" "<<s[i][2]<<endl;*/
	for(int i=0;i<n;i++)
	cout<<s[i][2]<<endl;
	return 0;
}

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

int main(){
        int d,g,i,j,cnt,num,idx,ans=1000;
        cin >> d >> g;
        vector<int> p(d);
        vector<int> c(d);
        for(i=0;i<d;++i){
                cin >> p.at(i) >> c.at(i);
        }
        for(i=0;i<(1<<d);++i){
                cnt = 0;
                num = 0;
                idx = 0;
                for(j=0;j<d;++j){
                        if((i>>j)&1==1){
                                cnt += p[j]*((j+1)*100)+c[j];
                                num += p[j];
                        }
                        else idx = max(idx, j);
                }
                if(cnt>=g) ans = min(ans, num);
                else{
                        for(j=0;j<p[idx];++j){
                                cnt += (idx+1)*100;
                                ++num;
                                if(cnt>=g){
                                        ans = min(ans,num);
                                        break;
                                }
                        }
                }
        }
        cout << ans << endl;
        return 0;
}

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

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

    int t = 0;
    for (; n; n /= 10) {
        t += n % 10;
    }
    cout << (tt % t ? "No" : "Yes") << endl;

    return 0;
}


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

using namespace std;

#define rep(i,a,b) for(int i=(a); i<(b); i++)

int main(){
  int n , m;
  while(cin >> n >> m , n + m){
    vector<int> ha;
    vector<int> ta;
    rep(i,0,n){
      int b; cin >> b;
      ta.push_back(b);
    }
    rep(i,0,m){
      int b; cin >> b;
      ha.push_back(b);
    }
    int pta = accumulate( ta.begin(), ta.end(), 0 );
    int pha = accumulate( ha.begin(), ha.end(), 0 );
    sort( ta.begin(), ta.end() );
    sort( ha.begin(), ha.end() );
    int d = abs(pta - pha);
    if(d%2 == 1) goto bad;
    d/=2;
    if(pta >= pha){
      rep(i,0,n){ rep(j,0,m){
          if(ta[i] - ha[j] == d){
            cout << ta[i] << " " << ha[j] << endl;
            goto good;
          }
          if(ta[i] - ha[j] < d){
            break;
          }
        } }
    }
    if(pta < pha){
      rep(i,0,m){ rep(j,0,n){
          if(ha[i] - ta[j] == d){
            cout << ta[j] << " " << ha[i] << endl;
            goto good;
          }
          if(ha[i] - ta[j] < d){
            break;
          }
        } }
    }
  bad:;
    cout << -1 << endl;
  good:;
  }
  return 0;
}

Measured memory_bytes: 1220
import javax.swing.*;
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public void execute(CustomReader in) throws IOException {
        int[] dg = in.readLineAsIntArray();
        final int D = dg[0];
        final int G = dg[1];
        int[] p = new int[D];
        int[] c = new int[D];
        int totalProblems = 0;
        for (int i = 0; i < D; i++) {
            int[] pc = in.readLineAsIntArray();
            p[i] = pc[0];
            c[i] = pc[1];
            totalProblems += p[i];
        }
        int ans = totalProblems;

        for (int i = 0, bound = 1 << D; i < bound; i++) {
            int score = 0;
            int cnt = 0;
            ArrayList<Integer> problems = new ArrayList<>();
            for (int j = 0; j < D; j++) {
                int mask = 1 << j;
                if ((i & mask) > 0) {
                    score += p[j] * 100 * (j + 1) + c[j];
                    cnt += p[j];
                } else {
                    for (int k = 0; k < p[j] - 1; k++) {
                        problems.add(100 * (j + 1));
                    }
                }

            }

            for (int k = problems.size() - 1; score < G && k >= 0; k--) {
                score += problems.get(k);
                cnt++;
            }
            if (score >= G) {
                ans = Math.min(ans, cnt);
            }
        }
        System.out.println(ans);
    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

Measured memory_bytes: 37340
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

long long gcd(long long a, long long b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        long long r = a%b;
        a=b;
        b=r;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}


struct XX{
    int u;
    int v;
    int t;
};

class xxIntu {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.u) == (riRight.u)){
            return riLeft.v < riRight.v;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
        }
        //第1条件
        return (riLeft.u) < (riRight.u);
    }
};
/*bool operator< (const XX &riLeft, const XX &riRight){
    return riLeft.d < riRight.d;
};*/

int index(string in){
    if(in=="A"){
        return 0;
    }else if(in=="B"){
        return 1;
    }else if(in=="C"){
        return 2;
    }else if(in=="D"){
        return 3;
    }else if(in=="E"){
        return 4;
    }else if(in=="F"){
        return 5;
    }else if(in=="G"){
        return 6;
    }else if(in=="H"){
        return 7;
    }else if(in=="I"){
        return 8;
    }else if(in=="J"){
        return 9;
    }else if(in=="K"){
        return 10;
    }else if(in=="L"){
        return 11;
    }else if(in=="M"){
        return 12;
    }else if(in=="N"){
        return 13;
    }else if(in=="O"){
        return 14;
    }else if(in=="P"){
        return 15;
    }else if(in=="Q"){
        return 16;
    }else if(in=="R"){
        return 17;
    }else if(in=="S"){
        return 18;
    }else if(in=="T"){
        return 19;
    }else if(in=="U"){
        return 20;
    }else if(in=="V"){
        return 21;
    }else if(in=="W"){
        return 22;
    }else if(in=="X"){
        return 23;
    }else if(in=="Y"){
        return 24;
    }else if(in=="Z"){
        return 25;
    }
    return -1;
}

int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから

    int N,K;
    cin >> N >> K;
    
    int ans=K;
    for(int i=1;i<N;i++){
        ans=ans*(K-1);
    }
    cout << ans << endl;
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, 0, a) cin >> s[i];
    rep(i, 0, b) cin >> t[i];
    s.push_back(-1e18);
    s.push_back(1e18);
    t.push_back(-1e18);
    t.push_back(1e18);
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    rep(i, 0, q) {
        ll x;
        cin >> x;
        auto itr_s = lower_bound(s.begin(), s.end(), x);
        auto itr_t = lower_bound(t.begin(), t.end(), x);
        ll tmp1 = 1e18, tmp2 = 1e18, tmp3 = 1e18, tmp4 = 1e18;
        ll tmp5 = max(*itr_s, *itr_t) - x;
        ll tmp6 = x - min(*(itr_s - 1), *(itr_t - 1));
        // s-, t+
        {
            ll dt = abs(*itr_t - x);
            ll ds = abs(*(itr_s - 1) - x);
            tmp1 = 2*min(dt, ds) + max(dt, ds);
        }
        // s-, t-
        {
            ll dt = abs(*(itr_t - 1) - x);
            ll ds = abs(*(itr_s - 1) - x);
            tmp2 = 2*min(dt, ds) + max(dt, ds);
        }
        // s+, t+
        {
            ll dt = abs(*itr_t - x);
            ll ds = abs(*itr_s - x);
            tmp3 = 2*min(dt, ds) + max(dt, ds);
        }
        // s+, t-
        {
            ll dt = abs(*(itr_t - 1) - x);
            ll ds = abs(*itr_s - x);
            tmp4 = 2*min(dt, ds) + max(dt, ds);
        }
        cout << min({tmp1, tmp2, tmp3, tmp4, tmp5, tmp6}) << endl;
    }
    return 0;
}

Measured memory_bytes: 5560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   if(a%3==0 || b%3==0 || (a+b)%3==0)cout<<"Possible"<<endl;
   else cout<<"Impossible"<<endl;
   
}

Measured memory_bytes: 256
class Inning
  def initialize
    @point = 0
    @outs_count = 0
    @runners_count = 0
  end
  
  def play
    until change?
      case gets.strip
      when "HIT" then hit
      when "OUT" then out
      when "HOMERUN" then homerun
      end
    end
    @point
  end
  
  def hit
    @runners_count += 1
    return_runner if over_runners_count?
  end
  
  def homerun
    @runners_count += 1
    return_runner while exist_runners?
  end
  
  def return_runner
    @runners_count -= 1
    @point += 1
  end
  
  def out
    @outs_count += 1
  end
  
  def change?
    @outs_count > 2
  end
  
  def over_runners_count?
    @runners_count > 3
  end
  
  def exist_runners?
    @runners_count > 0
  end
end

def input_innings_count
  gets.strip.to_i
end

innings_count = input_innings_count
innings = Array.new(innings_count){ Inning.new }
puts innings.map(&:play).join("\n")

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)

#define SZ(x) ((int)(x).size())


using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;

int main()
{
    ll A, B;
    ull V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if (V > W && (abs(A-B) <= T * (V-W)))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10 ** 9)

def rec(v):
 if memo[v]!=-1:
  return memo[v]

 res=0
 for nv in tree[v]:
  res=max(res,rec(nv)+1)

 memo[v]=res
 return res

n,m=map(int,input().split())

tree=[[] for i in range(n)]
memo=[-1 for i in range(n)]

for i in range(m):
 x,y=map(int,input().split())
 x-=1
 y-=1
 tree[x].append(y)

ans=0
for v in range(n):
 ans=max(ans,rec(v))
print(ans)

Measured memory_bytes: 152924
#include <iostream>

using namespace std;

int main(void)
{
	int x, y, s;
	while(cin >> x >> y >> s, x > 0){
		int maxi = 0;
		for(int p1 = 1, p2 = s-p1; p1 <= s-1; p1++, p2--){
			int p1_before, p2_before;
			int p1_after, p2_after;
			//税抜き価格の計算
			p1_before = (p1*100+(100+x-1))/(100+x);
			p2_before = (p2*100+(100+x-1))/(100+x);
			if (p1_before*(100+x)/100 + p2_before*(100+x)/100 != s)
				continue;
			//変更後税込価格の計算
			p1_after = p1_before*(100+y)/100;
			p2_after = p2_before*(100+y)/100;
			//最大値チェック
			maxi = max(maxi, p1_after+p2_after);
		}
		cout << maxi << endl;
	}
	return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
#include <utility>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
const ll unllMOD = 1e18;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/
//cout << std::fixed << std::setprecision(12) <<<< endl;

int main() {
	ll K,A,B;
	cin>>K>>A>>B;
	for(ll i=1;;i++){
		if(K*i>=A&&K*i<=B){cout<<"OK"<<endl;break;}
		else if(K*i>B){cout<<"NG"<<endl;break;}
	}
}

Measured memory_bytes: 3580
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

total_a = sum(a_list)
#約数の列挙
candidates = set()
for i in range(1, total_a):
    if i * i > total_a:
        break
    if total_a % i == 0:
        candidates.add(i)
        candidates.add(total_a // i)

ans = 1
for x in candidates:
    remainders = sorted(map(lambda a: a % x, a_list))
    total_r = sum(remainders)
    border = total_r // x
    need = sum(remainders[:(N - border)])
    if need <= K:
        ans = max(ans, x)
print(ans)


Measured memory_bytes: 3064