akhauriyash/Code-Regression huggingface dataset:
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を呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

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

    vector<long long> v(n);

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

    long long ans = 0;
    for(int i = 1; i < n; i++){
        if(v[i] < v[i-1]){
            ans += (abs(v[i]-v[i-1]));
            v[i] = v[i-1];
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4780
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	int n,d;
	cin>>n>>d;
	vector<int> a[n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			int a1;
			cin>>a1;
			a[i].pb(a1);
		}
	}
	int cnt=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			double d1=0;
			for(int k=0;k<d;k++)
			{
				d1+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
			}
			//cout<<sqrt(d1)<<" ";
			if(sqrt(d1)==floor(sqrt(d1)))
			{
				cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
}





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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

// #define DEBUG

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    int N;
    cin >> N;

    vec<ll> A;
    for(int i=0; i < N; i++){
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }

    // 1ずれに注意
    // multiset<ll> values;
    map<ll, ll> values;
    values.insert(pair<ll, ll>(-A.at(0) - 1, 1));
    // values.insert(-A.at(0) - 1);
    ll res = 0;
    for(int i=1; i < N; i++){
        if(values.find(A.at(i) - (i+1)) == values.end()){
        }else{
            res += values.at(A.at(i) - (i+1));
        }
        // res += values.count(A.at(i) - (i+1));;
        // values.insert(-A.at(i) - (i+1));
        if(values.find(-A.at(i) - (i+1)) == values.end()){
            values.insert(pair<ll, ll>(-A.at(i) - (i+1), 1));
        }else{
            values.at(-A.at(i) - (i+1))++;
        }
        
        #ifdef DEBUG
        printf("*START: hoge\n");
        for(auto iter: values){
            cout << iter.first << " " << iter.second << endl;
        }
        cout << "*" << res << endl;
        printf("*END: hoge\n");
        #endif
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 17132
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGoodDistance solver = new BGoodDistance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGoodDistance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();
            int x[][] = new int[n][d];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    x[i][j] = in.nextInt();
                }
            }
            int nb = 0;
            for (int i = 0; i < n; i++)
                for (int j = i + 1; j < n; j++) {
                    long res = 0;
                    for (int k = 0; k < d; k++) {
                        res += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
                    }
                    double result = Math.sqrt(res);
                    int res1 = (int) result;
                    if (Math.abs(result - res1) <= 0.000001 || Math.abs(result - res1 - 1) <= 0.000001)
                        nb++;
                }
            out.println(nb);
        }

    }
}



Measured memory_bytes: 21716
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		char[] s = stdIn.next().toCharArray();
		
		for(int i = 0; i < s.length;i++) {
			int x = s[i] - 'A';
			x = (x+n)%26;
			char a = (char)(x+'A');
			System.out.print(a);
			
			
			
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
			
		}
		
		
		
	}

}


Measured memory_bytes: 26580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int front = Integer.parseInt(s.substring(0,2));
		int back = Integer.parseInt(s.substring(2));
		
		if(front>=1 && front<=12) {
			if(back>=1 && back <=12) {
				System.out.println("AMBIGUOUS");
			}else {
				System.out.println("MMYY");
			}
		}else if(back>=1 && back<=12) {
			System.out.println("YYMM");
		}else {
			System.out.println("NA");
		}
		
		
		sc.close();
	}

}


Measured memory_bytes: 23252
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False

from libcpp.string cimport string
from libcpp.vector cimport vector
from libc.stdio cimport getchar, printf
cdef extern from *:
    ctypedef long long ll "long long"

cdef extern from "<atcoder/string>" namespace "atcoder":
    vector[int] lcp_array(string s, vector[int] sa)
    vector[int] lcp_array[ll](vector[ll] s, vector[int] sa)

cpdef vector[int] LcpArray(string s, vector[int] sa):
    return lcp_array(s, sa)

cpdef vector[int] LcpArrayNum(vector[ll] s, vector[int] sa):
    return lcp_array(s, sa)
cpdef inline vector[int] ReadInt(int n):
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef inline vector[string] Read(int n):
    cdef char c
    cdef vector[string] *vs = new vector[string]()
    cdef string *s
    for i in range(n):
        s = new string()
        while 1:
            c = getchar()
            if c<=32: break
            s.push_back(c)
        vs.push_back(s[0])
    return vs[0]

