akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,h) for (int i=0; i<h; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,w) (((x)%(w)+w)%w)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,w,h) {for (int _=0; _<w; _++) {for (int __=0; __<h; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,w,h)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int freq[30];

bool check(int one, int two, int four)
{
    for (int i=0; i<26; i++) {
        int x = freq[i];
        while (x >= 4 and four > 0) {
            x -= 4;
            four--;
        }
        while (x >= 2 and two > 0) {
            x -= 2;
            two--;
        }
        while (x >= 1 and one > 0) {
            x -= 1;
            one--;
        }
        if (x != 0)
            return false;
    }
    return true;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    ms(freq,0);
    int h,w;
    cin >> h >> w;
    for0(i,h) {
        string s;
        cin >> s;
        for0(j,s.length()) {
            freq[s[j]-'a']++;
        }
    }
    
    int total = h*w;
    int one = (h%2 == 1 and w%2 == 1) ? 1 : 0;
    total -= one;
    int two;
    if (h%2 == 1 and w%2 == 1) 
        two = (h+w)/2 - 1;
    else if (h%2 == 1)
        two = w/2;
    else if (w%2 == 1)
        two = h/2;
    else 
        two = 0;    
    total -= two*2;
    int four = total/4;
    pr(four) pr(two) pr(one) nl
    assert(one + 2*two + 4*four == h*w);
    
    if (check(one,two,four)) 
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
}


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

int N,M;
vector<vector<int>> G;
vector<int> num;


// 現在地v,親pのとき、今のマスをnとする。
void dfs (int v, int p, int n){
    num[v] = n;
    for ( int i = 0; i < G[v].size(); ++i){
        int nv = G.at(v).at(i);
        if ( nv == p or num[nv] != 0 ) continue;
        else dfs(nv,v,n);
    }
    return;
}



int main() {
    cin >> N >> M;
    G.assign(N,vector<int>());
    vector<int> X(M),Y(M),Z(M);
    for ( int i = 0; i < M; ++i){
        cin >> X.at(i) >> Y.at(i) >> Z.at(i);
        G[X[i]-1].push_back(Y[i]-1);
        G[Y[i]-1].push_back(X[i]-1);
    }
    num.assign(N,0);
    
    int res = 1;
    for ( int i = 0; i < N; ++i){
        if ( num[i] == 0 ){
            dfs(i,-1,res);
            ++ res;
        }
    }
    cout << res-1 << endl;
    
    
    return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
int n;
LL m,a[1005],sum,ans;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		sum+=a[i];
		if(sum<=m) ans++;
		//cout<<sum<<' '<<m<<endl;
	}
	if(sum<m) ans--;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
bk=0
ans=0
for i in range(n):
  if bk+b[i]-a[i]>=0:
    if bk>a[i]:
      bk=b[i]
    else:
      bk=bk+b[i]-a[i]
    ans+=a[i]
  else:
    ans+=bk+b[i]
    bk=0
ans+=bk if a[n]>=bk else a[n]
print(ans)

Measured memory_bytes: 19116
import java.util.Scanner;

//Mirror Illusion
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[][][] g = {
				{{0, 0},{0, 800}},
				{{0, 0},{800, 0}},
				{{0, 800},{800, 800}},
				{{800, 0},{800, 800}}
		};
		for(;;){
			int n = sc.nextInt();
			if(n<0)break;
			int px = 75, py = 25, dx = 1, dy = 1;
			int[][][] wall = new int[n+1][2][2];
			wall[0][0][0] = wall[0][1][0] = 75;
			wall[0][0][1] = wall[0][1][1] = 25;
			for(int i=1;i<=n;i++){
				char ch = sc.next().charAt(0);
				int a = sc.nextInt()*100, b = sc.nextInt()*100;
				if(ch=='x'){
					wall[i][0][0] = a; wall[i][0][1] = b;
					wall[i][1][0] = a+100; wall[i][1][1] = b;
				}
				else{
					wall[i][0][0] = a; wall[i][0][1] = b;
					wall[i][1][0] = a; wall[i][1][1] = b+100;
				}
			}
			for(;;){
				int id = -1, min = 1000;
				for(int i=0;i<=n;i++){
					int x1 = wall[i][0][0], x2 = wall[i][1][0], y1 = wall[i][0][1], y2 = wall[i][1][1];
					if(x1==x2){
						int t = (x1-px)/dx;
						if(t<=0||min<=t)continue;
						int y = py+t*dy;
						if(y1<=y&&y<=y2){
							id = i;
							min = t;
						}
					}
					else{
						int t = (y1-py)/dy;
						if(t<=0||min<=t)continue;
						int x = px+t*dx;
						if(x1<=x&&x<=x2){
							id = i;
							min = t;
						}
					}
				}
				if(id==-1){
					min = 1000;
					for(int i=0;i<4;i++){
						int x1 = g[i][0][0], x2 = g[i][1][0], y1 = g[i][0][1], y2 = g[i][1][1];
						if(x1==x2){
							int t = (x1-px)/dx;
							if(t<=0||min<=t)continue;
							int y = py+t*dy;
							if(y1<=y&&y<=y2)min = t;
						}
						else{
							int t = (y1-py)/dy;
							if(t<=0||min<=t)continue;
							int x = px+t*dx;
							if(x1<=x&&x<=x2)min = t;
						}
					}
					System.out.println((px+min*dx)+" "+(py+min*dy));
					break;
				}
				if(id==0){
					System.out.println("75 25");
					break;
				}
				px+=min*dx; py+=min*dy;
				if(wall[id][0][0]==wall[id][1][0])dx*=-1;
				else dy*=-1;
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int> > A(H+1, vector<int>(W+1));
    rep(i , 1, H+1) rep(j, 1, W+1) cin >> A[i][j];
    rep(i , 1, H+1) rep(j, 1, W+1) {int t;cin >> t; A[i][j] = abs(A[i][j] - t);}

    bitset<12801> dp[81] = {};
    dp[0][6400] = 1;
    rep(i, 1, H+1){
        rep(j,1,W+1){
            int a = A[i][j];
            dp[j] = ((dp[j-1] | dp[j]) << a) | ((dp[j-1] | dp[j]) >> a);
        }
        dp[0][6400]=0;
    }

    rep(j , 0, 81){
        //cerr << dp[W][6400 + j] << endl;
        if(dp[W][6400 + j]){cout << j << endl; return 0;}
    }
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"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 getString() string {
	sc.Scan()
	return sc.Text()
}

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

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

	H, W := getInt(), getInt()
	X := make([][]int, H)
	Y := make([][]int, H)

	for y := 0; y < H; y++ {
		X[y] = make([]int, W)
		Y[y] = make([]int, W)
		s := getString()
		for x := 0; x < W; x++ {
			if s[x] == '#' {
				X[y][x] = 0
				Y[y][x] = 0
			} else {
				if x == 0 {
					X[y][x] = 1
				} else {
					X[y][x] = X[y][x-1] + 1
				}
				if y == 0 {
					Y[y][x] = 1
				} else {
					Y[y][x] = Y[y-1][x] + 1
				}
			}
		}
	}

	ymax := make([]int, W)
	for x := 0; x < W; x++ {
		ymax[x] = -1
	}
	for y := H - 1; y >= 0; y-- {
		xmax := -1
		for x := W - 1; x >= 0; x-- {
			if X[y][x] == 0 || xmax < X[y][x] {
				xmax = X[y][x]
			} else {
				X[y][x] = xmax
			}
			if Y[y][x] == 0 || ymax[x] < Y[y][x] {
				ymax[x] = Y[y][x]
			} else {
				Y[y][x] = ymax[x]
			}
		}
	}

	ans := 0
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			ans = max(ans, Y[y][x]+X[y][x])
		}
	}
	out(ans - 1)
}


