akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;

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

	vector<int> P(n), Q(n);
	for (int i = 0; i < n; i++)
	{
		cin >> P[i];
	}

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

	vector<int> array(n);
	iota(array.begin(), array.end(), 1);

	int a = 0, b = 0;
	int count = 0;
	do
	{
		if (equal(array.begin(), array.end(), P.begin()))
		{
			a = count;
		}

		if (equal(array.begin(), array.end(), Q.begin()))
		{
			b = count;
		}

		count++;
	} while (next_permutation(array.begin(), array.end()));

	int ans = abs(a - b);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;
ll power(ll x, ll y) { 
    ll temp, f; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2)%mod; 
    if (y%2 == 0) 
        return (temp * temp) % mod; 
    else{   
        f = (x * temp) % mod;
        f = (f * temp) % mod;
        return f; 
    }
}  
map<pll,ll> pos, neg;
int main(){
	IOS;
	ll n;
	cin >> n;
	ll num = 0, den = 0, both = 0;
	ll x, y;
	loop(i, 1, n + 1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			both++;
			continue;
		}
		ll a = (x > 0? 1 : -1), b = (y > 0? 1: -1);
		x = abs(x), y = abs(y);
		if(x == 0){
			num++;
			continue;
		}
		if(y == 0){
			den++;
			continue;
		}
		ll temp = __gcd(x, y);
		x = x / temp, y = y / temp;
		debug(x, y, a * b);
		if(a * b > 0)
			pos[{x, y}]++;
		else
			neg[{x, y}]++;
		
	}

	ll ans = 1;
	for(auto & node : pos)
		ans = (ans * ( power(2, pos[{node.x.x, node.x.y}]) + power(2, neg[{node.x.y, node.x.x}]) + mod - 1)% mod ) % mod ;
	
	debug(ans);
	for(auto & node : neg){
		debug(node);
		if(pos.find({node.x.y, node.x.x}) == pos.end())
			ans = (ans * power(2, neg[{node.x.x, node.x.y}])) % mod;
	}
	debug(ans) ;
	ans = (ans * (power(2, num) + power(2, den) + mod - 1) % mod ) % mod;
	ans = (ans + both + mod - 1) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 22300
#include<bits/stdc++.h>
using namespace std;
bool dp[81][321][321];
int L;
int t[80];
 
