akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b,c;

int main(){
	cin>>a>>b>>c;
	if(a<c^b<c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int n; ll k;
	cin >> n >> k;
	vector<vector<int>> a(n, vector<int>(65));
	for (int i = 0; i < n; ++i) {
		cin >> a[i][0]; --a[i][0];
	}
	for (int j = 1; j < 65; ++j) {
		for (int i = 0; i < n; ++i)
			a[i][j] = a[a[i][j - 1]][j - 1];
	}
	int now = 0;
	for (int j = 62; j >= 0; --j) {
		if (k & (1LL << j)) {
			now = a[now][j];
		}
	}
	cout << (++now) << endl;
	return 0;
}

Measured memory_bytes: 61012
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A <= 8 && B <= 8){
            System.out.println("Yay!");
        }else{
            System.out.println(":(");
        }
    }
}

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

int main() {
    vector<vector<int>>data(3,vector<int>(3));
    rep(i,3){
        rep(j,3)cin>>data[i][j];
    }
    bool judge =false;
    int N;
    cin>>N;
    vector<int>b(N);
    rep(i,N)cin>>b[i];
    int count;

    rep(i,3){
        count=0;
        rep(k,3){
        rep(j,N){
            if(data[i][k]==b[j]){
                count++;
                break;
            }
        }
        if(count>=3)judge=true;
        }
    }
     rep(k,3){
         count=0;
        rep(i,3){
        rep(j,N){
            if(data[i][k]==b[j]){
                count++;
                break;
            }
        }
        if(count>=3)judge=true;
        }
    }
    count =0;
    rep(i,3){
        rep(j,N){
        if(data[i][i]==b[j]){
            count ++;
            break;
    }
    }
}
if(count>=3)judge =true;

     count =0;
    rep(i,3){
        rep(j,N){
        if(data[2-i][i]==b[j]){
            count ++;
            break;
    }
    }
}
if(count>=3)judge =true;
if(judge)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}



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

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> csfs(N - 1, vector<int>(3));
  for (int i = 0; i < N - 1; i++)
  {
    cin >> csfs.at(i).at(0) >> csfs.at(i).at(1) >> csfs.at(i).at(2);
  }

  for (int i = 0; i < N - 1; i++)
  {
    long long int t = csfs.at(i).at(1) + csfs.at(i).at(0);
    for (int j = i + 1; j < N - 1; j++)
    {
      if (t <= csfs.at(j).at(1))
      {
        t = csfs.at(j).at(1) + csfs.at(j).at(0);
      }
      else if (t % csfs.at(j).at(2) == 0)
      {
        t += csfs.at(j).at(0);
      }
      else
      {
        t += csfs.at(j).at(2) - (t % csfs.at(j).at(2)) + csfs.at(j).at(0);
      }
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int i;
    char s[1012];
    scanf("%s", s);
    for (i = 0; s[i] != 0; i++) {
        printf("%c", s[i]);
    }
    if (s[i - 1] == 's') printf("es\n");
    else printf("s\n");
    return 0;
}

Measured memory_bytes: 1620
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    int n = s.length;
    int a = 0;
    for(int i = 0; i < n / 2; i++){
      if(s[i] == s[n - 1 - i]){
        continue;
      }else{
        a++;
      }
    }
    System.out.println(a);

  }
}

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

int main(){
    int k;
    cin >> k;
    int ans = 0;
    if(k % 2 != 0){
        ans = (k/2) * (k+1)/2;
    }else{
        ans = (k/2)*(k/2);
    }
    cout << ans << endl;
} 

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

int main()
{
  int a[10];
  for (int i = 0; i < 10; i++) cin >> a[i];
  sort(a, a + 10);
  reverse(a, a + 10);

  cout << a[0] << endl;
  cout << a[1] << endl;
  cout << a[2] << endl;
}



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

#define sz(s) (int)(s).size()
#define sqr(x) (x) * (x)
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define pi acis(-1)
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 1000000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	if (n > m)
		cout << "safe";
	else
		cout << "unsafe";





}



Measured memory_bytes: 3652
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using namespace atcoder;
using ll = long long;
const int mod = 1e9 + 7;

