akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (auto &x : p) {
        cin >> x;
        --x;
    }
    print(p);
    map<int, int> vis;
    vis[0] = 0;
    int x = 0;
    int t = 1;
    int offset, period, start;
    while (true) {
        x = p[x];
        if (vis.find(x) != vis.end()) {
            int t0 = vis[x];
            start = x;
            offset = t0;
            period = t - t0;
            break;
        }
        vis[x] = t++;
    }
    print(offset, period);
    if (k <= offset) {
        print("!");
        x = 0;
        for (int m = 0; m < k; ++m) {
            x = p[x];
        }
        cout << x + 1 << endl;
        return 0;
    }
    print("?");

    k -= offset;
    k %= period;
    x = start;
    for (int m = 0; m < k; ++m) {
        x = p[x];
    }
    cout << x + 1 << endl;
}


Measured memory_bytes: 17100
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    from collections import Counter as cc
    S = []
    for i in range(n):
        S.append(input())
    S = cc(S)
    print('AC x {}'.format(S['AC']))
    print('WA x {}'.format(S['WA']))
    print('TLE x {}'.format(S['TLE']))
    print('RE x {}'.format(S['RE']))


if __name__ == '__main__':
    main()

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

int main(){
    int a,b,gap=0,high=0,ans=0;
    cin >> a >> b;
    gap=b-a;
    high=((1+gap)*gap)/2;
    ans=high-b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;	
int main(){
	vector<int> a(3, 0);
	int x, y; cin>>x>>y;
	a[x]++; a[y] ++;
	for(int i =1;i <=3; i++){
		if(a[i] == 0){
			cout<<i;
			return 0;
		}
	}
		
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct Competition {
	int cost, vote;
} Competition;

int main() {
	int i, j, n, m, cost, max_vote = 0, max_index;
	Competition sports[1000];
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		sports[i].vote = 0;
		scanf("%d", &sports[i].cost);
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &cost);
		for (j = 0; j < n; j++) {
			if (sports[j].cost <= cost) {
				sports[j].vote++;
				if (max_vote < sports[j].vote) {
					max_vote = sports[j].vote;
					max_index = j;
				}
				break;
			}
		}
	}

	printf("%d\n", max_index+1);
	return 0;
}

Measured memory_bytes: 2720
N =int(input())
if N >=10 and N<=99:
  print(9)
elif N >=100 and N<=999:
  print(N-90)
elif N >= 1000 and N<= 9999:
  print(9 + 900)
elif N >= 10000 and N<= 99999:
  print(N-90-9000)
elif N == 100000:
  print(9 + 900 + 90000)
else:
  print(N)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

#define fori(x) for(int i=0;i<x;++i)
#define forj(x) for(int j=0;j<x;++j)

constexpr int maximum = 100100;


int main() {
	string s;
	cin >> s;
	fori(s.length()) { cout << "x"; }
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	s := scanString()
	_ = scanString()
	a := scanInt()
	b := scanInt()
	u := scanString()

	if s == u {
		a--
	} else {
		b--
	}

	fmt.Println(a,b)
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a < b)
    {
        cout << "a < b\n";
    }
    else if(a > b)
    {
        cout << "a > b\n";
    }
    else
    {
        cout << "a == b\n";
    }
    
    return 0;
}


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


int main(){
 int n;
 cin>>n;
 vector<ll> a(n);
 for(ll i=0;i<n;i++)cin>>a[i];
 vector<ll> dp(n+1,1000);

 for(ll i=0;i<n;i++){
  if( i != 0 ) dp[i] = max(dp[i] , dp[i-1]);
  for(ll j=i+1;j<n;j++){
   if( a[i] < a[j] ){
    dp[j] = max(dp[j], dp[i] + (a[j]-a[i])*( dp[i]/a[i] ) );
   }
  }
 }
 cout<<dp[n-1]<<endl;


    return 0;
}


Measured memory_bytes: 3600
// https://atcoder.jp/contests/abc114/tasks/abc114_d

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// http://tutuz.hateblo.jp/entry/2018/12/22/125205
ll dp[110][101];
int main() {
    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 2; i <= n; i++) {
        int tmp = i;
        // 素因数分解
        for (int j = 2; j * j <= n; j++) {
            while (tmp % j == 0) {
                cnt[j]++;
                tmp /= j;
            }
        }
        if (tmp > 1)
            cnt[tmp]++;
    }
    dp[0][1] = 1;
    for (int i = 0; i <= n; i++) {
        for (int have = 1; have <= 75; have++) {
            for (int take = 1; take <= cnt[i] + 1 && have * take <= 75;
                 take++) {
                dp[i + 1][have * take] += dp[i][have];
            }
        }
    }
    cout << dp[n][75] << endl;

    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func calcLoss(day int, c, last []int) (int, []int) {
	ret := make([]int, 26)
	tot := 0
	for i := 0; i < 26; i++ {
		ret[i] = c[i] * (day - last[i])
		tot += ret[i]
	}
	return tot, ret
}