Measured memory_bytes: 68736
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <queue>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll          = long long;
using db          = double;
using ld          = long double;
using uint        = unsigned int;
using ull         = unsigned long long;

using pii         = pair<int, int>;
using pll         = pair<ll, ll>;
using tiii        = tuple<int, int, int>;

#define mod7        1000000007
#define mod9        1000000009

#define forall(v)   v.begin(), v.end()
#define prec(x)     setprecision(x) << fixed

/* [💭] [💡] [🎈] */

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

    int n, s = 0;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    sort(forall(a));

    bool flag = (a[n - 1] * 2 < s);

    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

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

  cout<< ( (a+b)%2==0 ? (a+b)/2 : (a+b)/2+1 )<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_NM = 2005;
const ll MOD = 1e9+7;
ll S[MAX_NM],T[MAX_NM];
ll dp[MAX_NM][MAX_NM],sum[MAX_NM][MAX_NM];

int main()
{
	ll N,M;
	cin >> N >> M;
	rep(i,N)
	{
		cin >> S[i];
	}
	rep(i,M)
	{
		cin >> T[i];
	}

	dp[0][0] = 1;
	sum[1][1] = 1;
	rep(i,N+1)
	{
		rep(j,M+1)
		{
			if (i-1 >= 0 && j-1 >= 0 && S[i-1] == T[j-1])
			{
				dp[i][j] = sum[i][j];
			}
			sum[i+1][j+1] = ((((sum[i+1][j] + sum[i][j+1]) % MOD) + MOD - sum[i][j]) % MOD + dp[i][j]) % MOD;
		}
	}
	cout << sum[N+1][M+1] << endl;
	return 0;
}

