akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> stringDecoded = new ArrayList<String>();
		
		int numLine = Integer.parseInt(br.readLine());
		for(int i = 0; i < numLine; i++){
			String line = br.readLine();
			int[] key = getKey(line);
			stringDecoded.add(decodeString(line, key[0], key[1]));
		}
		
		for(String str : stringDecoded){
			System.out.println(str);
		}
	}
	
	public static String encodeString(String str, int key1, int key2){
		char[] arrayChar = str.toCharArray();
		//a〜zならエンコード
		for(int i = 0; i < arrayChar.length; i++){
			if( 0 <= (arrayChar[i] - 'a') && (arrayChar[i] - 'a') <= 25){
				int codeEncoded = ((arrayChar[i] - 'a') * key1 + key2) % 26;
				arrayChar[i] = (char)(codeEncoded + 'a');
			}
		}
		return String.copyValueOf(arrayChar);
	}
	
	public static String decodeString(String str, int key1, int key2){
		char[] arrayChar = str.toCharArray();
		//a〜zならデコード
		for(int i = 0; i < arrayChar.length; i++){
			int codeEncoded = arrayChar[i]- 'a' - key2;
			if(0 <= (arrayChar[i] - 'a') && (arrayChar[i] - 'a') <= 25){
				while(codeEncoded % key1 != 0){
					codeEncoded += 26;
				}
				int codeDecoded = (codeEncoded / key1) % 26;
				arrayChar[i] = (char)(codeDecoded + 'a');
			}
		}
		return String.copyValueOf(arrayChar);
	}
	
	public static boolean successDecode(String str, int key1, int key2){
		String stringDecoded = decodeString(str, key1, key2);
		if(stringDecoded.indexOf("that") > -1 || stringDecoded.indexOf("this") > -1){
			return true;
		}
		else{
			return false;
		}
	}
	
	public static int[] getKey(String str){
		int[] key = new int[2];
		for(int key1 = 1; key1 <= 25; key1 += 2){
			if(key1 == 13) continue;
			for(int key2 = 0; key2 <= 25; key2++){
				if(successDecode(str, key1, key2)){
					key[0] = key1;
					key[1] = key2;
					return key;
				}
			}
		}
		return key;
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> ans(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
    int s = vec.at(i) - 1;
    ans.at(s) = i + 1;
  }
  for(int i = 0; i< N; i++){
    if(i != N - 1){
      cout << ans.at(i) << ' ';
    }
    else{
      cout << ans.at(i) << endl;
    }
  }
}
  

Measured memory_bytes: 1536
package main

import (
	"fmt"
)

func main() {
	var line, row int
	fmt.Scan(&line, &row)

	// two dimention
	a := make([][]int, line)
	for i := 0; i < line; i++ {
		a[i] = make([]int, row)
	}
	for i := 0; i < line; i++ {
		for j := 0; j < row; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	// one dimention
	b := make([]int, row)
	for i := 0; i < row; i++ {
		fmt.Scan(&b[i])
	}

	for i := 0; i < line; i++ {
		var result int
		for j := 0; j < row; j++ {
			result += a[i][j] * b[j]
		}
		fmt.Println(result)
	}
}



Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


int main(){
 intl X;
  cin >> X;
  intl money = 100;
  int count = 0; 
  while( money < X){
    money = money * 1.01;
    count ++;
  }
  cout << count;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int k=sc.nextInt();
int x=sc.nextInt();
if(k==1)
System.out.println(x);
else
{
int s=x-k+1;
int e=x+k-1;
for(int i=s;i<=e;i++)
System.out.print(i+" ");
}
}

}

Measured memory_bytes: 22868
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#else
	#define DEBUG(x) true
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> LP;
typedef pair<LL,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	LL l;
	cin >> n >> l;
	vector<LL> a(n);
	REP(i,n) cin >> a[i];
	string ans = "Impossible";
	int hoge = -1;
	REP(i,n-1){
		if(a[i]+a[i+1] >= l){
			ans = "Possible";
			hoge = i;
			break;
		}
	}
	cout << ans << endl;
	if(hoge != -1){
		REP(i,hoge){
			cout << i+1 << endl;
		}
		RFOR(i,hoge+1,n-1){
			cout << i+1 << endl;
		}
		cout << hoge+1 << endl;
	}
	return 0;
}


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