cpdef inline void PrintLongN(vector[long] l, int n):
    for i in range(n): printf("%ld\\n", l[i])

cpdef inline void PrintLong(vector[long] l, int n):
    for i in range(n): printf("%ld ", l[i])
cdef extern from *:
    ctypedef long long ll "long long"

cdef extern from "<atcoder/string>" namespace "atcoder":
    vector[int] suffix_array(string s)
    vector[int] suffix_array[ll](vector[ll] s)
    vector[int] suffix_array(vector[int] s, int upper)

cpdef vector[int] SuffixArray(string s):
    return suffix_array(s)

cpdef vector[int] SuffixArrayNum(vector[ll] s):
    return suffix_array(s)

cpdef vector[int] SuffixArrayNumUp(vector[int] s, int upper):
    return suffix_array(s, upper)
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code = code.replace("USERNAME", getpass.getuser())
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import Read, SuffixArray, LcpArray

def main():
    S = Read(1)[0]
    sa = SuffixArray(S)
    ans = (len(S) * (len(S)+1))//2
    for x in LcpArray(S, sa):
        ans -= x
    print(ans)
if __name__=="__main__":
    main()

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

int main(int argc, char **argv)
{
	string str; cin >> str;

	stack<char> st;
	st.push(str[0]);

	int res{0};
	for (size_t i = 1; i < str.size(); ++i)
	{
		if (st.empty() || str[i] == st.top()) st.push(str[i]);
		else
		{
			st.pop();
			res += 2;
		}
	}

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


Measured memory_bytes: 512
n, k, q = [int(x) for x in input().split()]
a = []
for _ in range(q):
    a.append(int(input()))


lst = [k for _ in range(n)]

for x in range(q):
    lst[a[x]-1] += 1

for i in range(n):
    if lst[i] > q:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10460
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A[200000], N;
int main(){
  int i;
  long long res, sum;
  map<long long,int> mp;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sum = res = 0;
  mp[sum]++;
  for(i=0;i<N;i++){
    sum += A[i];
    if(mp.count(sum)){
      res += mp[sum];
    }
    mp[sum]++;
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180303-1 [beta]

// --- original code ---
// int N, A[2d5];
// {
//   int i;
//   ll sum, res;
//   map<ll,int> mp;
// 
//   rd(N,A(N));
// 
//   sum = res = 0;
//   mp[sum]++;
//   rep(i,N){
//     sum += A[i];
//     if(mp.count(sum)) res += mp[sum];
//     mp[sum]++;
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using P = pair<int,int>;
using ll = long long;

int main(){
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int lim = 1<<10;

ll dp[lim+1][MAX+1];
vector<P> dat;
int n;

void dfs(int v) {
    if (v > lim || v > n) return;
    memcpy(dp[v],dp[v/2],sizeof(dp[v]));
    for (int i = MAX; i >= dat[v-1].second; i--) {
        chmax(dp[v][i],dp[v/2][i-dat[v-1].second]+dat[v-1].first);
    }
    dfs(v*2);
    dfs(v*2+1);
}

P get_top(int v) {
    int ct = 0;
    while (v > lim) {
        v >>= 1;
        ct++;
    }
    return P(ct,v);
}

int main() {
    cin >> n;
    dat.resize(n);
    rep(i,n) {
        int v, w; cin >> v >> w;
        dat[i] = P(v,w);
    }
    memset(dp[0],0,sizeof(dp[0]));
    dfs(1);
    int q; cin >> q;
    rep(i,q) {
        int v, l; cin >> v >> l;
        if (v <= lim) {
            cout << dp[v][l] << endl;
        } else {
            ll ans = 0;
            P p = get_top(v);
            int top = p.second;
            int ct = p.first;
            rep(i,1<<ct) {
                int tmp = v;
                int V = 0, W = 0;
                rep(j,ct) {
                    if (i>>j&1) {
                        V += dat[tmp-1].first;
                        W += dat[tmp-1].second;
                    }
                    tmp /= 2;
                }
                if (l-W >= 0) chmax(ans,dp[top][l-W]+V);
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 806008
#include <stdio.h>
void selectionsort(int A[],int N);
int main(){
  int i,N,A[100],MIN;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  selectionsort(A,N);
  return 0;
}
void selectionsort(int A[],int N){
  int i,j,k,MIN,t,count=0;
  for(i=0;i<N-1;i++){
    MIN=A[i];
    for(j=i+1;j<N;j++){
      if(MIN>A[j]){
        MIN=A[j];
        k=j;
      }
    }
    if(MIN!=A[i]){
      t=A[i];
      A[i]=A[k];
      A[k]=t;
      count++;
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[N-1],count);
}

Measured memory_bytes: 2720
def main():
    n,m=map(int,input().split())
    ans=1
    mod=10**9+7
    if abs(n-m)>=2:
        print(0)
    elif n==m:
        for i in range(1,n+1):
            ans=(ans*i**2)%mod
        ans=(2*ans)%mod
        print(ans)
    else:
        for i in range(1,min(m,n)+1):
            ans=(ans*i**2)%mod
        ans=(ans*max(m,n))%mod
        print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;
		int e = 0;
		int f = 0;
		int g = 0;
		for (int i = 0; i < n; i++){
			int q; cin >> q;
			if (q < 10)a++;
			else if (q < 20)b++;
			else if (q < 30)c++;
			else if (q < 40)d++;
			else if (q < 50)e++;
			else if (q < 60)f++;
			else g++;
		}
		cout << a << endl << b << endl << c << endl << d;
		cout << endl << e << endl << f << endl << g << endl;
	}
}

Measured memory_bytes: 3064
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

int dp[101][10101]; // i 個目までみて重さが j 以下のときの価値の最大値

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

  int N, W; cin >> N >> W;
  vector<int> v(N), w(N);
  rep(i, N) cin >> v[i] >> w[i];

  rep(i, 10101) {
    dp[0][i] = 0;
  }

  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (j < w[i - 1]) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      }
    }
  }

  print(dp[N][W]);

  return 0;
}


Measured memory_bytes: 7120
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
#include<bitset>


using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) //0から
#define REP(i,n) for(int j=i;j<n;j++) //iから

typedef long long ll;



//英字ならture、数字ならfalse
bool isalpha(char s){
    if(('A'<=s&&s<='Z')||('a'<=s&&s<='z')){
        return 1;
    }else{
        return 0;
    }
}
//全ての文字が英字ならture、数字ならfalse
bool Isalpha(string s){
    ll n;
    bool tmp = true;
    rep(i,n){
        if(isalpha(s[i])){
            tmp = false;
        }
    }
    return tmp;
}




using Graph = vector<vector<ll>>;



//cout<<fixed<<setprecision(10);

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

#define MOD 1000000007



ll INFLL =  pow(10,9)+1;

int main(){
    ll n;
    cin>>n;
    vector<ll> p(n+1, 0);
    for(int i = 1; i <= n; i++){
        for(int k = i; k <=n; k+=i){
            p[k]++;
        }
    }

    ll ans = 0;
    rep(i,n+1){
        ans += i*p[i];
    }

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

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

using namespace std;
char a[101][101];
int n, m;
int main(){
    cin >> n >> m;
    n--;
    m--;
    for(int i = 1; i <= 100; i++){
        if(i % 2 == 0){
            for(int j = 1; j <= 50; j++){
                a[i][j] = '#';
            }
            for(int j = 51; j <= 100; j++){
                a[i][j] = '.';
            }
        }
        else{
            for(int j = 1; j <= 50; j++){
                if(j % 2 && n){
                    n--;
                    a[i][j] = '.';
                }
                else{
                    a[i][j] = '#';
                }
            }
            for(int j = 51; j <= 100; j++){
                if(j % 2 == 0 && m){
                    m--;
                    a[i][j] = '#';
                }
                else{
                    a[i][j] = '.';
                }
            }
        }
    }
    cout << 100 << " " << 100 << '\n';
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            cout << a[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 256
N = int(input())
D = sorted([int(_) for _ in input().split()])
#最小値の最大値
if D[0] == 0:
    print(0)
    exit()

p = m = 0
a = 99

for d in D:
    #asign positive
    e = min(a, d - p, 24 - d - m)
    #asign negative
    f = min(a, d - m, 24 - d - p)
    if e < f:
        a = f
        m = d
    else:
        a = e
        p = d
print(a)


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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

/*
Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->p = y;
  
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25172
pub mod io {
    use std::io;

    pub fn read_line() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }

    pub trait Read {
        fn read(s: &str) -> Self;
    }

    macro_rules! def_read {
        ($t: ty) => {
            impl Read for $t {
                fn read(s: &str) -> $t {
                    s.parse().unwrap()
                }
            }
        }
    }

    def_read!(i32);
    def_read!(i64);
    def_read!(isize);
    def_read!(usize);
    def_read!(f64);

    impl<T: Read> Read for Vec<T> {
        fn read(s: &str) -> Self { s.split_whitespace().map(|w| T::read(w)).collect() }
    }

    macro_rules! def_read_tuple {
        ($($t: ident),*) => {
            impl<$($t : Read + Default),*> Read for ($($t),*) {
                fn read(s: &str) -> Self {
                    let ws = s.split_whitespace().collect::<Vec<_>>();
                    let mut i = 0;
                    ( $({i += 1; $t::read(ws[i - 1])}),* )
                }
            }
        };
    }

    def_read_tuple!(T0, T1);
    def_read_tuple!(T0, T1, T2);
    def_read_tuple!(T0, T1, T2, T3);
    def_read_tuple!(T0, T1, T2, T3, T4);

    pub fn readln<T: Read>() -> T { T::read(&read_line()) }
}

fn main() {
    let (n, a, b): (i32, i32, i32) = io::readln();
    let s = io::read_line();

    let mut cur = 0;
    let mut abr = 0;

    for c in s.chars() {
        let b = match c {
            'a' => cur < a + b,
            'b' => cur < a + b && abr < b,
            _ => false,
        };

        if b {
            cur += 1;
            if c == 'b' { abr+=1 }
        }

        println!("{}", if b {"Yes"} else {"No"});
    }
}


Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <string>
#include <memory.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <time.h>
#include <assert.h>
#include <cmath>
#include <stack>
#include <string.h>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, a, b;
vector<vector<int> > g[2];
int sqr[200001];
int R, C;
int clr[2][4 * 300 * 300];
int id(int a, int b) {
	return a*C + b;
}
void addEdge(int a, int b, bool w) {
	g[w][a].push_back(b);
	g[w][b].push_back(a);
}
void DFS(int u, bool color, bool w) {
	clr[w][u] = color;
	for (auto v : g[w][u])
		if (clr[w][v] == -1)
			DFS(v, !color, w);
}
int main()
{
	memset(sqr, -1, sizeof(sqr));
	for (int i = 0; i*i <= 200000; ++i)
		sqr[i*i] = i;
	cin >> n >> a >> b;
	if (a > b)
		swap(a, b);
	R = n << 1;
	C = n << 1;
	g[0].resize(R*C);
	g[1].resize(R*C);
	for (int i = 0; i < 2 * n; ++i)
		for (int j = 0; j < 2 * n; ++j) {
			for (int d = 0; d*d <= b; ++d) {
				for (int it = 0; it < 2; ++it) {
					if (d*d <= a) {
						int w = it;
						int D = a - d*d;
						if (sqr[D] != -1) {
							D = sqr[D];
							for (int dx = -1; dx <= 1; dx += 2) {
								for (int it = 0; it < 2; ++it) {
									int r = i + d*dx;
									int c = j + D;
									if (r < R && c < C && r >= 0 && c >= 0)
										addEdge(id(i, j), id(r, c), w);
									swap(d, D);
								}
							}
						}
					}
					swap(a, b);
				}
			}
		}
	memset(clr, -1, sizeof(clr));
	vector<pair<int, int> > sol;
	int in = 0;
	for (int w = 0; w < 2; ++w)
		for (int i = 0; i < g[w].size(); ++i) {
			if (clr[w][i] != -1)
				continue;
			DFS(i, 0, w);
		}
	vector<int> who[4];
	for (int i = 0; i < g[0].size(); ++i)
		who[clr[0][i] * 2 + clr[1][i]].push_back(i);
	for (int i = 0; i < 4; ++i)
		if (who[i].size() >= n*n) {
			for (int j = 0; j < n*n; ++j) {
				int x = who[i][j];
				sol.push_back(make_pair(x / C, x%C));
			}
			break;
		}
	for (auto x : sol)
		printf("%d %d\n", x.first, x.second);
	return 0;
}

Measured memory_bytes: 183092
n = int(input())

a = list(map(int,input().split()))

ans = []

for i in range(n-1):
    if a[i] >= a[i+1]:
        ans.append(a[i] - a[i + 1])
        a[i+1] += a[i]-a[i+1]

print(sum(ans))

Measured memory_bytes: 106660
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n, input;
	map <long long, long long> mp;
	cin >> n;
	for(long long i=0;i<n-1;i++){
		cin >> input;
		mp[input]++;
	}
	for(long long i=1;i<=n;i++){
		cout << mp[i] << endl;
	}
	return 0;
}

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

int main(){
  int n,k,s=1;
  cin >>n>>k;
  
  for(int i=0;i<n;i++){
    if(s+k<s*2)
      s+=k;
    else
      s+=s;
  }
  cout << s << endl;
}


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

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  ll dp[100][2];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  rep(i, 0, 50) {
    ll mask = 1LL << (50 - i - 1);
    int cnt = 0;
    rep(j, 0, N) if (A[j] & mask) cnt++;
    ll cost[2] = {mask * cnt, mask * (N - cnt)};
    bool OK = (K & mask) ? 1 : 0;
    rep(d, 0, 2) {
      if (dp[i][1] != -1) chmax(dp[i + 1][1], dp[i][1] + cost[d]);
      if (dp[i][0] != -1) chmax(dp[i + 1][!d & OK], dp[i][0] + cost[d & OK]);
    }
  }
  cout << max(dp[50][0], dp[50][1]) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
#define M 1000000007
#define endl "\n"
#define int long long 
using namespace std;
int32_t main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b;
}



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

int main(){
  string N;
  cin >> N;
  
  if(N[0] == N[1] and N[1] == N[2] and N[2] == N[3]){
    cout << "Yes" << endl;
  }
  else if(N[0] == N[1] and N[1] == N[2]) cout << "Yes" << endl;
  else if(N[1] == N[2] and N[2] == N[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

typedef long long ll;
typedef vector<int> vi;

#define PB push_back
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll countDivisors(ll n)
{
    ll div = 1;
    for(ll i = 2; i * i <= n; i++) {
        ll cnt = 0;
        while(n % i == 0) {
            n /= i;
            cnt ++;
        }
        div = div * (cnt + 1);
    }
    if(n > 1) div = div * 2;
    return div;

}

int main()
{
    optimize();
    ll n,cnt=0;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int x=n-i;
        cnt+=countDivisors(x);
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
int p[100001];
int ans[100001]={};
vint bubundepth[100001];
bool visited[100001]={};
vint edgedepth[100001];
int depthmax=0;
map<pint,bool> usededge;
void dfs(int u,int depth){
	visited[u]=1;
	edgedepth[depth].push_back(u);
	depthmax=max(depthmax,depth);
	int flag=0;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(visited[v]==0){
			flag=1;
			p[v]=u;
			usededge[{u,v}]=1;
			usededge[{v,u}]=1;
			dfs(v,depth+1);
		}
	}
}
int main(){
	int N,a[100001];
	scan(N);
	rep1(i,N-1){
		scan(a[i]);
		a[i]--;
		adj[a[i]].push_back(i);
	}
	dfs(0,0);
	for(int d=depthmax;d>=0;d--){
		rep(i,edgedepth[d].size()){
			int u=edgedepth[d][i];
			int v=p[u];
			if(bubundepth[u].empty()){
				ans[u]=0;
			}
			else{
				sort(ALL(bubundepth[u]));
				rep(j,bubundepth[u].size()){
					ans[u]=max(ans[u],bubundepth[u][j]+(int)bubundepth[u].size()-j);
				}
			}
			if(d) bubundepth[v].push_back(ans[u]);
		}
	}
	prin(ans[0]);
	return 0;
}


Measured memory_bytes: 42880
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	if (a <= 12 && a >= 1 && b <= 12 && b >= 1)cout << "AMBIGUOUS\n";
	else if (a <= 12 && a >= 1)cout << "MMYY\n";
	else if (b <= 12 && b >= 1)cout << "YYMM\n";
	else cout << "NA\n";
	return 0;
}


Measured memory_bytes: 256
s=input()
s=str(0)+s
count=0
k=0

for i in range(1,len(s)):
    if s[i+k-1]==s[i+k]:
        count+=2
        k+=2
        if i+k==len(s)+1:
            print(count-2)
            exit()
        if i+k==len(s):
            print(count-1)
            exit()
        if i+k==len(s)-1:
            print(count)
            exit()
    else:
        count+=1
        if i+k>=len(s)-1:
            print(count)
            exit()

Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {

	static char[][] soroban;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		boolean first = true;
		while(cin.hasNext()){
			if(first){
				first=false;
			}
			else{
				System.out.println();
			}
			soroban = new char[9][6];
			make();
			String str =cin.next();
			for(int i = str.length();i<=5;i++){
				str = "0"+str;
			}
			for(int i = 1;i<=str.length();i++){
				int keta = str.length()-i;
				int value = str.charAt(keta)-'0';
				if(value/5+1 == 2){
					soroban[1][6-i]=' ';	
				}
				else{
					soroban[2][6-i]=' ';	
				}
				soroban[value%5 + 4][6-i]=' ';
			}
			output();
		}
	}
	static void output(){
		for(int i = 1;i< 9; i++){
			for(int j = 1;j < 6;j++){
				System.out.print(soroban[i][j]);
			}
			System.out.println();
		}
		
	}
	static void make(){
		for(int i = 1;i< 9; i++){
			for(int j = 1;j < 6;j++){
				soroban[i][j]='*';
			}
		}
		for(int i = 1;i<6;i++){
			soroban[3][i]='=';
		}
	}
}

Measured memory_bytes: 12000
import sys
from collections import deque

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N,Q = LI()
str = S()
# l = [list(map(int,input().split())) for i in range(N)]

# 累積和
sum = list(range(N+1))
for i in range(N):
    if i+1<N and str[i] == 'A' and str[i+1] == 'C':
        sum[i+1] = sum[i] + 1
    else:
         sum[i+1] = sum[i]



for q in range(Q):
    l,r = LI()
    l -= 1
    r -= 1
    print(sum[r]-sum[l])

Measured memory_bytes: 54360
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for(int i = 0; 1; i++) {
    if(i % 2 == 0) {
      c -= b;
      if(c <= 0) {
        cout << "Yes";
        return 0;
      }
    } else {
      a -= d;
      if(a <= 0) {
        cout << "No";
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        lld h,w;
        cin>>h>>w>>m;
        set<pair<lld,lld>> st;
        lld row[h+1];
        lld col[w+1];
        for(i=0;i<=h;i++) row[i]=0;
        for(i=0;i<=w;i++) col[i]=0;
        for(i=0;i<m;i++){
            cin>>x>>y;
            row[x]++;
            col[y]++;
            st.insert(mp(x,y));
        }
        vec v1;
        pair<lld,lld> pp;
        lld mx1=0,mx2=0;
        for(i=0;i<=h;i++){
            if(row[i]>mx1)
            {
                v1.clear();
                mx1 = row[i];
                v1.pb(i);
            }
            else if(row[i]==mx1)
                v1.pb(i);
        }
        vec v2;
        for(i=0;i<=w;i++)
        {
            if(col[i]>mx2)
            {
                v2.clear();
                mx2 = col[i];
                v2.pb(i);
            }
            else if(col[i]==mx2)
                v2.pb(i);
        }
        for(auto u:v1)
        {
            for(j=0;j<v2.size();j++)
            {
                x = u; y = v2[j];
                cnt = mx1+mx2;
                pp.ff = x; pp.ss=y;
                if(st.find(pp)!=st.end())
                    cnt--;
                else
                {
                    ans = max(ans,cnt);
                    flag=true;
                    break;
                }
                ans = max(ans,cnt);
            }
            if(flag)
                break;
        }
        op(ans);
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 35016
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<class T>
class BIT {
    vector<T> bit;


public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T max(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret = std::max(ret, bit[k]);
        return ret;
    }

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] = std::max(bit[k], x);
    }
};


int main() {
    int n;
    cin >> n;
    vector<int> h(n), a(n);
    for (auto &&i : h) scanf("%d", &i);
    for (auto &&i : a) scanf("%d", &i);
    BIT<ll> b(n);
    for (int i = 0; i < n; ++i) {
        b.add(h[i]-1, b.max(h[i]-1)+a[i]);
    }
    cout << b.max(n-1) << "\n";
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
ll dp[3001][3001];
ll arr[3001];
ll solvedp(ll start,ll end)
{
  if(start == end)
  {
    return arr[start];
  }
  if(dp[start][end] != -1)
  {
    return dp[start][end];
  }
  ll ans = LLONG_MIN;
  ans = max(ans,max(arr[start] - solvedp(start + 1,end),arr[end] - solvedp(start,end - 1)));
  dp[start][end] = ans;
  return ans;
}
int main()
{
  fast_io
  ll n;
  cin >> n;
  rep(i,0,n)
  {
    cin >> arr[i];
  }
  memset(dp,-1,sizeof(dp));
  cout << solvedp(0,n - 1);
  return 0;
}



Measured memory_bytes: 70784
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
vector<int> v[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		int t, d;
		cin >> t >> d;
		v[t].push_back(d);
	}
	for (int i = 1; i <= n; i++)
	{
		sort(v[i].rbegin(), v[i].rend());
	}
	sort(v + 1, v + n + 1, [](vector<int>& v1, vector<int>& v2)->bool
		{
			if (v1.empty()) return false;
			if (v2.empty()) return true;
			return v1[0] > v2[0];
		});
	priority_queue<int, vector<int>, greater<int>> pq;
	LL tot = 0;
	LL ans = 0;
	LL sum = 0;
	for (int i = 1; i <= k; i++)
	{
		if (v[i].empty()) break;
		sum += v[i][0];
		for (int j = 1; j < v[i].size(); j++)
		{
			pq.push(v[i][j]);
			sum += v[i][j];
		}
		while (pq.size() + i > k)
		{
			sum -= pq.top();
			pq.pop();
		}
		ans = max(ans, sum + 1LL * i * i);
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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


    for( int j = X; j > 0; j--)
    {
    for( int i = sqrt(X)+1; i > 1; i--)
    {
        int tmp_X = j;
        bool flag = false;
        while(tmp_X >= i)
        {
            if( tmp_X == i )
            {
                flag = true;
                break;
            }
            if( tmp_X%i != 0 ) break;
            tmp_X /= i;
        }
        if(flag)
        {
            cout << j << endl;
            return 0;
        }
    }
    }
    cout <<  1 << endl;
}


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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>0 ?(a):-(a))
#define llong long long

// 目先のことだけ考えてみる

int main(){
	int D; scanf("%d",&D);
	int c[26],s[D][26];
	int last[26]={0};
	
	//llong score=0;
	
	rep(i,0,26) scanf("%d",c+i);
	rep(i,0,26) rep(j,0,D) scanf("%d",&s[j][i]);
	
	rep(i,1,D+1){
		int max_score=INT_MIN,max_j=0;
		rep(j,0,26){
			if( max_score <= s[i][j]+c[i]*(i-last[j]) ){
				max_score = s[i][j]+c[i]*(i-last[j]);
				max_j = j;
			}
		}
		last[max_j] = i;
		printf("%d\n",max_j+1);
		/*
		score += s[i][max_j];
      
		rep(j,0,26){
			score -= c[j]*(i-last[j]);
		}
		printf("%lld\n",score);*/
	}
	return 0;
}


Measured memory_bytes: 1732
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] dRew = new int[4];
        int[] dRns = new int[2];
        Integer tmpD=0;
        int[] diceN=new int[6];
        
        for(int i=0; i<6; i++)
            diceN[i]=scan.nextInt();
        
        dRns[0]=diceN[4];
        dRns[1]=diceN[1];
        dRew[0]=diceN[3];
        dRew[1]=diceN[0];
        dRew[2]=diceN[2];
        dRew[3]=diceN[5];
        
        //System.out.println(Arrays.toString(dRew)+"1:"+Arrays.toString(dRns));
        
        
        String command=scan.next();
        for(int i=0; i<command.length(); i++){
            switch(command.substring(i,i+1)){
                case "E":
                    tmpD=dRew[3];
                    dRew[3]=dRew[2];
                    dRew[2]=dRew[1];
                    dRew[1]=dRew[0];
                    dRew[0]=tmpD;
                break;
                case "W":
                    tmpD=dRew[3];
                    dRew[3]=dRew[0];
                    dRew[0]=dRew[1];
                    dRew[1]=dRew[2];
                    dRew[2]=tmpD;
                break;
                case "S":
                    tmpD=dRns[0];
                    dRns[0]=dRew[3];
                    dRew[3]=dRns[1];
                    dRns[1]=dRew[1];
                    dRew[1]=tmpD;
                break;
                case "N":
                    tmpD=dRns[0];
                    dRns[0]=dRew[1];
                    dRew[1]=dRns[1];
                    dRns[1]=dRew[3];
                    dRew[3]=tmpD;
                break;
            }
        //System.out.println(dRew+":"+dRns);
        }
        System.out.println(dRew[1]);
        
    }
}


