akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
int ctoi(char a) {
	return (int)a - '0';
}
 //#define int long long
const long long Inf = 4523372036854775807;
const int inf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s, t;
	cin >> s;
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < s.size(); j++) {
			if ((int)s[j] - 'a' == i) {
				goto loop;
			}
		}
		cout << s + (char)(i + 'a') << endl;
		goto stop;
	loop:;
	}
	for (int i = s.size() - 1; i >= 0; i--) {
		for (int j = (int)(s[i] - 'a') + 1; j < 26; j++) {
			for (int z = 0; z < i; z++) {
				if ((int)s[z] - 'a' == j) {
					goto heap;
				}
			}
			for (int z = 0; z < i; z++)
				cout << s[z];
			cout << (char)(j + 'a') << endl;
			goto stop;
		heap:;
		}
	}
	cout << -1 << endl;
stop:;
	getchar(); getchar();
}

Measured memory_bytes: 256
h,w = [],[]
while True:
    (h,w) = [int(x) for x in input().split()]
    if h == w == 0:
        break
    for x in range(h):
        for y in range(w):
            if (x + y) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 6808
def c():
    N = int(input())
    abc = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * N for _ in range(3)]
    dp[0][0], dp[1][0], dp[2][0] = abc[0][0], abc[0][1], abc[0][2]
    i = 0
    for i in range(1, N):
        dp[0][i] = max(dp[1][i - 1] + abc[i][0], dp[2][i - 1] + abc[i][0])
        dp[1][i] = max(dp[0][i - 1] + abc[i][1], dp[2][i - 1] + abc[i][1])
        dp[2][i] = max(dp[0][i - 1] + abc[i][2], dp[1][i - 1] + abc[i][2])
    return max(dp[0][i], dp[1][i], dp[2][i])


if __name__ == '__main__':
    ans = c()
    print(ans)

Measured memory_bytes: 65368
#include<stdio.h>
int main ()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A+B>C+D)
    {
        printf("Left");
    }
    else if(A+B==C+D)
    {
        printf("Balanced");
    }
    else
    {
        printf("Right");
    }
}


Measured memory_bytes: 1720
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	for sc.Scan() {
		s := sc.Text()
		if s == "-" {
			break
		}
		r := []rune(s)

		sc.Scan()
		m, _ := strconv.Atoi(sc.Text())
		for i := 0; i < m; i++ {
			sc.Scan()
			h, _ := strconv.Atoi(sc.Text())
			r = append(r, r...)
			r = r[h : len(r)/2+h]
		}
		fmt.Println(string(r))
	}
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

	int n , d;
	cin >> n >> d;
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		int x, y;
		cin >> x >> y ; if( x*x + y*y <= d*d) ans++;
	}    
	cout << ans << "\n";
  return 0;
}


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

const double eps = 1e-10;

int dcmp(double x) {
        if(fabs(x) < eps) return 0;
        return x < 0 ? -1 : 1;
}

bool same(double a, double b) {return dcmp(a - b) == 0;}
#define Vector P
struct P {
        double x, y;
        P(double x = 0, double y = 0): x(x), y(y) {}
        P operator + (P b) {return P(x + b.x, y + b.y);}
        P operator - (P b) {return P(x - b.x, y - b.y);}
        P operator * (double b) {return P(x * b, y * b);}
        P operator / (double b) {return P(x / b, y / b);}
        double operator * (P b) {return x * b.x + y * b.y;} // Dot
        double operator ^ (P b) {return x * b.y - y * b.x;} // Cross
        double abs() {return hypot(x, y);}
        P unit() {return *this / abs();}
        P spin(double o) {
                double c = cos(o), s = sin(o);
                return P(c * x - s * y, s * x + c * y);
        }
};

struct Line {
        //ax + by + c = 0
        double a, b, c, theta;
        P pa, pb;
        Line(): a(0), b(0), c(0), theta(0), pa(), pb() {}
        Line(P pa, P pb): a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), theta(atan2(-a, b)), pa(pa), pb(pb) {}        P projection(P p) {return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());}                P reflection(P p) {return p + (projection(p) - p) * 2;}
        double get_ratio(P p) {return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs());}
        P dis(P p) {return ((pb - pa) ^ (p - pa)) / (pb - pa).abs();} // directed distance
};
bool onsegment(P p, P a, P b) {
        return dcmp((a - p) ^ (b - p)) == 0 && dcmp((a - p) * (b - p)) <= 0;
}

