akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for(int i = 1; i < n+1; i++){
		char* num = (char*)calloc(10, sizeof(char));
		snprintf(num, 10,"%d", i);
		int sum = 0;
		while(*num != '\0'){
			sum += *num - 48;
			num++;
		}
		if(sum >= a && sum <= b) {
			ans += i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4072
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	int H, W;
	cin >> H >> W >> K;
	vector< string > A(H);
	rep(i, H) cin >> A[i];
	pii s;
	rep(i, H) rep(j, W) if (A[i][j] == 'S') s = make_pair(i, j);
	vector< vector< int > > d(H, vector< int >(W, LINF));
	d[s.first][s.second] = 0;
	queue< pii > q;
	q.push(s);
	while (!q.empty()) {
		pii p = q.front();
		q.pop();
		rep(k, 4) {
			int ni = p.first + di[k];
			int nj = p.second + dj[k];
			if (0 <= ni && ni < H && 0 <= nj && nj < W && A[ni][nj] != '#' && d[ni][nj] > d[p.first][p.second] + 1) {
				d[ni][nj] = d[p.first][p.second] + 1;
				q.push(make_pair(ni, nj));
			}
		}
	}
	pii t = s;
	int mind = LINF;
	rep(i, H) rep(j, W) {
		if (d[i][j] > K)
			continue;
		int d = min(min(i, H - 1 - i), min(j, W - 1 - j));
		if (chmin(mind, d))
			t = make_pair(i, j);
	}
	//cout << mind << endl;
	int ans = 1 + (mind + K - 1) / K;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	List<List<Integer>> G;
	int n;
	int[] color;

	private void run() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		int m = scanner.nextInt();
		G = new ArrayList<List<Integer>>();
		color = new int[n];
		for (int i = 0; i < n; i++) {
			G.add(new ArrayList<Integer>());
		}
		for (int i = 0; i < m; i++) {
			int s = scanner.nextInt();
			int t = scanner.nextInt();
			G.get(s).add(t);
			G.get(t).add(s);
		}
		assiginColor();

		int q = scanner.nextInt();
		for (int i = 0; i < q; i++) {
			int s = scanner.nextInt();
			int t = scanner.nextInt();
			if (color[s] == color[t]) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}

	private void assiginColor() {
		Arrays.fill(color, -1);
		int id = 1;
		for (int i = 0; i < n; i++) {
			if (color[i] == -1)
				dfs(i, id++);
		}
	}

	private void dfs(int r, int c) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.push(r);
		color[r] = c;
		while (!deque.isEmpty()) {
			int u = deque.poll();
			for (int i = 0; i < G.get(u).size(); i++) {
				int v = G.get(u).get(i);
				if (color[v] == -1) {
					color[v] = c;
					deque.push(v);
				}
			}
		}
	}
}

Measured memory_bytes: 111156
#include <stdio.h>

