akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, x: usize, l: [usize; n]);

    let mut count = 0;
    let mut d = 0;
    loop {
        if x < d {
            break;
        }
        if count >= n {
            count += 1;
            break;
        }

        d += l[count];

        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define ll long long
#define INF 10000000
#define int long long
using namespace std;
signed main(){
  int k,s;
  int cnt = 0;
  cin >> k >> s;
  for(int i=0; i<=k; i++){
    for(int j=0; j<=k; j++){
      int l = s - i -j ;
      if(i+j+l == s && l >= 0 && l <= k) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 1000
for i in range(N - 1):
    a = A[i]
    if a < A[i + 1]:
        units = ans // a
        ans = (ans - units * a) + units * A[i + 1]
    # print(i, ans)

print(ans)


Measured memory_bytes: 9036
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int A=sc.nextInt();
    	int B=sc.nextInt();
    	
    	if(A==1) {
    		
    		if(B==1) {
    			System.out.println("Draw");
    		}else {
    			System.out.println("Alice");
    		}
    		
    	}else if(B==1) {
    		    System.out.println("Bob");
    	}else {
    		
    		if(A>B) {
    			System.out.println("Alice");
    		}else if(B>A){
    			System.out.println("Bob");
    		}else {
    			System.out.println("Draw");
    		}
    		
    	}
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	long long mod = pow(10, 9) + 7;
	char s;
	int alpha[26];
	for (int i = 0; i < 26; i++) {
		alpha[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> s;
		alpha[s - 'a']++;
	}
	long long ans = 1;
	for (int i = 0; i < 26; i++) {
		ans *= alpha[i] + 1;
		ans %= mod;
	}
	cout << (ans-1)%mod << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 234567;
vector<int> e[maxn];
int dist[maxn];
int f[maxn];
void dfs(int u, int v){
	for(int nu: e[u]){
		if(nu == v) continue;
		dist[nu] = dist[u] + 1;
		dfs(nu, u);
	}
}
int main(){
	int n; cin >> n;
	for(int i = 0; i < n - 1; i++){
		int x, y; cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dist[1] = 0; dfs(1, 0);
	int root = max_element(dist + 1, dist + 1 + n) - dist;
	dist[root] = 0; dfs(root, 0);
	int dim = *max_element(dist + 1, dist + 1 + n);
	f[0] = 1;
	f[1] = 2;
	for(int i = 2; i <= dim; i++){
		int mx = max(f[i - 1], f[i - 2]);
		f[i] = 3 - mx;
	}
	if(f[dim] == 1) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}


Measured memory_bytes: 22912
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>

#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//priority_queue<int, vector<int>, greater<int>> min_heap;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//   return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll a[100001];

int main() { // E 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; ll q; ll k; cin >> n >> k >> q;
	rep(i, n)a[i] = k;
	rep(i, q) {
		ll x; cin >> x;
		a[x - 1] += 1;
	}
	
	rep(i, n) {
		a[i] -= q;
		if (a[i] > 0) {
			cout << "Yes" << '\n';
		}
		else {
			cout << "No" << '\n';
		}
	}
	




}

Measured memory_bytes: 1408
h,n=list(map(int ,input().split()))
l=list(map(int ,input().split()))
ans=0
count=0
for i in range(0,n):
    ans+=l[i]
    if(ans==h or ans>h):
        count+=1
    else:
        count+=0
        
        
        
if(count>0):
    print("Yes")
else:
    print("No")

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

int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==5&&B==5&&C==7||A==7&&B==5&&C==5||A==5&&B==7&&C==5)
    {
        printf("YES");
    }
    else{
        printf("NO");
    }
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)




int main(){
    ll N,M;
    cin>>N>>M;
    int a;
    rep(i,M){
      cin>>a;
      N-=a;
    }
 if(0<=N)cout<<N<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 3568
from math import hypot
def dijkstra(s,n,cost):
    d=[float("inf")]*n
    used=[False]*n
    d[s]=0
    while True:
        v=-1
        for i in range(n):
            if(not used[i])and v==-1:
               v=i
            elif(not used[i])and d[i]<d[v]:
                v = i
        if v==-1:
            break
        used[v]=True
        for j in range(n):
            d[j]=min(d[j],d[v]+cost[v][j])
    return d
xs,ys,xt,yt,n,*t=map(int,open(0).read().split())
e=[(xs,ys,0)]+list(zip(t[::3],t[1::3],t[2::3]))+[(xt,yt,0)]
cost=tuple([float('inf')]*(n+2)for i in range(n+2))
for i,(x,y,z)in enumerate(e):
    for j,(a,b,c)in enumerate(e):
        cost[i][j]=max(0,hypot(x-a,y-b)-z-c)
print(dijkstra(0,n+2,cost)[-1])


Measured memory_bytes: 36980
#include <iostream>
using namespace std;
#define MAX_SIZE (101)

int main() {
	int n;
	cin >> n;
	// p[i-1], p[i] correspond to M[i]'s row and column size
	int p[MAX_SIZE];
	for (int i=1;i<=n;++i) {
		cin >> p[i-1] >> p[i];
	}
	// [i][j] is a cost for multiplying matrices between M[i] and M[j].
	int dp[MAX_SIZE][MAX_SIZE];
	// [i][i] = 0, i=1,...,n
	for (int i=1;i<=n;++i) {
		dp[i][i] = 0;
	}
	// [i][j], i<j, i=1,...,n
	// j - i = l-1 = 1,2,...,n-1
	// このindexの指定の仕方: なんとなくnまでに合わせたい, l=2,...,nで(l-1)=1,...,n-1になる
	// j = i + (l-1)で, i+1, ..., n まで動く.
	for (int l=2;l<=n;++l) {
		for (int i=1;i<=n-l+1;++i) {
			int j = i + l - 1;// i+1, i+2, ..., n
			dp[i][j] = (1 << 30); 
			for (int k=i;k<j;++k) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j]); 
			}
		}
	}
	cout << dp[1][n] << endl;
	return 0;
}




Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n, k;
char g[N];

int main(){
	scanf("%d%d %s", &n, &k, g);
	int an = 0;
	for(int i = 0; i<n-1; ++i){
	    if(g[i] == g[i+1]){++an; continue;}
	}
	printf("%d\n", min(n-1,an+k*2));
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


int main()
{
    int N;
    // vector<int> a(100100);
    int former,latter;
    int tmp=0;
    int score=0;

    scanf("%d",&N);
    if(N<=1){
        cout<<0<<"\n";
    }
    else if(N==2)
    {
        cin>>former;
        cin>>latter;
        if (former>=latter)
        {
            cout<<1<<"\n";
        }
        else
        {
            cout<<0<<"\n";
        }
    }
    else{
        cin>>former;
        cin>>latter;
        for(int i=2;i<N;i++)
        {
            if(former>=latter)tmp++;
            else 
            {
                if(score<tmp) score=tmp;
                tmp=0;
            }
            
            former=latter;
            cin >> latter;
        }
        // cout<<tmp<<" "<<former<<" "<<latter<<"\n";
        if(former>=latter)tmp++;
        if(score<tmp) score=tmp;

        cout<<score<<"\n";
    }    
}



Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int ver,edge,ans=0; 
vi g[55]; 
int deg[55]; 
stack <int> s;

signed main()
{
    cin >> ver >> edge ; 
    for (int i=1;i<=edge;i++){
        int u,v; cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    } 
    for (int i=1;i<=ver;i++){
        deg[i] = sz(g[i]);
        if (deg[i]==1) s.push(i);
    }
    while (s.size()){
        int x=s.top();
        s.pop();
        if (deg[x]==1) ans++;
        deg[x] = 0; 
        for (auto &it: g[x]){
            if (deg[it]>0){
                deg[it]--;
                if (deg[it]==1){
                    s.push(it);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
#define NIL -1
int D[50000],H[52000];
struct ecs{int p;int l;int r;}a[50000];

int ssibling(int u)
{
    if(a[u].p==NIL)return NIL;
    if(a[a[u].p].l!=NIL && a[a[u].p].l!=u)return a[a[u].p].l;
    if(a[a[u].p].r!=NIL && a[a[u].p].r!=u)return a[a[u].p].r;
    return NIL;
}
void Depth(int u,int d)
{
    if(u==NIL)return;
    D[u]=d;
    Depth(a[u].l,d+1);
    Depth(a[u].r,d+1);
}
int Height(int u)
{
    int h1=0,h2=0;
    if(a[u].l!=NIL)h1=Height(a[u].l)+1;
    if(a[u].r!=NIL)h2=Height(a[u].r)+1;
    return H[u]=(h1>h2?h1:h2);
}
void pp(int u)
{
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<a[u].p<<", ";
    cout<<"sibling = "<<ssibling(u)<<", ";
    int dg=0;
    if(a[u].l!=NIL)dg++;
    if(a[u].r!=NIL)dg++;
    cout<<"degree = "<<dg<<", ";
    cout<<"depth = "<<D[u]<<", ";
    cout<<"height = "<<H[u]<<", ";
    if(a[u].p==NIL)cout<<"root"<<endl;
    else if(a[u].l==NIL&&a[u].r==NIL)
    cout<<"leaf"<<endl;
    else cout<<"internal node"<<endl;
}
int main()
{
    int v,l,r,root,n;
    cin>>n;
    for(int i=0;i<n;i++)a[i].p=NIL;
    for(int i=0;i<n;i++)
    {
        cin>>v>>l>>r;
        a[v].l=l;
        a[v].r=r;
        if(l!=NIL)a[l].p=v;
        if(r!=NIL)a[r].p=v;
    }
    for(int i=0;i<n;i++)if(a[i].p==NIL)root=i;
    Depth(root,0);
    Height(root);
    for(int i=0;i<n;i++)pp(i);
    return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>

int bubbleSort(int A[] ,int n){
  int j,v;
  int sw=0;
  int flag = 1;
  while (flag){
    flag = 0;
    for(j=n-1;j>=1;j--){
      if(A[j]<A[j-1]){
	v=A[j-1];
	A[j-1]=A[j];
	A[j]=v;
	flag = 1;
	sw++;
      }
    }
  }
  return sw;
}
int main(){
  int i,n,sw;
    int A[100];
    scanf("%d",&n);
    for(i = 0;i<n;i++){
      scanf("%d",&A[i]);
    }
    sw =bubbleSort(A,n);
    for(i = 0;i < n; i++)
  {
    printf("%d",A[i]);
    if(i != n-1)
    printf(" ");
  }
    printf("\n");
    printf("%d\n",sw);
     
    return 0;
}
    



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
long W;
    long int a[101][100001];
long int dp(int v,int i,int val[],long w[])
{   long ans;
    if(v>=0)
    if(a[i][v]!=-1)
    return a[i][v];
    if(v<=0)
    ans=0;
    else if(i==0 && val[i]<v)
    ans= INT_MAX;
    else if(i==0 && val[i]>=v)
    ans=w[0];
    else 
    ans =min(dp(v,i-1,val,w),dp(v-val[i],i-1,val,w)+w[i]);
    if(v>=0)
    a[i][v]=ans;
    return ans;
}
int main(){
    int n;
    cin>>n>>W;
    long int w[n];int val[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>val[i];
        sum+=val[i];
    }
    for(int i=0;i<101;i++)
    for(int j=0;j<100001;j++)
    a[i][j]=-1;
    int max=-1;
    for(int i=0;i<100001;i++)
    {
       // cout<<"for val i="<<i<<"min weight ="<<dp(i,n-1,val,w)<<endl;
        if(dp(i,n-1,val,w)<=W)
        max=i;
        
    }
    cout<<max;
    

    
    
    
    
    
}

Measured memory_bytes: 79232
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int n;
    cin >> n;
    int m = n;
    int cnt = 0;
    while (m) {
        m /= 10;
        cnt++;
    }
    vector<vector<int>> table(9, vector<int>(9, 0));
    for (int i = 1; i <= n; i++) {
        int head = i;
        while (true) {
            if (head < 10) {
                break;
            }
            head /= 10;
        }
        int tail = i % 10;
        if (tail > 0) {
            table[head - 1][tail - 1]++;
        }
        else
            continue;
    }
    int sum = 0;
    rep(i, 9) rep(j, 9) {
        sum += table[i][j] * table[j][i];
    }
    cout << sum << endl;
    return 0;
}

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

int main(){

    int n; cin >> n;
    vector<int> a(2*n);
    for(int i = 0; i < 2*n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < 2*n; i += 2) ans += a[i];
    return !printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define INF 100000000000000000

using namespace std;

long equal_cut(long * a, long offset, int n){  // n is the number of factors, a is summension
    long m1 = *lower_bound(a, a + n, (a[n-1] + offset) / 2);
    long m2 = *(max(lower_bound(a, a + n, (a[n-1] + offset) / 2) - 1, a));
    if(abs(a[n-1] - 2 * m1 + offset) > abs(a[n-1] - 2 * m2 + offset)) return m2 - offset;
    else return m1 - offset;
}

int main(){
    int N; 
    cin >> N;
    long A[N];
    long S[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        S[i] = A[i];
        if(i != 0) S[i] += S[i-1];
    } 
    long x[4];
    long p, q, r, s;
    long ans = INF;
    
    for(int i=2; i<N-1; i++){
        x[0] = equal_cut(S, 0, i);
        x[1] = S[i-1] - x[0];
        x[2] = equal_cut(S + i, S[i-1], N - i);
        x[3] = S[N-1] - S[i-1] - x[2];
        long m = * min_element(x, x + 4);
        long M = * max_element(x, x + 4);
        ans = min(ans, M - m);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
s = set()
for i in range(n):
    num = ii()
    if num in s:
        s.remove(num)
    else:
        s.add(num)

print(len(s))

Measured memory_bytes: 11884
/*input
4 5
##...
.###.
.###.
...##
*/

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int H, W;

	cin >> H >> W;
	// cout << "H:" << H << " W:" << W << endl;

	vector<string> field(H);

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

	int sharp_count = 0;

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			sharp_count += field[i].substr(j,1) == "#";
		}
	}

	// cout << sharp_count << endl;

	if(sharp_count == (H+W-1)){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from decimal import *
a,b,c = map(int,input().split())
from decimal import *

getcontext().prec = 20      # デフォルト28桁のところを20桁にする
m = Decimal(a*b).sqrt()
if a+b-c+2*m < 0:
    print('Yes')
else:
    print('No')

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

int N;

void rec(char k1, char k2, string S) {
  if(S.size() == N) {
    cout << S << endl;
    return;
  }
  for(char i='a'; i<=k1 && i<=k2+1; i++) {
    string SS = S;
    SS.push_back(i);
    rec(k1+1, max(i, k2), SS);
  }
}

signed main() {
  cin >> N;
  rec('a', 'a', "");
}


Measured memory_bytes: 1536
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int all = 0;
		int[] array = new int[n];
		for(int i =0; i < n; i++){
		    int a = sc.nextInt();
		    array[i] = a;
		    all = all^a; 
		}
		
		// 計算
		//String result = "";
		for(int i =0; i < n; i++){
		    int res = all^array[i];
		    System.out.print(res + " ");
		}
		
		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 57124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#define CL(a) memset(a,0,sizeof(a))
#define cl(a,b) memset(a,(b),sizeof(a))
#define For(i,a,b) for(i=a;i<b;i++)
#define LL long long 
using namespace std;
int a[200];
int n;
void print(int * a){
	printf("%d",a[0]);
	for(int i=1;i<n;i++)
		printf(" %d",a[i]);
	printf("\n");
} 
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",a+i);
	int cnt = 0;
		int minsub;
	for(int i=0;i<n-1;i++)
	{
		minsub = i;
		for(j=i+1;j<n;j++)
		{
			if(a[j]<a[minsub]) minsub = j;	
		}
		if(minsub!=i) swap(a[i],a[minsub]),cnt++;
		
	}
	print(a);
	
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;
const double PI = acos(-1);
int main()
{
    int n;
    int ans = 0;
    cin >> n;
    vector<ll>a(n);
    ll bef;
    ll la = 0LL;
    ll lb = 0LL;
    rep(i, n)
    {
       cin>>a[i];
    }
    sort(all(a),greater<ll>());
    int i=0;
    for(i=0;i<a.size()-1;i++){
        if(a[i]==a[i+1]){
            if(la==0LL){
                la=a[i];
                i++;
            }else if(lb==0LL){
                lb=a[i];
                i+=1000000;
            }
        }
    }

    //  clog<<la<<" "<<lb;
    cout << (la * lb) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y;
    scanf("%d %d %d",&n,&x,&y);
    int cnt1=0,cnt2=0,cnt3=0;
    for(int i=0;i<n;i++)
    {
        int t;
        scanf("%d",&t);
        if(t<=x) cnt1++;
        else if(t<=y) cnt2++;
        else cnt3++;
    }
    int ans=min(cnt1,cnt2);
    ans=min(ans,cnt3);
    printf("%d\n",ans);
    return 0;
}


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

# import numpy as np
# from itertools import combinations as comb
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
import math


def get_factors(X):
    """Xの約数を求める"""
    factors = []
    for i in range(1, math.ceil(X ** 0.5) + 1):
        if X % i == 0:
            factors.append(i)
            factors.append(X // i)
    factors.append(X)
    return sorted(factors)


def solve(X: int):
    factors = get_factors(X)

    # B < 0 の時
    a_max = math.floor(X ** (1 / 5))
    # A - B は X の約数
    for amb in factors:
        for a in range(1, a_max + 1):
            b = a - amb
            if a ** 5 - b ** 5 == X:
                return str(a) + ' ' + str(b)

    # B >= 0 の時
    a_min = math.ceil(X ** (1 / 5))
    a_max = math.floor(X ** (1 / 4))
    # A - B は X の約数
    for amb in factors:
        for a in range(a_min, a_max + 1):
            b = a - amb
            if a ** 5 - b ** 5 == X:
                return str(a) + ' ' + str(b)

    return (0, 0)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # X = map(int, line.split())
    X = int(next(tokens))  # type: int
    answer = solve(X)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;
    int Ch, Cw;
    cin >> Ch >> Cw;
    --Ch; --Cw;
    int Dh, Dw;
    cin >> Dh >> Dw;
    --Dh; --Dw;
    vector<string> S(H);
    rep(i, H) {
        string s;
        cin >> s;
        S[i] = s;
    }
    vector<vector<int>> dist(H, vector<int> (W, INF));
    deque<tuple<int, int, int>> que;
    auto update = [&] (int i, int j, int d) {
        if (dist[i][j] <= d) return;
        dist[i][j] = d;
        que.emplace_front(i, j, d);
    };
    auto updateWarp = [&] (int i, int j, int d) {
        if (dist[i][j] != INF) return;
        dist[i][j] = d;
        que.emplace_back(i, j, d);
    };
    update(Ch, Cw, 0);
    while (!que.empty()) {
        int ci = get<0>(que.front());
        int cj = get<1>(que.front());
        int cd = get<2>(que.front());
        que.pop_front();
        if (dist[ci][cj] < cd) continue;
        rep(dir, 4) {
            int ni = ci + dx[dir];
            int nj = cj + dy[dir];
            if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
            if (S[ni][nj] == '#' || dist[ni][nj] <= dist[ci][cj]) continue;
            update(ni, nj, dist[ci][cj]);
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int ni = ci + i;
                int nj = cj + j;
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (S[ni][nj] == '#' || dist[ni][nj] != INF) continue;            
                updateWarp(ni, nj, dist[ci][cj] + 1);
            }            
        }
    }
    int ans = dist[Dh][Dw];
    cout << (ans != INF ? ans : -1) << '\n';
    return 0;
}

Measured memory_bytes: 8700
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

int main(){

	int t;
	std::cin >> t;

	for (int i = 0; i < t; i++){
		int n, k, res;
		std::cin >> n >> k;

		std::vector<int>x(n), sa(n - 1);
		for (int j = 0; j < n; j++)std::cin >> x[j];
		for (int j = 0; j < n - 1; j++)sa[j] = x[j + 1] - x[j];

		if (n <= k)std::cout << 0 << std::endl;

		else{
			std::sort(sa.begin(), sa.end(), std::greater<int>());

			res = x[x.size() - 1] - x[0];

			for (int j = 0; j < k - 1; j++)res -= sa[j];

			std::cout << res << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
const int N=2e6+10;
const int mod1=998244353;
const int mod2=19260811;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int a[N],vis[N];
int main()
{
    ll ans=0;
    int n;read(n);
    for(re int i=1;i<=n;i++) read(a[i]),vis[a[i]]++;
    for(re int i=1;i<=n;i++) if(vis[i]) ans+=1ll*vis[i]*(vis[i]-1)/2;
    for(re int i=1;i<=n;i++) 
    {
        if(vis[a[i]]) ans-=1ll*vis[a[i]]*(vis[a[i]]-1)/2;
        vis[a[i]]--;
        if(vis[a[i]]) ans+=1ll*vis[a[i]]*(vis[a[i]]-1)/2;
        printf("%lld\n",ans);
        if(vis[a[i]]) ans-=1ll*vis[a[i]]*(vis[a[i]]-1)/2;
        vis[a[i]]++;
        if(vis[a[i]]) ans+=1ll*vis[a[i]]*(vis[a[i]]-1)/2;
    }
    return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5],b,c;
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if(a[2]-a[1]==a[3]-a[2])
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
}

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

using namespace std;
typedef long long ll;

int main(){ 
  ll t1,t2; cin >> t1 >> t2;
  ll a1,a2; cin >> a1 >> a2;
  ll b1,b2; cin >> b1 >> b2;
  
  if( a1 < b1){ swap(a1,b1); swap(a2,b2);}
  
  ll P = (a1-b1)*t1; ll Q = (a2-b2)*t2;
  
  if( P+Q > 0){ cout << 0 << endl; return 0;}
  else if( P+Q == 0){ cout << "infinity" << endl; return 0;}
  else{
    //ここらへんがおかしい
    ll np;
    
    if( -Q % (-(P+Q))  == 0){ np = (Q/(P+Q))-1;}
    else{ np = (Q/(P+Q));}
    
    
    ll ans = 2*np-1;
    if( (np+1)*P + np*Q == 0){ ans++;}
    
    cout << ans << endl;
    
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll S, W, ans = 0;
    cin >> S >> W;
    if (S <= W)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x=(n%k);
    ll y=abs(x-k);
    cout<<min(x,y)<<endl;
}


Measured memory_bytes: 3620
//
//  main.cpp
//  AOJ1166
//
//  Created by aki33524 on 2014/07/06.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

typedef pair<int, int> P;
const int INF = 1e8;
int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

int W, H;
int d[50][50];
int maze[50][50];

void solve(){
    queue<P> que;
    for(int h=0; h<H; h++)
        for(int w=0; w<W; w++)
            d[h][w] = INF;
    
    que.push(P(0, 0));
    d[0][0] = 1;
    
    while(!que.empty()){
        P p = que.front(); que.pop();
        for(int i=0; i<4; i++){
            int nh = p.first + dh[i];
            int nw = p.second + dw[i];
            if(0<=nh&&nh<H && 0<=nw&&nw<W && !(maze[p.first][p.second]&(1<<i)) && d[nh][nw]==INF){
                que.push(P(nh, nw));
                d[nh][nw] = d[p.first][p.second] + 1;
            }
        }
    }
    cout << (d[H-1][W-1]==INF ? 0 : d[H-1][W-1]) << endl;
}

int main(int argc, const char * argv[]){
    while(cin>>W>>H, W|H){
        memset(maze, 0, sizeof(maze));
        
        for(int h=0; h<H*2-1; h++){
            if(h%2 == 0){
                for(int w=0; w<W-1; w++){
                    int a;
                    cin >> a;
                    if(a){
                        maze[h/2][w] |= (1<<1);
                        maze[h/2][w+1] |= (1<<3);
                    }
                }
            }else{
                for(int w=0; w<W; w++){
                    int a;
                    cin >> a;
                    if(a){
                        maze[h/2][w] |= (1<<0);
                        maze[h/2+1][w] |= (1<<2);
                    }
                }
            }
        }
        solve();
    }
    return 0;
}

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

long long h, w, ans = 100000000000000;

long long myabs(long long x) { return max(x, -x); }
void solve();

int main() {
  cin >> h >> w;
  solve();
  swap(h, w);
  solve();
  cout << ans << endl;
  return 0;
}

void solve() {
  for(long long i = 1; i < h; ++i) {
    long long top = i * w;
    long long nh = h - i;
    if(nh * w % 2 == 0)
      ans = min(ans, myabs(top - (nh * w / 2)));
    else {
      long long a = w * (nh / 2), b = w * (nh / 2 + 1),
                maxn, minn;
      maxn = max(top, max(a, b));
      minn = min(top, min(a, b));
      ans = min(ans, myabs(maxn - minn));
      a = nh * (w / 2), b = nh * (w / 2 + 1);
      maxn = max(top, max(a, b));
      minn = min(top, min(a, b));
      ans = min(ans, myabs(maxn - minn));
    }
  }
}

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

int divisors(int a, int div) {
    int count = 0;
    for (int i = 1; i <= a; i++) {
        if (div % i == 0) {
            count++;
        }
    }
    return count;

}

int main(int argc, char const *argv[]) {

    int a, b, c;
    cin >> a >> b >> c;

    cout << divisors(b, c) - divisors(a-1, c) << endl;
    

    return 0;
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int sum[200005][2];

signed main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;

  REP(n,S.size()) {
    if(S[n] == '.') sum[n+1][0]++;
    else sum[n+1][1]++;
    sum[n+1][0] += sum[n][0];
    sum[n+1][1] += sum[n][1];
  }

  int ans = INF;

  REP(n,S.size()+1) {
    ans = min(ans, sum[n][1] + sum[S.size()][0] - sum[n][0]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

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

ll f(ll a,ll b,ll x){
    return floor(a*x/b)-a*floor(x/b);
}

int main(){
    ios::sync_with_stdio(false);
    ll a,b,n; cin >> a >> b >> n;
    if(n>=(b-1)){
        cout << f(a,b,b-1) << endl;
    } else{
        cout << f(a,b,n) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<=n;i++)
typedef int long long ll;
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    int aa=atoi(a.c_str());
    
   /* for(int i=1;i<=sqrt(aa);i++){
        if(i*i==aa){
            cout<<"Yes"<<endl;
            return 0;
        }
        
    }*/
    
    
    
    if((int)sqrt((double)aa)==sqrt((double)aa)){
        cout<<"Yes"<<endl;return 0;
    }
    cout<<"No"<<endl;
   
return 0;
}

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

int main (){
  int N;
  cin >>N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >>P.at(i);
  }
  vector<int> C(N);
  int count =0;
  for(int i=0;i<N;i++){
    if(P.at(i) != i+1){
      count ++;
    }
  }
  if(count == 2||count ==0){
    cout <<"YES"<<endl;
  }
  else {
    cout <<"NO"<<endl;
  }
}


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

int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(){
	int n, x;
	cin >> n >> x;
	int ans;
	cin >> ans;
	ans = abs(x - ans);
	for (int i = 1; i < n; ++i){
		int a;
		cin >> a;
		a = abs(x - a);
		ans = GCD(ans,  a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    
    while (true) {

        val line = readLine() ?: ""
        var a = 0
        var b = 0

        if (line == "0" || line == "") {
            break
        }
        for (i in 1..line.length -1 ) {
            when (line.get(i)) {
                'A' -> a++
                'B' -> b++
                else -> {}
            }
        }

        if (a > b) a++
        else b++

        println("${a} ${b}")
    }
}


Measured memory_bytes: 25380
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
    n <- readLn
    putStrLn $ shows n ": " ++ unwords (map show $ primeFactors n)

smallPrimes :: [Int]
smallPrimes=2:[n|n<-[3,5..46337],and.map((0<).rem n)$takeWhile(\x->x*x<=n)smallPrimes]

primeFactors :: Int -> [Int]
primeFactors n | n < 2 = []
primeFactors n = go n smallPrimes
  where
    go !n pps@(p:ps)
        | n < p * p = [n]
        | r > 0     = go n ps
        | otherwise = p : go q pps
      where
        (q, r) = quotRem n p
    go n [] = [n]

Measured memory_bytes: 4208
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
#include<cstring>
using namespace std;
#define MOD 1000000007
map<long long,long long>m;
int main() {
    long long n,i,t,x,count=0,k;
    char a[100005];
    cin>>a>>k;
    n=strlen(a);
    for(i=0;i<n;i++)
    {
        if(a[i]!='a')
        {
            if(k>='z'-a[i]+1)
            {
                k-='z'-a[i]+1;
                a[i]='a';
                
            }
        }
    }
    if(k!=0)
    {
        a[n-1]=(char)((a[n-1]-'a'+k)%26+'a');
    }
    cout<<a;
  return 0;
}

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

int main(){
  int n,cnt=1,now;
  cin >> n;
  vector<int> buttons(n);
  for(int i=0;i<n;i++){
    cin >> buttons.at(i);
  }
  now=buttons.at(0);
  while(now!=2){
    now=buttons.at(now-1);
    cnt++;
    if(cnt>n){cnt=-1;break;}
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, a;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }
  sort(vec.rbegin(), vec.rend());
  
  int half = vec.size()/2 -1;
  cout << vec.at(half) - vec.at(half+1) << endl;

  return 0;
}

Measured memory_bytes: 3772
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string sa, sb, sc; cin >> sa >> sb >> sc;
    char nx = 'a';
    while (true) {
        if (nx == 'a') {
            if (sa.size() == 0) {
                cout << "A" << endl;
                return 0;
            }
            nx = sa[0];
            sa = sa.substr(1, sa.size()-1);
        } else if (nx == 'b') {
            if (sb.size() == 0) {
                cout << "B" << endl;
                return 0;
            }
            nx = sb[0];
            sb = sb.substr(1, sb.size()-1);
        } else {
            if (sc.size() == 0) {
                cout << "C" << endl;
                return 0;
            }
            nx = sc[0];
            sc = sc.substr(1, sc.size()-1);
        }
    }
    return 0;
}

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

int main() {
    string S,T;
    cin>>S>>T;
    int counter=0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)==T.at(i)){
            counter++;
        }
    }
    if(counter==S.size()){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int N = 233;
typedef long long LL;
typedef pair <LL,LL> pr;
const LL mo = 1000000007;
const LL Max = 1E18 + 233LL;

int q,tp;
LL f[N];

#define fr first
#define sc second
#define mp(a,b) (make_pair((a),(b)))

vector <pr> v[N];

inline LL getLL()
{
	char ch = getchar(); LL ret = 0;
	while (ch < '0' || '9' < ch) ch = getchar();
	while ('0' <= ch && ch <= '9')
		ret = ret * 10LL + 1LL * (ch - '0'),ch = getchar();
	return ret;
}

inline void Solve(LL x,LL y)
{
	if (x == 1)
	{
		printf("1 %d\n",y % mo); return;
	}
	else if (x == 2 && y == 2) {puts("1 4"); return;}
	int Ans = 0; LL cnt = 0;
	for (int i = 1; ; i++)
		if (f[i] > x || f[i + 1] > y) {Ans = i - 1; break;}
	for (int i = 0; i < v[Ans - 1].size(); i++)
	{
		pr now = v[Ans - 1][i];
		if (now.fr <= x)
			cnt += (y - now.sc) / now.fr;
		if (now.fr <= y)
			cnt += (x - now.sc) / now.fr;
		cnt %= mo;
	}
	printf("%d %d\n",Ans,cnt % mo);
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	f[0] = f[1] = 1;
	for (int i = 2; ; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		if (f[i] > Max) {tp = i; break;}
	}
	v[1].push_back(mp(2,1)); v[1].push_back(mp(3,1));
	for (int i = 2; i < tp - 1; i++)
		for (int j = 0; j < v[i - 1].size(); j++)
		{
			pr now = v[i - 1][j];
			for (LL k = 1; ; k++)
			{
				pr nex = mp(now.fr * k + now.sc,now.fr);
				if (nex.fr > f[i + 2] || nex.sc > f[i + 2]) break; v[i].push_back(nex);
			}
		}
	q = getLL();
	while (q--)
	{
		LL x = getLL(),y = getLL();
		if (x > y) swap(x,y); Solve(x,y);
	}
	return 0;
}

Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static long[][] dp;
    private static long calculate(int current, int previous, int[][] arr){
        if(current >= arr.length) return 0;
        if(previous == -1){
            long ans = Long.MIN_VALUE;
            for(int i = 0; i < 3; i++){
                long x = calculate(current + 1, i, arr);
                if(x != Long.MIN_VALUE) x+=arr[current][i];
                ans = Math.max(ans, x);
            }
            return ans;
        }
        if(dp[current][previous] != -1) return dp[current][previous];
        long ans = Long.MIN_VALUE;
        for(int i = 0; i < 3; i++){
            if(previous == i) continue;
            long x = calculate(current + 1, i, arr);
            if(x != Long.MIN_VALUE) x+=arr[current][i];
            ans = Math.max(ans, x);
        }
        dp[current][previous] = ans;
        return ans;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int n = nextInt(br);
        int[][] arr = new int[n][3];
        for(int i = 0; i < n; i++){
            arr[i] = nextIntArray(br, 3);
        }
        dp = new long[n][3];
        for(int i = 0; i < n; i++){
            Arrays.fill(dp[i], -1);
        }
        sb.append(calculate(0, -1, arr));
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


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

    int y = x / 100;
    if(y * 100 <= x && x <= y * 105){
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<llong> a(n + 1);
  rep(i, n + 1) cin >> a[i];
  vector<llong> b(n);
  rep(i, n) cin >> b[i];

  llong ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (b[i] <= a[i + 1]) {
      ans += b[i];
      a[i + 1] -= b[i];
    } else {
      int num = min(a[i + 1] + a[i], b[i]);
      ans += num;
      a[i] = a[i + 1] + a[i] - num;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
/*
	Problem: Eternal Average
	Source: AtCoder Grand Contest 009 E
	Author: fts2001 (the_silliest)
 */
using namespace std;
int n,m,k,dp[2005][2005],ans=0;
bool vis[2005][2005];
int dfs(int x,int y){
    if(x+y==1)return dp[x][y]=1;
    if(x+y==k){
        if(x==k || y==k)return dp[x][y]=0;
        return dp[x][y]=1;
    }
    if(vis[x][y])return dp[x][y];
    vis[x][y]=1;
    int &res=dp[x][y];
    res=0;
    for(int i=0;i<k;i++){
        if(x>=i && y>=k-i-1){
            res=(res+dfs(x-i,y-(k-i-1)))%MOD;
        }
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    for(int i=n;i>0;i-=k-1){
        for(int j=m;j>0;j-=k-1){
            ans=(ans+dfs(i,j))%MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 20096
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){

	double x,h;
	double s;
	double skseki;

	while(1){

		cin >> x >> h;

		if(x == 0 && h == 0) break;

		double tei = x * x;
		double skmnh = sqrt((x/2 * x/2) + (h * h));
		
		skseki = (skmnh * x / 2) * 4;
		s = skseki + x * x;

		printf("%6f\n", s);
	}

	return 0;
}

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

int main() {
  int N = 0;
  cin >> N;
  int count = 1;
  vector<tuple<string, int, int>> SP;
  
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    SP.push_back(make_tuple(s, 100 - p, count));
    count++;
  }
  
  sort(SP.begin(), SP.end());
  for (auto t : SP) {
  	cout << get<2>(t) << endl;
  }
}

Measured memory_bytes: 3640