int n;
int memo[35];

int solve(int n){
  if(memo[n] != -1)return memo[n];
  int rec = 0;
  if(n == 0 || n == 1)return memo[n] = 1;
  else if(n == 2)return memo[n] = 2;
  for(int i = 1;i <= 3;i++){
    rec += solve(n - i);
  }
  return memo[n] = rec;
}

int main(){
  while(cin >> n , n){
    memset(memo,-1,sizeof(memo));
    int ans = solve(n);
    cout << (ans - 1) / 3650 +1 <<endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int N; cin >> N;
    vector<int> ans;
    while(N != 0) {
        for (int i = 1; ; ++i) {
            if (i*(i-1)/2 < N && N <= (i+1)*i/2) {
                ans.push_back(i);
                N -= i;
                break;
            }
        }
    }

    rep(i,ans.size()) {
        out(ans[i]);
    }

    return 0;
}









Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
	
	var Input = input.split("\n");
	
  	var N = parseInt(Input[0],10);
  	
  	var cnt = 0
  
    var arr = Input[1].split(" ")
    
  	for(var i in arr){
      for(var j in arr){
        var x = parseInt(arr[i],10);
        var y = parseInt(arr[j],10);
        if(i != j){
        var ans = x * y
        cnt = cnt + ans
        }
      }
    }
  
  cnt = cnt / 2
  
	//出力
	console.log(cnt);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

int main()
{
  int N;
  cin >> N;
  
  vector<int> A1, A2;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A1.push_back(a);
  }
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A2.push_back(a);
  }
  
  int max = 0;
  for (int i = 0; i < N; i++)
  {
    int sum = 0;
    for (int j = 0; j <= i; j++)
      sum += A1[j];
    for (int j = i; j < N; j++)
      sum += A2[j];
    if (sum > max)
      max = sum;
  }
      

    RESULT_OUTPUT(max);

	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
    using System.Collections.Generic;
    using System.Linq;
     
    class program{
    	static void Main(string[] args){
        	string[] input = Console.ReadLine().Split(' ');
          	int N = int.Parse(input[0]);
          	int K = int.Parse(input[1]);
          	int ans = K;
          	for(int i = 0;i < N - 1; i ++){
            	ans = ans * (K - 1);
            }
          	Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main(){
  ll n,m,x;
  cin >> n >> m >> x;
  
  vector<ll>c(n);
  vector<vector<ll>>a(n,vector<ll>(m));
  
  for(int i=0; i<n; i++){
    cin >> c[i];
    for(int j=0; j<m; j++){
      cin >> a[i][j]; 
    }

  }
  
  ll Ans=10e9;
  
  for(int i=0; i< 1<<n; i++){
    vector<ll>ans(m,0);
    bool judge = true;
    ll count=0;
    for(int j=0; j<n; j++){
     if(i>>j & 1){
      count+=c[j];
      for(int k=0; k<m; k++){
        ans[k]+=a[j][k];
      }
     }
    }
    
    for(int j=0; j<m; j++){
     if(ans[j]<x)judge=false;
     //cout << ans[j] << endl;
    }
    
    //cout << i << " " << judge << endl;
    if(judge) Ans=min(count,Ans);
    
  }
  
  if(Ans==10e9) cout << -1 << endl;
  else cout << Ans << endl;
  
  return 0;
}
  
  


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll N, M;

    cin >> N >> M;

    vector<p> C, ans;
    vector<vector<ll>> H(N + 1);

    ll P, Y;

    rep(i, M) {
        cin >> P >> Y;
        C.emplace_back(P, Y);
        H[P].push_back(Y);
    }

    rep(i, N + 1) {
        sort(H[i].begin(), H[i].end());
    }


    rep(i, M) {
        P = C[i].first;      
        Y = find(H[P].begin(), H[P].end(), C[i].second) - H[P].begin() + 1;
        ans.emplace_back(P, Y);
    }

    char fillSaved = cout.fill('0');

    rep(i, M) {
        cout << setw(6) << ans[i].first << setw(6) << ans[i].second << endl;
    }

    cout.fill(fillSaved);

    return 0;
}



ll gcd(ll a, ll b) {
    if (a % b == 0)return(b);
    else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

Measured memory_bytes: 13044
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    n = int(input().strip())
    h = list(map(int, input().split()))
    cnt=0
    cnt_max=0
    for i in range(n-1):
        if h[i] >= h[i+1]:
            cnt+=1
        else:
            cnt_max=max(cnt,cnt_max)
            cnt=0
    print(max(cnt_max,cnt))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 87912
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<string>
#include<iostream>
#define R(i, n) for(int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d",  &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a);
#define PY printf("%s", "Yes");
#define PN printf("%s", "No");
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> IR;

int main(){
	int n;
	S(n);
	vector<ll> dp(n + 1);
	dp[0] = 2;
	dp[1] = 1;
	for(int i = 2; i <= n; i++) dp[i] = dp[i -1] + dp[i -2];
	PL(dp[n]);

}

Measured memory_bytes: 3792
import java.util.*;

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

		// 入力
		Scanner sc = new Scanner(System.in);
		
		// 数値
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		int ans = 0;
		if (a+b >= x && a <= x) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll mod;
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll mod=2019;
    string s;cin>>s;
    ll n=s.size();
    vvi v(mod);
    vi t(n);
    ll sum=0;
    ll k=1,ans=0;
    for(ll i=n-1;i>=0;i--){
        sum+=(s[i]-'0')*k;
        k*=10;
        k%=mod;
        sum%=mod;
        v[sum].pb(n-1-i);
        t[n-1-i]=sum;
        if(sum==0)ans++;
    }
    rep(i,mod)ans+=(v[i].size()*(v[i].size()-1))/2;
    out(ans);
}


Measured memory_bytes: 7884
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int c[n],a[n][m];
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }
    ll ans =INFL;
    bool fl =false;
    rep(bit,(1<<n)){
        vi now(m,0);
        ll sum =0;
        bool f =true;
        rep(i,n){
            if(bit & (1<<i)){
                sum+=c[i];
                rep(j,m){
                    now[j]+=a[i][j];
                }
            }
        }
        rep(i,m){
            if(now[i]<x){
                f=false;
            }
        }
        if(f){
            ans=min(ans,sum);
            fl =true;
        }
    }
    if(ans==INFL)cout<<-1<<endl;
    else cout<<ans<<endl;
    
}