func main() {
	sc.Split(bufio.ScanWords)
	D := getInt()
	c := getInts(26)
	s := make([][]int, D)
	for i := 0; i < D; i++ {
		s[i] = getInts(26)
	}

	last := make([]int, 26)
	score := make([]int, 26)

	for i := 0; i < D; i++ {
		t := getInt() - 1
		score[t] += s[i][t]
		last[t] = i + 1
		_, loss := calcLoss(i+1, c, last)
		ans := 0
		for j := 0; j < 26; j++ {
			score[j] -= loss[j]
			ans += score[j]
		}
		out(ans)
	}

	// for i := 0; i < D; i++ {
	// 	maxS := 0
	// 	idxS := 0
	// 	for j := 0; j < 26; j++ {
	// 		if maxS < s[i][j] {
	// 			maxS = s[i][j]
	// 			idxS = j
	// 		}
	// 	}
	// 	out(idxS + 1)
	// }
}


Measured memory_bytes: 1992
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK= 2;

int n;
vector<pair<int, int> > adj[MAX]; // 重み付き有向グラフの隣接リスト表現

void dijkstra() {
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    for (int i=0; i<n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;
    
    while ( !PQ.empty() ) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        
        color[u] = BLACK;
        
        // 最小値を取り出し、それが最短でなければ無視
        if (d[u] < f.first * (-1)) continue;
        
        for (int j=0; j<adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] =  d[u] + adj[u][j].second;
                // priority_queueはデフォルトで大きい値を優先するため-1をかける
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }
    
    for (int i=0; i<n; i++) {
        printf("%d %d\n", i, d[i]);
    }
}

int main() {
    int k, u, v, c;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%d %d", &u, &k);
        for (int j=0; j<k; j++) {
            scanf("%d %d", &v, &c);
            adj[u].push_back(make_pair(v, c));
        }
    }
    
    dijkstra();
    
    return 0;
}


Measured memory_bytes: 8156
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int n;
    while(cin >> n,n){
        int m;
        cin >> m;
        int x[11], y[11];
        for(int i=0; i<m; i++){
            cin >> x[i] >> y[i];
        }
        vector<string> v1, v2;
        for(int i=0; i<m-1; i++){
            if(i!=0){
                double s=(x[i]-x[i+1])*(y[i-1]-y[i+1])-(y[i]-y[i+1])*(x[i-1]-x[i+1]);
                if(s<0) v1.push_back("L");
                else v1.push_back("R");
            }
            int dis=sqrt((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i]));
            v1.push_back(to_string(dis));
        }
        for(int i=m-1; i>0; i--){
            if(i!=m-1){
                double s=(x[i]-x[i-1])*(y[i+1]-y[i-1])-(y[i]-y[i-1])*(x[i+1]-x[i-1]);
                if(s<0) v2.push_back("L");
                else v2.push_back("R");
            }
            int dis=sqrt((x[i-1]-x[i])*(x[i-1]-x[i])+(y[i-1]-y[i])*(y[i-1]-y[i]));
            v2.push_back(to_string(dis));
        }
        // for(int i=0; i<v1.size(); i++){
        //     cout << v1[i];
        // }
        // cout << "\n";
        // for(int i=0; i<v2.size(); i++){
        //     cout << v2[i];
        // }
        // cout << "\n";
        //ここまで元の画像
        vector<int> ans;//答えの頂点番号いれておく
        for(int step=1; step<=n; step++){
            int m2;
            cin >> m2;
            vector<string> v3;
            int x2[11], y2[11];
            for(int i=0; i<m2; i++){
                cin >> x2[i] >> y2[i];
            }
            if(m2!=m) continue;
            for(int i=0; i<m2-1; i++){
                if(i!=0){
                    double s=(x2[i]-x2[i+1])*(y2[i-1]-y2[i+1])-(y2[i]-y2[i+1])*(x2[i-1]-x2[i+1]);
                    if(s<0) v3.push_back("L");
                    else v3.push_back("R");
                }
                int dis=sqrt((x2[i+1]-x2[i])*(x2[i+1]-x2[i])+(y2[i+1]-y2[i])*(y2[i+1]-y2[i]));
                v3.push_back(to_string(dis));
            }
            bool tf1=true, tf2=true;
            // cout << "step=" << step << " ";
            // for(int i=0; i<v3.size(); i++){
            //     cout << v3[i];
            // }
            // cout << "\n";
            if(v3.size()!=v1.size()) continue;
            for(int i=0; i<v3.size(); i++){
                if(v1[i]!=v3[i]){
                    tf1=false;
                    break;
                }
            }
            for(int i=0; i<v3.size(); i++){
                if(v2[i]!=v3[i]){
                    tf2=false;
                    break;
                }
            }
            if(tf1||tf2) ans.push_back(step);
        }
        for(int i=0; i<ans.size(); i++){
            cout << ans[i] << "\n";
        }
        cout << "+++++" << "\n";
    }    
}


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