Measured memory_bytes: 26376
<?php
fscanf(STDIN, "%d %d", $n, $d);
$x = []; $c = 0;
for ($i=0; $i < $n; $i++) {
    $x[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($i=0; $i < $n - 1; $i++) {
    for ($j=$i + 1; $j < $n; $j++) {
        if(isSquare(calcDist($x[$i], $x[$j]))) $c++;
    }
}
echo $c;

function isSquare($v) {
    return pow(floor(sqrt($v)), 2) == $v;
}
function calcDist($a, $b) {
    global $d;
    $ret = 0;
    for ($i=0; $i < $d; $i++) {
        $ret += pow($a[$i] - $b[$i], 2);
    }
    return $ret;
}
?>

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

int main() {
    int n, x, ans = 0;
    cin >> n >> x;
    vector<int> pos(n + 1);
    pos.at(0) = 0;
    rep(i, n) {
        int t;
        cin >> t;
        pos.at(i + 1) = pos.at(i) + t;
    }
    rep(i, n + 1) if(pos.at(i) <= x) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	char a[9];
	rep(i, 9) {
		cin >> a[i];
	}
	cout << a[0] << a[4] << a[8] << endl;

}



Measured memory_bytes: 256
def Hina_Arare(n , sl):

    ans = ""

    count = len(set(sl))

    if count == 3:
        ans = "Three"
    else:
        ans = "Four"

    return ans

def main():
    n = int(input())
    sl = list(map(str , input().split()))
    print(Hina_Arare(n , sl))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if(s[i] == t[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
def cost(a,b):
    return abs(a-b)

INF = 10**9
N = int(input())
H = list(map(int,input().split()))
#dp[i][0]:V_iに行かない
#dp[i][1]:V_iに行く
dp = [ INF for __ in range(N)]
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])

Measured memory_bytes: 52856
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int dd[6111][6111] = {0};

int main()
{
	ios::sync_with_stdio(false);

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	int ansx, ansy;
	double best = -1;
	
	dd[0][0] = 1;
	for(int y=0; 100*y<=f; ++y)
		for(int x=0; 100*y+x<=f; ++x) if(dd[100*y][x])
		{
			if(e*(100*y) < 100*x)
				continue;
			
			double dens = 100*x/(100.0*y+x);
			//print(x,y,dens);
			
			if(best < dens)
			{
				ansx = x;
				ansy = y;
				best = dens;
			}
			
			dd[100*(y+a)][x] = 1;
			dd[100*(y+b)][x] = 1;
			dd[100*y][x+c] = 1;
			dd[100*y][x+d] = 1;
		}
	
	//print(ansx, ansy, best);
	cout << ansy*100+ansx << " " << ansx << "\n";

	return 0;
}


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

bool comp(int a,int b){
  return a>b;
}

int main(){
  int N;
  cin>>N;
  long long A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N,comp);
  long long total=0;
  int index=0;
  for(int i=1;i<N;i++){
    total=total+A[index];
    if(i%2==1){
      index++;
    }
  }
  cout<<total<<endl;
}


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

using namespace std;

int main(void) {
  long N, M;
  cin >> N >> M;
  vector<long> X;
  for (long i = 0; i < M; i++) {
    long tmp;
    cin >> tmp;
    X.push_back(tmp);
  }
  sort(X.begin(), X.end());
  /*
  for (auto it = X.begin(); it != X.end(); it++) {
    cout << *it << ",";
  }
  cout << endl;
  */
  vector<long> X_diff;
  for (long i = 0; i < M-1; i++) {
    X_diff.push_back(X[i+1] - X[i]);
  }
  /*
  for (auto it = X_diff.begin(); it != X_diff.end(); it++) {
    cout << *it << ",";
  }
  cout << endl;
  */
  sort(X_diff.begin(), X_diff.end());
  long ans = 0;
  for (long i = 0; i < M - N; i++) {
    ans += X_diff[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2548
#include <stdio.h>
int main(void)
{
	int n;
	int m;
	int s = 0;
	int roop = 0;
	
	scanf("%d", &n);
	
	m = n;
	while (roop < 10){
		s = s + (n % 10);
		n /= 10;
		roop++;
	}
	
	
	if (m % s == 0){
		printf("Yes\n");
	}
	
	else {
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 128