Measured memory_bytes: 3676
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////


int cnt = 0;

bool dp[51][51][51] = {};

void solve(int a , int b , int c , int num){
	//printf("a:%d b:%d c:%d num:%d\n",a,b,c,num);
	if( dp[a][b][c] ){
		//P("done");
		ret;
	}
	else 
		dp[a][b][c] = true;
	
	if( num == 0 ){
		cnt++;
		ret;
	} 
	
	if( num >= 500 && a > 0 ){
		solve( a-1 , b , c , num - 500 );
	}
	
	if( num >= 100 && b > 0 ){
		solve( a , b-1 , c , num - 100 );
	}
	
	if( num >= 50 && c > 0 ){
		solve( a, b ,c-1 , num - 50);
	}
	


}

int main(){
	int a,b,c,d;
	C4(a,b,c,d);
	solve(a,b,c,d);
	P(cnt);
	ret 0;
}

Measured memory_bytes: 384
#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;

ll N;
ll A[100001];
ll B[100001];
ll sum[100002];

int main(){
    cin>>N;
    rep(i,N+1) cin>>A[i];
    for(int i=N;i>=0;i--) sum[i]=sum[i+1]+A[i];
    if(N==0){
        if(A[0]!=1){
            cout<<-1<<endl;
            return 0;
        }
    }

    B[0]=1-A[0];
    rep(i,N-1){
        ll b1=2*B[i]-A[i+1];
        ll b2=sum[i+2];
        B[i+1]=min(b1,b2);
    }

    bool check=true;
    rep(i,N+1){
        if(i!=N){
            if(!(B[i]<=A[i+1]+B[i+1] && A[i+1]+B[i+1]<=2*B[i])){
                check=false;
                break;
            }
        }
        if(!(B[i]<=sum[i+1])){
            check=false;
            break;
        }
    }
    if(!check){
        cout<<-1<<endl;
        return 0;
    }

    ll ans=0;
    rep(i,N+1){
        ans+=A[i]+B[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n, m, p; cin >> n >> m >> p, --m;
    if (n == 0) break;
    V<> x(n); for (int i = 0; i < n; ++i) cin >> x[i];
    int sum = accumulate(begin(x), end(x), 0) * (100 - p);
    int res = x[m] ? sum / x[m] : 0;
    cout << res << '\n';
  }
}


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

using namespace std;

int main() {
  int N, Q;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  for (int i = 1; i <= N; ++i) cin >> V[i] >> W[i];
  cin >> Q;
  constexpr int b = 9;
  vector<pair<int, int>> l1, l2, tmp;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    l1.clear();
    l2.clear();
    auto gen = [&](vector<pair<int, int>> &l, int thr) {
      l.emplace_back(0, 0);
      while (v >= thr) {
        int p1 = 0, p2 = 0;
        while (p1 < l.size() || p2 < l.size()) {
          pair<int, int> nxt;
          if (p1 < l.size() && l[p1].first < l[p2].first + W[v])
            nxt = l[p1++];
          else
            nxt = {l[p2].first + W[v], l[p2++].second + V[v]};
          if (tmp.empty() || tmp.back().second < nxt.second) tmp.push_back(nxt);
        }
        v /= 2;
        l.swap(tmp);
        tmp.clear();
      }
    };
    gen(l1, 1 << b);
    gen(l2, 1);
    int p1 = 0, p2 = 0;
    while (p2 + 1 < l2.size() && l1[p1].first + l2[p2 + 1].first <= L) p2++;
    int ans = l1[p1].second + l2[p2].second;
    while (++p1 < l1.size() && l1[p1].first <= L) {
      while (l1[p1].first + l2[p2].first > L) p2--;
      ans = max(ans, l1[p1].second + l2[p2].second);
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 5368
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
const int p=1e9+7;
ll qmi(ll a, ll k)
{
    ll res = 1;
    while (k)
    {
        if (k & 1) res = (ll)res * a % p;
        a = (ll)a * a % p;
        k >>= 1;
    }
    return res;
}


ll C(int a, int b)
{
    ll res = 1;
    for (ll i = 1, j = a; i <= b; i ++, j -- )
    {
        res = (ll)res * j % p;
        res = (ll)res * qmi(i, p - 2) % p;
    }
    return res;
}


ll lucas(ll a, ll b)
{
    if (a < p && b < p) return C(a, b);
    return (ll)C(a % p, b % p) * lucas(a / p, b / p) % p;
}
int main()
{
    ll n, a, b;
    cin >>n>>a>>b;
    cout <<(qmi(2,n)-(lucas(n,a)%p+lucas(n,b)%p)%p-1+p)%p<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, a, b;
	cin >> a >> b >> n;
	cout << a * min(b - 1, n) / b << endl;
	ggr
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

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

Measured memory_bytes: 3632
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    List<List<Integer>> all = extract(new ArrayList<>(), n);
    List<Integer> p = IntStream.range(0, n)
      .mapToObj(i -> Integer.valueOf(sc.next())).collect(Collectors.toList());
    List<Integer> q = IntStream.range(0, n)
      .mapToObj(i -> Integer.valueOf(sc.next())).collect(Collectors.toList());
    int pIndex = all.indexOf(p) + 1;
    int qIndex = all.indexOf(q) + 1;
    pw.println(Math.abs(pIndex - qIndex));
  }

  static List<List<Integer>> extract(List<Integer> current, int n) {
    Set<Integer> contained = new HashSet<>(current);
    if (current.size() == n) {
      return Arrays.asList(current);
    }
    List<List<Integer>> ans = new ArrayList<>();
    for (int i = 1; i <= n; i++) {
      if (contained.contains(i)) {
        continue;
      }
      List<Integer> copy = new ArrayList<>(current);
      copy.add(i);
      ans.addAll(extract(new ArrayList<>(copy), n));
    }
    return ans;
  }
}


Measured memory_bytes: 61356
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

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

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int par[200000]; //親
int rnk[200000]; //木の深さ

				 //n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
//木のrootを求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rnk[x] < rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

//xとyが同じ集合に属するかどうか
bool same(int x, int y) {
	return find(x) == find(y);
}


struct edge { int pre,to, cnt; };
int main() {
	cin.sync_with_stdio(false);
	ll N;
	cin >> N;
	init(N*2);
	ll M;
	cin >> M;
	bool flag = true;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		unite(a, b + N);
		unite(b, a + N);
		if (same(a, a + N) || same(b, b + N))flag = false;
	}
	int cnt = 0;
	rep(i, N) {
		if (same(0, i))cnt++;
	}
	cout << (flag ? (cnt*(N - cnt) - M) : (N*(N - 1) / 2 - M)) << endl;

	
	return 0;
}

Measured memory_bytes: 1792
def compare(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order:
                return True
                break
            if z[i][3] in [0, 3] and sum(order) % 2:
                return True
                break
            if z[i][3] == 1 and not sum(order) % 2:
                return True
                break
    return False
 
n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
different = True
for i in range(n):
    for j in range(i+1, n, 1):
        if compare(x[i], x[j]):
            different = False
            break
    if not different:
        break
if different:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7768
#include<stdio.h>

#define RMAX 1000000
#define Max 200000
#define Min 2

int main(){
  int n,i;
  int R[RMAX];
  
  scanf("%d",&n);
  if(n>=Min && n<=Max)
    for(i=0; i<n; ++i){
      scanf("%d",&R[i]);
    }

  int min = R[0], max = R[1]-R[0];

  for(i=1; i<n; ++i){
    max = max < R[i] - min ? R[i] - min : max;
    min = min > R[i] ? R[i] : min;
  }

  printf("%d\n",max);
 
  return 0;
}



Measured memory_bytes: 2636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0; i < s.size()-8; ++i){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3616
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 1e5 + 1;
int n , m;

int a[N] , d[N];

main(){
	scanf("%d" , &n);
	ll sum = 0;
	rep(i , 0, n-1)
		scanf("%d" , a + i) , sum += a[i];
	if(sum % (1ll * n * (n + 1)	/ 2ll) != 0)
		ret("NO");
	int k = sum / (1ll * n * (n + 1)/ 2ll);
	rep(i , 0 , n - 1)
		d[i] = -a[i] + a[(i + 1)%n];			

	int cnt = 0; 
	rep(i , 0 , n - 1){
		if(k - d[i] < 0)ret("NO");
		if((k - d[i]) % n != 0)ret("NO");
		cnt += (k - d[i])/n;
	}

	if(cnt != k)ret("NO");
	ret("YES");
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

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

int main() {
	double n;
	while (cin >> n, n >= 0) {
		n *= 16;
		ll a = n;
		
		if (a < n) { puts("NA"); continue; }
		
		int ans[12] = {};
		REP(i, 12) {
			ans[11 - i] = a % 2;
			a /= 2;
		}
		
		if (a > 0) puts("NA");
		else {
			REP(i, 8) putchar('0' + ans[i]);
			putchar('.');
			FOR(i, 8, 12) putchar('0' + ans[i]);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 3196
N,M,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(N):
   a.append(a[i]+A[i])
for i in range(M):
   b.append(b[i]+B[i])
ans,j=0,M
for i in range(N+1):
   if a[i]>K:
      break
   while K-a[i]<b[j]:
      j-=1
   ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47680
while True:
    n, m, s = map(int, input().split())
    if not n:
        break
    n2 = n ** 2
    dpp = [0] * (s + 1)
    dpp[0] = 1

    for i in range(1, n2 + 1):
        dpn = [0] * (s + 1)
        for j in range(i * (i + 1) // 2, s + 1):
            dpn[j] += dpp[j - i] + dpn[j - i]
            if j - m - 1 >= 0:
                dpn[j] -= dpp[j - m - 1]
            dpn[j] %= 100000
        dpp = dpn

    print(dpp[s])

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
int main(){
int M, D, a, b, ans; cin >> M >> D;
for(int m=1; m<=M; m++){
for(int d=22; d<=D; d++){
a=d%10; b=round((d-a)/10);
if(a>=2&&b>=2&&m==a*b){ans++;}
}}
cout << ans << "\n";
}


Measured memory_bytes: 256
// B
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg int n = read(), cnt = 0, k = read();
    for (reg int i = 1; i <= n; i++) {
        reg int x = read();
        if (x >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc147/tasks/abc147_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
constexpr ll MOD=1e9+7;
int main() {
#if LOCAL&01
    //std::ifstream in("./test/sample-3.in"); //input.txt
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N;cin>>N;
    vector<ll> an(N+1);
    FOR(i,1,N+1){
        cin>>an.at(i);
    }    

    ll ans=0;
#if 1
    unordered_map<ll,ll> bitnum;
    FOR(i,1,N+1){
        ll a=an.at(i);
        ll cnt=0;
        while(a>0){
            if(a&(1)!=0) ++bitnum[cnt];
            a>>=1;
            ++cnt;
        }
    }
    for(const auto& b:bitnum){
        dump(b.first,b.second);
        ll k=b.second;
        ll tmp=k*(N-k);
        tmp%=MOD;
        ll sft=(1LL<<b.first)%MOD;
        ans += ((tmp*sft)%MOD);
        ans %= MOD;
    }
#if LOCAL&01
    ll ans2=0;
    FOR(i,1,N){
        FOR(j,i+1,N+1){
            dump(i,j,an[i],an[j],an[i]^an[j])
            ans2 += (an[i] ^ an[j]);
            ans2 %= MOD;
        }
    }
    dump(ans2);
#endif
#endif
    cout<<ans<<endl;

    return 0;
}

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

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

	int b[n - 1];

	for(int i = 0; i < n - 1; i++) {
		cin >> b[i];
	}
	int ans = b[0] + b[n - 2];

	for (int i = 0 ; i < n - 2; i++) {
		ans += min(b[i], b[i + 1]);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    
  int N=0;
  int K=0;
  int count=0;
  
  scanf("%d",&N);
  scanf("%d",&K);
  
  int h[N];
  
  for(int i=0;i<N;i++){
      scanf("%d",&h[i]);
  }
  
  for(int i=0;i<N;i++){
      if(K<=h[i]){
          count = count +1;
      }
  }
  
  printf("%d",count);
  
  return 0;
}
  

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    ll rt; cin >> rt;
    ll rt_min = rt;
    ll profit_max = -INF;
    for (int i=0; i<n-1; i++){
        cin >> rt;
        profit_max = max(profit_max, rt - rt_min);
        rt_min = min(rt_min, rt);
    }
    cout << profit_max << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	long long a[7] = { 0,0,0,0,0,0,0 };
	for (int i = 0; i < 7; i++)cin >> a[i];
	long long cnt = a[1];
	long long cnt2 = 0;
	for (int i = 0; i <= min(20000000LL, min(a[0], min(a[3], a[4]))); i++) {
		long long ret1 = 3 * i;
		long long ret2 = 2 * ((a[0] - i) / 2);
		long long ret3 = 2 * ((a[3] - i) / 2);
		long long ret4 = 2 * ((a[4] - i) / 2);
		cnt2 = max(cnt2, ret1 + ret2 + ret3 + ret4);
	}
	cout << cnt + cnt2 << endl;
	return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
  } else {
    cout << "B" << 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 N = sc.nextInt();
    	long count = 0;
    	for (int i = 0; i < N; i++) {
    		int a = sc.nextInt();
    		count += a-1;
    	}
    	System.out.println(count);
    }
}

Measured memory_bytes: 25704
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

using namespace std;
using ll = long long;

int main()
{
    char b;
    cin >> b;

    if (b == 'A') {
        cout << 'T' << endl;
    } else if (b == 'T'){
        cout << 'A' << endl;
    } else if (b == 'C'){
        cout << 'G' << endl;
    } else if (b == 'G'){
        cout << 'C' << endl;
    }

    return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    cout << a[2] - a[0] << 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 n = sc.nextInt();
        int max = 0;
        int min = 1000000001;
        for(int i=0; i<n; i++){
                int temp = sc.nextInt();
                max = Math.max(max, temp);
                min = Math.min(min, temp);
        }
        System.out.println(max-min);
    }
}


Measured memory_bytes: 22740
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int z=0,y=0,x=0,x2=0;
		while(z<N){
			y=stdIn.nextInt();
			if(y%2==0)
				x++;
			else
				x2++;
			z++;
		}
		if(x2==0||x==0)
			System.out.println("YES");
		else
			if(x2%2==0)
				System.out.println("YES");
			else
				System.out.println("NO");
	}
}

Measured memory_bytes: 51012
#include<bits/stdc++.h>
using namespace std;
const int N=200005; 
vector<int> G[N];
int idx[N];
void DFS(int i,int id){
	if(idx[i]>0) return;
	idx[i]=id;
	for(vector<int>::iterator it=G[i].begin();it!=G[i].end();++it)
		DFS(*it,id);
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	//save the graph
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int a,b;
		cin>>a>>b;
		G[a].push_back(b); 
		G[b].push_back(a);
	} 
	
	//求连通块
	int id=0;
	for(int i=1;i<=n;++i)
		if(idx[i]==0) DFS(i,++id);
	
	//收集各连通块个数
	int *A=new int[id+1];
	for(int i=1;i<=id;++i)
		A[i]=0;
	for(int i=1;i<=n;++i){
		++A[idx[i]];
	} 
	int maxn=0;
	for(int i=1;i<=id;++i){
		maxn=max(maxn,A[i]);
	}
	
	//cout
	cout<<maxn<<endl;
	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int a;
    cin >> a;

    cout << 8 - (a-400)/200 << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 3772
N = int(input())
for h in range(1,3500):
    for n in range(1,3500):
        if 4*h*n-N*h-N*n != 0 and N*h*n%(4*h*n-N*h-N*n) == 0 and 0 < N*h*n//(4*h*n-N*h-N*n):
            print(h,n,N*h*n//(4*h*n-N*h-N*n))
            break
    else:
        continue
    break

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

typedef long long ll;
const int MAX = 1000001;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll X, Y;
    cin >> X >> Y;

    COMinit();

    ll res = 0;
    for (int n = 0; n <= X; n++) {
        if ((X - n) % 2 != 0) continue;
        if ((X - n) / 2 != (Y - 2 * n)) continue;

        ll m = Y - 2 * n;
        res += COM(n + m, n);
    }

    cout << res % MOD << endl;
    return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=(ll)1e9;
const ll mod=(ll)1e9+7;

void solve(){
	int n,W,w,v;
	cin>>n>>W;
	vector<vector<ll>>dp(n,vector<ll>(W+1,0));
	for (int i = 0; i < n; ++i)
	{
		cin>>w>>v;
		for (int j = 0; j <=W; ++j)
		{
			if(i==0){
				if(j>=w){
					dp[i][j]=v;
				}
			}
			else{
				dp[i][j]=dp[i-1][j];
				dp[i][j]=max(dp[i][j],(j>=w?dp[i-1][j-w]+v:0));
			}
		}
	}
	cout<<dp[n-1][W];
}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}


Measured memory_bytes: 79488
def main():
    import sys
    input = sys.stdin.readline

    a,b = map(int,input().split())

    if a % 2 == 0:
        lis_a = [i for i in range(int(12.5 * a), int(12.5 * a)+13)]
    else:
        lis_a = [i for i in range(int(12.5 * a + 1), int(12.5 * a + 12.5))]
    lis_b = [i for i in range(int(10 * b),int(10*b)+10)]
    a_new = set(lis_a)
    b_new = set(lis_b)
    c = list(a_new & b_new)
    if len(c) > 0:
        print(min(c))
    else:
        print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    if s in ['AKIHABARA','KIHABARA','AKIHBARA','AKIHABRA','AKIHABAR',\
             'KIHBARA','KIHABRA','KIHABAR','AKIHBRA','AKIHBAR','AKIHBRA',\
             'KIHBRA','KIHBAR','KIHABR','AKIHBR','KIHBR',]:
       print('YES')
    else:
        print('NO')
resolve()


Measured memory_bytes: 2940