void solve()
{
    int s;
    cin >> s;
    vector<ll> dp(2020);
    dp[3] = 1;
    rep(i, s + 1)
    {
        if (i > 3)
            dp[i] = dp[i - 3] % mod + dp[i - 1] % mod;
        dp[i] %= mod;
    }
    cout << dp[s] << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int a = 0, b = 0;
  rep(i, 0, N) if (s[i] == 'R') a++;
  int ans = max(a, b);
  rep(i, 0, N) {
    if (s[i] == 'R')
      --a;
    else
      b++;
    int now = max(a, b);
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3752
#include  <bits/stdc++.h>
using namespace std;
#define    error(args...){string _s=#args;replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);err(_it,args);}
void err  (istream_iterator<string> it) {}
template  <typename T, typename... Args>
void err  (istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<" ; ";
    err(++it, args...);
    cout << endl;
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
/*Let's start.............*/
#define   ll                long long
#define   pb                push_back
#define   ff                first
#define   ss                second
#define   srt(v)            sort(v.begin(),v.end())
#define   inf               200000000000000000
#define   mxn               100009
#define   MOD               1000000007
#define   pi                acos(-1)



int main()
{

    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll X,a,b;
    cin >> X >> a >> b;
    X = abs(X);
    ll keep = (X/b);
    if(X == 0){
        if(a%2== 0) cout << 0 << endl;
        else cout << b << endl;
    }
    else if(a <= keep){
        cout << X - (a*b) << endl;
    }
    else{
        ll  rem = (X - (X/b)*b);
        ll  keep = (b - rem);

        ll peek = (X/b);
        ll ans = 0;
        if(peek%2 == (a%2)) ans = rem;
        else ans = keep;
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 3648
n=int(input())
l=list(map(int,input().split()))
c=0
x=[]
y={}
for i in range(n):
	x.append(l[i]+i)
	if (i-l[i]) in y: 
		y[i-l[i]]+=1
	else:
		y[i-l[i]]=1
for i in x:
	if i in y :
		c+=y[i]

	
print(c)

Measured memory_bytes: 124296
#include <stdio.h>
#include <set>
#include <queue>
using namespace std;
const int N=1e2+10;
int main(){
    int n,u,d;
    char c[10];
    set<int> m,lock[N],wait[N],bewait[N];
    queue<int> q;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&u);
        scanf("%s",c);
        scanf("%d",&d);
        if(c[0]=='w'){
            wait[u].insert(d);
            bewait[d].insert(u);
        }
        else lock[u].insert(d);
    }
    for(int i=0;i<N;i++)if(wait[i].empty())q.push(i);
    while(!q.empty()){
        u=q.front();
        q.pop();
        while(!lock[u].empty()){
            d=*lock[u].begin();
            lock[u].erase(lock[u].begin());
            for(auto i:bewait[d]){
                wait[i].erase(d);
                if(wait[i].empty())q.push(i);
            }
            bewait[d].clear();
        }
    }
    for(int i=0;i<N;i++)if(!wait[i].empty()){
        printf("1\n");
        return 0;
    }
    printf("0\n");
}


Measured memory_bytes: 2844
#include<stdio.h>
#include<stdlib.h>

int top=0,Stack[100];

void push(int);
int pop();

int main(){
  int x,y;
  char stack[100];

  while(scanf("%s",stack) != EOF){
    
    if (stack[0] == '+'){
      x = pop();
      y = pop();
      push(x+y);
    }
    else if (stack[0] == '-'){
      x = pop();
      y = pop();
      push(y-x);
    }
    else if (stack[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }
    else push(atoi(stack));
  }

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

void push(int a)
{
  Stack[++top] = a;
}

int pop()
{
  top--;
  return Stack[top+1];
}



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

bool less_second(pair<int, int> a, pair<int, int> b) {
  return a.second < b.second;
}

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

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

  vector<pair<int,int>> A(M);

  rep(i, M) {
    int a,b;
    cin >> a >> b;
    A[i] = make_pair(a, b);
  }

  sort(A.begin(), A.end(), less_second);

  int ans = 0;
  int x = 0;
  rep(i, M) {
    if(A[i].first >= x) {
      x = A[i].second;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
using namespace std;

#define ll long long
typedef pair<ll , ll > pii;
const int MOD = 998244353;
const int N=500004;

vector<int> BIT;

void update(int i, int add)
{
    while (i > 0 && i < BIT.size())
    {
        BIT[i] += add;
        i = i + (i & (-i));
    }
}

int sum(int i)
{
    int ans = 0;
    while (i > 0)
    {
        ans += BIT[i];
        i = i - (i & (-i));
    }

    return ans;
}
int findKthSmallest(int k)
{
    int l = 0;
    int h = BIT.size();
    while (l < h)
    {
        int mid = (l + h) / 2;
        if (k <= sum(mid))
            h = mid;
        else
            l = mid+1;
    }

    return l;
}

void insertElement(int x)
{
    update(x, 1);
}

void deleteElement(int x)
{
    update(x, -1);
}

int findRank(int x)
{
    return sum(x);
}

///


void min_self(int &a , int b){
    a=min(a,b);
}

int add(int x, int y)
{
    return (x + y) % MOD;
}

int sub(int x, int y)
{
    return add(x, MOD - y);
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
    int z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}

int inv(int x)
{
    return binpow(x, MOD - 2);
}

int fact[N];

int C(int n, int k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}
/////-----//////
int calc(int e){
    if( e == 0) return 0;
    int ans=0;
    for(int i=1; i<=100; i++){
        if(e>=i){
            ans++;
            e-=i;
        }
        else{
            break;
        }
    }
    return ans;
}




int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   //freopen("input.txt", "r", stdin);
   ll n,s; cin>>n>>s;
   vector<ll> v(n+1);
   for(int i=1; i<=n; i++){
       cin>>v[i];
   }
   vector<vector<ll>> dp(n+1,vector<ll>(s+1,0));
   for(int i=0; i<=n; i++){
       dp[i][0]=1;
   }
   for(ll i=1; i<=n; i++){
       for(int j=0; j<=s; j++){
           dp[i][j]=2*dp[i-1][j];
           dp[i][j]%=MOD;
       }
       for(int j=0; j+v[i]<=s; j++){
           dp[i][j+v[i]]+=dp[i-1][j];
           dp[i][j+v[i]]%=MOD;

       }
   }
   cout<<dp[n][s]<<endl;
   return 0;
}


Measured memory_bytes: 73692
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int v[200], w[200];

int DP[200][20000];

int main(){
	
	int N, W;
	
	cin >> N >> W;
	
	for(int i = 1; i <= N; i++){
		cin >> v[i] >> w[i];
	}
	
	for(int i = 0; i <= W; i++){
		DP[0][i] = 0;
	}
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= W; j++){
			if(j < w[i]){
				DP[i][j] = DP[i - 1][j];
			}else{
				DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	
	cout << DP[N][W] << endl;
	
	return 0;
}

Measured memory_bytes: 7412
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Darker and Darker
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 1000;
const int MAX_W = 1000;
const int INF = 1 << 30;
const int dxs[] = { 1, 0, -1, 0 }, dys[] = { 0, -1, 0, 1 };

/* typedef */

typedef pair<int,int> pii;

/* global variables */

char flds[MAX_H][MAX_W + 4];
int dists[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);
  for (int y = 0; y < h; y++) scanf("%s", flds[y]);

  memset(dists, -1, sizeof(dists));
  queue<pii> q;
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      if (flds[y][x] == '#')
	dists[y][x] = 0, q.push(pii(x, y));

  int maxd = 0;
  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int &ux = u.first, &uy = u.second;
    int &ud = dists[uy][ux], vd = ud + 1;

    if (maxd < ud) maxd = ud;

    for (int di = 0; di < 4; di++) {
      int vx = ux + dxs[di], vy = uy + dys[di];
      if (vx >= 0 && vx < w && vy >= 0 && vy < h &&
	  flds[vy][vx] == '.' && dists[vy][vx] < 0) {
	dists[vy][vx] = vd;
	q.push(pii(vx, vy));
      }
    }
  }

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


Measured memory_bytes: 13328
#include <stdio.h>

int main(void)
{
	int n,m=1000000000,M=0,a[101],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>M){
			M=a[i];
		}
		if(a[i]<m){
			m=a[i];
		}
	}
	printf("%d",M-m);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n,m;
ll x,sum;

int main() {
    ios::sync_with_stdio(false);
    cin>>n>>m;
     for(int i=0;i<m;++i){
         cin>>x;
          sum+=x;
     }
     if(n-sum>=0)
     printf("%lld\n",n-sum);
     else printf("-1\n");
    return 0;
}

Measured memory_bytes: 3780
fun main(args : Array<String>) {
    val (n, q) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val bits = BIT(n)

    aa.forEachIndexed { idx, a ->
        bits.add(idx, a)
    }

    repeat(q) {
        val (t, u, v) = readLine()!!.split(" ").map { it.toInt() }
        if (t == 0) {
            bits.add(u, v)
        } else {
            println(bits.sum(u, v))
        }
    }
}

private class BIT(val size: Int) {
    private val data = LongArray(this.size){0L}

    fun add(idx: Int, value: Int) {
        var i = idx+1
        while (i <= this.size) {
            this.data[i-1] += value.toLong()
            i += i and -i
        }
    }

    // NOTE: data[rIdx] is not included
    fun sum(rIdx: Int): Long {
        var i = rIdx
        var sum = 0L

        while (i > 0) {
            sum += this.data[i-1]
            i -= i and -i
        }

        return sum
    }

    // NOTE: data[rIdx] is not included
    fun sum(lIdx: Int, rIdx: Int): Long {
        return sum(rIdx)-sum(lIdx)
    }
}


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

int main() {
 
   int n;
	string s, t;
	
	cin >> n;
   cin >> s >> t;

   for (int i = 0; i < n; ++i) {
      cout << s[i];
      cout << t[i];
   }
   
   cout << endl;
   return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final String in = sc.next();
			
			if("#".equals(in)){
				break;
			}
			
			int[][] next = new int[][]{
					{ 1,  2},
					{-1,  3},
					{ 1, -1},
					{ 4,  5},
					{ 5,  2},
					{ 2,  1}
			};
					
			int cur = 0;
			char[] path = in.toCharArray();
			
			boolean miss = false;
			
			for(int i = 0; i < path.length; i++){
				int p = path[i] == '1' ? 1: 0;
				
				if(next[cur][p] == -1){
					miss = true;
					break;
				}
				
				cur = next[cur][p];
				//System.out.println(cur);
			}
			
			if(miss || cur != 5){
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}
		}
	}

}

Measured memory_bytes: 17172
s, t, q = list(input()), list(input()), int(input())
ssum, tsum = [0], [0]
for i in range(len(s)):
    if s[i]=="A": ssum.append(ssum[-1]+1)
    else: ssum.append(ssum[-1]+2)
for i in range(len(t)):
    if t[i]=="A": tsum.append(tsum[-1]+1)
    else: tsum.append(tsum[-1]+2)
for i in range(q):
    a,b,c,d = map(int,input().split())
    sa = (ssum[b]-ssum[a-1])-(tsum[d]-tsum[c-1])
    if abs(sa)%3==0:print("YES")
    else: print("NO")

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

int main() {
  long int H;
  long int W;
  cin >> H >> W;
  
  if(H == 0 || W == 0)
    cout << 0 << endl;
  else if(H == 1 || W == 1)
    cout << 1 << endl;
  else if (H * W % 2 == 0)
    cout << H * W / 2 << endl;
  else if (H * W % 2 != 0)
    cout << H * W / 2 + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const int NUM=1e5;

int main(){
    int n;
    cin>>n;
    ll a[n+1]={};
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    ll ans=1e18;
    for(int m=2;m<=n-2;m++){
        ll lsum=a[m],rsum=a[n]-a[m];
        ll lmin,lmax,rmin,rmax;
        auto it=upper_bound(a,a+n+1,lsum/2);
        lmax=min(*it,lsum-*prev(it));
        lmin=lsum-lmax;
        it=upper_bound(a,a+n+1,a[m]+rsum/2);
        rmax=min(*it-a[m],rsum-*prev(it)+a[m]);
        rmin=rsum-rmax;
        ans=min(ans,max(lmax,rmax)-min(lmin,rmin));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import std.stdio;

immutable mod = 4294967311L;

void main(){
	long x, y;
	int n, op;
	scanf("%d", &n);
	foreach(i; 0..n){
		scanf("%d%lld", &op, &y);
		if(op == 1) x += y;
		else if(op == 2) x -= y;
		else if(op == 3) x *= y;
		else if(op == 4) x = mul(x, inv(y));
		x %= mod;
	}

	if(x < 0) x += mod;
	if(x > int.max) x -= mod;

	writeln(x);
}

long inv(long y){
	long ret = 1;
	for(long e=mod-2; e; e>>=1, y=mul(y,y))if(e&1){
		ret = mul(ret, y);
	}
	return ret;
}

long mul(long x, long y){
	if(y < 0){
		y = -y; x = -x;
	}
	return ( ((x*(y>>16)%mod)<<16) + (x*(y&0xffff)) ) % mod;
}

Measured memory_bytes: 1012
// AOJ 2792: SNS
// 2017.11.24 bal4u@uu

#include <stdio.h>

int main()
{
	long long a, b, jj, k, t, ans;
	int n, i, j;
	
	scanf("%lld%lld%d", &a, &b, &n);
	ans = 1LL << 60;
	for (i = 1; i <= n; i++) {
		if (b % i) continue;
		for (k = b/i, jj = k, j = 1; j <= n; j++, jj += k) {
			t = a - jj;
			if (t < 0) t = -t;
			if (t < ans) {
				ans = t;
				if (!ans) goto done;
			}
		}
	}
done:
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1852
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int dp[3100][3100] = {0};

int main(void){
    string s,t;
    cin >> s >> t;

    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            if(s[i] == t[j]){
                if(dp[i + 1][j + 1] < dp[i][j] + 1){
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                }
            }

            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);

            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }

    string ans = "";

    int i = s.size();
    int j = t.size();

    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i - 1][j]){
            i--;
        } else if(dp[i][j] == dp[i][j - 1]){
            j--;
        } else {
            ans = s[i - 1] + ans;
            i--;
            j--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 37120
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int main() {
	ll c = 0, ans = 0;
	char *str = new char[200005];
	scanf("%s", str);
	int len = strlen(str);
	rep(i, 0, len) {
		if (str[i] == 'B')c++;
		else ans += c;
	}
	printf("%lld", ans);
	return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i64 = int64_t;
using f64 = double;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
if (comp(xmax, x)) {
xmax = x;
return true;
}
return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
if (comp(x, xmin)) {
xmin = x;
return true;
}
return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
cout << a;
if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
print(vec);
  }
}

struct ProconInit {
static constexpr int IOS_PREC = 15;
static constexpr bool AUTOFLUSH = false;

ProconInit() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(IOS_PREC);
if (AUTOFLUSH)
cout << unitbuf;
}
} PROCON_INIT;
#pragma endregion

signed main()
{
	string s;
	cin >> s;
	map<char,int> mp;
	REP(i, SIZE(s)){
		mp[s[i]]++;
		if (mp[s[i]] > 1){
			print("no");
			return 0;
		}
	}
	print("yes");
	return 0;
}


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

int q = 0;
void merge(auto v, auto l, auto m, auto r) {
    auto n1 = m - l;
    auto n2 = r - m;
    vector<int> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++) L[i] = v[l + i];
    for (int i = 0; i < n2; i++) R[i] = v[m + i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    
    int i = 0;
    int j = 0;
    for (int k = l; k < r; k++) {
        if (L[i] <= R[j]) { v[k] = L[i++]; q++; }
        else { v[k] = R[j++]; q++; } 
    }
}

void merge_sort(int v[], auto l, auto r) {
    if (l + 1 < r) {
        auto m = (l + r) / 2;
        merge_sort(v, l, m);
        merge_sort(v, m, r);
        merge(v, l, m, r);
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, x;
    cin >> n;
    int v[600000];
    for (int i = 0; i < n; i++) { cin >> v[i]; }
    merge_sort(v, 0, n);
    for (int i = 0; i < n - 1; i++) { cout  << v[i] << " "; }
    cout << v[n - 1] << "\n";
    cout << q << "\n";
    return 0;
}


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

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double y = (2 * (x / a)) / b;
    if (y < a)
        cout << fixed << setprecision(10)
             << atan(b / y) * 180 / (atan(1.0) * 4) << endl;
    else {
        y = (2 * (x / a)) / a - b;
        cout << fixed << setprecision(10)
             << atan((b - y) / a) * 180 / (atan(1.0) * 4)
             << endl;
    }
    return 0;
}

Measured memory_bytes: 4032
#include<stdio.h>
int main(){
    int i=1,x=0;
    while (1) {
        scanf("%d\n", &x);
        if(x == 0){
            break;
        }else if (1 <= x || x <= 10000) {
            printf("Case %d: %d\n", i, x);
        }else{
            break;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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 main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> c(m);
    rep(i, m) cin >> c[i];
    sort(c.begin(), c.end());
    vector<vector<ll>> dp(25, vector<ll>(50005, -1));
    dp[0][0] = 0;
    rep(i, m){
        rep(j, n + 1){
            if(dp[i][j] != -1) dp[i + 1][j] = dp[i][j];
            if(j >= c[i]){
                if(dp[i + 1][j] == -1 || dp[i + 1][j] > dp[i + 1][j - c[i]] + 1)
                    dp[i + 1][j] = dp[i + 1][j - c[i]] + 1;
            }
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}


Measured memory_bytes: 13104
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut counts: HashMap<usize, usize> = HashMap::new();
    for _ in 0..n {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        *counts.entry(ai).or_insert(0) += 1;
    }

    let mut ans = 0;
    for (k, v) in counts {
        if k > v {
            ans += v;
        } else {
            ans += v - k;
        }
    }
    return format!("{}", ans);
}


Measured memory_bytes: 12540
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    cout << "Possible" << endl;
    else 
    cout << "Impossible" << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int total = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    total += (r - l + 1);
  }
  
  cout << total << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int m,f,r;

	m=0;
	f=0;
	r=0;

	while(m!=-1 || f!=-1 || r!=-1){
		scanf("%d %d %d",&f,&m,&r);
	
		if(f==-1 && m==-1 && r==-1){
			break;
		}
		else if(f==-1||m==-1){
			printf("F\n");
		}
		else if(m+f>=80){
			printf("A\n");
		}
		else if(m+f>=65 && m+f<80){
			printf("B\n");
		}
		else if((m+f>=50 && m+f<65)){
				printf("C\n");
			
		}
		else if(m+f>=30 && m+f<50){
			if(r>=50){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
		else if(m+f<30){
			printf("F\n");
		}
	}

	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  n/=3;
  cout<<n<<"\n";
  
  return 0;
}

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

int main(){
     int f  = 0, s = 0 ;
     for(int i=0;i<4;i++){
        char c;cin>>c;
        if(i == 0 || i == 1){
            f*=10;
            f+=(int)(c-'0');
        }
        if(i == 2 || i == 3){
            s*=10;
            s+=(int)(c-'0');
        }
     }
    // cout<<f<< " "<<s<<endl;
     if((f >=1 && f <= 12) && (s>=1&&s<=12)){
        cout<<"AMBIGUOUS"<<endl;
        return 0 ;
     }
     if((f >=1 && f <= 12)){
        cout<<"MMYY"<<endl;
        return 0 ;
     }
     if((s >=1 && s <= 12)){
        cout<<"YYMM"<<endl;
        return 0 ;
     }
     cout<<"NA"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  
  REP(i,n-1){
    FOR(j,i+1,n){
      if(s.at(i)==s.at(j)){
        cout <<"no"<<endl;
        return 0 ;
      }
    }
  }
  
  cout <<"yes"<<endl;
        

  return 0 ;
}

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

int main(){
    ll X,K,D;
    cin>>X>>K>>D;
    ll check=X/D;
    check=abs(check);
    ll result=0;
    if(check+1>K){
        if(X<0){
            result=X+D*K;
            cout<<abs(result)<<endl;
            return 0;
        }else{
            result=X-D*K;
            cout<<abs(result)<<endl;
            return 0;
        }
    }
    if(check%2==0){
        if(K%2==0){
            if(X>=0){
                result=X-D*check;
            }else{
                result=X+D*check;
            }
        }else{
            check=check+1;
            if(X>=0){
                result=X-D*check;
            }else{
                result=X+D*check;
            }
        }
    }else{
        if(K%2==0){
            check=check+1;
            if(X>=0){
                result=X-D*check;
            }else{
                result=X+D*check;
            }
        }else{
            if(X>=0){
                result=X-D*check;
            }else{
                result=X+D*check;
            }
        }
    }
    cout<<abs(result)<<endl;
    return 0;
}

Measured memory_bytes: 3624
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
if np.count_nonzero(A) != len(A):
    answer = np.abs(A).sum()
else:
    negative = np.count_nonzero(A < 0)
    if negative%2 == 0:
        answer = np.abs(A).sum()
    else:
        answer = np.abs(A).sum()
        answer -= 2 * np.min(np.abs(A))

print(answer)
# 37

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

int main() {
	ll n,W;
	cin>>n>>W;
	vector < pair < ll , ll > > v(n+1);
	for(int i = 1 ; i <= n ; i++) {
		cin>>v[i].first>>v[i].second;
	}
	vector < vector < ll > > dp(n+1,vector< ll > (W+1));
	for(ll i = 1 ; i <= n ; i++) {
		for(ll j = 1 ; j <= W ; j++) {
			if(j>=v[i].first) { 
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-v[i].first]+v[i].second);
			}
			else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][W];
	return 0;
}


Measured memory_bytes: 80256
import sys

N = int(input())
H = list(map(int, input().split()))

max_hight = 0
for i in range(N):
    if i != 0 and H[i] < H[i-1]:
        print('No')
        sys.exit()

    if i != 0 and H[i] < max_hight:
        print('No')
        sys.exit()

    if i != 0 and H[i] != H[i-1]:
        H[i] -= 1
    max_hight = max(max_hight, H[i])

print('Yes')

Measured memory_bytes: 63856
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

ll dp[5005][5005];

signed main() {
  init();
  ll N;
  string S;
  cin >> N >> S;

  repr(i, N - 1) {
    repr(j, N - 1) {
      if (S[i] != S[j])
        dp[i][j] = 0;
      else
        dp[i][j] = dp[i + 1][j + 1] + 1;
    }
  }
  ll ans = 0;

  rep(i, N) rep(j, N) {
    if (i >= j) continue;
    ll now = min(dp[i][j], j - i);
    ans = max(ans, now);
  }
  ANS;

  return 0;
}

Measured memory_bytes: 199084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N; cin>>N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        A[tmp-1] = i+1;
    }
    for (int i = 0; i < N; ++i) {
        cout<<A[i]<<" ";
    }

    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] cnt = new long[26];
		foreach(var s in S) cnt[s[0] - 'A']++;
		
		List<int> idx = new List<int>();
		foreach(var c in "MARCH") idx.Add(c - 'A');
		
		long ans = 0;
		for(int i=0;i<idx.Count;i++){
			for(int j=i+1;j<idx.Count;j++){
				for(int k=j+1;k<idx.Count;k++){
					ans += cnt[idx[i]] * cnt[idx[j]] * cnt[idx[k]];
				}
			}
		}
		
		Console.WriteLine(ans);
		
		
		
	}
	int N;
	String[] S;
	public Sol(){
		N = ri();
		S = new String[N];
		for(int i=0;i<N;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

typedef long long ll;
ll dp[101][101][256];
ll mod=1e9+7;
int n,k;
int a[101];

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>a[i];
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<256;k++){
        (dp[i+1][j][k]+=dp[i][j][k])%=mod;
        (dp[i+1][j+1][k^a[i]]+=dp[i][j][k])%=mod;
      }
    }
  }
  
  ll ans=0,num=1;
  for(ll i=1;i<=n;i++){
    num=(num*i)%mod;
    ans+=(dp[n][i][k]*num);
    ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 20608
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    const nums = args.slice(1, N + 1);
    const isValid = nums.every((n) => {
        var ns = n.split(' ');
        var t = parseInt(ns[0], 10),
            x = parseInt(ns[1], 10),
            y = parseInt(ns[2], 10);
        var sum = x + y;

        return t >= sum && t % 2 === sum % 2;
    });

    if (isValid) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29932
import sys
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()
a = input()
a = int(a)
if  a == 1:
 print("Yes")
 sys.exit()
k = range(1,a)
for s in k:
 res = a/s
 #print("s",s)
 #print("res",res)
 try:
  res = int(res)
 except:
  break
 if is_integer(s):
  if is_integer(res):
   if len(str(s)) == 1:
    if len(str(res)) == 1:
     #print(res,s)
     if res * s == a:
      print("Yes")
      sys.exit() 
print("No")


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

int main()
{
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    int diff = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] > C[i]) {
            diff += V[i] - C[i];
        }
    }

    cout << diff << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