Measured memory_bytes: 65872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  ll N,T,ans=0;
  cin>>N>>T;
  
  ll t[N];
  REP(i,N) cin>>t[i];
  
  for(int i=0; i<N-1; ++i){
    if(t[i]+T>t[i+1]){
      ans+=t[i+1]-t[i];
    }
    else ans+=T;
  }
  
  ans+=T;
  
  co(ans);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  int H, W, N;
  cin >> H >> W >> N;

  int cnt = N / (max(H, W));

  if(N % (max(H, W)) != 0) cnt++;

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define MOD 998244353
#define db(a) cout << a << endl
#define adb(a) for(auto i:a) cout << i << " "
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

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

    int a[n], i, j;
    for(i=0;i<n;i++) cin >> a[i];

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j<0) break;

            if(j == 1) dp[i] = dp[i-j] + abs(a[i] - a[i-j]);
            else dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
        }
    }

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,t=1;
  string s;
  cin>>n;
  cin>>s;
  //int x=s.size();
 if(n%2)
 cout<<"No";
 else  
 { for(int i=0;i<n/2;i++)
  {
    
    if(s[i]!=s[i+n/2])
     { t=0;
    break;
     }
  }

  if(t)
    cout<<"Yes";
  else
    cout<<"No";
 }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

int main(){
    int Q;
    std::cin >> Q;

    REP(i, Q){
        int c, a, n, can_max;
        std::cin >> c >> a >> n;

        can_max = std::min(c, std::min(a, n));

        int res = 0;

        REP(j, can_max+1){// CAN型いくつ
            int nc = c - j, na = a - j, nn = n - j;
            for(int k=0;nc-3*k>=0;k++){// CCC型いくつ
                res = std::max(res, j + k + std::min((nc-3*k)/2, na));
            }
        }

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

    return 0;
}

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

int maxHeapify(int i,int h){
    int l,r,largest;
    l=2*i+1;
    r=2*i+2;
    //if(l>=h&&r>=h)

    if(l<h&&a[l]>a[i])largest=l;
    else largest=i;
    if(r<h&&a[r]>a[largest])largest=r;
    if(largest!=i){
        swap(a[i],a[largest]);
        maxHeapify(largest,h);
    }
}
void buildMaxheap(int h){
    for(int i=(h-1)/2;i>=0;i--)maxHeapify(i,h);
}
/*void print(vector<int>a){
    for(int i=1;i<a.size();i++){
        cout<<"node "<<i<<": key = "<<a[i]<<", ";
        if(i!=1)cout<<"parent key = "<<a[i/2]<<", ";
        if(2*i+1<a.size()){
            cout<<"left key = "<<a[2*i]<<", right key = "<<a[2*i+1]<<", ";
        }else if(2*i<a.size()){
            cout<<"left key = "<<a[2*i]<<", ";
        }
        cout<<endl;
    }
}*/
int main(){
    int h;
    cin>>h;
    for(int i=0;i<h;i++){
        cin>>a[i];
    }
    buildMaxheap(h);
    rep(i,h)cout<<" "<<a[i];
    cout<<endl;
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);

ll f(ll x){
  if(x == 1) return 1;
  ll a = f(x/2);
  return a*2+1; 
}

int main() {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}

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

int main() {
  ll n, x, t;
  cin >> n >> x >> t;
  if (n%x==0)
    cout << (n/x)*t << endl;
  else
    cout << ((n/x)+1)*t << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int BIG_INT = 1000000000;



int main() {
	string s, t;
	cin >> s >> t;
	vector<vector<int>> v(26);
	for (int i = 0; i < s.length(); i++) {
		v[(s[i] - 'a')].emplace_back(i + 1);
	}


	ll cnt = 0;
	int last = 0;
	for (int i = 0; i < t.length(); i++) {
		int num = t[i] - 'a';
		if (v[num].size() == 0) {
			cout << -1 << endl;
			return 0;
		}

		auto it = upper_bound(v[num].begin(), v[num].end(),last);
		if (it == v[num].end()) {
			cnt++;
			last = v[num][0];
			
		}
		else {
			last = *it;
		}

	}
	cout << cnt * s.length() + last << endl;
	
}



Measured memory_bytes: 1216
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int P1[310000], P2[310000];
long long int ans[110000];

int main(){
	
	int A, B, Q;
	cin >> A >> B >> Q;
	
	vector<P> v;
	
	for(int i = 0; i < A; i++){
		long long int x;
		cin >> x;
		v.push_back(P(x, 0));
	}
	for(int i = 0; i < B; i++){
		long long int x;
		cin >> x;
		v.push_back(P(x, 1));
	}
	for(int i = 0; i < Q; i++){
		long long int x;
		cin >> x;
		v.push_back(P(x, i + 2));
	}
	v.push_back(P(-INF, 0));
	v.push_back(P(-INF, 1));
	v.push_back(P(INF, 0));
	v.push_back(P(INF, 1));
	
	sort(v.begin(), v.end());
	
	long long int Sp = 0, Tp = 0;
	for(int i = 0; i < v.size(); i++){
		if(v[i].second == 0){
			P1[i] = Tp;
			Sp = i;
		}else if(v[i].second == 1){
			P1[i] = Sp;
			Tp = i;
		}else{
			P1[i] = max(Sp, Tp);
		}
	}
	Sp = v.size() - 1, Tp = v.size() - 1;
	for(int i = v.size() - 1; i >= 0; i--){
		if(v[i].second == 0){
			P2[i] = Tp;
			Sp = i;
		}else if(v[i].second == 1){
			P2[i] = Sp;
			Tp = i;
		}else{
			P2[i] = min(Sp, Tp);
		}
	}
	/*
	for(int i = 0; i < v.size(); i++){
		cout << v[i].first << " " << v[i].second << " " << P1[i] << " " << P2[i] << endl;
	}
	*/
	for(int i = 0; i < v.size(); i++){
		if(v[i].second > 1){
			long long int S = INF;
			S = min(S, abs(v[i].first - v[P1[i]].first) + abs(v[P1[i]].first - v[P1[P1[i]]].first));
			S = min(S, abs(v[i].first - v[P1[i]].first) + abs(v[P1[i]].first - v[P2[P1[i]]].first));
			S = min(S, abs(v[i].first - v[P2[i]].first) + abs(v[P2[i]].first - v[P1[P2[i]]].first));
			S = min(S, abs(v[i].first - v[P2[i]].first) + abs(v[P2[i]].first - v[P2[P2[i]]].first));
			ans[v[i].second - 2] = S;
		}
	}
	
	for(int i = 0; i < Q; i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 13544
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define ll long long int 
int main() {
    ll h1,h2,m1,m2;
    cin>>h1>>m1>>h2>>m2;
    ll ans;
    ll k;
    cin>>k;
    ans=(h2-h1)*60+(m2-m1);
    if((ans-k)<=0) cout<<0;
    else cout<<(ans-k);
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
int h, w;
while(1){cin >> h >> w; 
if(h==0&&w==0)break;
for(int j=1; j<=h; j++){ 
if(j==1||j==h){
for(int i=1;i<=w;i++){
cout<<"#";
}
}else{
for(int i=1; i<=w; i++){
if(i==1||i==w){
cout<<"#";
}else{ 
cout<<".";
}
}
}cout<<"\n";
}cout<<"\n";
}
}

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

int main()
{
  int n, k, q;
  cin >> n >> k >> q;
  int a[n];
  rep(i, n) a[i] = 0;
  int x;
  rep(i, q){
    cin >> x;
    a[x - 1]++;
  }
  rep(i, n){
    if(q - a[i] < k) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3984
#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()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n;
	cin>>n;
	string prev, curr;
	cin>>prev;
	set<string> st = {prev};
	for(int i=0; i<n-1; i++)
	{
		cin>>curr;
		if(st.count(curr) || prev[prev.length()-1]!=curr[0])
		{
			cout<<"No\n";
			return;
		}
		st.insert(curr);
		prev = curr;
	}
	cout<<"Yes\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3580
program main
	implicit none
	integer N, M, i, j
	integer, allocatable :: a(:), b(:), c(:)
	read(*, *) N, M
	allocate(a(1: M))
	allocate(b(1: M))
	allocate(c(1: N))
	do i = 1, M
		read(*, *) a(i), b(i)
	end do
	c(1: N) = 0
	do i = 1, N
		do j = 1, M
			if(a(j) == i) then
				c(i) = c(i) + 1
			end if
			if(b(j) == i) then
				c(i) = c(i) + 1
			end if
		end do
	end do
	do i = 1, N
		write(*, *) c(i)
	end do
end program main

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	double ans=0;
	for(int i=1; i<=a; i++) {
		double pos=1.0/a;
		int now=i;
		while(now<b) {
			now*=2;
			pos/=2;
		}
		ans+=pos;
	}
	printf("%.12f\n",ans);
	return 0;
}

Measured memory_bytes: 3732
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    match &s[..]{
        "Sunny" => println!("Cloudy"),
        "Cloudy" => println!("Rainy"),
        "Rainy" => println!("Sunny"),
        _ => panic!("no way"),
    }
}


Measured memory_bytes: 4352
grad =[]
while True:
    m,f,r = map(int,input().split())
    if m ==-1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        grad.append("F")
    elif (m+f) >= 80:
        grad.append("A")
    elif 65 <= (m+f) < 80:
        grad.append("B")
    elif 50 <= (m+f) < 65:
        grad.append("C")
    elif 30 <= (m+f) < 50:
        if r >= 50:
            grad.append("C")
        else:grad.append("D")
    elif (m+f)<30:grad.append("F")

for i in grad:
    print(i)



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

using namespace std;

string bin_string(int size, int n) {
    string ret = "";
    for (int i = size - 1; i >= 0; i--) {
        int k = n >> i;
        if (k & 1) {
            ret += "1";
        } else {
            ret += "0";
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> testimonies(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int k = 0; k < a; k++) {
            int x, y;
            cin >> x >> y;
            testimonies[i].emplace_back(make_pair(x, y));
        }
    }
    int ans = 0;
    for (int i = 0; i < pow(2, n); i++) {
        string s = bin_string(n, i);
        vector<int> honest(n, -1);
        int count = 0;
        bool able = true;
        for (int l = 0; l < n; l++) {
            if (s[l] == '1') {
                count++;
                for (auto e: testimonies[l]) {
                    int target = e.first - 1;
                    if (e.second == 1) {
                        if (honest[target] == 0 || s[target] == '0') {
                            able = false;
                            break;
                        }
                        honest[target] = 1;
                    } else {
                        if (honest[target] == 1 || s[target] == '1') {
                            able = false;
                            break;
                        }
                        honest[target] = 0;
                    }
                }
            }
        }
        if (able) {
            ans = max(ans, count);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

bool isOK(ll idx,ll key,vector<ll>& a){
  if(a[idx]>=key)return true;
  return false;
}

ll binary_search(ll key,ll s,ll g,vector<ll> &a){
  ll ng=s-1;
  ll ok=(ll)g;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOK(mid,key,a)) ok=mid;
    else ng=mid;
  }
  return ok;
}

int main(){
  ll n,m;
  cin>>n>>m;
  vec(a,n);
  vector<pair<ll,ll>> p(m);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,m){
    cin>>p[i].second>>p[i].first;
  }
  sort(all(p));
  sort(all(a));
  ll s=0;
  ll g=a.size();
  ll ans=0;
  for(ll i=m-1;i>=0;i--){
    ll tmp=binary_search(p[i].first,s,g,a);
    if(tmp!=0){
      ans+=p[i].first*min(tmp-s,p[i].second);
      s=min(tmp,s+p[i].second);
      
    }else break;
  }
  repf(i,s,g){
    ans+=a[i];
  }
  op(ans);
  return 0;
}


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

#define FOR(type, i, a, b) for (type i = (a); i < (b); ++i)
#define REP(type, i, n) for (type i = 0; i < (n); ++i)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

int main(void) {
  long N, K; cin >> N >> K;
  vector<long> S;
  char pre = '0';
  long c = 0;
  int ss = 1;
  REP(long, i, N) {
    char s; cin >> s;
    if (i == 0 && pre == s) ss = 0;

    if (pre == s) c++;
    else {
      pre = s;
      if (c != 0) {
        if (S.empty()) S.push_back(c);
        else S.push_back(c+S.back());
      }
      c = 1;
    }
  }
  if (S.empty()) S.push_back(c);
  else S.push_back(c+S.back());

  long max = 0;
  FOR(long, i, 0, S.size()) {
    long li = K-1+(i+ss+K)%2;
    long l = MAX(0, i-li), r = MIN(i+li, S.size()-1);
    long v;
    if (l == 0) v = S.at(r);
    else v = S.at(r) - S.at(l-1);
    if (max < v) max = v;
  }
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 1400
N, K = map(int, input().split())
p = list(map(int, input().split()))

P = list(map(lambda x: (1+x)/2, p))

ans = sum(P[0:K])
temp = sum(P[0:K])
for i in range(N-K):
    temp = temp-P[i]+P[i+K]
    ans = max(ans, temp)
print(ans)


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k, a[202020];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = k; i < n; i++){
		if(a[i] > a[i-k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

int main()
{
    long long n;
    cin >> n;
    int cnt = 0;
    for (; n >= 500; n -= 500)
    {
        cnt += 1000;
    }
    for (; n >= 5; n -= 5)
    {
        cnt += 5;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cfloat>
#include<functional>
#include<string>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<random>
#include<map>
#include<chrono>
#include<cctype>
#include<iterator>
#include<bitset>
#include<locale>
#include <chrono>
#include <ctime>
#include<cstring> // for memset
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define all(x) x.begin(),x.end()
#define clr(v,val) memset(v,val,sizeof(v))
#define rep(i,m,n) for(int i=m ; i<n ; i++)
#define forr(i,m,n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define pff push_front
#define re return
#define cmod(x,y) cout<<x%y;
#define bit __builtin_popcountll
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N = 1e5 + 5;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
	IO;
	int n, m, a[N]; 
	priority_queue<ll>p;
	cin >> n >> m;
	rep(i, 0, n) {
		cin >> a[i];
		p.push(a[i]);
	}
	rep(i, 0, m) {
		ll t = p.top();
		p.pop(); p.push(t / 2);
	}
	ll ans = 0;
	rep(i, 0, n) {
		ans += p.top();
		p.pop();
	}
	
	cout << ans << endl;
	
	
}

Measured memory_bytes: 1656
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
ll b_pow(ll x,ll n){return n ? n==1 ? x: b_pow(x,n>>1)*b_pow(x,(n>>1)+(n&1)) : 1;}

set<pair<ll,ll> > c;

void func(int pa , int pb , vector<  pair<long long,int> > &a,vector<  pair<long long,int> > &b , long long A, long long B){
	if(a.size() == pa && b.size() == pb){
		c.insert(make_pair(min(A,B),max(A,B)));
		return;
	}
	//cout << pb << "(" << a.size() << ")" << pb << "(" << b.size() << ")" << A << " " << B << endl;
	
	if(b.size() == pb || (a.size() != pa && pa <= pb) ){
		for(int i = 0 ; i <= a[pa].second ; i++){
			//cout <<"[" << A << "]" << endl;
			func(pa+1,pb,a,b,A,B);
			A *= a[pa].first;
		}
	}else{
		for(int i = 0 ; i <= b[pb].second ; i++){
			//cout <<"[" << B << "]" << endl;
			func(pa,pb+1,a,b,A,B);
			B *= b[pb].first;
		}
	}
}
int f(long long n){
	c.clear();
	map<long long,int> v;
	for(long long i = 2 ; i*i <= n ; i++)
		while(n%i==0) v[i]++ , n /= i;
	if(n != 1) v[n]++;
	vector< pair<long long,int> > q;
	for(map<long long,int>::iterator it = v.begin();it != v.end();++it) q.push_back(*it);
	long long ans = 0;
	for(int i = 0 ; i < (1<<q.size()) ; i++){
		long long a = 1 , b = 1;
		vector< pair<long long,int> > x,y;
		for(int j = 0 ; j < q.size() ; j++){
			if(i>>j&1)	a *= b_pow(q[j].first,q[j].second) , y.push_back(q[j]);
			else		b *= b_pow(q[j].first,q[j].second) , x.push_back(q[j]);
		}
		func(0,0,x,y,a,b);
	}
	return c.size();
	
}
// 2 3
// 6 __ 1 [1 , 2 , 3 , 2*3]
// 2*[1,3] __ 3*[1,2]
int main(){
	long long n;
	while(cin >> n && n){
		cout << f(n) << endl;
	}
}

Measured memory_bytes: 2068
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

int main()
{
	int n;
	int height[25] = {};
	int maxv = 0;
	int ans = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &height[i]);
	}

	for (int i = 0 ; i < n; i++) {
		if (maxv <= height[i]) {
			maxv = height[i];
			ans++;
		}
	}
	
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
int arr[100000]={0};
int main() {
     string x,y;
     long long a=0,d=0;
  cin>>x>>y;
  for(int i=0;i<x.size();i++){
      if(x[i]!=y[i])
          a++;
  }
  cout<<a;
    }

Measured memory_bytes: 3836
//
// Created by Kiran Chavhan on 19/09/2020.
//

#include<bits/stdc++.h>

#define int long long
#define MOD 1000000007
#define sort(a) sort(a.begin(),a.end())
#define endl '\n'

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    int flag=1;
    for(int i=0;i<(n-2);i++){
        if(v[i].first==v[i].second){
            if(v[i+1].second==v[i+1].first)
                if(v[i+2].first==v[i+2].second){
                    cout<<"Yes";
                    flag=0;
                    break;
                }
        }
    }
    if(flag)
    cout<<"No";
}

Measured memory_bytes: 3652
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
P = [int(i) for i in input().split()]
P = sorted(P)
diff = abs(x-(P[0]-1))
ans = P[0]-1
for i in range(1, 102):
  if i not in P and abs(x-i) < diff:
    diff = abs(x-i)
    ans = i
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	int ans = 0;
	ans = max(ans, A + B);
	ans = max(ans, A + A - 1);
	ans = max(ans, B + B - 1);
	cout << ans << endl;
}

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

int main(void){
    string s;
    cin>>s;
    int cnt[3] = {};
    for(char c : s) cnt[c-'a']++;
    sort(cnt,cnt+3);
    cout<<((cnt[2] - cnt[0] <= 1) ? "YES" : "NO")<<endl;
}


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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    int n; cin >> n;
    vi v(n); for (int &x : v) cin >> x;

    int left = 0;
    ll pairs = 0;
    for (int x : v) {
        if (x == 0) left = 0;
        else {
            pairs += (x + left) / 2;
            left = (x + left) % 2;
        }
    }

    cout << pairs << endl;
	
	return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var a int
	var b int
	var c int
	var d int
	var e int
	var k float64
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&e)
	fmt.Scan(&k)

	if math.Abs(float64(a-b)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(a-c)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(a-d)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(a-e)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(b-c)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(b-d)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(b-e)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(c-d)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(c-e)) > k {
		fmt.Println(":(")
		return
	}
	if math.Abs(float64(d-e)) > k {
		fmt.Println(":(")
		return
	}
	fmt.Println("Yay!")

}


Measured memory_bytes: 512
import math
H,W = list(map(int,input().split()))
ans = 1
if H == 1 or W == 1:
    ans = 1
elif H * W % 2 == 0:
    ans = H * W / 2
else:
    ans = ((H-1) * W / 2) + math.ceil(W/2)
print(int(ans))

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

int main(){
    string ans = "NO";
    long a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    
    a += 1000000000;
    b += 1000000000;
    
    int max_coordinate = 0;
    long buf_oni = 0, buf_child = 0;
    if (b - a > 0) {
        max_coordinate = 1;
        buf_oni = a + v * t;
        buf_child = b + w * t;
        
    } else {
        max_coordinate = 0;
        buf_oni = a - v * t;
        buf_child = b - w * t;
    }
    
    int max_coordinate2 = 0;
    if (buf_child - buf_oni > 0) {
        max_coordinate2 = 1;
    } else if (buf_child == buf_oni) {
        ans = "YES";
    } else {
        max_coordinate2 = 0;
    }
    
    if (max_coordinate != max_coordinate2) {
        ans = "YES";
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3640
def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if (a % b==0) else gcd(b, a%b)

def solve(n, k, a):
    if k in a:
        return "POSSIBLE" 
    p = a[0]
    for i in range(1, n):
        p = gcd(p, a[i])
    q = max(a) - p
    if (k <= q) and (gcd(q, k) == p):
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n,k,a))

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long q,a,b,f=0,z;
	cin>>q;
	for(long long i=-1000;i<1000;i++)
	{
		for(long long j=-1000;j<1000;j++)
		{
			z=i*i*i*i*i-j*j*j*j*j;
			if(z==q)
			{
				a=i;
				b=j;
				f=1;
				break;
			}
		}
		if(f==1)
		break;
	}
	cout<<a<<" "<<b;
//	long long qq=-2000;
//	long long ww=-1;
//	long long zz=qq*qq*qq*qq*qq-ww*ww*ww*ww*ww;
//	cout<<"??"<<zz;
}

Measured memory_bytes: 3640
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn sum_check(v: &Vec<i64>, x: i64) -> bool {
    let m = v.iter().sum::<i64>() - x.abs();
    if m < 0 || m % 2 != 0 {
        return false;
    }
    let n: usize = m as usize / 2;
    let mut b: Vec<bool> = vec![false;n+1];
    b[0] = true;
    for x in v {
        for i in 0..cmp::max(0,n as i64 + 1 - *x) as usize {
            if b[i] {
                b[i + *x as usize] = true;
            }
        }
    }
    b[n]
}

fn main() {
    let s = read_vec_char();
    let v = read_vec::<i64>();
    let (mut x,y) = (v[0],v[1]);
    let mut moves: Vec<Vec<i64>> = vec![Vec::new();2];
    let mut tmp = 0;
    let mut d = 0;
    for c in s {
        if c == 'F' {
            tmp += 1;
        } else {
            moves[d].push(tmp);
            tmp = 0;
            d = (d + 1) % 2;
        }
    }
    moves[d].push(tmp);
    x -= moves[0][0];
    moves[0].remove(0);
    if sum_check(&moves[0],x) && sum_check(&moves[1],y) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define end "\n"
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define soa(arr,n) sort(arr,arr+n)
#define sov(arr) sort(arr.begin(),arr.end())
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t=1;
    while(t--){
        int x;
        cin>>x;
        if(x>=30) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    A[i] /= 2;
  }
  int cnt = 0;
  int temp = A[0];
  while(temp%2==0){
    temp /= 2;
    cnt++;
  }
  for(int i=1; i<N; i++){
    int t = A[i];
    int c = 0;
    while(t%2==0){
      c++;
      t /= 2;
    }
    if(c != cnt){
      cout << 0 << endl;
      return 0;
    }
  }
  ll lcm = A[0];
  for(int i=1; i<N; i++){
    lcm = lcm/gcd(lcm,A[i])*A[i];
    if(lcm > M){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << M/lcm - M/(lcm*2) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a,b;
  cin >> a >> b;

  int ans = a;
  if(a > b) --ans;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
//		int c=scan.nextInt();
//		int d=scan.nextInt();
//		int d=scan.nextInt();
//		String str=scan.next();
		int ans=0;
		System.out.println((a*3+b)/2);
	}
}


Measured memory_bytes: 23636
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

int main(){


	string s;
	cin>>s;
	long long k;
	cin>>k;

	for(int i=0;i<s.size();i++){
		long long x=(26-(s[i]-'a'))%26;
		if(x<=k){
			k-=x;
			s[i]='a';
		}
	}

	k%=26LL;
	while(k){
		if(s[s.size()-1]=='z') s[s.size()-1]='a';
		else s[s.size()-1]++;
		k--;
	}
	cout<<s<<endl;

}

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

#define PI 3.14159265358979323846
  
double min(double x, double y)  
{  
    return (x < y)? x: y;  
      
}  
  
double calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
       // printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  

int main() 
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double d=calcAngle(h,m);
    //cout<<d<<"\n";
    //cout<<fixed<<setprecision(20)<<cos((117*PI)/(180));
    double y=cos(d*(PI/180.0));
//     			double ans=(double)a*a+(double)b*b-(double)2*a*b*y;
// 			cout<<fixed<<setprecision(10)<<sqrt(ans);
    // if(d==180)
    // cout<<fixed<<setprecision(20)<<a+b;
    // else if(d==0)
    // cout<<fixed<<setprecision(20)<<abs(b-a);
    // else
    // {
        
          double r=a*a+b*b-(2*a*b*cos(d*(PI/180)));
        
        r=sqrt(r);
        cout<<fixed<<setprecision(10)<<r;
   // }
}

/*1.000000000
2.414213562
127.321336469



*/

Measured memory_bytes: 4160
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  ll a[5];
  rep(i, 0, 5) cin >> a[i];

  rep(i, 0, 5){
    if(a[i] == 0) cout << i+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc091_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  ll h = N == 2 ? 0 : max(1, N - 2);
  ll w = M == 2 ? 0 : max(1, M - 2);

  cout << h * w << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

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

typedef long long ll;
typedef string str;

#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vi vector<int>


int main() {
    IOS;
	
	int a;
	cin >> a;
	cout << a + a * a + a*a*a;
}



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

int main(){
    int N,ans=0;
    cin>>N;
    vector<int>a(N+1),S(N+1);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
        S.at(i)=0;
    }
    bool flag = true;
    int i=1;
    while(flag){
        i=a.at(i-1);
        S.at(i)++;
        ans++;
        if(S.at(2)==1){
            break;
        }
        if(S.at(i)==2){
            flag = false;
        }
    }
    if(flag){
        cout<<ans<<endl;
    }else{
        cout<<"-1"<<endl;
    }
}


Measured memory_bytes: 1152
n = gets.chomp.to_i
array = gets.split(" ").map(&:to_i)

s1 = 0
count = 0
a = (array.inject(:+)/ 2.to_f).round

array.each do |i|
    if (s1 - a).abs >= (s1 + i - a).abs
        s1 += i
        count += 1
    else
        break
    end
end

s2 = array[count..(n-1)].inject(:+)

puts (s1 - s2).abs


Measured memory_bytes: 1916