const int N = 2e5+5;

int n, a[N], marked[N];
ll k;

int main() {
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    int cur = 1, offset = 0;
    while(!marked[cur]) {
        marked[cur] = 1;
        cur = a[cur];
        offset++;
    }
    memset(marked, 0, sizeof(marked));
    int cyc = 0;
    while(!marked[cur]) {
        marked[cur] = 1;
        cur = a[cur];
        cyc++;
    }
    if(k > offset-cyc) {
        k -= offset-cyc;
        k %= cyc;
    } else cur = 1;
    
    for(int i=0; i<k; i++)
        cur = a[cur];
    cout << cur;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 1000000000
vector<char>name;
void print(long long k)
{
    if(k<=26)
    {
        if(k>0)
        {
            printf("%c",'a'+(k-1));
        }
        else
        {
            printf("z");
        }
        return;
    }
    if(k%26>0)
    {
        print(k/26);
        printf("%c",'a'+(k%26-1));
    }
    else
    {
        print(k/26-1);
        printf("z");
    }
}
int main()
{
    long long n;
    scanf("%lld",&n);
    //n--;
    print(n);
    return 0;
}


Measured memory_bytes: 3760
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N,K;
    cin >> N >> K;
    if(N >= 10){
        cout << K << endl;
        return;
    }
    cout << K + 100 * (10-N) << endl;

    return;
}

// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

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