using ll = long long;

int main()
{   ll n,l,i,j,digit,sum=0,p,q;
    cin>>n;
    vector<int> a;

    for(i=1;i<=n;i++)
    {
        if(i%3==0 && i%5==0 || i%3==0 || i%5==0)
        {

        }
        else
            a.push_back(i);

    }
    for(i=0;i<a.size();i++)
    {
        sum=sum+a[i];
    }

    cout<<sum;
    return 0;
}


Measured memory_bytes: 7288
<?php
$day = ['SUN' ,'MON' , 'TUE' , 'WED', 'THU', 'FRI', 'SAT'];
$input = trim(fgets(STDIN));
$count = 0;
for($i=0; $i < count($day); $i++) {
    if($input == $day[$i] && ($input != 'SUN')) {
        for($j=$i + 1; $j < count($day); $j++) {
            if($day[$j] == 'SUN') {
                echo $count;
                exit;
            }
            $count += 1;
        }
        echo $count + 1;
        exit;
    }
}
    echo '7';
?>

Measured memory_bytes: 4728
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class LazySegTree
  attr_accessor:node,:lazy,:n,:lazyF
  def initialize(n)
    @n=1
    @n*=2 while @n<n
    @node=array(2*@n-1,1,0)
    @lazy=array(2*@n-1,1,0)
    @lazyF=array(2*@n-1,1,false)
  end


  def lazy_eval(i,l,r)
    if @lazyF[i]
      @node[i]=@lazy[i]
      if r-l>1
        @lazy[i*2+1]=@lazy[i]/2
        @lazy[i*2+2]=@lazy[i]/2
        @lazyF[i*2+1]=true
        @lazyF[i*2+2]=true
      end
      @lazy[i]=0
      @lazyF[i]=false
    end
  end
  def update(s,t,x,i,l,r)
    lazy_eval(i,l,r)
    return if r<=s or t<=l
    if s<=l and r<=t
      @lazyF[i]=true
      @lazy[i]=x*(r-l)
      lazy_eval(i,l,r)
    else
      mid=(l+r)/2
      update(s,t,x,i*2+1,l,mid)
      update(s,t,x,i*2+2,mid,r)
      @node[i]=@node[i*2+1]+@node[i*2+2]
    end
  end

  def getSum(s,t,i,l,r)
    return 0 if r<=s or t<=l
    lazy_eval(i,l,r)
    return @node[i] if s<=l and r<=t
    mid=(l+r)/2
    leaf_l=getSum(s,t,i*2+1,l,mid)
    leaf_r=getSum(s,t,i*2+2,mid,r)
    return leaf_l+leaf_r
  end
