akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long

int dgt(int a) {
	if (!a)return 0;
	return a % 10 + dgt(a / 10);
}

signed main() {
	int n; cin >> n;
	if (n%dgt(n))cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int d;
	while(~scanf("%d%d", &N, &d)) {
		vector<int> p(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &p[i]);
		int ans = 0;
		rep(i, N)
			ans += max(0, p[i] - d);
		if(ans == 0)
			puts("kusoge");
		else
			printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3228
import java.util.Scanner;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long a1 = scanner.nextLong(), a2 = scanner.nextLong();
			long s = a1 + a2, x = 0L;
			for (int i = 2; i < n; i++) {
				long ai = scanner.nextLong();
				x ^= ai;
			}
			long d = (s - x);
			if ((d & 1) > 0) {
				System.out.println(-1);
				return;
			}
			d >>= 1;
			if ((d < 0) || (0 != (d & x)) || (d > a1)) {
				System.out.println(-1);
				return;
			}
			long y = 0L;
			for (int i = 62; i >= 0; i--) {
				if ((x & (1L << i)) > 0) {
					if ((d ^ (y | (1L << i))) <= a1) {
						y |= (1L << i);
					}
				}
			}
			System.out.println((0 == (d ^ y)) ? -1 : (a1 - (d ^ y)));
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> p[i];
  }

  vector<int> ord(n);
  iota(ord.begin(), ord.end(), 0);

  sort(ord.begin(), ord.end(),  [&](int a, int b) {
    if (s[a] == s[b]) return p[a] > p[b];
    return s[a] < s[b];
  });

  for (auto e: ord) cout << e + 1 << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s;
bool bl = true;

signed main() {
	cin >> s;
	int n = (int)s.size();
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i])bl = false;
	}
	int m = (n - 1) / 2;
	for (int i = 0; i < m / 2; i++) {
		if (s[i] != s[m - 1 - i])bl = false;
	}
	int t = (n + 3) / 2 - 1;
	for (int i = t; i < t + n / 2 / 2; i++) {
		if (s[i] != s[n - 1 - (i - t)])bl = false;
	}
	if (bl)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
a_group = [1, 3, 5, 7, 8, 10, 12]
b_group = [4, 6, 9, 11]
c_group = [2]

x, y = list(map(int, input().split()))

if x in a_group and y in a_group:
    print('Yes')
elif x in b_group and y in b_group:
    print('Yes')
elif x in c_group and y in c_group:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EActiveInfants {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<P> a(n);
      rep(i, n) {
        cin >> a[i].first;
        a[i].second = i;
      }
      sort(a.rbegin(), a.rend());

      vector<vector<ll>> dp(n+1, vector<ll>(n+1, LLONG_MIN/2));
      dp[0][0] = 0;
      rep(i, n) {
        for(int j=0; j<=i; j++) {
          // left
          chmax(dp[i+1][j+1], dp[i][j] + a[i].first * abs(a[i].second - j));
          // right
          int p = i-j;
          chmax(dp[i+1][j], dp[i][j] + a[i].first * abs(a[i].second - (n-1-p)));
        }
      }
      ll ans = 0;
      rep(i, n+1) {
        chmax(ans, dp[n][i]);
      }
      cout << ans << endl;
    }
};