struct Circle {
        P c;
        double r;
        Circle(P c, double r = 0): c(c), r(r) {}
};
int point_in_polygon(vector<P> ps, P p) {
        int cnt = 0;
        int wn = 0;
        for(int i = 0; i < (int)ps.size(); i++) {
                int ii = (i + 1) % (int)ps.size();
                if(onsegment(p, ps[i], ps[ii])) return -1;
                int k = dcmp((ps[ii] - ps[i]) ^ (p - ps[i]));
                int d1 = dcmp(ps[i].y - p.y);
                int d2 = dcmp(ps[ii].y - p.y);
                if(k > 0 && d1 <= 0 && d2 > 0) wn++;
                if(k < 0 && d2 <= 0 && d1 > 0) wn--;
        }
        if(wn != 0) return 1; // inside
        return 0; // outside
}
int main() {
        ios_base::sync_with_stdio(false); cin.tie(0);
        int n; cin >> n;
        vector<P> ps;
        for(int i = 0; i < n; i++) {
                P p; cin >> p.x >> p.y;
                ps.push_back(p);
        }
        int q; cin >> q;
        while(q--) {
                P p; cin >> p.x >> p.y;
                int res = point_in_polygon(ps, p);
                if(res == -1) cout << 1 << '\n';
                else if(res == 1) cout << 2 << '\n';
                else cout << 0 << '\n';
        }
        return 0;
}


Measured memory_bytes: 3300
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;
int main() {
	int X;
	cin >> X;
	int D = X % 10;
	X /= 10;
	int C = X % 10;
	X /= 10;
	int B = X % 10;
	X /= 10;
	int A = X % 10;
	int Bi, Cj, Dk;;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				int sum = A;
				if (i == 0) {
					sum += B;
				}
				else {
					sum -= B;
				}
				if (j == 0) {
					sum += C;
				}
				else {
					sum -= C;
				}
				if (k == 0) {
					sum += D;
				}
				else {
					sum -= D;
				}
				if (sum == 7) {
					Bi = i;
					Cj = j;
					Dk = k;
				}
			}
		}
	}
	char y1, y2, y3;
	if (Bi == 0) {
		y1 = '+';
	}
	else {
		y1 = '-';
	}
	if (Cj == 0) {
		y2 = '+';
	}
	else {
		y2 = '-';
	}
	if (Dk == 0) {
		y3 = '+';
	}
	else {
		y3 = '-';
	}
	cout << A << y1 << B << y2 << C << y3 << D << "=7" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s,u,t; int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u)
    a--;
  else if (t==u)
    b--;
  cout<<a<<endl<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int H, W, N, x, y, a;
	int ans[100][100] = {},c=0;
	cin >> W >> H >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> x >> y >> a;
		switch (a)
		{
		case 1:
			for (int i = 0; i < H; i++)
			{
				for (int j = x-1; j >= 0; j--)
				{
					ans[i][j] = 1;
				}
			}
			break;
		case 2:
			for (int i = 0; i < H; i++)
			{
				for (int j = x; j < W; j++)
				{
					ans[i][j] = 1;
				}
			}
			break;
		case 3:
			for (int i = y - 1; i >= 0; i--)
			{
				for (int j = 0; j < W; j++)
				{
					ans[i][j] = 1;
				}
			}
			break;
		case 4:
			for (int i = y ; i < H; i++)
			{
				for (int j = 0; j < W; j++)
				{
					ans[i][j] = 1;
				}
			}
			break;
		default:
			break;
		}
	}
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)if(ans[i][j] == 0)c++;
	cout << c;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            sum += v[i] * v[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        System.out.println(s1.substring(0, 1) + s2.substring(0, 1) + s3.substring(0, 1));
    }
}


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

using namespace std;
typedef long long ll;
const int Q = 50;
int n, m, q, ans = 0;
int a[Q], b[Q], c[Q], d[Q];