void swapmax(int *a, int *b){
	int tmp;
	if(*a > *b) return ;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int ans = 0;
	int n, Max, nextMax;
	
	scanf("%d", &n);
	Max = n;
	
	scanf("%d", &n);
	swapmax(&Max, &n);
	nextMax = n;
	scanf("%d", &n);
	swapmax(&nextMax, &n);
	swapmax(&Max, &nextMax);
	printf("%d\n", Max * 10 + nextMax + n);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Code20171210B
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            Console.WriteLine(funcMain(s1,s2));
        }

        static public string funcMain(string arg1, string arg2)
        {
            int ret=0;

            List<int> arglist = arg2.Split().Select(s=>int.Parse(s)).ToList();

            while(true)
            {
                if (arglist.Where(s => s % 2 != 0).Count() > 0) { break; }
                arglist = arglist.Select(s => s / 2).ToList();
                ret++;
            };
            
            return ret.ToString();
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int d;

int main() {
    cin >> d;
    d=25-d;
    string res = "Christmas";
    Rep(i,d){
        res += " Eve";
    }
    put(res);
    return 0;
}


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


def solve(W, H, x, y):
    ans = str(H*W/2)
    if x == 0 or y == 0:
        flag = "0"
    else:
        if x == W/2 and y == H/2:
            flag = "1"
        else:
            flag = "0"
    print(ans + " " + flag)

    return


# Generated by 1.1.4 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()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(W, H, x, y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int M = 1e9 + 7;
int A[N];
int n , k , c;
string str;
int pre[N];
int suf[N];

void solve()
{
    cin >> n >> k >> c >> str;

    int i = 0;
    while(i < n)
    {
        int val = (str[i]=='o')?1:0;
        if(val)
        {
            pre[i]++;
            i += c+1;
        }
        else i++;
    }

    i = n-1;
    while(i >= 0)
    {
        int val = (str[i]=='o')?1:0;
        if(val)
        {
            suf[i]++;
            i -= c+1;
        }
        else i--;
    }

    loop(i,1,n)pre[i] += pre[i-1];
    for(int i = n-1; i >= 0; i--)suf[i] += suf[i+1];

    loop(i,0,n)
    {
        if(str[i] == 'o')
        {
            if(pre[i-1]+suf[i+1] < k)cout << i+1 << endl;
        }
    }

}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    
     
     int t = 1;
     // cin >> t;
     while(t--)solve();
  
}


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

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

int main(){
    int a,b,k;cin>>a>>b>>k;
    REP(i,k)
    {
        if (i%2==0&&a%2==0)
        {
            /* code */
            b+=a/2;
            a-=a/2;
        }
        else if(i%2==0&&a%2==1)
        {
            a-=1;
            b+=a/2;
            a-=a/2;
        }
        else if(i%2==1&&b%2==0)
        {
            a+=b/2;
            b-=b/2;

        }
        else if(i%2==1&&b%2==1)
        {
            b-=1;
            a+=b/2;
            b-=b/2;
        }
        
    }
    cout<<a<<' '<<b<<endl;

    }

Measured memory_bytes: 256
import sys
X, N = map(int, input().split())
P = list(map(int, input().split()))

k = 0
for i in range(N):
    if P[i] == X:
        k = 1
if k == 0:
    print(X)
    sys.exit()

mi = X-1
ma = X+1
while(True):
    k = 0
    for i in range(N):
        if P[i] == mi:
            k = 1
    if k == 0:
        print(mi)
        sys.exit()
    mi -= 1
    k = 0
    for i in range(N):
        if P[i] == ma:
            k = 1
    if k == 0:
        print(ma)
        sys.exit()
    ma += 1

Measured memory_bytes: 63768
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

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

    int N; cin >> N;
    vector<ll> l(N);
    rep(i, N) cin >> l[i];
    sort(l.begin(), l.end());

    ll ans = 0;
    rep(i, N) repr(j, i+1, N) {
        int pos = upper_bound(l.begin(), l.end(), l[j]-l[i]) - l.begin();
        ans += max(0, i - pos);
    }
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s;
  cin>>s;
  for(char c:s){
    cout<<'x';
  }
  cout<<endl;
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    rep(i,12){
        if(i == 4) cout << " ";
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
 
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }
 
void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}
 
 
void execute()
{
    int N, K;
    cin >> N >> K;
    vector<pair<int,int>> A(N);
    vector<pair<int,int>> B(N);
    for(int i = 0; i < N; i++){
        int v;
        cin >> v;
        A[i] = make_pair(i, v);
    }
 
    auto &read = A;
    auto &write = B;
    for(int i = 0; i < K; i++){
        bool allN = true;
        sort(read.begin(), read.end(), 
            [](pair<int,int>& x, pair<int,int>& y) { 
                return x.first - x.second  < y.first - y.second;
            });
 
        int idx = 0;
        multiset<int> st;
        for(int j = 0; j < N; j++){
            // 新規要素の追加
            do{
                auto &r = read[idx];
                if(r.first - r.second <= j){
                    st.insert(r.first + r.second);
                }else{
                    break;
                }
            }while(++idx < N);
 
            // 要らないものの消去
            for(auto itr = st.begin(); itr != st.end();) {
                if(j <= *itr){
                    break;
                }
                itr = st.erase(itr);
            }
 
            write[j] = make_pair(j, st.size());

            if(st.size() != N) allN = false;
        }
 
        if(allN){
            for(int i = 0; i < N-1; i++){
                cout << N << " ";
            }
            cout << N << endl;
            return;
        }

        auto & t = read;
        read = write;
        write = t;
    }
 
    for(int i = 0; i < N-1; i++){
        cout << read[i].second << " ";
    }
    cout << read[N-1].second << endl;
}

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