signed main() {
  EActiveInfants solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 34640
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;

int a[15][1005];
int dp[15][1005];
int n,m;
int find(int x1,int y1,int x2,int y2)
{
      return dp[x2][y2]-dp[x2][y1-1]-dp[x1-1][y2]+dp[x1-1][y1-1];
}

int solve(vector<int>& cuts,int k)
{
     int ans=0;
     int start_y=1; 
     rep(end_y,1,m+1)
     {
           bool g=true;
           rep(i,1,cuts.size())
           {
                 int start_x=cuts[i-1]+1;
                 int end_x=cuts[i];
                 if(start_x>end_x)continue;
                 if(find(start_x,end_y,end_x,end_y)>k)return INF;
                 if(find(start_x,start_y,end_x,end_y)<=k)continue;
                 g=false;
                 break;
           }
           if(!g){ans++;start_y=end_y;} 
     }
     return ans;
}


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
            int k;
            cin>>n>>m>>k;
            rep(i,1,n+1)
            {
                  string s;
                  cin>>s;
                  rep(j,1,m+1)
                  {
                        a[i][j]=s[j-1]-'0';
                  }
            }
            rep(i,1,n+1)
            {
                  rep(j,1,m+1)
                  {
                        dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]+a[i][j];
                  }
            }

            int lim=(1<<n);
            int ans=INF;
            rep(x,0,lim)
            {
                 vector<int> cuts;
                 cuts.push_back(0);
                 rep(i,0,n)
                 {
                       if((1<<i)&x)
                       {
                             cuts.push_back(i+1);
                       }
                 }
                 cuts.push_back(n);
                 ans=min(ans,solve(cuts,k)+__builtin_popcount(x));
            }
            cout<<ans<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> S(n); rep(i, n) cin >> S[i];
  vector<int> cnt(26, inf);
  rep(i, n) {
    vector<int> cnt2(26);
    for(char c: S[i]) cnt2[c-'a']++;
    rep(j, 26) cnt[j] = min(cnt2[j], cnt[j]);
  }
  rep(i, 26) {
    cout << string(cnt[i], 'a'+i);
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n,m,k;
    cin>>n>>m>>k;
    string s[n];
    int ans=0;
    for(int i=0;i<n;i++) cin>>s[i];

    for(int i=0;i<(1<<n);i++)
    {
        for(int j=0;j<(1<<m);j++)
        {
            string t[n];
            int now=0;
            for(int i=0;i<n;i++) t[i]=s[i];
            for(int p=0;p<n;p++)
            {
                for(int q=0;q<m;q++)
                {
                      if((1<<p)&i)
                      {
                          t[p][q]='-';
                      }
                      if((1<<q)&j)
                      {
                          t[p][q]='-';
                      }
                      if(t[p][q]=='#')
                            now++;
                }
            }

            if(now==k)
                ans++;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S, T, X):
    i = S.index(X)
    return sum(T[i+1:])


def main():
    N = read_int()
    S, T = [], []
    for _ in range(N):
        s, t = read_str_n()
        t = int(t)
        S.append(s)
        T.append(t)
    X = read_str()
    print(slv(N, S, T, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7876
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string n; cin >> n;
    int mod9 = 0;
    rep(i,0,SZ(n)){
        int digit = chartoint(n[i]);
        mod9 =  (mod9 + digit) % 9;
    }
    if(mod9 == 0){
        cout << "Yes" << enld;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h> 
using namespace std; 
long long countPrimeFactors(long long x) 
{ 
    long long res = 0; 
    if (x % 2 == 0) { 
        res++; 
        while (x % 2 == 0) 
            x = x / 2; 
    } 
    for (long long i = 3; i <= sqrt(x); i = i + 2) 
    { 
        if (x % i == 0)
        { 
            res++; 
            while (x % i == 0) 
                x = x / i; 
        } 
    } 
    if (x > 2) 
        res++; 
    return res; 
} 
long long countCommonPrimeFactors(long long a, long long b) 
{ 
    long long gcd = __gcd(a, b); 
    return countPrimeFactors(gcd); 
} 
int main()
{
    long long A,B,i;
    cin>>A>>B;
    cout<<countCommonPrimeFactors(A,B)+1;
}


Measured memory_bytes: 256
/* ex5_4
melo */
#include <stdio.h>
int main(void){
    char text[11],*ptr;//文字列の箱とポインタを用意
    int len=0,maxi=0;//連続した文字列の長さとその最長の長さをいれるための箱を用意
    scanf("%s",text);//文字列を入力
    ptr=&text[0];//ptr=textでも可
    while(*ptr){//*ptr=='\0'になるまで行う
        if(*ptr!='A'&&*ptr!='C'&&*ptr!='G'&&*ptr!='T'){//A,T,G,Cでなかったら
            len=0;
        }
        else{//A,T,G,Cのいずれかであったら
            len++;
            if(len>maxi){//最長の長さを更新
                maxi=len;
            }
        }
        ptr++;
    }
    printf("%d\n",maxi);//最長の長さを出力
    return 0;//正常終了
}

Measured memory_bytes: 1716
while True:
    n = int(raw_input())
    if n == 0: break
    ans = [[0]*4 for i in range(n)]
    for i in range(n):
        line = raw_input().split()
        ans[i][2] = -i
        ans[i][3] = line[0]
        for c in line[1:]:
            if c == '0':
                ans[i][0] += 1
            elif c == '1':
                ans[i][1] -= 1
    for a in sorted(ans, key=lambda x: (x[0], x[1], x[2]), reverse=True):
        print a[3]

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a && c <= b) {
  	cout << "Yes\n";
  }else {
  	cout << "No\n";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
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<vs> vvs;


typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;

int table[2019];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int l, r, i, j;
    cin >> l >> r;
    vi t;
    for (i=l;i<r+1;i++){
        int m = i % 2019;
        if (table[m]==1) break;
        t.push_back(m);
        table[m] = 1;
    }
    
    int min_mod = 2019;
    for (i=0;i<t.size()-1;i++) for (j=i+1;j<t.size();j++){
        int m_tmp = (t[i] * t[j]) % 2019;
        min_mod = min(min_mod, m_tmp);
    }
    cout << min_mod << endl;
}


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


ll f(ll b){
  ll s=b-b%4;
  ll res=0;
  for(ll i=s; i<=b;i++){
    res^=i;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  cout << (f(b)^f(max(a-1,0LL))) << endl;
    
  




  
  return 0;
    

}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $n, $k);
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d', $h[]);
}
sort($h);
$ans = 10 ** 9;
for ($i = 0; $i < $n - $k + 1; $i++) {
    $ans = min($h[$i + $k - 1] - $h[$i], $ans);
}
echo $ans;

Measured memory_bytes: 12792
/***************************************************************************
* File Name: AT2.cpp
* Author: lcy
* Created Time: Sun, 21 Jun 2020 20:04:52 +0800�
***************************************************************************/

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

int N,K;
int num[1001];

int main(){
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) scanf("%d",&num[i]);
	sort(num+1,num+N+1);
	int ans=0;
	for(int i=1;i<=K;i++) ans+=num[i];
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3868
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , a[N] , cnt[2] , mn ;
ll sum ;

inline void print (bool f) {
	cout << (!f ? "First" : "Second") << '\n' ;
	exit(0) ;
}

inline void fill () {
	cnt[0] = cnt[1] = 0 ;
	sum = 0 , mn = a[0] ;
	for (int i = 0 ; i < n ; i ++) cnt[a[i] & 1] ++ , sum += a[i] , mn = min(mn , a[i]) ;
}

void go (int cur = 0) {
	fill() ;
	
	if (!cnt[0]) print(1 ^ cur) ;
	if (cnt[0] == 1) print(0 ^ cur) ;
	if (cnt[1] > 1 || ((sum - n) & 1) || mn == 1) print(!((sum - n) & 1) ^ cur) ;

	int g = 0 ;
	for (int i = 0 ; i < n ; i ++) {
		if (a[i] & 1) a[i] -- ;
		g = __gcd(g , a[i]) ;
	}

	for (int i = 0 ; i < n ; i ++) a[i] /= g ;

	go(cur ^ 1) ;
}

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

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

	if (n == 1) print(1) ;

	go() ;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s,t;
    cin>>s>>t;
    
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
           int n = scanner.nextInt();

           Set<String> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                int a = scanner.nextInt();
                String s = Integer.toString(a);
                set.add(s);
            }
            int m = scanner.nextInt();
            boolean flag = true;
            for (int i = 0; i < m; i++) {
                int b = scanner.nextInt();
                String s1 = Integer.toString(b);
                if (!set.contains(s1)){
                    flag = false;
                    break;
                }
            }
            System.out.println(flag?1:0);

        } catch (Exception e) {

        } finally {

        }

    }

}