end

n,q=get_i
lst=LazySegTree.new(n)
q.times do
  qu=get_i
  if qu[0].zero?
    lst.update(qu[1],qu[2]+1,qu[3],0,0,lst.n)
  else
    puts lst.getSum(qu[1],qu[2]+1,0,0,lst.n)
  end
end


Measured memory_bytes: 13156
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
const int mod=1e9+7;
typedef long long ll;
ll quick_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1)res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	int n;
	cin>>n;
	if(n==1){
		cout<<"0"<<endl;
		return 0;
	}else if(n==2){
		cout<<2<<endl;
		return 0;
	}
	cout<<((quick_pow(10,n)+mod+mod+mod-2*quick_pow(9,n))%mod+quick_pow(8,n))%mod;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  long long N,T;
  T=0;
  cin >> N;
  vector<long long> a(N),b(N),c(N-1);
  for (int i=0;i<N;i++) {cin >> a.at(i);}
  for (int i=0;i<N;i++) {cin >> b.at(i);}
  for (int i=0;i<N-1;i++) {cin >> c.at(i);}
  
  for (int i=0;i<N;i++) {
    T+=b.at(a.at(i)-1);
	if (i>0) {
	  if (a.at(i-1)+1==a.at(i)) {
	    T+=c.at(a.at(i-1)-1);
	  }
	}
  }
  cout << T << endl;
  
}


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