void solve(vector<int> &v) {
    if (v.size() == n) {
        int cur = 0;
        for (int i = 0; i < q; i++) {
            if (v[b[i]] - v[a[i]] == c[i]) cur += d[i];
        }
        ans = max(ans, cur);
        return;
    }
    int last = v.empty() ? 1 : v.back();
    for (int i = last; i <= m; i++) {
        v.push_back(i);
        solve(v);
        v.pop_back();
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
    vector<int> v;
    solve(v);
    cout << ans << "\n";
}


Measured memory_bytes: 3628
#include <cstdio>
using namespace std;

int main(){
    char str[4][4], ans[4][4];
    for(int i = 1; i <=2; i++) scanf("%s", str[i]+1);
    
    for(int i = 2, ii = 1; i >= 1; i--, ii++)
        for(int j = 3, jj = 1; j >= 1; j--, jj++)
            ans[ii][jj] = str[i][j];
    int i, j, flag = 0;
    for(i = 1; i <= 2 && !flag; i++)
        for(int j = 1; j <= 3; j++)
            if(ans[i][j] != str[i][j]) {
                flag = 1;
                break;
            }   
    if(!flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

int main(){
  int n,d,x,ans;
  cin >> n >> d >> x;
  vector<int> A(n);
  for(int i =0;i < n;i++){
    cin >> A.at(i);
  }
  ans = x;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < d;j++){
      if(A.at(i)*j+1 <= d){
        ans++;
      }else{
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int n, m, X, Y, x, y, max = -101, min = 101;
    cin >> n >> m >> X >> Y;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (max < x){
            max = x;
        } 
    }
    for (int i = 0; i < m; i++){
        cin >> y;
        if (min > y){
            min = y;
        } 
    }
    if (X > max){
        max = X;
    }
    if (max >= Y ){
        cout << "War" << endl;
    }else if (min >= max + 1){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static double n, m, d, s, t;
    static int[] U, V, A, B;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        double ans = ((m-1) * 2 * (n-d)) / (n*n);
        if(d==0) System.out.println(ans/2);
        else System.out.println(ans);
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextDouble();
        m = in.nextDouble();
        d = in.nextDouble();
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

Measured memory_bytes: 24404
#include <iostream>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <stack>

int main()
{
	long long N;
	std::cin >> N;

	long long min = N - 1;
	for (long long i = 2; i * i <= N; ++i)
	{
		if (N % i == 0)
		{
			long long j = N / i;
			long long d = (i - 1) + (j - 1);
			if (d < min)
			{
				min = d;
			}
		}
	}

	std::cout << min << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const ll mod = 10000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(void){
    int K , S;
    cin >> K >> S;
    int ans = 0;
    for (int x = 0; x <= K; x++){
        for (int y = 0; y <= K; y++){
            int z = S - x - y;
            if (z >= 0 && z <= K){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,-1,0,1 };
const int LIT = -32768 * 100;

int n, m;
int arr[101];

void solve() {
    string s, t;
    cin >> s >> t;
    int ans = 1001;

    if (s.length() == t.length()) {
        int cnt = 0;
        for (int i = 0; i < s.length(); i++)
            if (s[i] != t[i]) cnt++;
        cout << cnt;
    }
    else {
        for (int i = 0; i < s.length() - t.length(); i++) {
            int cnt = 0;
            for (int j = 0; j < t.length(); j++) {
                if (s[i + j] != t[j])  cnt++;
            }
            ans = min(ans, cnt);

        }
        cout << ans;
    }
}

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


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

using namespace std;

int n;
vector<long long>vec;

void input(){
    for(int i=0;i<n;i++){
        long long a;
        cin>>a;

        vec.push_back(a);
    }
}

long long dp[3003][3003];
bool vis[3003][3003];


//rec(L,R) will return the value of (x-y) for range [L,R]
long long rec(int L, int R){

    if(vis[L][R]==true)return dp[L][R];

    if(L==R)return vec[L];  //base case
    //if the current player removes the first element of the range
    long long score1 = vec[L] - rec(L+1,R);
    //if the current player removes the last element of the range
    long long score2 = vec[R] -  rec(L,R-1);

    vis[L][R]=true; //done for this range
    return dp[L][R] = max(score1,score2);
}


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

    memset(vis,false,sizeof vis);
    cin>>n;

    input();

    //rec(0, n-1) will return the answer for range [0,n-1]
    //(x-y) where x is the score of first player , y is for second player
    cout<<rec(0,n-1)<<"\n";
}


Measured memory_bytes: 78592
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using s64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int a,b;
    cin >> a >> b;
    if(b%a == 0)
        cout << a+b << endl;
    else
        cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a

    return gcd(b, a % b)

ll = []
lr = []

ll.append(a[0])
lr.append(a[n - 1])
for i in range(1, n):
    ll.append(gcd(ll[i - 1], a[i]))
    lr.append(gcd(lr[i - 1], a[n - i - 1]))

ll.insert(0, lr[n - 2])
lr.insert(0, ll[n - 1])

ans = 0
for i in range(n):
    t = gcd(ll[i], lr[n - i - 1])
    if t > ans:
        ans = t

print(ans)

Measured memory_bytes: 14436
import java.util.ArrayList;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			//入力と配列準備
			int n = sc.nextInt();
			int max = (int)Math.pow(2,n) - 1;
			int tLen = sc.nextInt();
			ArrayList<Integer> list = new ArrayList<Integer> ();
			for (int i = 0; i<tLen; i++) list.add(sc.nextInt());
			ArrayList<Integer> ans = new ArrayList<Integer>();
			//--------------------------------------------------------
			if (tLen == 0) System.out.println("0:");
			for (int i = 1; i<=max; i++) {
				ans.clear(); //初期化
				String binary = Integer.toBinaryString(i);
				for (int j=0; j<binary.length(); j++) {
					char c =  binary.charAt(binary.length()-j-1);
					if (c == '1') {
						ans.add(j);  //部分集合をキープ
					}
				}
				if (ans.containsAll(list)) {
					System.out.print(i+":");
					for (int j : ans) System.out.print(" " + j);
					System.out.print('\n');
				}
			}
		}
	}
}


Measured memory_bytes: 71104
use proconio::input;
use proconio::marker::{Bytes, Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        x: u32,
        y: u32,
    }
    if 2*x > y {
        println!("No");
        return;
    }
    let mut sum = 2*x;
    for _ in 0..x+1 {
        if sum == y {
            println!("Yes");
            return;
        }
        sum += 2;
    }
    // for bit in 0..2_i64.pow(x) {
    //     let mut sum = 0;
    //     for i in 0..x {
    //         let mask = 1 << i;
    //         if bit & mask > 0 {
    //             sum = sum + 2;
    //         }
    //         else {
    //             sum = sum + 4;
    //         }
    //     }
    //     if sum == y {
    //         println!("Yes");
    //         return;
    //     }
    // }
    println!("No");
}


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll H, W, m;
  cin >> H >> W >> m;
  vector<ll> h(m), w(m), hs(H), ws(W);
  rep(i, m) {
    cin >> h[i] >> w[i];
    --h[i];
    --w[i];
    ++hs[h[i]];
    ++ws[w[i]];
  }
  using pll = pair<ll, ll>;
  set<pll> s;
  rep(i, m) s.emplace(h[i], w[i]);
  ll hsmax = -1, wsmax = -1;
  itr(x, hs) updatemax(hsmax, x);
  itr(x, ws) updatemax(wsmax, x);
  vector<ll> hsmaxi, wsmaxi;
  rep(i, H) if (hs[i] == hsmax) hsmaxi.push_back(i);
  rep(i, W) if (ws[i] == wsmax) wsmaxi.push_back(i);
  ll ans = hsmax + wsmax;
  if (hsmaxi.size() * wsmaxi.size() <= m) {
    itr(hi, hsmaxi) itr(wi, wsmaxi) {
      if (s.find(pll(hi, wi)) == s.end()) goto end;
    }
    --ans;
  }
end:
  cout << ans << endl;
}


Measured memory_bytes: 39696
package main
 
import (
  "fmt"
  "os"
)
 
func main() {
  var b string
  fmt.Scan(&b)
  //fmt.Fscan(os.Stdin, &b)
  
  switch b{
    case "A":
    fmt.Print("T")
    case "T":
    fmt.Println("A")
    case "G":
    fmt.Fprintln(os.Stdout, "C")
    case "C":
    c := fmt.Sprint("G")
    fmt.Print(c) 
  }
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

double powr(double x, ll y)
{

    double ret = 1.0;
    for(ll i = 0; i < y; i++) ret*=x;
    return ret;
}

int main()
{

    double n, k;
    cin >> n >> k;
    double ans = 0.0;
    for(double i = 1; i <= n; i+=1.0)
    {

        ll cnt=0;
        double nn = i;
        while(1)
        {

            if(nn >= k) break;
            nn*=2.0;
            cnt++;
        }
        double cur = 1.0/n;
        cur *= powr(.5, cnt);
        ans+=cur;
    }
    printf("%.15lf\n", ans);
}


Measured memory_bytes: 256
n,m = list(map(int, input().split()))
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for r in range(n-m+1):
    for c in range(n-m+1):
        flg=True
        for i in range(m):
            for j in range(m):
                if a[r+i][c+j] != b[i][j]:
                    flg=False
                    break
            if not flg:
                break
        if flg:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 9160
import sys
n, m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for m in range(m)]

k=0
t=0
x=0
a=[0]*n

for i in table:
	k=i[0]
	t=i[1]
	if k>n:
		print(-1)
		sys.exit()
	b=a[k-1]
	if k==1 and t==0 and n!=1:
		x=-1
	elif k>n:
		x=-1
	if b!=t and b!=0:
		x=-1
	else:
		a[k-1]=t
if len(a)==3 and x==0:
	if a[0]==0:
		a[0]=1
	x=a[0]
	y=a[1]
	z=a[2]
	print(x*100+y*10+z)
if len(a)==2 and x==0:
	if a[0]==0:
		a[0]=1
	x=a[0]
	y=a[1]
	print(x*10+y)
if len(a)==1 and x==0:
	x=a[0]
	print(x)
if x==-1:
	print(-1)

Measured memory_bytes: 3064
class UnionFind:
	"""
	class UnionFind
	https://note.nkmk.me/python-union-find/
	
	order O(log(n))
	
	n = the number of elements
	parents = the list that contains "parents" of x. be careful that it doesn't contain "root" of x.
	"""
	def __init__(self, n):
		"""
		make UnionFind
		:param n: the number of elements
		"""
		self.n = n
		self.parents = [-1] * n
	
	def find(self, x):
		"""
		:param x: an element
		:return: the root containing x
		"""
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	
	def union(self, x, y):
		"""
		:param x, y: an element
		"""
		# root
		x = self.find(x)
		y = self.find(y)
		if x == y:
			# already same group so do nothing
			return
		if self.parents[x] > self.parents[y]:
			# the root should be min of group
			x, y = y, x
		# remind that x, y is the root, x < y, then, y unions to x.
		self.parents[x] += self.parents[y]
		# and then y's parent is x.
		self.parents[y] = x
	def size(self, x):
		# return the size of group
		return -self.parents[self.find(x)]
	
	def same(self, x, y):
		# return whether the x, y are in same group
		return self.find(x) == self.find(y)
	
	def members(self, x):
		# return members of group
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]
	
	def roots(self):
		# return all roots
		return [i for i, x in enumerate(self.parents) if x < 0]
	
	def group_count(self):
		# return how many groups
		return len(self.roots())
	
	def all_group_members(self):
		# return all members of all groups
		return {r: self.members(r) for r in self.roots()}

n,m= map(int,input().split())
union = UnionFind(n)
for i in range(m):
	a,b = map(int,input().split())
	union.union(a-1,b-1)
print(union.group_count()-1)

Measured memory_bytes: 12976
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <random>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;

int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
int main() {
  int n; cin>>n;
  int an=1e9;
  for(int i=1;i<n;i++) {
    an = min(an, keta(i) + keta(n-i));
  } 
  cout<<an<<endl;
}

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

int main(){
  int n, k;
  int x;
  int sum = 0;
  int tmp_a, tmp_b;
  std::cin >> n >> k;
  for(int i=0; i<n; i++){
    std::cin >> x;
    tmp_a = 2 * x; 
    tmp_b = 2 * std::abs(x - k);
    if(tmp_a>tmp_b)sum += tmp_b;
    else sum += tmp_a;
  }
  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;
ll inf = 1001001001;
int main(){
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(), v.end());
  ll x = v[n-1];
  ll y;
  double div = x/2.;
  double t = (double)inf;
  rep(i,n) {
    if(abs(v[i]-div) < t) {
      y = v[i];
      t = abs(v[i]-div);
    }
  }
  std::cout << x << ' ' << y << std::endl;
  return 0;
}



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

int a, b, c;

int main(){
	scanf("%d %d %d", &a, &b, &c);
	a = a * 100 + b * 10 + c;
	if(a % 4 == 0){
		puts("YES");
	} else {
		puts("NO");
	}
	return 0;
}


Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

typedef pair<ll,ll> pll;

ll me(ll a,ll b)
{
    ll res=1;

    while(b)
    {
        if(b&1)
        res=(res*a)%mod;

        b>>=1; a=(a*a)%mod;
    }

    return res;
}

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

int main()
{
    int n;

    scn(n);

    map<pll,ll> ma;

    ll az=0,xz=0,yz=0;

    rep(i,0,n)
    {
        ll a,b; lscn(a); lscn(b);

        if(a==0 and b==0)
        az++;
        else if(a==0)
        xz++;
        else if(b==0)
        yz++;
        else
        {
            pll p;

            ll d=gcd(abs(a),abs(b));

            a/=d; b/=d;

            int sa=a/abs(a),sb=b/abs(b);

            if(a<0)
            a*=-1;

            if(b<0)
            b*=-1;

            if(sa*sb<0)
            p=mp(-a,b);
            else            
            p=mp(a,b);

            if(ma.find(p)!=ma.end())
            ma[p]++;
            else
            ma[p]=1;
        }
    }

    ll ans=0,other=1;

    for(auto &it:ma)
    {
        pll ph=it.F,preq;

        if(ph.F<0)
        preq=mp(ph.S,-ph.F);
        else
        preq=mp(-ph.S,ph.F);

        ll cnt1=it.S,cnt2=0;

        if(ma.find(preq)!=ma.end())
        cnt2=ma[preq],ma[preq]=0,it.S=0;

        ll contribution=(me(2,cnt1)+me(2,cnt2)-1+mod)%mod;

        other=(other*contribution)%mod;
    }

    ans=(other-1+mod)%mod; //remove the empty set

    ll temp=(me(2,xz)-1+mod)%mod,temp1;

    temp=(temp*other)%mod;

    ans=(ans+temp)%mod;

    temp=(me(2,yz)-1+mod)%mod;

    temp=(temp*other)%mod;

    ans=(ans+temp)%mod;

    ans=(ans+az)%mod; 

    lpri(ans);

    return 0;
}


Measured memory_bytes: 16188
N, Y = map(int, input().split())
import sys
for x in range(N+1):
  for y in range(N+1 - x):
    if 9000 * x + 4000 * y == Y - 1000 * N:
      print(x, y, N - x - y)
      sys.exit()
else:
  print(-1, -1, -1)

Measured memory_bytes: 40556
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int x;
    cin >> x;
    if(x == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3592
n=int(input())
l=list(map(int,input().split()))
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
for i in range(n):
    if i%2:
        dq.append(l[i])
    else:dq.appendleft(l[i])
print(*list(dq)[::-(-1)**(n%2)])

Measured memory_bytes: 26180
from collections import defaultdict

primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,10**7]
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7

factors=defaultdict(lambda: 0)

for i in a:
    lfactors=defaultdict(lambda: 0)
    for prime in primes:
        if prime>i:
            lfactors[i]+=1
            break
        while i%prime==0:
            i=i//prime
            lfactors[prime]+=1
    for key,value in zip(lfactors.keys(),lfactors.values()):
        factors[key]=max(factors[key],value)
ans=1
for fact,p in zip(factors.keys(),factors.values()):
    ans=(ans*pow(fact,p))%mod
print(sum([(ans*pow(i,mod-2,mod))%mod for i in a])%mod)

Measured memory_bytes: 54640
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    rob: [(i64, i64); n],
  }
  let mut rob: Vec<_> = rob.into_iter().map(|(x, l)| (x + l, x - l)).collect();
  rob.sort();
  let mut ans = 0;
  let mut current = -(1i64 << 60);
  for &(r, l) in &rob {
    if l >= current {
      ans += 1;
      current = r;
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 10492
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1,0);
    rep(i,1,n+1){
        rep(j,1,n/i+1){
            a[i*j]++;
        }
    }
    ll ans = 0;
    rep(i,1,n+1){
        ans += a[i]*i;
    }
    PRINT(ans);
}


Measured memory_bytes: 81340
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;

const int N=131072+10;
const LL Inf=1e16+10;

int n,f[N],v[N],left[N],right[N];

void Init()
{
	scanf("%d",&n);
	for (int i=2;i<=n;++i)
	{
		scanf("%d%d",&f[i],&v[i]);
		if (left[f[i]]) right[f[i]]=i;
		else left[f[i]]=i;
	}
}

vector<pair<LL,LL> > P[N],L,R;

LL g[N];
void Dfs(int x,int Lim)
{
	if (!left[x] && !right[x]) { P[x].push_back(make_pair(v[x],v[x])); return ; }
	Dfs(left[x],Lim); Dfs(right[x],Lim);
	
	if ((int)P[left[x]].size()>(int)P[right[x]].size()) swap(left[x],right[x]);
	
	LL Min=Inf;int p=0;
	for (int i=0;i<(int)P[left[x]].size();++i) 
	{
		while (0ll+P[left[x]][i].first+Min>Lim && p<(int)P[right[x]].size()) { Min=min(Min,P[right[x]][p].second); p++; }
		if (0ll+P[left[x]][i].first+Min>Lim) break;
			L.push_back(make_pair(P[right[x]][p-1].first,P[left[x]][i].second));
	}

		Min=Inf; p=0;
	for (int i=0;i<(int)P[left[x]].size();++i) g[i]=Inf;
	for (int i=0;i<(int)P[right[x]].size();++i)
	{
		while (0ll+P[right[x]][i].first+Min>Lim && p<(int)P[left[x]].size()) { Min=min(Min,P[left[x]][p].second); ++p;  }
		if (0ll+P[right[x]][i].first+Min>Lim) break;
		g[p-1]=min(g[p-1],P[right[x]][i].second);
	}
	
	for (int i=0;i<(int)P[left[x]].size();++i) 
		if (g[i]!=Inf) R.push_back(make_pair(P[left[x]][i].first,g[i]));

	int p1=0,p2=0;
	while (p1<(int)L.size() || p2<(int)R.size())
	{
		if (p2>=(int)R.size()) P[x].push_back(L[p1]),++p1;
		else if (p1>=(int)L.size()) 
			P[x].push_back(R[p2]),++p2;
		else if (L[p1].first<R[p2].first || (L[p1].first==R[p2].first && L[p1].second<R[p2].second)) 
			P[x].push_back(L[p1]),++p1;
		else P[x].push_back(R[p2]),++p2;
	}
	
	L.erase(L.begin(),L.end()); R.erase(R.begin(),R.end()); 
	P[left[x]].erase(P[left[x]].begin(),P[left[x]].end()); 
	P[right[x]].erase(P[right[x]].begin(),P[right[x]].end());
	
	for (int i=0;i<(int)P[x].size();++i) 
	{
		P[x][i].first+=v[x];
		P[x][i].second+=v[x];
	}
}

bool Check(int x)
{
	for (int i=1;i<=n;++i) P[i].erase(P[i].begin(),P[i].end());
	Dfs(1,x);
	if ((int)P[1].size()) return 1;
	return 0;
}

void Solve()
{
	int l=0,r=1e9;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (Check(mid)) r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",l);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, t;
    cin >> n >> t;
    ll ans = 0;
    int prev = -1;
    REP(i,n) {
        int x; cin >> x;
        if (i != 0) {
            if (prev+t <= x) ans += t;
            else ans += x-prev;
        }
        prev = x;
    }
    ans += t;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
cnt=0
ans=0
kaisu=0
while cnt<len(h)-1:
  if h[cnt]< h[cnt+1]:
    
    ans=max(ans,kaisu)
    #print(ans)
    kaisu=0
    cnt+=1
  else:
    cnt+=1
    kaisu+=1

ans=max(ans,kaisu)
    
print(ans)

Measured memory_bytes: 14252
fn main() {
    let a: String = read();
    let b: String = read();
    let s: String = format!("{}{}", a, b);
    let n = s.parse::<f64>().unwrap();
    let sqrt = n.sqrt();
    if sqrt as i64 as f64 == sqrt {
        println!("Yes");
    } else {
        println!("No");
    }
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

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

    int current = m;
    int max_ = current;
    for (int i = 0; i < n; ++i) {
        if (current < 0) {
            max_ = 0;
            break;
        }
        int in, out;
        cin >> in >> out;
        current += in;
        current -= out;
        max_ = max(current, max_);
    }
    cout << max_ << endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<algorithm>
//#include <bits/stdc++.h>

using namespace std;
bool is_para(string s){
    string p = s;
    reverse(p.begin(), p.end());
    return s == p;
}

int main (){
    string s;
    int  mid_fs, mid_ss;
    cin >> s;
    int n = s.size();
    mid_fs = ((n - 1)/2);
    mid_ss = ((n + 1)/2);
    if (is_para(s) && is_para(s.substr(0, mid_fs)) && is_para(s.substr(mid_ss))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  int main()
{
 long long  int n,d;
  cin>>n>>d;
  int ans=0;
    d=d*d;
    for(int i=0;i<n;i++)
    {
     long long  int a,b;
      cin>>a>>b;
      a=a*a;
      b=b*b;
     long long int temp=(a+b);
      if(temp<=d)
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final int MAX = 1000000;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean[] prime = new boolean[MAX + 1];
        Arrays.fill(prime, true);
        prime[1] = false;
        for (int i = 2; i <= 1000; i++) {
            if (prime[i]) {
                for (int j = i * 2; j < MAX + 1; j += i) {
                    prime[j] = false;
                }
            }
        }
        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if ((n | x) == 0) {
                break;
            }
            int[] m = new int[n];
            for (int i = 0; i < n; i++)
                m[i] = sc.nextInt();
            boolean[] b = new boolean[x + 1];
            b[0] = true;
            String ans = "NA";
            for (int i = 1; i <= x; i++) {
                for (int j = 0; j < n; j++) {
                    if (i - m[j] >= 0 && b[i - m[j]]) {
                        b[i] = true;
                        if (prime[i])
                            ans = i + "";
                        break;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 16000
num = int(raw_input())
list_ = [[False for i in range(13)] for j in range(4)]
for x in range(0, num):
	mark, number = map(str, raw_input().split())
	if mark == 'S':
		list_[0][int(number) - 1] = True
	if mark == 'H':
		list_[1][int(number) - 1] = True
	if mark == 'C':
		list_[2][int(number) - 1] = True
	if mark == 'D':
		list_[3][int(number) - 1] = True

for x in range(0, 4):
	for y in range(0, 13):
		if not list_[x][y]:
			if x == 0:
				print "S", y + 1
			elif x == 1:
				print "H", y + 1
			elif x == 2:
				print "C", y + 1
			else:
				print "D", y + 1

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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a).size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define endl "\n"

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//K-th smallest
//cout << k << "rd smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

// priority_queue <ll,vector<ll>,greater<ll> > p;

typedef long long ll;
typedef pair<ll,ll> pii;

ll mod=1000000007;

ll power(ll x, ll y) 
{
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return (temp*temp)%mod;
	else
		return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll min_pr = 1;
	ll ans = 0;
	for(ll i=0;i<n;i++)
	{
		ll val;
		cin>>val;
		val--;
		ans += val/min_pr;
		if(i==0 || val+1 == min_pr)
			min_pr++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	
	int out=inf;
	vi d(n+1);
	rep(i,n)d[i+1]+=d[i]+in[i];
	rep(i,n-1){
		int a=d[i+1],b=d[n]-d[i+1];
		cmin(out,abs(a-b));
	}
	
	if(out==inf)out=0;
	cout<<out<<endl;
}












Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    vector<vector<int>> acts(N, vector<int>(3, 0));
    rep(i, 0, N) cin >> acts[i][0] >> acts[i][1] >> acts[i][2];

    vector<vector<int>> states(N+1, vector<int>(3, 0));
    rep(date, 0, N)
    {
        rep(act, 0, 3)
        {
            states[date+1][act] = max(states[date+1][act], states[date][(act+1)%3] + acts[date][(act+1)%3]);
            states[date+1][act] = max(states[date+1][act], states[date][(act+2)%3] + acts[date][(act+2)%3]);
            // cout << date << ' ' << act << endl;
        }
    }

    int res = 0;
    res = max(res, states[N][0]);
    res = max(res, states[N][1]);
    res = max(res, states[N][2]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136