Measured memory_bytes: 166764
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main(){
    ll A, B;
    cin >> A >> B;

    ll a = A + B;
    ll b = A - B;
    ll c = A * B;

    cout << max(max(a, b), c) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import collections
from collections import Counter
input = sys.stdin.readline
N = int(input())
S = list(input())
count = -1000
del S[-1]
for i in range(N) :
    a = 0
    Sa = S[:i]
    Sb = S[i:]
    ca = collections.Counter(Sa)
    cb = collections.Counter(Sb)
    ka = list(ca.keys())
    kb = list(cb.keys())
    for j in ka :
        for k in kb :
            if j == k :
                a +=1
    count = max(a,count)
print(count)

Measured memory_bytes: 3316
Var N,i,Min,x:Integer;
    C:Array[1..9] Of Integer;
Begin
        //Assign(Input,'A.INP'); Reset(Input);
        //Assign(Output,'A.OUT'); Rewrite(Output);
        Read(N);
        Fillchar(C,SizeOf(C),0);
        For i:=1 to N Do
                Begin
                Read(x);
                Case x Of
                1..399: Inc(C[1]);
                400..799: Inc(C[2]);
                800..1199: Inc(C[3]);
                1200..1599: Inc(C[4]);
                1600..1999: Inc(C[5]);
                2000..2399: Inc(C[6]);
                2400..2799: Inc(C[7]);
                2800..3199: Inc(C[8]);
                3200..4800: Inc(C[9]);
                End;
                End;
        Min:=0;
        For i:=1 to 8 Do If C[i]<>0 Then Inc(Min);
        If Min=0 Then Write(1,' ') Else Write(Min,' ');
        Write(Min+C[9]);
        //Close(Input);
        //Close(Output);
End.


Measured memory_bytes: 128
n, *d = map(int, open(0).read().split())
a = [0] * (n + 1)
for x in d:
	a[x] += 1
mod = 998244353
if a[0] != 1 or d[0] != 0:
	print(0)
	exit()
ans = 1
for x, y in zip(a, a[1:]):
	ans *= x ** y
	ans %= mod
print(ans)

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

#define MAX_N 100003

int main() {
	int N, K;
	int h[MAX_N] = {0};
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	sort(h, h+N);

	int min = 1e9+10;
	for (int i = 0; i <= N-K; i++) {
		min = std::min(min, h[i+K-1]-h[i]);
	}
	cout << min << endl;
}


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

int main()
{
    int N, T;
    cin>>N>>T;
    vector<int> A(N), B(N);
    for (int i=0; i<N; i++)
        cin>>A[i]>>B[i];

    vector<vector<int>> X1(N, vector<int>(T, -1));
    X1[0][0] = 0;
    for (int i=0; i<N-1; i++)
    {
        X1[i+1] = X1[i];
        for (int j=0; j<T; j++)
            if (X1[i][j]>=0 && j+A[i]<T)
                X1[i+1][j+A[i]] = max(X1[i+1][j+A[i]], X1[i][j]+B[i]);
    }

    vector<vector<int>> X2(N, vector<int>(T, -1));
    X2[N-1][0] = 0;
    for (int i=N-1; i>0; i--)
    {
        X2[i-1] = X2[i];
        for (int j=0; j<T; j++)
            if (X2[i][j]>=0 && j+A[i]<T)
                X2[i-1][j+A[i]] = max(X2[i-1][j+A[i]], X2[i][j]+B[i]);
    }

    for (int i=0; i<N; i++)
    {
        for (int j=1; j<T; j++)
        {
            X1[i][j] = max(X1[i][j], X1[i][j-1]);
            X2[i][j] = max(X2[i][j], X2[i][j-1]);
        }
    }

    int ans = 0;
    for (int i=0; i<N; i++)
        for (int t=0; t<T; t++)
            ans = max(ans, X1[i][t]+X2[i][T-t-1]+B[i]);
    cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> u(N - 1);
  vector<int> v(N - 1);
  vector<int> w(N - 1);  
  for (int i = 0; i < (N - 1); i++) {
    cin >> u.at(i) >> v.at(i) >> w.at(i);
  }
  vector<int> ans(N, -1);
  ans.at(0) = 0;
  
  int a, b, c;
  bool ok = false;
  int count = 0;
  while (ok == false) {
    count++;
    if (count % 2 == 1) {
      for (int i = 0; i < (N - 1); i++) {
        if (u.at(i) == 0) continue;
        a = u.at(i) - 1;
        b = v.at(i) - 1;
        if (ans.at(a) == -1 && ans.at(b) == -1) continue;
        else if (ans.at(a) != -1 && ans.at(b) != -1) continue;
        else if (ans.at(a) != -1 && ans.at(b) == -1) {
          u.at(i) = 0;
          c = w.at(i);
          if ((c % 2 == 0 && ans.at(a) == 0) || (c % 2 == 1 && ans.at(a) == 1)) {
            ans.at(b) = 0;
            continue;
          }
          else {
            ans.at(b) = 1;
            continue;
          }
        }
        else {
          u.at(i) = 0;
          c = w.at(i);
          if ((c % 2 == 0 && ans.at(b) == 0) || (c % 2 == 1 && ans.at(b) == 1)) {
            ans.at(a) = 0;
          }
          else {
            ans.at(a) = 1;
          }
        }
      }
    }
    if (count % 2 == 0) {
      for (int i = (N - 2); i > -1; i--) {
        if (u.at(i) == 0) continue;
        a = u.at(i) - 1;
        b = v.at(i) - 1;
        if (ans.at(a) == -1 && ans.at(b) == -1) continue;
        else if (ans.at(a) != -1 && ans.at(b) != -1) continue;
        else if (ans.at(a) != -1 && ans.at(b) == -1) {
          u.at(i) = 0;
          c = w.at(i);
          if ((c % 2 == 0 && ans.at(a) == 0) || (c % 2 == 1 && ans.at(a) == 1)) {
            ans.at(b) = 0;
            continue;
          }
          else {
            ans.at(b) = 1;
            continue;
          }
        }
        else {
          u.at(i) = 0;
          c = w.at(i);
          if ((c % 2 == 0 && ans.at(b) == 0) || (c % 2 == 1 && ans.at(b) == 1)) {
            ans.at(a) = 0;
          }
          else {
            ans.at(a) = 1;
          }
        }
      }
    }
    
    ok = true;
    for (int i : ans) {
      if (i == -1) ok = false;
    }
  }
  
  for (int i : ans) {
    cout << i << endl;
  }
}


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

int main() {
  int N;
  cin >>N;
  int sum=0;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  for(int i=0;i<N-1;i++){
    sum+=l[i];
  }
  if(l[N-1]<sum)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    S = input().strip()
    n = len(S)

    T = ''
    i = 0
    while i < n:
        if S[i] == 'A':
            T += 'A'
            i += 1
        elif S[i:i+2] == 'BC':
            T += 'D'
            i += 2
        else:
            T += S[i]
            i += 1

    ans = 0
    cnt = 0
    for c in T:
        if c == 'A':
            cnt += 1
        elif c == 'D':
            ans += cnt
        else:
            cnt = 0

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f first 
#define s second
#define pb(i) push_back(i)
#define mk(u,v) make_pair(u,v)
int main()
{
    int n;
    cin>>n;
    vector<int>mtr[n+1];
    bool vis[n+1]={false};
    pair<int,int>edges[n];
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        mtr[u].pb(v);
        mtr[v].pb(u);
        edges[i].f=u;
        edges[i].s=v;
    }
    queue<int>q;
    map<pair<int,int>,int>mp;
    q.push(1);
    int color[n+1]={0};
    vis[1]=true;
    while(!q.empty())
    {
        int col=1;
        int v=q.front();q.pop();
        for(auto u:mtr[v])
        {
            if(vis[u])continue;
            if(col==color[v])col++;
            color[u]=mp[{u,v}]=mp[{v,u}]=col;
            col++;
            q.push(u);vis[u]=true;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int s=mtr[i].size();
        ans=max(ans,s);
    }
    cout<<ans<<endl;
    for(int i=0;i<n-1;i++)
    {
        auto all=edges[i];
        cout<<mp[all]<<endl;
    }
}


Measured memory_bytes: 19840
import java.util.*

val sc = Scanner(System.`in`)
val S: String = sc.next()

fun main(args: Array<String>) {
    println(judge(S))
}

fun judge(s: String): String {
    for (c in 'a'..'z') {
        if (!s.contains(c)) {
            return c.toString()
        }
    }
    return "None"
}


Measured memory_bytes: 32312
def main():
    A = [int(s) for s in input().split()]
    Cost_Ptn = []
    Zero2One = abs(A[0] - A[1])
    One2Two = abs(A[1] - A[2])
    Two2Zero = abs(A[2] - A[0])

    Cost_Ptn.append(Zero2One + One2Two)
    Cost_Ptn.append(Two2Zero + Zero2One)
    Cost_Ptn.append(Two2Zero + One2Two)

    reCost_Ptn = sorted(Cost_Ptn)
    print(reCost_Ptn[0])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
def xorsum(n):
    if n % 2:
        return 0 if (n // 2) % 2 else 1
    else:
        return n + 1 if (n // 2) % 2 else n

a, b = map(int, input().split())
if a != 0:
    print(xorsum(b) ^ xorsum(a - 1))
else:
    print(xorsum(b))


Measured memory_bytes: 2940
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#include <bits/stdc++.h>
 
int main() {
    int n;
	string s;
	cin >> n >> s;
	long res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			for (int k = 0; k < j; k++) if (j - k != i - j && s[k] != s[i] && s[k] != s[j]) res++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

long long h1[120000],h2[120000],h3[120000],h4[120000],x[120000],y[120000];
long long m,s,t;

//#define int ll
signed main(){
    ll n,c;
    cin>>n>>c;
    repe(i,1,n)cin>>x[i]>>y[i];
    
    t=0;
    for(int i=1;i<=n;i++){
        t=t+y[i];
        h1[i]=max(h1[i-1],t-x[i]);
        h2[i]=max(h2[i-1],t-2*x[i]);
    }
    
    t=0;
    for(int i=n;i>0;i--){
        t=t+y[i];
        h3[i]=max(h3[i+1],t-(c-x[i]));
        h4[i]=max(h4[i+1],t-2*(c-x[i]));
    }
    
    rep(i,0,n+1){
        s=max(s,max(h1[i]+h4[i+1],h2[i]+h3[i+1]));
    }
    
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

string data;

int main()
{
    cin >> data;

    int i = 0;
    int st = 0, cnt = 0;
    while (i < (int)data.size()) {
        if (data[st] != data[i]) {
            cnt++;
            st = i;
        } 
        i++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};


int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<ll>X(N);
    REP(i, N) cin >> X.at(i);
    vector<ll>dp(N, 0);
    for(int i = 1; i < N; i++){
        ll a, b;
        a = (X.at(i) - X.at(i - 1)) * A + dp[i - 1];
        b = B + dp[i - 1];
        dp[i] = min(a, b);
    }
    print(dp[N - 1]);
    return 0;
}

Measured memory_bytes: 1792
N = gets.to_i
A = Array.new(N)
B = Array.new(N)
N.times do |i|
    A[i],B[i] = gets.split.map(&:to_i)
end
index = N
num = 0
loop do
    index -= 1
    break if index < 0
    a = A[index] + num
    b = B[index]
    mod = a%b
    next if mod == 0
    d = b - mod
    num += d
end
puts num

Measured memory_bytes: 3324
from fractions import gcd
from functools import reduce
# from collections import deque
# from math import factorial
# import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
n = int(input())
# n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]


def gcd_list(numbers):
    return reduce(gcd, numbers)


print(gcd_list(a))


Measured memory_bytes: 88428
n = int(input())
if n > 81:
    print("No")
else:
    is_ok = False
    for x in range(1, 10):
        if n % x == 0 and n // x <= 9:
            is_ok = True
            break
    if is_ok:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int n;
	int flg[10001];
	int i,j;
	int p1,q1;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=2;i<=n;i++){
			flg[i]=0;
		}
		for(i=2;i*i<=n;i++){
			if(flg[i]==0){
				for(j=2;i*j<=n;j++){
					flg[i*j]=1;
				}
			}
		}
		for(i=2;i<=n;i++){
			if(flg[i]==0 && flg[i-2]==0){
				p1=i-2;
				q1=i;
			}
		}
		printf("%d %d\n",p1,q1);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
//#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;
map<string, int> cnt;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s;
        cin >> s;
        ++cnt[s];
    }
    cout << "AC x " << cnt["AC"] << "\n";
    cout << "WA x " << cnt["WA"] << "\n";
    cout << "TLE x " << cnt["TLE"] << "\n";
    cout << "RE x " << cnt["RE"] << "\n";
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef long long ll;

const int maxn = 2e3 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int n; cin >> n;
  vector<pair<int,int> > a(n + 1);
  a[0] = mp(mod, 0);
  for (int i = 1; i <= n; ++i){
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(All(a), greater<pair<int,int> >());
  vector<vector<ll> > f(n+1, vector<ll>(n+1, 0));
  ll ans = 0;
  for (int i = 0; i <= n; ++i) for (int j = 0; i + j <= n; ++j){
    if (i + j == n) ans = max(ans, f[i][j]);
    else {
      f[i][j+1] = max(f[i][j+1], f[i][j] + 1ll * abs(n - j - a[i+j+1].second) * a[i+j+1].first);
      f[i+1][j] = max(f[i+1][j], f[i][j] + 1ll * abs(a[i+j+1].second - (i+1) ) * a[i+j+1].first);
    }
  }
  cout << ans;
}




Measured memory_bytes: 34624
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double g = 9.8;
    while (sc.hasNext()) {
      double vMin = sc.nextDouble();
      double t = vMin/g;
      double y = 0.5*g*t*t;
      for (int i = 0; ; i++) {
        if (5*i-5 > y) {
          System.out.println(i);
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 12000
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main() {
    unsigned a, b; cin >> a >> b;
    bitset<32> x(a), y(b);
    cout << (x & y) << endl;
    cout << (x | y) << endl;
    cout << (x ^ y) << endl;
    return 0;
}


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

#define ios ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define FOR(i, a, b) for(int i=(int)a; i<(int)b; i++)
#define len(a) a.length()
#define ndl "\n";
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define inrep int t; cin >> t; for(int tc=1; tc<=t; tc++)
#define debug cout << "DEBUG" << ndl;
#define in(a) cin >> a
#define out(a) cout << a << ndl
const int N = 1e5+7;
const int LOGN = log(N) + 2;
const int MOD = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

ull lcm(ull a, ull b) {return a/__gcd(a, b)*b;}

int main()
{
	ios;
	ull n; cin >> n;
	ull a, ans = 0;
	FOR(i, 0, n) {
		cin >> a;
		if (i == 0) {ans = a;}
		else {
			ans = lcm(ans, a);
		}
	}
	cout << ans << ndl;
	return 0;
}

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

class Main {

	static final int TOP = 0;
	static final int NORTH = 1;
	static final int EAST = 2;
	static final int SOUTH = 3;
	static final int WEST = 4;
	static final int DOWN = 5;

	static int[] northPos = { TOP, SOUTH, DOWN, NORTH };
	static int[] southPos = { TOP, NORTH, DOWN, SOUTH };
	static int[] eastPos = { TOP, WEST, DOWN, EAST };
	static int[] westPos = { TOP, EAST, DOWN, WEST };
	static int[] rightPos = { SOUTH, EAST, NORTH, WEST };
	static int[] leftPos = { SOUTH, WEST, NORTH, EAST };
	
	static void apply( int[] dice, int[] pos ) {
		int tmp = dice[ pos[ 0 ] ];
		for ( int i = 0; i < 3; i++ ) {
			dice[ pos[ i ] ] = dice[ pos[ i + 1 ] ];
		}
		dice[ pos[ 3 ] ] = tmp;
	}
	
    public static void main( final String[] args ) {
		
		final Scanner stdin = new Scanner( System.in );

		int[] dice = new int[ 6 ];
		Map<String, int[]> map = new HashMap<String, int[]>();
		map.put( "North", northPos );
		map.put( "South", southPos );
		map.put( "East", eastPos );
		map.put( "West", westPos );
		map.put( "Left", leftPos );
		map.put( "Right", rightPos );
		
		while ( true ) {
			final int n = Integer.parseInt( stdin.nextLine() );
			if ( n == 0 ) break;
			
			int sum = 1;
			dice[ TOP ] = 1;
			dice[ NORTH ] = 5;
			dice[ EAST ] = 3;
			dice[ SOUTH ] = 2;
			dice[ WEST ] = 4;
			dice[ DOWN ] = 6;
			
			for ( int i = 0; i < n; i++ ) {
				String input =  stdin.nextLine();
				apply( dice, map.get( input ) );
				sum += dice[ TOP ];
			}
			System.out.println( sum );
		}	
    }    
}

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

#define vi push_back
#define vo pop_back
#define mp make_pair
#define fe first
#define se second
typedef long long ll;

int n;
vector <int> a, Foura;

void Solve () {
	int tmp, FourCount = 0, TwoCount = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (tmp % 4 == 0) {
			FourCount++;
		}
		else if (tmp % 2 == 0) {
			TwoCount++;
		}
	}
	if (FourCount + (TwoCount / 2) < (n / 2)) {
		cout << "No\n";
		exit (0);
	}
	else {
		cout << "Yes\n";
		exit(0);
	}
}

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



Measured memory_bytes: 256
from heapq import heappop, heappush, heapify
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))

N, M = inpl()
LRC = sorted([inpl() for _ in range(M)])
points = sorted(list({lrc[i] for i in range(2) for lrc in LRC} | {1,N}))
m = 0
dq = [(0,1)]
for i in points:
    while dq and dq[0][1] < i:
        heappop(dq)
    if not dq:
        print(-1)
        break
    d = dq[0][0]
    while m < M and LRC[m][0] == i:
        heappush(dq, (d+LRC[m][2], LRC[m][1]))
        m += 1
else:
    print(d)


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    replace(s.begin(), s.end(), '/', ' ');
    istringstream iss(s);
    int y, m, d;
    iss >> y >> m >> d;
    if (m <= 4) {
      cout << "Heisei" << endl;
    } else {
      cout << "TBD" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())
smallK = [i for i in range(A, A+K) if i <= B] 
largeK = [i for i in range(B, B-K, -1) if i >= A] 
# largeK.sort()
# print(smallK)
# print(largeK)

# リスト同士の結合
smallK.extend(largeK)

# 重複を除外する
set1=list(set(smallK))

set1.sort()

for i in set1:
  print(i)

Measured memory_bytes: 3064
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

intt c[10];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n;
    cin >> n;
    intt any = 0, cnt = 0;
    for (intt i = 1; i <= n; i++) {
        intt x;
        cin >> x;
        if (x < 400) c[1] = 1;
        else if (x < 800) c[2] = 1;
        else if (x < 1200) c[3] = 1;
        else if (x < 1600) c[4] = 1;
        else if (x < 2000) c[5] = 1;
        else if (x < 2400) c[6] = 1;
        else if (x < 2800) c[7] = 1;
        else if (x < 3200) c[8] = 1;
        else if (x >= 3200) any ++;
    }
    for (intt i = 1; i <= 8; i++)
        cnt += c[i];
    if (cnt == 0)
        cout << 1 << " ";
    else 
        cout << cnt << " ";
    cout << cnt + any << endl;
    return 0;
}


Measured memory_bytes: 256
# B - Ruined Square

x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
int main(){
	int a,b,K;cin>>a>>b>>K;
	vector<int>v;
	for(int i=1;i<=100;i++){
		if(a%i==0&&b%i==0){
			v.push_back(i);
		}
	}
	cout<<v[v.size()-K]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;
//#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = 0; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int i = n; i >= 0; i--)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int main() {
	int n, m;
	float sum = 0;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	};
	rep(i, n) {
		float vote = sum / (4 * m);
		if (a[i] < vote) a[i] = -1;
	}
	int ans_sum = 0;
	rep(i, n) {
		if (a[i] >= 0) ans_sum += 1;
	};
	string ans;
	ans = (ans_sum >= m) ?  "Yes" : "No";
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256