int main (){
  int h,w;
  do{
  cin >> h >> w;
  for (int i = 0; i<h; i++){
    for (int j = 0; j<w; j++){
      cout << '#' ;
    }
    cout << endl;
  }
  if (h!=0 && w!=0){
  cout << endl;
  }
  }while (h!=0 && w!=0);

  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
#define rep(i,n) ;for( int i =0; i < n ; i ++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
int main(){
  int n;
  cin>>n;
  int p=0;
  vector<int> x(n);
  rep(i,n){
    cin>>x[i];
    p += x[i];
  }
  ll wa1=0;
  ll wa2=0;
  for(int i=0;i<n;i++){
    wa1 += abs(x[i]-p/n)*abs(x[i]-p/n);
  }
  for(int i=0;i<n;i++){
    wa2 += abs(x[i]-p/n-1)*abs(x[i]-p/n-1);
  }
  cout<<min(wa1,wa2)<<endl;
}


Measured memory_bytes: 256
// include
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<vector>
#include<string>
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;


int main(void) {
	int a, b, c, d, x, y, z, n, l, i, j, count = 0;
	string str, temp;
	vector<int> p, q;
	char ch;

	vector<string> svec;
	cin >> n >> l;
	rpt(i, n) {
		cin >> str;
		svec.push_back(str);
	}
	rpt(i, n - 1) {
		for (j = i; j < n; j++) {
			if (svec[i].compare(svec[j]) > 0) {
				temp = svec[i];
				svec[i] = svec[j];
				svec[j] = temp;
			}
		}
	}
	rpt(i, n) {
		cout << svec[i];
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
ll arr[3005];
ll dp[3005][3005];
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll k=1;
	if (n%2==0)
		k=-1;
	for(ll i=0;i<n;i++)
		dp[i][i]=k*arr[i];
	for(ll i=1;i<n;i++)
	{
		for(ll j=0;j<n-i;j++)
		{
			if(k==-1)
			{
				if(i%2==1)
					dp[j][j+i]=max(dp[j+1][j+i]+arr[j],dp[j][j+i-1]+arr[j+i]);
				else
					dp[j][j+i]=min(dp[j+1][j+i]-arr[j],dp[j][j+i-1]-arr[j+i]);
			}
			else if(k==1)
			{
				if(i%2==0)
					dp[j][j+i]=max(dp[j+1][j+i]+arr[j],dp[j][j+i-1]+arr[j+i]);
				else
					dp[j][j+i]=min(dp[j+1][j+i]-arr[j],dp[j][j+i-1]-arr[j+i]);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
	return 0;
}

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

using ll = long long;

const ll MOD = 1e9+7;

int main() {
   int H, W, K;
   cin >> H >> W >> K;
   --K;

   ll dp[H+1][W];
   fill(dp[0], dp[H+1], 0);
   dp[0][0] = 1;

   for (int h = 0; h < H; h++) { // それぞれの高さについてループを回す
      for (int msk = 0; msk < (1<<(W-1)); ++msk) { // mskit全探索のループ

         // 横線が隣り合っていないかチェック
         bool ok = true;
         for (int i = 0; i < W-2; ++i) {
            // これで末尾が11のときにはじくことが出来る
            if (((msk >> i) & 3) == 3) ok = false;
         }
         if (!ok) continue;

         // 各始点がどこへ移動するか求める
         int perm[W];
         for (int i = 0; i < W; ++i) perm[i] = i;

         for (int i = 0; i < W-1; ++i) {
            // あみだくじのルールにしたがって位置をswap
            if ((msk >> i) & 1) swap(perm[i], perm[i+1]);
         }

         // 配る
         for (int i = 0; i < W; ++i) {
            dp[h+1][perm[i]] += dp[h][i];
            dp[h+1][perm[i]] %= MOD;
         }
      }
   }

   cout << dp[H][K] << endl;

   return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define mod 1000000007
#define t() int tst;cin>>tst;for(int test=1;test<=tst;++test)
#define rep(i,a,b) for(i=a;i<b;++i)
#define repr(i,a,b) for(i=a;i>=b;--i)
typedef pair<int,int> pii;
#define F first
#define S second
#define pb push_back
#define all(p) p.begin(), p.end()
#define MAX 10000005

int powG(int x,int y)
{

  if(y==1)return x;
  if(y==0)return 1;

  int temp=powG(x,y/2);

  temp*= temp;

  if(y&1)
    temp*=x;
  
    return temp;
}


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //t()
    {
        int i;
        int ans = 0;
        rep(i,1,6)
        {
            int a;
            cin>>a;
            if(a == 0)
            {
                ans = i;
            }
        }
        cout << ans << endl;
    }
    return 0; 
} 





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

using u64 = uint64_t;
constexpr const u64 INF = UINT64_MAX / 2;

void warshall_floyd(vector<vector<u64>> &graph) {
    int N = graph.size();
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;

    vector<int> visits(R);
    for (int r = 0; r < R; r++) {
        cin >> visits[r];
        visits[r]--;
    }
    sort(visits.begin(), visits.end());

    vector<vector<u64>> graph(N, vector<u64>(N, INF));
    for (int i = 0; i < M; i++) {
        int a, b;
        u64 l;
        cin >> a >> b >> l;
        a--; b--;
        graph[a][b] = l;
        graph[b][a] = l;
    }
    warshall_floyd(graph);

    u64 msum = INF;
    do {
        u64 sum = 0;
        for (int i = 1; i < R; i++) {
            sum += graph[visits[i-1]][visits[i]];
        }
        msum = min(msum, sum);
    } while (next_permutation(visits.begin(), visits.end()));
    cout << msum << endl;

    return 0;
}


Measured memory_bytes: 512
H, W = map(int, input().split())
S = []
for i in range(H):
  ss = input()
  S.append(ss)
L = [[-1]*W for i in range(H)]
R = [[-1]*W for i in range(H)]
U = [[-1]*W for i in range(H)]
D = [[-1]*W for i in range(H)]
for i in range(H):
  n = -1
  for j in range(W):
    if S[i][j] == "#":
      n = j
    L[i][j] = j-n
  n = W
  for j in reversed(range(W)):
    if S[i][j] == "#":
      n = j
    R[i][j] = n-j
for j in range(W):
  n = -1
  for i in range(H):
    if S[i][j] == "#":
      n = i
    U[i][j] = i-n
  n = H
  for i in reversed(range(H)):
    if S[i][j] == "#":
      n = i
    D[i][j] = n-i
#for i in range(H):
#  print(D[i])
r = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      r = max(r, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(r)


Measured memory_bytes: 181012
import sys
from collections import deque
import bisect

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, M, K = in_nn()
    A = in_nl()
    B = in_nl()

    Asum = [0] * (N + 1)
    Bsum = [0] * (M + 1)

    for i in range(N):
        Asum[i + 1] += Asum[i] + A[i]

    for i in range(M):
        Bsum[i + 1] += Bsum[i] + B[i]

    ans = 0
    for i in range(N + 1):
        time = K - Asum[i]
        if time < 0:
            break
        else:
            ans = max(ans, i + bisect.bisect_right(Bsum, time) - 1)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48816
#include <algorithm>
#include <iostream>
#include <list>
#include <forward_list>
#include <vector>

using namespace std;

struct Info {
	int k;
	int l;
	int r;
};

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

	vector<long long> resultList(T);

	for(int t = 0; t < T; t++) {
		int N;
		cin >> N;

		vector<Info> list;
		vector<Info> list2;
		for(int i = 0; i < N; i++) {
			int k, l, r;
			cin >> k >> l >> r;
			if(l - r >= 0) {
				list.push_back(Info{k - 1, l, r});
			} else {
				list2.push_back(Info{k - 1, l, r});
			}
		}
		sort(list.begin(), list.end(), [](auto &a, auto &b) {
			if((a.l - a.r) == (b.l - b.r)) {
				return a.k > b.k;
			}
			return (a.l - a.r) > (b.l - b.r);
		});
		sort(list2.begin(), list2.end(), [](auto &a, auto &b) {
			if((a.r - a.l) == (b.r - b.l)) {
				return a.k < b.k;
			}
			return (a.r - a.l) > (b.r - b.l);
		});

		long long result = 0;
		vector<int> check(list.size());
		for(int i = 0; i < list.size(); i++) {
			check[i] = i;
		}
		for(int i = 0; i < list.size(); i++) {
			auto itr = upper_bound(check.begin(), check.end(), list[i].k);
			if(itr == check.begin()) {
				result += list[i].r;
				continue;
			}
			itr--;
			check.erase(itr);
			result += list[i].l;
		}
		vector<int> check2(list2.size());
		for(int i = 0; i < list2.size(); i++) {
			check2[i] = N - 1 - i;
		}
		reverse(check2.begin(), check2.end());
		for(int i = 0; i < list2.size(); i++) {
			auto itr = upper_bound(check2.begin(), check2.end(), list2[i].k);
			if(itr == check2.end()) {
				result += list2[i].l;
				continue;
			}
			check2.erase(itr);
			result += list2[i].r;
		}
		resultList[t] = result;
	}

	for(int t = 0; t < T; t++) {
		cout << resultList[t] << endl;
	}

	return 0;
}


Measured memory_bytes: 6416
#include <stdio.h>
using namespace std;
int main(void){
    int ryouri[20];
    int manzokudo[20];
    int omake[19];
    int maxryori;
    int kotae=0;
    scanf("%d",&maxryori);
    for(int i=0;i<maxryori;i++)
    {
        scanf("%d",&ryouri[i]);
    }
    for(int i=0;i<maxryori;i++)
    {
        scanf("%d",&manzokudo[i]);
        kotae += manzokudo[i];
    }
    for(int i=0;i<maxryori-1;i++)
    {
        scanf("%d",&omake[i]);
    }
    for(int i=0;i<maxryori-1;i++)
    {
        if(ryouri[i+1]-ryouri[i]==1)
        {
            kotae += omake[ryouri[i]-1];
        }
    }
    printf("%d\n",kotae);

}

Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]
ans = [0, 0]

for i in range(2):
  S = 0
  for j in range(n):
    S += a[j]
    if j % 2 == i:
      if S <= 0:
        ans[i] += 1 - S
        S = 1
    else:
      if S >= 0:
        ans[i] += 1 + S
        S = -1
        
print(min(ans))

Measured memory_bytes: 63216
import math

def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True


n = int(input())
arr = []
count = 0

for i in range(n):
    arr.append(int(input()))

for j in arr:
    if is_prime(j):
        count += 1
print(count)



Measured memory_bytes: 6004
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<math.h>
//#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>P;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

int n,m;
int X,Y;
int a[110],b[110];

int main() {
	IOS;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
	//a = 999999866000004473;
	//b = 999999822000007597;
    cin >> n >> m;
    cin >> X >> Y;
    for(int i = 0 ; i < n; ++i)
        cin >> a[i];
    sort(a,a+n);
    for(int i = 0 ; i < m; ++i)
        cin >> b[i];
    sort(b,b+m);
    for(int i = X+1; i <= Y; ++i){
        if(i>a[n-1]&&i<=b[0]){
            cout << "No War"<<endl;
            return 0;
        }
    }
    cout << "War";
	return 0;
}


Measured memory_bytes: 256
from bisect import *
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
zahyou=[[0,0] for i in range(H*W+1)]
for h in range(H):
    for w in range(W):
        zahyou[A[h][w]][0]=h
        zahyou[A[h][w]][1]=w
dp=[0 for i in range(H*W+1)]
for i in range(len(dp)):
    if i>=D:
        A1=zahyou[i][0]-zahyou[i-D][0]
        A2=zahyou[i][1]-zahyou[i-D][1]
        if A1<0:A1=-A1
        if A2<0:A2=-A2
        dp[i]=dp[i-D]+A1+A2

for i in range(int(input())):
    l,r=map(int,input().split())
    print(dp[r]-dp[l])


Measured memory_bytes: 62044
paths = []
while (line = gets)
  ns = line.chomp.split(",").map{|s| s.to_i}
  paths.push ns
end

sums = []
for ns in paths
  if sums.length < ns.length
    sums.unshift 0
    sums.push 0
  end

  sums0 = []
  for i in (0...ns.length)
    sums0[i] = [sums[i], sums[i + 1]].max + ns[i]
  end
  sums = sums0
end

puts sums[0]

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);

#define EQ(a,b) (abs((a)-(b))<eps)

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag()
                                    : lhs.real() < rhs.real();
  }
}

struct L{ P a, b; };
struct C { P p; ld r; };

// counter clockwise
int ccw (P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > eps) return 1;   // counter clockwise
  if (cross(b, c) < -eps) return -1; // clockwise
  if (dot(b, c) < 0) return 2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line
  return 0;                          // a--c--b on line
}