int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>L;
    for(int i=0;i<L;i++)cin>>t[i];
    if(L==1){
      cout<<t[0]<<endl;
      continue;
    }else if(L==2){
      cout<<t[1]<<endl;
      continue;
    }
 
    for(int i=0;i<=80;i++)
      for(int j=0;j<=320;j++)
        for(int k=0;k<=320;k++)
          dp[i][j][k]=false;
 
    dp[1][t[0]][t[1]]=true;
    for(int i=1;i+1<L;i++){
      for(int j=0;j<=320;j++){
        for(int k=0;k<=320;k++){
          if(dp[i][j][k]){
            if(k)dp[i+1][k-1][j+t[i+1]]=true;
            dp[i+1][k][t[i+1]]=true;
          }
        }
      }
    }
 
    int ans=t[L-1];
    for(int i=0;i<=320;i++){
      for(int j=1;j<=320;j++){
        if(dp[L-2][i][j]){
          ans=max(ans,t[L-1]+i);
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 9312
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    for(;;) {
        cin >> n;
        map<char, int> mp;
        if(n == 0) break;
        char e;
        char c[110];
        e = c[0];
        rep(i, n) cin >> c[i];
        rep(i, n) {
            
            mp[c[i]] ++;

            if(mp[e] < mp[c[i]]) e = c[i];
            int l = n - i - 1;
            bool flag = true;
            rep(j, 27) {
                char d = 'A' + j;
                if(e == d) continue;
                if(mp[e] <= mp[d] + l) {
                    flag = false;
                }
            }
            if(flag) {
                cout << e << " " << i + 1 << endl;
                break;
            }
            if(i == n - 1) {
                    cout << "TIE" << endl;
                    break;
            }
        }
    }
	return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int L, A, B, C, D;
	int aa, bb;
	cin >> L >> A >> B >> C >> D;
	if (A % C == 0) {
		aa = A / C;
	} else {
		aa = A / C + 1;
	}
	if (B % D == 0) {
		bb = B / D;
	} else {
		bb = B / D + 1;
	}
	cout << L - max(aa, bb) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
typedef long long ll;
typedef pair<ll,ll> P;
int main()
{
  ll n,k,i,res;
  P p[N_MAX];
  cin >> n >> k;
  for(i=0;i<n;i++)
    cin >> p[i].first >> p[i].second;
  sort(p,p+n);
  for(i=0;i<n;i++){
    k-=p[i].second;
    if(k<=0){
      cout << p[i].first << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 5176
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N;
  cin >> N;
  vector<long> b(N);
  rep (i, N) cin >> b[i];
  vector<long> answer;
  while (b.size() > 0) {
    long max_pos = -1;
    rep (i, b.size()) {
      if (b[i] > i + 1) {
        cout << -1 << endl;
        return 0;
      }
      if (b[i] == i + 1) {
        max_pos = i;
      }
    }
    if (max_pos == -1) {
      cout << -1 << endl;
      return 0;
    }
    answer.push_back(max_pos + 1);
    b.erase(b.begin() + max_pos);
  }
  for (auto it = answer.rbegin(); it != answer.rend(); it++) {
    cout << *it << endl;
  }
  return 0;
}


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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
 int n, a, b;
 cin >> n >> a >> b;
 cout << min(a*n,b) << endl;
}

Measured memory_bytes: 3604
a = list(input())
b = list(input())
c = list(input())

n = "a"
ok = False
while not ok:
  if n == "a":
    if len(a) == 0: 
      ok = True
      break
    n = a[0]
    a.pop(0)
  elif n == "b":
    if len(b) == 0: 
      ok = True
      break
    n = b[0]
    b.pop(0)
  else:
    if len(c) == 0: 
      ok = True
      break
    n = c[0]
    c.pop(0)
print(n.upper())

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int count=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        for(int j=2;j<=sqrt(a[i]);j++){
            if(a[i]%j==0){
                count++;
                break;
            }
        }
    }
    cout << n-count << endl;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		double ans = i * 1.08;
		if ((int) ans == n) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << ":(" << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int a, b, x;
    // a: known cats; b:animals; x: qntd of cats
    
    scanf("%d %d %d", &a, &b, &x);
    
    if (a+b<x || a>x){
        printf("NO\n");
    }
    else{
        printf("YES\n");
    }
    
    return 0;
}


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

int main() {
	int n;
	string s;
	cin>>n;
	cin>>s;
	int count = 0;
	for(int i=0; i<n-2; i++){
	    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
	        count++;
	    }
	}
	cout<<count;
}

Measured memory_bytes: 256
# 辞書を用意して最大値を取得する

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

cnt = {}

for i in a:
    for j in [-1,0,1]:
        cnt.setdefault(i+j, 0)
        cnt[i+j] += 1

print(max(cnt.values()))

Measured memory_bytes: 20692
#include<stdio.h>
int main()
{
    int r;
scanf("%d",&r);

if (r < 1200)

    printf("ABC");

else if (1200 <= r &&  r< 2800)

    printf("ARC");

else{
        if (2800<=r && r <= 4208);

    printf("AGC");
}
    return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CSpecialTrains {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] c = new int[n - 1]; // 乗車時間
            int[] s = new int[n - 1]; // 開業時刻
            int[] f = new int[n - 1]; // 運転間隔
            for (int i = 0; i < n - 1; i++) {
                c[i] = in.nextInt();
                s[i] = in.nextInt();
                f[i] = in.nextInt();
            }

            for (int i = 0; i < n; i++) {
                long time = 0;
                for (int j = i; j < n - 1; j++) {
                    if (time < s[j]) {
                        time = s[j];
                    }
                    time = (time + f[j] - 1) / f[j] * f[j];
                    time += c[j];
                }
                out.println(time);
            }
        }

    }
}