using namespace std;

int main()
{
	int N,K,a,b,c,cnt=0;
	
	cin >> N >> K;
	
	pair<int,int> v[100000];
	
	if(K > (N-2)*(N-1)/2) {
		cout << -1 << endl;
		return 0;
	}
	
	
	for(int i=0;i<N-1;i++){
		v[i].first = 1;
		v[i].second = i+2;
	}
	
	a = ((N-2)*(N-1)/2) - K;
	b = 2;
	c = 3;
	
	for(int i=0;i<a;i++){
		v[N-1+i].first = b;
		v[N-1+i].second = c;
		c = c+1;
		if(c == N+1){
			b = b+1;
			c = b+1;
		}
	}
	cout << N-1+a << endl;
	for(int i=0;i<N-1+a;i++){
		cout << v[i].first << ' '<< v[i].second << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1024
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in); 
      int n = sc.nextInt();
      int k = sc.nextInt();
      int result = 1; // 
      for(int i = 0; i<n ; i++){
         if(result > k){
            result += k;
         }else{
            result *=2;
         }
      }
      out.println(result);
   } 
}

Measured memory_bytes: 21716
def is_ok(index, key):
    return B[index] <= key

def upper_bound(key): 
    ng = len(B)
    ok = -1

    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, key):
            ok = mid
        else:
            ng = mid
    
    return ok 

n, m, k = map(int, input().split())
tmpA = list(map(int, input().split()))
tmpB = list(map(int, input().split()))
A = [0]
B = [0]
# 読むのにかかる時間の累計和のリスト
if A:
    for i in range(n):
        tmp = A[i] + tmpA[i]
        if tmp > k:
            break
        else:
            A.append(tmp)
if B:
    for i in range(m):
        tmp = B[i] + tmpB[i]
        if tmp > k:
            break
        else:
            B.append(tmp)

answer = 0
for i in range(len(A)):
    key = k - A[i]
    answer = max(answer, upper_bound(key) + i)

print(answer)

Measured memory_bytes: 42684
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion



int main(void) {
  ll a[55];
  cin >> n;
  FOR(i, 0, 50) {
	a[i] = i + n / 50;
  }
  FOR(i, 50 - n % 50, 50) {
	a[i]++;
  }
  cout << "50" << endl;
  FOR(i, 0, 50) {
	cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256