vector<L> tangent_cp(C c, P p) {
  vector<L> ret;
  P v = c.p - p;
  ld d = abs(v);
  ld l = sqrt(norm(v) - c.r * c.r);
  if (isnan(l)) { return ret; }
  P v1 = v * P(l / d,  c.r / d);
  P v2 = v * P(l / d, -c.r / d);
  ret.push_back((L){p, p + v1});
  if (l < eps) return ret;
  ret.push_back((L){p, p + v2});
  return ret;
}

vector<L> tangent_cc(C c1, C c2) {
  vector<L> ret;
  if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
    P center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
    ret = tangent_cp(c1, center);
  }
  if (abs(c1.r - c2.r) > eps) {
    P out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
    vector<L> nret = tangent_cp(c1, out);
    ret.insert(ret.end(), ALL(nret));
  }
  else {
    P v = c2.p - c1.p;
    v /= abs(v);
    P q1 = c1.p + v * P(0,  1) * c1.r;
    P q2 = c1.p + v * P(0, -1) * c1.r;
    ret.push_back((L){q1, q1 + v});
    ret.push_back((L){q2, q2 + v});
  }
  return ret;
}

int main() {
  while(1) {
    int n,m;
    cin>>n>>m;
    if(!n) break;
    VP vb, vw;
    REP(i,n) {
      int x,y;
      cin>>x>>y;
      vb.emplace_back(x,y);
    }
    REP(i,m) {
      int x,y;
      cin>>x>>y;
      vw.emplace_back(x,y);
    }
    bool ok = false;
    ld delta = 1e-4;
    REP(i,n)REP(j,m) {
      C ci = {vb[i], delta};
      C cj = {vw[j], delta};
      vector<L> vl = tangent_cc(ci, cj);
      for (L l : vl) {
        int ccwi = ccw(l.a, vb[i], l.b);
        int ccwj = ccw(l.a, vw[j], l.b);
        if (ccwi * ccwj >= 0) continue;
        bool valid = true;
        REP(k,n) {
          if (ccw(l.a, vb[k], l.b) * ccwi <= 0) {
            valid = false;
            break;
          }
        }
        if (!valid) continue;
        REP(k,m) {
          if (ccw(l.a, vw[k], l.b) * ccwi >= 0) {
            valid = false;
            break;
          }
        }
        if (valid) ok = true;
      }
    }
    if (ok) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3164
import itertools
def myAnswer(N:int,P:list,Q:list) -> int:
   l = [i for i in range(1,N+1)]
   a = 0
   b = 0
   for n,i in enumerate(itertools.permutations(l,N)):
      if(i == tuple(P)):
         a = n
      if(i == tuple(Q)):
         b = n
   return abs(a - b)

   

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   P = list(map(int,input().split()))
   Q = list(map(int,input().split()))
   print(myAnswer(N,P,Q))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_100_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(6).
    01 maxlen PIC 9(1)  VALUE 2.
    01 cur    PIC 9(2)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(2).
    01 ans    PIC -(8)9.
    01 AB1.
        03 AB11 OCCURS 2.
            05 AB PIC S9(8).
    01 y      PIC X(4)  VALUE "Yay!".
    01 n      PIC X(2)  VALUE ":(".
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO AB(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    IF AB(1) <= 8 AND AB(2) <= 8 THEN
        DISPLAY y;
    ELSE
        DISPLAY n;
    END-IF.

    STOP RUN.


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


template <typename T>
std::vector<std::pair<T,T>> interval_scheduling(std::vector<std::pair<T,T>> intervals){ // 区間は[a,b]
  std::vector<std::pair<T,T>> ret;
  std::sort(intervals.begin(), intervals.end(), [](const auto &a, const auto &b){return a.second < b.second;});

  T b = 0;
  for(auto &p : intervals) chmin(b, p.first);
  for(auto &p : intervals){
    if(p.first >= b){
      ret.push_back(p);
      b = p.second;
    }
  }

  return ret;
}


int main(){
  int N;
  while(cin >> N){
    vector<pair<LLI,LLI>> p(N);
    REP(i,N){
      LLI x,l; cin >> x >> l;
      p[i] = make_pair(x-l, x+l);
    }

    auto ans = interval_scheduling(p);

    cout << ans.size() << endl;
  }

  return 0;
}


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

long a[222222];
int main() {
    int n, m, x = 0;
    long k;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i + 1], a[i + 1] += a[i];
    for(int i = 0;; i++) {
        if(k >= 0) {
            int j = upper_bound(a, a + n + 1, k) - a - 1;
            x = max(x, i + j);
        }
        if(i == m)
            break;
        int b;
        cin >> b;
        k -= b;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 5192
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  vi ss(26), tt(26);
  rep(i, s.size()){
    int sn = ss[int(s[i] - 'a')];
    int tn = tt[int(t[i] - 'a')];
    if(sn != tn){
      cout << "No" << endl;
      return 0;
    }
    ss[int(s[i] - 'a')]++;
    tt[int(t[i] - 'a')]++;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
n=int(input())
a=[int(x) for x in input().split()]
f=True
for i in a:
  if i%2==0:
    if i%3==0 or i%5==0:
      f=True
    else:
      f=False
      break
if f:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i, N, x=0;
  char S;
  cin >> N;
  for(i=0; i<N; i++){
    cin >> S;
    if(S == 'Y')x=1;
  }
  if(x==1){
    cout << "Four" << endl;
  }
  else  cout << "Three" << endl;
}

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

int main(){
    int n;
    cin >> n;
    cout << 3*n*n << endl;

    return 0;
}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {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;}



int main(){
    ll lmao;
    string output;
    cin >> lmao;
    while (lmao > 0) {
        lmao -= 1;
        int remainder = lmao % 26;
        output = (char) ('a' + remainder) + output;
        lmao = lmao / 26;
        }

    cout << output;
}

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

int main() {
    int q;
    ll a, b;
    scanf("%d", &q);
    while (q--) {
        scanf("%lld%lld", &a, &b);
        if (a > b) swap(a, b);
        ll ans=0;
        ll c=a*b;
        ll d=sqrt(c);
        if(d*d==c) d--;
        if(a==b||a==b+1)
           ans=2*a-2;
        else if(d*(d+1)>=a*b)
            ans=2*d-2;
        else ans=2*d-1;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    int t = kbd.nextInt();
    boolean[][] card = new boolean[13][4];
        //0:S 1:H 2:C 3:D
    int i;
    int j;
    for(i=0; i<t; i++){
        String m = kbd.next();
        int n = kbd.nextInt();
        card[n-1][mark(m)] = true;
    }
 
    for(j=0; j<4; j++){
        for(i=0; i<13; i++){
        if(card[i][j]==false)
            System.out.println(mark(j)+" "+(i+1));
        }
    }
    }
    static int mark(String m){
    if(m.equals("S")) return 0;
    if(m.equals("H")) return 1;
    if(m.equals("C")) return 2;
    return 3;
    }
    static String mark(int j){
    if(j==0) return "S";
    if(j==1) return "H";
    if(j==2) return "C";
    return "D";
    }
}




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

void main(){
    auto buf = readln().strip().split().map!(to!int)();
    immutable N = buf[0];
    immutable K = buf[1];

    if((N-1)/2 + 1 >= K) {
        writeln("YES");
    } else {
        writeln("NO");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n;
    cin>>n;
    int a[n],b[n],j=0;
    for(auto &i:a){cin>>i,b[j]=i;j++;}
    sort(b,b+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[n-1])
        cout<<b[n-2]<<endl;
        else
        cout<<b[n-1]<<endl;
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int INF = 1e18;
const int N = 1e3;
int grid[N][N], vis[N][N], cc[N][N];
int h,w;

int dir[4][2] = {{-1,0},{0,-1},{1,0},{0,1}};

void dfs(int hh, int ww, int id){
	vis[hh][ww] = 1;
	cc[hh][ww] = id;
	for(int i = 0; i < 4;i++){
		int nh = hh + dir[i][0];
		int nw = ww + dir[i][1];
		if(nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
		if(!vis[nh][nw]&&!grid[nh][nw]) dfs(nh,nw,id);
	}
}

signed main(){
	fastio
	cin >> h >> w;
	int cx, cy, dx ,dy;
	cin >> cx >> cy >> dx >> dy;
	
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			char tmp;
			cin >> tmp;
			if(tmp=='#') grid[i][j] = 1;
		}
	}
	cx--, cy--, dx--, dy--;
	int id = 1;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(grid[i][j]) continue;
			if(!vis[i][j]) dfs(i,j,id), id++;
 		}
	}
	unordered_set<int> adj[id];
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(grid[i][j]) continue;
			for(int a = max((int)0,i-2); a<=min(h-1,i+2);a++){
				for(int b = max((int)0,j-2); b<=min(w-1,j+2);b++){
					if(grid[a][b]) continue;
					//cout << a << " " << b << " " << grid[a][b] << "\n";
					if(cc[i][j]==cc[a][b]) continue;
					//cout << i << " " <<  j << " " << a << " " << b << "\n";
					adj[cc[i][j]].insert(cc[a][b]);
					adj[cc[a][b]].insert(cc[i][j]);
				}
			}
 		}
	}
	/*for(int i = 1;i < id;i++){
		cout << i << " ";
		for(auto u : adj[i]) cout << u << " ";
		cout << "\n";
	}*/
	int dis[id];
	for(int i = 1;i < id;i++) dis[i] = INF;
	queue<int> q;
	dis[cc[cx][cy]] = 0;
	q.push(cc[cx][cy]);
	while(!q.empty()){
		auto x = q.front(); q.pop();
		for(auto v : adj[x]){
			if(dis[v] > dis[x]+1){
				dis[v] = dis[x]+1, q.push(v);
			}
		}
	}
	if(dis[cc[dx][dy]]==INF) cout << -1 << "\n";
	else if(cc[dx][dy]) cout << dis[cc[dx][dy]] << "\n";
	else cout << -1 << "\n";
}


Measured memory_bytes: 52452
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static long B;
  static long C;
  static double min = 9999999;
  static long ans = 0;




  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    String s = scanner.nextLine();

    boolean ans = retAns(s);

    if(ans){
        System.out.println("Heisei");
      }else{
        System.out.println("TBD");
    }


  }

  public static boolean retAns(String s){


    String[] h = s.split("/");

    if(Integer.parseInt(h[0]) <= 2018) return true;

    if(Integer.parseInt(h[1])  <= 4) return true;


    return false;
  }


}