Measured memory_bytes: 26500
def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            n=int(a/b)
            return gcd(a-n*b,b)
        else:
            n=int(b/a)
            return gcd(a,b-n*a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    string a,b; cin>>a>>b;
    string ans="";
    rep(i,n){
        ans=ans+a[i]+b[i];
    }
    cout<<ans<<endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    int ans = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3108
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int[][] a = new int[3][3];
			int[][] c = new int[3][3];
			
			int n;
			
			for(int i=0;i<3;i++) {
				for(int j=0;j<3;j++) {
					a[i][j]= sc.nextInt();
				}
			}
			
			n = sc.nextInt();
			int[] b = new int[n];
			for(int i=0;i<n;i++) {
				b[i] = sc.nextInt();
			}
			
			for(int k=0;k<n;k++) {
				for(int i=0;i<3;i++) {
					for(int j=0;j<3;j++) {
						if(b[k]==a[i][j]) {
							c[i][j]=1;
						}
					}
				}
			}
			
			if(c[0][0]==1&&c[0][1]==1&&c[0][2]==1) {
				System.out.println("Yes");
				return;
			}
			
			
			if(c[1][0]==1&&c[1][1]==1&&c[1][2]==1) {
				System.out.println("Yes");
				return;
			}
			
			if(c[2][0]==1&&c[2][1]==1&&c[2][2]==1) {
				System.out.println("Yes");
				return;
			}
			
			if(c[0][0]==1&&c[1][0]==1&&c[2][0]==1) {
				System.out.println("Yes");
				return;
			}
			
			if(c[0][1]==1&&c[1][1]==1&&c[2][1]==1) {
				System.out.println("Yes");
				return;
			}
			
			if(c[0][2]==1&&c[1][2]==1&&c[2][2]==1) {
				System.out.println("Yes");
				return;
			}
			
			if(c[0][0]==1&&c[1][1]==1&&c[2][2]==1) {
				System.out.println("Yes");
				return;
			}
			
			if(c[2][0]==1&&c[1][1]==1&&c[0][2]==1) {
				System.out.println("Yes");
				return;
			}
			
			System.out.println("No");
		}
	}


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

int main() {
    int K;
    cin >> K;
    
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << vec.at(K-1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    static public void main(String[] av){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int A[] = new int[n];
	for(int i=0; i<n; i++){
	    A[i] = sc.nextInt();
	}

	for(int i=0; i<n; i++){
	    int v = A[i];
	    int j = i-1;
	    while(j>=0 && A[j]>v){
		A[j+1] = A[j];
		j--;
	    }
	    A[j+1] = v;
	    System.out.print(A[0]);
	    for(int x=1; x<n; x++){
		System.out.print(" "+A[x]);
	    }
	    System.out.println();
	}
    }
}




Measured memory_bytes: 32948
N, K = map(int, input().split())

answer = 0
for value in range(1, N+1):
    number_of_front = 0
    while True:
        if value >= K:
            break
        value = value*2
        number_of_front += 1
    answer += 0.5 ** number_of_front

print(answer/N)

Measured memory_bytes: 9404
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        dfs(n, (char) ('a' - 1), new StringBuilder());
    }

    private static void dfs(int n, char max, StringBuilder s) {
        if (s.length() == n) {
            System.out.println(s.toString());
            return;
        }
        for (char c = 'a'; c <= max + 1; c++) {
            StringBuilder temp = new StringBuilder(s.toString());
            temp.append(c);
            dfs(n, (char) Math.max(c, max), temp);
        }
    }
}

Measured memory_bytes: 48104
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
b = 0
c = 0
d = ""
l = 1 / (4 * m)
for i in a:
    b += i
b = b * l
while c < m:
  if a[c] < b:
    d = "No"
  else:
    d = "Yes"
  c += 1
print(d)

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

using namespace std;