int main(){
  int n;
  cin>>n;
  if(n<1200) cout<<"ABC"<<endl;
  else if(n<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  while(M%N and M/2>=N) N++;
  cout<<M/N<<endl;
}

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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int dp[1001][10001];

int main()
{
	int k, x;

	cin>>k >> x;

	if (500 * k >= x)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int group[13]={};
  group[0] = -1;
  group[2] = 2;
  REP(i,12){
    if(i==2)continue;
    if(i==4 || i==6 || i==9 || i==11){
      group[i] = 1;
    }
  }
  
  int x,y;
  cin>>x>>y;
  if(group[x]==group[y]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int M = one.get(1);
		int[] list = new int[N];
		for(int i = 0; i < M; i++){
			ArrayList<Integer> tmp = nextIntArray();
			list[tmp.get(0) - 1]++;
			list[tmp.get(1) - 1]++;
		}
		for(int i = 0; i < N; i++){
			myout(list[i]);
		}
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 25500
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int R;
  cin >> R;
  cout << 'A' << (R<1200?'B':R<2800?'R':'G') << 'C' << endl;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int a[4];
  rep(i, 4) {
    a[4-i-1] = n%10;
    n/=10;
  }

  rep(i, 1<<3) {
    vector<bool> v(3);
    rep(j, 3) {
      v[j] = i>>j&1;
    }
    int sum = a[0];
    rep(j, 3) {
      sum += a[j+1]*(v[j]?1:-1);
    }
    if(sum == 7) {
      rep(j, 3) {
	cout << a[j] << (v[j]?'+':'-');
      }
      cout << a[3] << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        for(int i=A;i<=B;i++){
            if(i % K ==0){
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }

}


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

int main () {
	std::string s;
	int K;

	std::cin >> s >> K;

	std::set<std::string> S;
	for(int i = 0; i < (int) s.length(); ++i) {
		for(int j = 1; j <= std::min(K, (int) s.length() - i); ++j) {
			S.insert(s.substr(i, j));
		}
	}

	int k = 1;
	for(auto ans : S) {
		if(k == K) {
			std::cout << ans << std::endl;
			return 0;
		}
		++k;
	}
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
	int N,i,o=0;
	cin>>N;
	int H[N];
	for(i=0;i<N;i++)
		cin>>H[i];
	for(i=0;i<N-1;i++)
	{
		if(H[i]-H[i+1]>0)
		{
			cout<<"No\n";
			break;
		}
		else if(H[i+1]>H[i])
		{
			H[i+1]--;
		}
	}
	if(i==N-1)
		cout<<"Yes\n";
}

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

typedef long long ll;
typedef pair<int, int> pii;

int pref[5000][3];

int getPref(int l, int r, int k) {
	return pref[r][k] - pref[l - 1][k];
}

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	s = "$" + s;
	map<char, int> color;
	color['R'] = 0;
	color['G'] = 1;
	color['B'] = 2;

	for (int i = 1; i <= n; i++) {
		for (int k = 0; k < 3; k++) {
			pref[i][k] += pref[i - 1][k];
		}

		if (s[i] == 'R') {
			pref[i][0]++;
		} else if (s[i] == 'G') {
			pref[i][1]++;
		} else {
			pref[i][2]++;
		}
	}

	ll res = 0;

	for (int i = 1; i <= n; i++) {
		for (int k = i + 2; k <= n; k++) {
			if (s[i] == s[k]) {
				continue;
			}

			if ((i + k) % 2 == 0) {
				int j = (i + k) / 2;
				int need = 3 - color[s[i]] - color[s[k]];
				res += getPref(i + 1, j - 1, need) + getPref(j + 1, k - 1, need);
			} else {
				int need = 3 - color[s[i]] - color[s[k]];
				res += getPref(i + 1, k - 1, need);
			}
		}
	}


	cout << res;

	return 0;
}

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

int main() {
    int a,b,c,k,cnt=0;
    cin>>a>>b>>c>>k;
    while(b<=a){
        b*=2;
        cnt++;
    }
    while(c<=b){
        c*=2;
        cnt++;
    }
    if(cnt>k){
        cout<<"No"<<endl;
    }else {
        cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  
  int d[N];
  
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  
  int sum=0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      sum += d[i]*d[j]; 
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import sys
range = xrange
input = raw_input

n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]


DP = [0]*(n+1)
DP[n] = n
for j in range(3):
    sell = A[j]
    get_back = B[j]
    if get_back > sell:
        for i in reversed(range(sell,len(DP))):
            val1 = DP[i - sell]
            val2 = DP[i] + get_back - sell
            if val2 > val1:
                DP[i-sell] = val2
n = max(DP)
A,B = B,A

DP = [0]*(n+1)
DP[n] = n
for j in range(3):
    sell = A[j]
    get_back = B[j]
    if get_back > sell:
        for i in reversed(range(sell,len(DP))):
            val1 = DP[i - sell]
            val2 = DP[i] + get_back - sell
            if val2 > val1:
                DP[i-sell] = val2

print(max(DP))

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

int dist(string s1, string s2, int len) {
    int ans = 0;
    for (int i = 0; i < len ; i++) {
        if (s1[i] != s2[i]) {
            ans++;
        }
    }
    
    return ans;
}

int main(){
    string S, T;
    cin >> S >> T;
    int len_S = S.length(), len_T = T.length();
    
    string subS = "";
    int minAns = len_T;
    for (int i = 0; i < len_S - len_T + 1; i++) {
        subS = S.substr(i, len_T);
        minAns = min(minAns, dist(subS, T, len_T));
    }
    
    cout << minAns << endl;
    
}




Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
typedef pair<int, pair<int, int> > PPII;
typedef pair<int, int> PII;
static const int INF = 1ll<<60;

int N,M,H,K;
vector<int> V[1005];
int a[1005];
int flg[1005][1005];
vector<int> pass[1005][1005];
int vi[1005];
int s;
int maxd;
int temp=0;
int ans=0;

void dfs(int n,int m,bool down){
    pass[n][V[n][m]].PB(s);
    if(V[n][m]==maxd+1){
        vi[s]=a[n];
        return ;
    }
    if(down==true&&m!=0){
        int it = lower_bound(V[n+1].begin(),V[n+1].end(),V[n][m])-V[n+1].begin();
        if(it==V[n+1].size()||flg[n][V[n][m]]==0||V[n+1][it]!=V[n][m]){
            it = lower_bound(V[n-1].begin(),V[n-1].end(),V[n][m])-V[n-1].begin();
            dfs(n-1,it,false);
        }
        else dfs(n+1,it,false);
    }
    else {
        int it = upper_bound(V[n].begin(),V[n].end(),V[n][m])-V[n].begin();
        dfs(n,it,true);
    }
}

signed main(){
    while(1){
        cin>>N>>M>>H>>K;
        if(N==0)break;
        for(int i=0;i<N;++i){
            cin>>a[i];
        }
        for(int i=0;i<M;++i){
            int A,B;
            cin>>A>>B;
            A--;
            maxd=max(maxd,B);
            V[A].PB(B);
            V[A+1].PB(B);
            flg[A][B]=1;
        }
        for(int i=0;i<N;++i){
            V[i].PB(0);
            V[i].PB(maxd+1);
        }
        for(int i=0;i<N;++i)sort(V[i].begin(),V[i].end());
        for(int i=0;i<N;++i){
            s=i;
            int it = lower_bound(V[i].begin(),V[i].end(),0)-V[i].begin();
            dfs(i,it,true);
        }
        for(int i=0;i<K;++i)temp+=vi[i];
        ans=temp;
        for(int i=0;i<N;++i){
            for(int j=0;j<V[i].size();++j){
                if(pass[i][V[i][j]].size()!=2||pass[i+1][V[i][j]].size()!=2)continue;
                if(min(pass[i][V[i][j]][0],pass[i][V[i][j]][1])!=min(pass[i+1][V[i][j]][0],pass[i+1][V[i][j]][1]))continue;
                if(max(pass[i][V[i][j]][0],pass[i][V[i][j]][1])!=max(pass[i+1][V[i][j]][0],pass[i+1][V[i][j]][1]))continue;
                int p1=min(pass[i][V[i][j]][0],pass[i][V[i][j]][1]),p2=max(pass[i+1][V[i][j]][0],pass[i+1][V[i][j]][1]);
                if(p1>=K&&p2>=K)continue;
                if(p1<K&&p2<K)continue;
                if(p1>=K||p2>=K)ans=min(ans,temp-vi[min(p1,p2)]+vi[max(p1,p2)]);
            }
        }
        cout<<ans<<endl;
        ans=0;
        temp=0;
        maxd=0;
        for(int i=0;i<N;++i){
            for(int j=0;j<V[i].size();++j){
                flg[i][V[i][j]]=0;
                pass[i][V[i][j]].clear();
            }
            V[i].clear();
            vi[i]=0;
        }
    }
}

Measured memory_bytes: 43148
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <algorithm>

#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<long long, long long> pii;

const int MAXN = 1e6;
const int inf = 1e9 + 5;
const long double eps = 1e-8;

long long f(long long a) {
    long long b = 0;
    while (a % 2 == 0) {
        b++;
        a /= 2;
    }
    return b;
}

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

    long long a, b, c;
    cin >> a >> b >> c;

    int count = 0;
    while (count < 1e7 && a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        long long a1 = a, b1 = b, c1 = c;
        a1 = b / 2 + c / 2;
        b1  = a / 2 + c / 2;
        c1 = a / 2 + b / 2;
        a = a1;
        b = b1;
        c = c1;
        count++;
    }

    if (count < 1e7)
        cout << count;
    else
        cout << -1;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    import math
    n = int(input())
    c = input()
    num = []
    r = 0
    w = 0
    for i in range(n):
        if c[i] == "R":
            r += 1
            num.append(0)
        else:
            w += 1
            num.append(1)
    fi = [0]*r+[1]*w
    ct = 0
    for i in range(n):
        if num[i] != fi[i]:
            ct += 1
    print(min(math.ceil(ct/2), w))
resolve()

Measured memory_bytes: 14204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int m, f, b;
  cin >> m >> f >> b;
  if(m + f < b) cout << "NA" << endl;
  else cout << max(0, b - m) << endl;
  return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool Judge_Prime(int num){
  if (num == 1) return false;
  for (int i = 2; i * i <= num; i++){
    if (num % i == 0) return false;
  }
  return true;
}

int N;
vector <int> Prime;

int main(){
  cin >> N;
  for (int i = 1; i <= 55555; i+=5){
    if (Judge_Prime(i)) Prime.push_back(i);
  }

  cout << Prime[0];
  for (int i = 1; i < N; i++) cout << " " << Prime[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 3604
n = int(input())
max_score = 0
word_list1 = []
for i in range(n):
    s = input()
    word_list1.append(s)

t = int(input())
word_list2 = []
for i in range(t):
    s = input()
    word_list2.append(s)


what_to_say = set(word_list1)


for i in what_to_say:
    score = 0
    for j in word_list1:
        if i == j:
            score += 1
    for k in word_list2:
        if i == k:
            score -= 1
    if score > max_score:
        max_score = score

print(max_score)

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    int a[200001];
    cin >> n;
    rep(i, n)
    {
        cin >> a[i + 1];
    }

    int arr[200001] = {};
    for (int i = 1; i <= n; i++)
    {
        arr[i] = arr[i - 1] + a[i];
    }

    map<int, int> m;
    for (int i = 1; i <= n; i++)
    {
        m[arr[i]]++;
    }
    int cnt = m[0];
    int sub = 0;
    for (int i = 1; i <= n; i++)
    {
        sub += arr[i] - sub;
        m[arr[i]]--;
        cnt += m[sub];
        // cout << m[sub] << ", " << sub << endl;
    }
    // for (int i = 1; i <= n; i++)
    // cout << arr[i] << " ";
    // cout << endl;
    cout << cnt << endl;
}

Measured memory_bytes: 15872
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 200002
#define mod 1000000007

ll add(ll x, ll y) {
	x += y;
	if(x >= mod) return x - mod;
	return x;
}

ll mul(ll x, ll y) {
	x *= y;
	if(x >= mod) return x % mod;
	return x;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll p = power(x, y/2);
	p = mul(p, p);
	if(y&1) return mul(p, x);
	return p;
}

const int N = 3e6 + 5;

ll F[N];
ll IF[N];

ll C(ll x, ll y) {
	return mul(F[x], mul(IF[y], IF[x-y]));
}

ll get(ll x, ll y) {
	return C(x - 1, y - 1);
}

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

	F[0] = 1;
	for(int i=1; i<N; i++) F[i] = mul(F[i-1], i);
	IF[N-1] = power(F[N-1], mod-2);
	for(int i=N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);

	int n, k;
	cin >> n >> k;
	int mx = min(k, n-1);
	ll ans = 0;
	for(int i=0; i <= mx; i++) {
		ans = add(ans, mul(C(n, i), get(n, n-i)));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
 
const int N = 2e5+5;
float L;
 
int32_t main()
{
	IOS;
	
	cin>>L;
	
	float i= L/(3.0);
	
    float ans= ((L-i)/2) * ((L-i)/2) * i;
	
	
	cout<<fixed<<setprecision(6)<<ans<<endl;
	return 0;
}

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

ll n, k, l, r;
vector<ll> a, f;

void input() {
    cin >> n >> k;
    a = f = vector<ll>(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
}

bool judge(ll x) {
    ll k_ = k;
    rep(i, n) {
        if (x >= a[i] * f[i]) continue;
        ll y = (f[i] * a[i] - x) / f[i];
        if (x % f[i] != 0) y++;
        k_ -= y;
    }
    if (k_ < 0) return false;
    return true;
}

ll binarySearch() {
    if (r - l < 2) return r;
    ll w = (r + l) / 2;
    if (judge(w)) r = w;
    else l = w;
    return binarySearch();
}

int main() {
    input();
    l = -1;
    r = 1e12;
    cout << binarySearch() << endl;
}


Measured memory_bytes: 3328
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N,M = II()
A = III()
B,C = Line(M)

a = []
for i in range(N):
  a.append([1,A[i]])
for i in range(M):
  a.append([B[i],C[i]])

a.sort(key=lambda x:x[1],reverse=True)
#a.sort(key=lambda x:-x[1])
counter = 0
ans = 0

for i in range(N+M):
  if counter + a[i][0] >= N:
    ans += a[i][1]*(N-counter)
    break
  else:
    counter += a[i][0]
    ans += a[i][1]*a[i][0]

print(ans)

Measured memory_bytes: 104832
#include <iostream>
#include<queue>
#define LEN 100010
using namespace std;

struct P {
  string name;
  int t;
};

int n, q;
queue <P> Q;

int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    P p;
    cin >> p.name >> p.t;
    Q.push(p);
  }
  int elaps = 0;
  int rest = q;
  while(!Q.empty()) {
    P p = Q.front(); Q.pop();
    if (p.t > rest) {
      // プロセスが終了しない時
      elaps += rest;
      p.t -= rest;
      Q.push(p);
    } else {
      // プロセスが終了する時
      elaps += p.t;
      cout << p.name << " " << elaps << endl;
    }
  }
}



Measured memory_bytes: 6220
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

int main(){
	int w; cin >> w;
	vector<int> amida;
	rep(i, w) amida.push_back(i + 1);
	int n; cin >> n;
	while(n --){
		int before, after;
		scanf("%d,%d", &before, &after);
		swap(amida[before - 1], amida[after - 1]);
	}
	rep(i, w) cout << amida[i] << endl;
	
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll x;
    cin >> x;
    ll tmp = 0;
    for(i = 1;i <= x;++i){
        tmp += i;
        if(tmp >= x){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> ans;
    map<int,int> manu,memo;
    for(int i=n; i>0; i--){
        for(int j=2; j<=n/i; j++){
            manu[i]+=memo[i*j];
        }
        if(manu[i]%2!=a[i-1]){
            ans.push_back(i);
            memo[i]++;
        }
    }
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 20856
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int   long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define all(o) o.begin(),o.end()
using namespace std;
vector<int> a[200005];
int vis[200005],dist[200005],par[200005];
int32_t main(){	
	int n,m,x,y,i;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	queue<int> q;
	q.push(1);
	vis[1]=1;
	int c=0;
	while(q.size())
	{
		int v=q.front();
		q.pop();
		for(auto x:a[v])
		{
			if(vis[x]==0)
			{
				vis[x]=1;
				dist[x]=dist[v]+1;
				par[x]=v;
				q.push(x);
			}
		}
		c++;
	}
	if(c==n)
	{
		cout<<"Yes\n";
		for(i=2;i<=n;i++)
			cout<<par[i]<<endl;
	}
	else cout<<"No\n";

	
	
}


Measured memory_bytes: 16840
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	ll M;
	ll s = 0;
	ll s2 = 0;
	cin >> M;
	for (int i = 0; i < M; i++) {
		ll d, c;
		cin >> d >> c;
		s += d * c;
		s2 += c;
	}
	cout << (s - 1) / 9 + s2 - 1 << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int N, A, B, C;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &N);
  long long sum = 0;
  sum+=std::min(N, A);
  N-=std::min(N, A);
  if (N==0){
    std::cout << sum << std::endl;
    return 0;
  } else {
    N-=std::min(N, B);
  }
  //  printf("N=%d\n", N);
  if (N==0) {
    std::cout << sum << std::endl;
    return 0;
  } else {
    sum-=std::min(N, C);
    N-=std::min(N, C);
    std::cout << sum << std::endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3276
#include <stdio.h>
int main(){
    int A,B,C,d,e;
    A>=0&&A<=10e9;
    B>=0&&B<=10e9;
    C>=0&&C<=10e9;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    e=A+B;
    if( A>=C||e>=C ){
        d=B+C;
        printf("%d",d);
    }
    else{
        d=A+B*2+1;
        printf("%d",d);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 入力の受け取り
		Scanner sc = new Scanner(System.in);
		int[] x = new int[5];
		x[0] = sc.nextInt();
		x[1] = sc.nextInt();
		x[2] = sc.nextInt();
		x[3] = sc.nextInt();
		x[4] = sc.nextInt();

		// 解法
		int ret = 0;
		for (int i = 0; i < 5; i++) {
			if (x[i]==0) {
				ret = i + 1;
			}
		}

		System.out.println(ret);

		sc.close();
	}
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	//int ans=0;
	cin >>h>>w;
	vector<string>s(h);
	vector<string>ans;
	bool none=true;
	rep(i,h){
		none=true;
		cin>>s[i];
		rep(j,w){
			none&=(s[i][j]=='.');
		}
		if(!none){
			ans.push_back(s[i]);
		}
	}
	/*
	clog<<endl;
	rep(i,ans.size()){
		clog<<ans[i]<<endl;
	}
	*/
	//clog<<ans.size()<<" "<<ans[1].size()<<endl;
	for(int j=0;j<ans[0].size();j++){
		none=true;
		for(int i=0;i<ans.size();i++){
			none&=(ans[i][j]=='.');
		}
		if(none==true){
			for (int i = 0; i < ans.size(); i++)
			{
				ans[i][j] = '0';
			}
		}
	}
	clog<<endl;
	rep(i,ans.size()){
		rep(j,ans[0].size()){
			if(ans[i][j]!='0'){
				cout<<ans[i][j];
			}
			if(j==ans[0].size()-1){
				cout<<endl;
			}
		}
	}
//	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 305;
bool dp[10000025][2];
int arr[MAX_N],n;
int dfs(int k,int t)
{
    if(dp[k][t]>0) return dp[k][t];
    int ans = 0;
    for(int i = 1;i<=n;++i)
        if(k>=arr[i])   ans |= !dfs(k-arr[i],!t);
    return dp[k][t] = ans;
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int k;
    scanf("%d%d",&n,&k);
    for(int i = 1;i<=n;++i) scanf("%d",&arr[i]);
    if(dfs(k,0)==false) printf("Second\n");
    else printf("First\n");
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
using namespace std;
int main(){
	int t=0,N,x[500][3];
	cin>>N;
	for(int i=0;i<N-1;i++){
		cin>>x[i][0]>>x[i][1]>>x[i][2];
	}
	for(int j=0;j<N-1;j++){
		t=0;
		for(int k=j;k<N-1;k++){
			if(t<x[k][1])t=t+(x[k][1]-t);
			else if(t%x[k][2]!=0)t=t+(x[k][2]-t%x[k][2]);
			t=t+x[k][0];
		}
		cout<<t<<endl;
	}
	cout<<0<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (m % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  vector<pair<int, int>> ans;
  vector<int> deg(n), vis(n), depth(n);
  function<void(int, int)> dfs = [&] (int cur, int par) {
    vis[cur] = 1;
    for (int child : g[cur]) {
      if (!vis[child]) {
        depth[child] = depth[cur] + 1;
        dfs(child, cur);
      } else {
        if (depth[child] > depth[cur]) {
          ans.emplace_back(cur, child);
          deg[cur]++;
        }
      }
    }
    if (deg[cur] % 2 == 1) {
      ans.emplace_back(cur, par);
      deg[cur]++;
    } else {
      if (par != -1) {
        ans.emplace_back(par, cur);
        deg[par]++;
      }
    }
  };
  dfs(0, -1);
  for (auto i : ans) {
    cout << i.first + 1 << " " << i.second + 1 << '\n';
  }
  return 0;
}

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

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        	String input = br.readLine();
        	String[] inputan = br.readLine().split(" ");
        	for (int j = Integer.parseInt(input) - 1; j >= 0; j--)
        	{
        		System.out.print(inputan[j]);
        		if (j > 0)
        			System.out.print(" ");
        		if (j == 0)
        			System.out.println();
        	}
        	
        	
	}

}

Measured memory_bytes: 24372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int n,m,k,i,j,count1=0,count2=0,w,u;
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    //cout<<a<<endl;
    ////cout<<b<<endl;
    n=b.size();
    // cout<<n<<endl;
    k=(n-1)/2;
    w=k;
    //cout<<w<<endl;
    //cout<<k<<endl;
    m=(n+3)/2;
    //cout<<m<<endl;
    u=(n-m)+1;
   // cout<<u<<endl;
       if(b==a)
    {
        for(i=0,j=k-1;i<k,j>=0;i++,j--)
        {
            if(a[i]==a[j])
                count1++;
        }
      // cout<<count1<<endl;
         for(i=m-1,j=n-1;i<n,j>=m-1;i++,j--)
        {
            if(a[i]==a[j])
                count2++;
        }
       //cout<<count2<<endl;
        if((count1==w&&count2==u))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256