Measured memory_bytes: 21972
package main

import (
        "bufio"
        "fmt"
        "os"
        "sort"
        "strconv"
)

var si = bufio.NewScanner(os.Stdin)

const MAX = 1000000001

func readInt() int {
        si.Scan()
        ret, _ := strconv.Atoi(si.Text())
        return ret
}

func main() {
        si.Split(bufio.ScanWords)
        N := readInt()
        A := make([]int, N, N)
        for i := range A {
                A[i] = readInt()
        }
        dp := make([]int, 1, N+1)
        dp[0] = A[N-1]
        for i := N - 2; i >= 0; i-- {
                t := sort.Search(len(dp), func(j int) bool { return dp[j] > A[i] })
                if len(dp) > t && dp[t] > A[i] {
                        dp[t] = A[i]
                } else {
                        dp = append(dp, A[i])
                }
        }
        fmt.Println(len(dp))

}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,min=INT_MAX,count=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<n;++i){
        if(min > a[i]){
            min = a[i];
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <bitset>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 2010;
const int MAX_V = 2000;

int N, A[MAX_N];

std::bitset<MAX_V * MAX_N> dp;

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    int sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += A[i];
    }

    dp.set(0);

    for (int i = 1; i <= N; i++) {
        dp = (dp | (dp << A[i]));
    }

    int begin = (sum % 2 == 0) ? sum / 2 : sum / 2 + 1;

    for (int i = begin; i <= sum; i++) {
        if (dp[i]) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int h,a;
    cin>>h>>a;
    if(h<=a)
        cout<<"1"<<endl;
    else
    {
        int time;
        if(h%a==0)
        {
            time = h/a;
        }
        else
            time = h/a+1;
        cout<<time<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    string s;
    cin >> s;
    ll ans = 0;
    rep(i,s.size() - 1){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512