int main(){
    string S;
    cin >> S;
    bool f = true;
    int l = S.length();

    if (l < 5 || l >= 10){
        f = false;
    }
    
    vector <char> s(9);
    for (int i = 0; i < min(9, l); i++){
        s[i] = S[i];
    }

    if (s[0] != 'A'){
        for (int i = 8; i >= 1; i--){
            s[i] = s[i - 1];
        }
        s[0] = 'A';
    }
    
    if (s[4] != 'A'){
        for (int i = 8; i >= 5; i--){
            s[i] = s[i - 1];
        }
        s[4] = 'A';
    }

    if (s[6] != 'A'){
        for (int i = 8; i >= 7; i--){
            s[i] = s[i - 1];
        }
        s[6] = 'A';
    }

    if (s[8] != 'A'){
        s[8] = 'A';
    }
    
    string K = "AKIHABARA";

    for (int i = 0; i < 9; i++){
        if (s[i] != K[i]){
            f = false;
            break;
        }
    }
    
    if (f == true){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using namespace std;

void solve() {
    string s;
    cin >> s;
    int flag1 = 0, flag2 = 0;
    for (auto x : s) {
        if (x == 'A') flag1 = 1;
        else flag2 = 1;
    }
    if (flag1 && flag2)
        cout << "Yes";
    else
        cout << "No";
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

int main(){
	long long r,d,x;
	cin>>r>>d>>x;
	for(int i=0;i<10;i++){
		cout<<r*x-d<<endl;
		x=r*x-d;
	}
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if( s[0] != '1' || s[n-1] != '0' ) { puts("-1"); return 0; }
  int croot = 1;
  int idx = 3;
  typedef pair<int,int> ii;
  vector<ii> vec;
  vec.push_back(ii(1,2));
  REP(i,1,n-1) {
    if( s[i] == '0' ) {
      vec.push_back(ii(croot,idx++));
    } else {
      vec.push_back(ii(croot,idx));
      int rem = n - idx + 1;
      if( s[rem-1] == '0' ) { puts("-1"); return 0; }
      croot = idx++;
    }
  }
  rep(i,(int)vec.size()) {
    cout << vec[i].first << " " << vec[i].second << endl;
  }
  compute();
  return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	ll int n,i,ans=0;
	cin>>n;
	ll int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=1;i<n;i++){
		if(a[i-1]<=a[i])
		continue;
		else{
			ans+=a[i-1]-a[i];
			a[i]+=(a[i-1]-a[i]);
		}
	}
	cout<<ans;
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 5176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();

		int ans = 1;
		int now = 0;
		for (int i = 0; i < n; i++) {
			now += l[i];
			if (now <= x) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans;
    
    ans = max({a,b,c}) - min({a,b,c});
    
    cout << ans << endl;
    
    return 0;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#define maxn 105

using namespace std;

char s[maxn];

int main()
{
    scanf("%s",s);
    int l=strlen(s);
    if (l&1)
    {
        cout <<"No";
        return 0;
    }
    bool f=1;
    for (int i=0;i<l;i+=2) if (s[i]=='h' && s[i+1]=='i') ;
    else f=0;
    if (f) cout <<"Yes";
    else cout <<"No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long  MOD=1000000007;
long long  binary_exp(long long  a,long long  b)
{
  long long  ans=1;
  while(b>0)
  {
    if(b&1)
    {
      ans=(ans*a);
    }
    a=(a*a);
    b=b>>1;

  }
  return ans;
}

map<long long ,long long > mp;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  long long  T;
  T=1;
  while(T--)
  {
    int n;
    cin>>n;
    vector<int> v(4,0);
    while(n--)
    {
      string s;
      cin>>s;
      if(s=="AC")
      v[0]++;
      else if(s=="WA")
      v[1]++;
      else if(s=="TLE")
      v[2]++;
      else
      v[3]++;
    }
    cout<<"AC x "<<v[0]<<endl;
    cout<<"WA x "<<v[1]<<endl;
    cout<<"TLE x "<<v[2]<<endl;
    cout<<"RE x "<<v[3]<<endl;
  }
   return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int l[4][3][10] = {};
    int n,b,f,r,v;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        l[b-1][f-1][r-1] += v ;
        
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10 ; k++){
                cout << " " << l[i][j][k];
            }
            cout << endl;
        }
        if(i < 3){
            cout << "####################" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
string str;
  cin>>str;
  if(str[0]=='S'){
cout<<"Cloudy"<<endl;
  }else if(str[0]=='C'){
cout<<"Rainy"<<endl;
  }else{
cout<<"Sunny"<<endl;
  }
  return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


vii G(51);
vi a, b;
vector<bool> used(51, false);

bool dfs(int now, int goal) {
	if (now == goal) {
		return true;
	}
	used[now] = true;
	bool flag = false;
	rep(i, G[now].size()) {
		if (!used[G[now][i]]) {
			flag |= dfs(G[now][i], goal);
		}
	}
	return flag;
}

int main() {
	int n;
	cin >> n;
	a.resize(n); b.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, 51) {
		rep1(j, 50) {
			G[i].push_back(i % j);
		}
		sort(G[i].begin(), G[i].end());
		G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
	}

	
	rep(i, n) {
		fill(used.begin(), used.end(), false);
		if (!dfs(a[i], b[i])) {
			cout << -1 << endl;
			return 0;
		}
	}
	vi must;
	int ma = 50;
	while(ma > 0){
		rep(i, 51) {
			G[i].clear();
			rep1(j, ma - 1) {
				G[i].push_back(i%j);
			}
			rep(j, must.size()) {
				G[i].push_back(i%must[j]);
			}
			sort(G[i].begin(), G[i].end());
			G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
		}
		rep(i, n) {
			fill(used.begin(), used.end(), false);
			if (!dfs(a[i], b[i])) {
				must.push_back(ma);
				break;
			}
		}
		ma--;
	}
	ll ans = 0;
	rep(i, must.size()) {
		ans |= (1LL << must[i]);
	}
	cout << ans << endl;
}

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	accumulate(s.begin(), s.end(), 0, [&](int x, char y){ return x + y - '0'; }) % 9 ? cout << "No\n" : cout << "Yes\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3736
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 2097153
int n,K,f[N],g[N],s[21][N>>1],len,ans=-1,ans1=0,le[24],all;char sc[N];
int main(){
	for(int i=0;i<=20;i++)le[i]=(1<<i)-1;all=(1<<21)-1;
	scanf("%d%d",&n,&K);int i,j,k,v,v1,v2;
	for(i=0;i<=n;i++){scanf("%s",sc);for(k=0;k<(1<<i);k++)if(sc[k]=='1'){v=1;for(j=0;j<i;j++)v=(v<<1)|((k>>j)&1);++f[v];}}
	for(i=0;i<=n;i++)
	{
		memset(g,0,sizeof(g));for(j=(1<<i);j<N;j++)s[i][j&le[i]]+=f[j];
		for(j=1<<(i+1);j<N;j++)
		if(v=f[j])
		{
			v1=j>>i;v1=v1>>(__builtin_ctz(v1)+1);if(v1)g[(v1<<(i+1))|(((j&le[i])<<1)|1)]+=v;
			v2=j>>i;v2=v2>>(__builtin_ctz(v2^all)+1);if(v2)g[(v2<<(i+1))|((j&le[i])<<1)]+=v;
		}
		memcpy(f,g,sizeof(g));
	}
	for(i=0;i<=n;i++)
	for(j=0;j<(1<<n);j++)if(s[i][j]>=K){if(i==ans)ans1=min(ans1,j);if(i>ans){ans=i;ans1=j;}}
	for(i=ans-1;i>=0;i--)printf("%d",(ans1>>i)&1);return 0;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = false;
  int num = 0;

  int x, a, b; cin >> x >> a >> b;

  a = abs(x - a);
  b = abs(x - b);

  if (a < b) cout << "A";
  else cout << "B";
  cout << endl;
  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 998244353;

int N;
bitset<4000> X, res, cur;
vector<bitset<4000>> A;
ll ans = 0, po2[4001];
int t;

bitset<4000> con() {
    string z; cin >> z;
    bitset<4000> b;
    F0R(i,z.length()) b[z.length()-1-i] = int(z[i]-'0');
    return b;
}

int ms(bitset<4000>& b) {
    F0Rd(i,4000) if (b[i] == 1) return i;
    return -1;
}

void solve() {
	while (1) {
	    int x = ms(X), y = ms(res);
	    auto a = res<<(x-y);
	}
}

void init() {
    ios_base::sync_with_stdio(0);cin.tie(0);
	F0R(i,A.size()) if (ms(A[i]) >= 0) res = A[i];
	po2[0] = 1;
	FOR(i,1,4001) po2[i] = 2*po2[i-1] % MOD;
	cin >> N; A.resize(N);
	X = con();
	F0R(i,N) A[i] = con();
	
	F0R(i,A.size()) F0R(j,i) {
	    while (1) {
	        int x = ms(A[j]), y = ms(A[i]);
	        if (x < 0 || y < 0) break;
	        if (x > y) A[j] ^= (A[i]<<(x-y));
	        else A[i] ^= (A[j]<<(y-x));
	    }
	}
	
	F0R(i,A.size()) if (ms(A[i]) >= 0) res = A[i];
}

void solve(int ind) {
    if (ind < 0) {
        F0Rd(i,4000) if (cur[i] != X[i]) {
            if (cur[i] < X[i]) ans = (ans+1) % MOD;
            return;
        }
        ans = (ans+1) % MOD;
        return;
    }
    if (cur[ind+t] == 0) { 
        if (X[ind+t] == 0) {
            solve(ind-1);
        } else {
            ans = (ans+po2[ind]) % MOD;
            cur ^= (res<<ind);
            solve(ind-1);
        }
    } else { 
        if (X[ind+t] == 0) { // 1, 0
            cur ^= (res<<ind);
            solve(ind-1);
        } else { // 1, 1
            ans = (ans+po2[ind]) % MOD;
            solve(ind-1);
        }
    }
}

int main() {
	init();
	t = ms(res);
	solve(ms(X)-t);
	cout << ans;
}

// read!
// ll vs. int!

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N 1000000
bool p[1000000];
int main(){
  int n;

  for(int i=0;i<N;i++)p[i]=true;
  p[0]=p[1]=false;

  for(int i=0;i<=N/2;i++)
    if(p[i]==true)
      for(int j=i*2;j<N;j+=i)
	p[j]=false;

  while(cin>>n){
    int count=0;
    for(int i=0;i<=n;i++)
      if(p[i]==true)count++;
    cout<<count<<endl;
  }
  return 0;
}

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

using namespace std;
int l,r,a=5000000,c,x,y;
int main(){
	cin>>l>>r;
	x=l%2019,y=r%2019;
	if(r-l>=2018){
		cout<<0<<endl;
		return 0;
	}
	if(x>=y)y+=2019;
	
	for(int i=x;i<y;i++){
		for(int j=i+1;j<=y;j++){
			c=i*j;
			c%=2019;
			a=min(a,c);
		
		}
	}
	cout<<a<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		VVI m(3, VI(3));
		m[0][0]=N;
		REP(i, 3) REP(j, 3) if(i+j!=0) cin>>m[i][j];
		ll ok=1;
		REP(x, 2) REP(y, 3) if(m[0][x+1]-m[0][x] != m[y][x+1]-m[y][x]) ok=0;
		REP(y, 2) REP(x, 3) if(m[y+1][0]-m[y][0] != m[y+1][x]-m[y][x]) ok=0;
		cout<<YN(ok)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# AtCoder
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = []
for i in range(N):
    if T[i] == 's':
        ans.append('r')
    elif T[i] == 'r':
        ans.append('p')
    elif T[i] == 'p':
        ans.append('s')

    if i >= K:
        if ans[i-K] == ans[i]:
            ans[i] = ''

count = 0
for i in range(N):
    # あいこ処理　
    if (T[i] == ans[i]) or ('' == ans[i]):
        continue

    if ans[i] == 'r':
        count += R
    elif ans[i] == 's':
        count += S
    elif ans[i] == 'p':
        count += P

print(count)


Measured memory_bytes: 74544
import java.util.Scanner;
 
public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(Math.min(A, B) + " " + Math.max(-(N - A - B), 0));
    }
}

Measured memory_bytes: 23764
while True:
    H,W= map(int,input().split())
    if H==0 and W==0:
        break
    for h in range(H):
        for w in range(W):
            if (h+w)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int b = sc.nextInt();
		int c = sc.nextInt();
		int a = sc.nextInt();
		System.out.println(a + " " + b + " " + c);

	}

}


Measured memory_bytes: 22228
n = int(input())
a = list(map(int, input().split()))
d = [0]*(10**5+1)
t = 0
for i in range(n):
    t += a[i]
    d[a[i]] += 1
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    t += (c-b)*d[b]
    d[c] += d[b]
    d[b] = 0
    print(t)

Measured memory_bytes: 20980
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    int a ,b ,c;
    cin >> a >> b >> c;
    int d = max(a,b) ;
    int e = min(a,b) ;
    int f = max(d,c) ;
    int t = min(d,c) ;
    cout << f *10 + t + e;
    return 0;
}


Measured memory_bytes: 3632
def read_input():
    n = int(input())

    stations = []
    for i in range(n - 1):
        c, s, f = map(int, input().split())
        stations.append((c, s, f))

    return n, stations


# 時刻currにてstationにいるとして、次の駅にたどり着く時刻を求める
def time_calc(curr, station):
    if curr <= station[1]:
        return station[0] + station[1]

    diff = curr - station[1]
    if diff % station[2] == 0:
        coef = diff // station[2]
    else:
        coef = diff // station[2] + 1
    return station[0] + station[1] + coef*station[2]


def total_time(stations):
    curr = 0
    for station in stations:
        curr = time_calc(curr, station)

    return curr


def submit():
    n, stations = read_input()

    for i in range(n - 1):
        print(total_time(stations[i:]))
    print(0)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 40176
n, k = list(map(int, input().split()))
#from collections import deque
if n < k:
    c = k//2  # 作れるccとsの数
    # print(c)
    # print(c-n)　#nコScc c-nがあまりの分
    # print((c-n)//2)
    print(n+(c-n)//2)
else:
    c = k//2
    print(c)


Measured memory_bytes: 2940
n,m = gets.split(" ").map(&:to_i)
a = []
sum = []
mm = m
n.times.each do |i|
  sum = 0
  a[i] = gets.split(" ").map(&:to_i)
end
a.sort!
n.times.each do |i|
  if a[i][1] < mm
    sum += a[i][0]*a[i][1]
    mm = mm - a[i][1]
  else
    sum += a[i][0] * mm
    break
  end
end
puts sum

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> edge;

ll A[1000000];
ll B[1000000];
double C[100][100];
ll n;
bool comp(const ll& left, const ll& right) {
        return A[left] < A[right];
}

int main(){
    ll n;
    string ss;
    cin >> n;
    cin >> ss;

    for( ll i=0; i<ss.length(); i++){
        ss[i] += n;
        if( ss[i] > 'Z' ) ss[i] -= 'Z' - 'A' + 1;
    }
 
    cout << ss << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,a[9999];
	for  (i = 0; ; (i++))
	{
		scanf("%d", &a[i]);
		if (a[i] == 0)
			break;
	}
	for ( i = 0;; i++)
	{
		if (a[i] == 0)
			break;
		else		
			printf("Case %d: %d\n", i+1, a[i]);
	}
	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int flag=0;
    
    sort(S.begin(), S.end());
    
    for(int i=0; i<S.size()-1; i++){
        if(S[i]==S[i+1]){
            flag=1;
            break;
        }
    }
    if(flag) cout << "no" << endl;
    else cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator>> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m, t;
	cin >> n >> m >> t;
	vi a(n); cin >> a;
	int ans = a[0] - m;
	REP(i, n - 1)
	{
		ans += max(0, a[i + 1] - a[i] - m * 2);
	}
	ans += max(0, t - a[n - 1] - m);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3228
#include <iostream>

using namespace std;

int main(){
        char a, b;

        cin >> a >> b;

        bool tcd;
        if(b == 'H')
                tcd = 1;
        else if(b == 'D')
                tcd = 0;

        if(a == 'D')
                tcd = !tcd;

        if(tcd)
                cout << "H" << endl;
        else
                cout << "D" << endl;

        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
  char str[26] = {0};
  int flag[26] = {0};
  scanf("%s",str);

  int i;

  for(i = 0;i<26;i++){
     if(str[i] == 0)
       continue;

     if(flag[str[i]%26] == 1){
       printf("no");
       return 0;
     }
     flag[str[i]%26]++;

  }
  printf("yes");
  return 0;
}


Measured memory_bytes: 128
// Be name khoda
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 1e5 + 5;
int n;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	if (n == 25)
		cout << "Christmas";
	if (n == 24)
		cout << "Christmas Eve";
	if (n == 23)
		cout << "Christmas Eve Eve";
	if (n == 22)
		cout << "Christmas Eve Eve Eve";
	return 0;
}

Measured memory_bytes: 256
def dout(chrs):
    for i in range(26):
        print(chr(97 + i))
        print(chrs[i])

Schrs = [list() for i in range(26)]
Tchrs = [list() for i in range(26)]
S = input()
T = input()
# Scan the S String
for i in range(0, len(S)):
    Schrs[ord(S[i]) - 97].append(i)
for i in range(0, len(T)):
    Tchrs[ord(T[i]) - 97].append(i)

ans = 'Yes'
for i in range(26):
    if len(Schrs[i]) >= 2:
        TargetChr = T[Schrs[i][0]]
        TargetIndex = ord(TargetChr) - 97
        if Schrs[i] != Tchrs[TargetIndex]:
            print('No')
            exit(0)
for i in range(26):
    if len(Tchrs[i]) >= 2:
        TargetChr = S[Tchrs[i][0]]
        TargetIndex = ord(TargetChr) - 97
        if Tchrs[i] != Schrs[TargetIndex]:
            print('No')
            exit(0)

print(ans)

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

int main(void) {
  int n,  m;
  scanf("%i %i", &n, &m);
  
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    scanf("%i %i", &a[i], &b[i]);
  }
  
  int c[m], d[m];
  for (int i = 0; i < m; i++) {
    scanf("%i %i", &c[i], &d[i]);
  }
  
  for (int i = 0; i < n; i++) {
    int best = 1 << 30, idx = -1;
    for (int j = 0; j < m; j++) {
      int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dist < best) {
        best = dist;
        idx = j;
      }
    }
    
    printf("%i\n", idx + 1);
  }
  
  return 0;
}

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

signed main() {
  int N, M;
  cin >> N >> M;
  
  int kake = 1;
  for( int i = 0; i < M; i++ ) kake *= 2;
  
  int ans = ((N-M)*100 + M*1900)*kake;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll D;
ll c[26+1];
ll s[365+1][26+1];

ll last[365+1];

void input(){
    cin>>D;
    repn(i,26) cin>>c[i];
    repn(i,D) repn(j,26) cin>>s[i][j];
}

// 貪欲法2
void solve2(){
    ll v[27][400];
    ll max_score=-LINF;
    ll max_idx=0;
    rep(k,27){
        ll score=0;
        fill(last,last+27,0);
        repn(d,D+k){
            ll maxi=-LINF;
            ll idx=0;
            repn(i,26){
                ll res=0;
                if(d<=D) res+=s[d][i];
                repn(j,26){
                    if(i==j) continue;
                    res-=c[j]*(d-last[j]);
                }
                if(maxi<res){
                    maxi=res;
                    idx=i;
                }
            }
            last[idx]=d;
            score+=maxi;
            v[k][d]=idx;
        }
        if(max_score<score){
            max_score=score;
            max_idx=k;
        }
    }

    repn(i,D){
        cout<<v[max_idx][i]<<endl;
    }  
}

int main(){
    input();
    solve2();
}

Measured memory_bytes: 3804
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
p = 10**9+7

# F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数
F = [None] * (N+1)
F[0] = 1
F[1] = 1
for i in range(2, N+1):
  if i-1 in a:
    tmp1 = 0
  else:
    tmp1 = F[i-1]
    
  if i-2 in a:
    tmp2 = 0
  else:
    tmp2 = F[i-2]
    
  F[i] = (tmp1 + tmp2) % p

# 基本的なDPの問題
# dp[v] = dp[v-1] + dp[v-2]だが、
# v-1, v-2は壊れていたら加算しない
print(F[N])

Measured memory_bytes: 13216
using System;
using System.Linq;

namespace ABC129
{
    class D
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int H = input[0];
            int W = input[1];

            string[] S = new string[H];
            for (int i = 0; i < H; i++)
            {
                S[i] = Console.ReadLine();
            }

            int[,] L = new int[H, W];
            int[,] R = new int[H, W];
            int[,] U = new int[H, W];
            int[,] D = new int[H, W];

            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W; w++)
                {
                    if (S[h][w] == '#') { L[h, w] = 0; }
                    else if (w == 0) { L[h, w] = 1; }
                    else if (0 < w) { L[h, w] = L[h, w - 1] + 1; }
                }

                for (int w = W - 1; w >= 0; w--)
                {
                    if (S[h][w] == '#') { R[h, w] = 0; }
                    else if (w == W - 1) { R[h, w] = 1; }
                    else if (w < W - 1) { R[h, w] = R[h, w + 1] + 1; }
                }

            }

            for (int w = 0; w < W; w++)
            {
                for (int h = 0; h < H; h++)
                {
                    if (S[h][w] == '#') { D[h, w] = 0; }
                    else if (h == 0) { D[h, w] = 1; }
                    else if (0 < h) { D[h, w] = D[h - 1, w] + 1; }
                }

                for (int h = H - 1; h >= 0; h--)
                {
                    if (S[h][w] == '#') { U[h, w] = 0; }
                    else if (h == H - 1) { U[h, w] = 1; }
                    else if (h < H - 1) { U[h, w] = U[h + 1, w] + 1; }
                }
            }

            int[,] Res = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    Res[i, j] = L[i, j] + R[i, j] + U[i, j] + D[i, j] - 3;
                }
            }

            int max = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    max = Math.Max(max, Res[i, j]);
                }
            }
            Console.WriteLine(max);
        }
    }
}

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

 int main() {
   string s, ans;
   int K;
   cin >> s >> K;
   vector<string> sub;
   rep(i, 1, 6) {
     rep(j, 0, s.length() + 1 - i) {
       sub.push_back(s.substr(j, i));
     }
   }
   sort(sub.begin(), sub.end());
   sub.erase(unique(sub.begin(), sub.end()), sub.end());
   cout << sub.at(K - 1) << endl;
 }


Measured memory_bytes: 1660