akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

template<typename T, unsigned int MAX_SIZE, unsigned long long mod>
struct PascalTriangle {
    T d[MAX_SIZE][MAX_SIZE];

    void precalc() {
        rep(i, MAX_SIZE) {
            d[i][0] = d[i][i] = 1;
            REP(j, 1, i) {
                d[i][j] = d[i-1][j-1]+d[i-1][j];
                if(mod != 0) d[i][j] %= mod;
            }
        }
    }

    PascalTriangle() {
        precalc();
    }

    T comb(int n, int r) {
        return d[n][r];
    }
};



int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vl v(n);
    rep(i, n) cin >> v[i];
    using D = double;
    D ans = 0;
    ll ans2 = 0LL;
    sort(rall(v));
    rep(i, a) ans += v[i];
    ans /= a;
    PascalTriangle<ll, 53, 0> pas;
    ll cnt = 0;
    ll l = 0, r = n;
    REP(i, 1, n) if(v[i-1] != v[a-1] && v[i] == v[a-1]) l = i;
    rep(i, n-1) if(v[i] == v[a-1] && v[i+1] != v[a-1]) r = i+1;
    cnt = r - l;
    // r - l ko nonakakara [a-l, b-l]ko erabu
    a -= l;
    b -= l;
    chmax(a, 1);
    if(l == 0) {
        REP(i, a, b+1) {
            ans2 += pas.comb(cnt, i);
            // dump(cnt), dump(i), dumpL(pas.comb(cnt, i));
        }
    }
    else ans2 = pas.comb(cnt, a);
    cout << fixed << setprecision(15);
    cout << ans << endl;
    cout << ans2 << endl;
    return 0;
}

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

using namespace std;

int main() {
  string S; cin >> S;
  long long K; cin >> K;
  int i = 0;
  while (S[i] == '1') {
    K -= 1;
    if (K == 0) break;
    i++;
  }
  cout << S[i] << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) {
    list($a) = ints();
    if (isset($cnt[$a])) $cnt[$a]++;
    else $cnt[$a] = 1;
}
$ans = 0;
foreach ($cnt as $v) if ($v % 2) $ans++;
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 13048
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    ll A,B,H,M;
    long double ans=0;
    cin>>A>>B>>H>>M;
    ans=sqrt(A*A+B*B-2*A*B*cos(abs(30*H-5.5*M)*M_PI/180));
    cout<<fixed<<setprecision(11)<<ans;
}



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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_k_digit = 40, MAX_N = 1e5;
ll N, K;
ll a[MAX_N];
ll c[MAX_k_digit] = {};

int main(){
  cin >> N >> K;
  REP(i, N){
    cin >> a[i];
    REP(j, MAX_k_digit){
      c[j] += ((a[i] >> j) & 1);
    }
  }
  ll dp_true = 0, dp_false = 0;
  REP(j, MAX_k_digit){
    ((K >> j) & 1) ? dp_true = max(dp_false + c[j] * (1ll << j), dp_true + (N - c[j]) * (1ll << j)) : dp_true += c[j] * (1ll << j);
    dp_false += max(c[j], N - c[j]) * (1ll << j);
  }
  cout << dp_true << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A;
  cin>>A;
  A%=10;
  if(A==3)
    puts("bon");
  else if(A==0||A==1||A==6||A==8)
    puts("pon");
  else	puts("hon");
  return 0;
}

Measured memory_bytes: 3632
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

totalMins = 0;
let stratFrom = 0;

rl.on('line', function(data){
    data = data.split(' ');
    //console.log(data);

    let from = parseInt(data[0]) * 60 + parseInt(data[1]);
    let to = parseInt(data[2]) * 60 + parseInt(data[3]);
    totalMins = to - from;
    //console.log(totalMins);

    stratFrom = totalMins - parseInt(data[4]);
    //console.log(stratFrom);
    rl.close();
});

rl.on('close', function(){
    console.log(`${stratFrom}`);
})

Measured memory_bytes: 30056
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 200010;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// End Template //

struct event{
    int l, r, x;
    int opt;

    bool operator<(event &o){
        if(o.l==l){
            return opt<o.opt;
        }
        return l<o.l;
    }
};

int main()
{sws;

    int n, q, d, x, s, t;
    cin >> n >> q;

    vector<event> sweep;

    for(int i=0;i<n;i++){
        cin >> s >> t >> x;
        sweep.pb((event){s-x, t-1-x, x, 1});
        sweep.pb((event){t-1-x, s-x, x, 3});
    }

    for(int i=0;i<q;i++){
        cin >> d;
        sweep.pb((event){d, d, i, 2});
    }


    sort(sweep.begin(), sweep.end());

    set<pii> open;

    // for(auto v: sweep)
    //     cout << v.l << " " << v.r << " " << v.opt << endl;

    vi ans(q, -2);

    for(auto v: sweep){
        // cout << v.l << " " << v.r << " " << v.opt << endl;
        if(v.opt==1)
            open.insert(mp(v.x, v.l));
        if(v.opt==2){
            int i = v.x;

            if(open.empty()){
                ans[i]=-1;
                continue;
            }

            pii b = *(open.begin());

            ans[i] = b.ff;
        }
        if(v.opt==3){
            open.erase(open.find(mp(v.x, v.r)));
        }

        // cout << "size = " << open.size() << endl;
    }


    for(auto a: ans)
        cout << a << endl;


    return 0;
    
}

Measured memory_bytes: 22692
n = int(input())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ans=0
for i in range(n):
    ans += b[a[i] - 1]
    if i>=1 and a[i] - 1 == a[i - 1]:
        ans += c[a[i]-2]
        
print(ans)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    var N= nextInt()
    val dp = IntArray(N + 1) { 1000000007 }
    dp[0] = 0
    for (n in 1 .. N) {
        var power = 1
        while (power <= n) {
            dp[n] = Math.min(dp[n], dp[n - power] + 1)
            power *= 6
        }
    }
    for (n in 1 .. N) {
        var power = 1
        while (power <= n) {
            dp[n] = Math.min(dp[n], dp[n - power] + 1)
            power *= 9
        }
    }
    println(dp[N])
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 33712
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
        for(int i = 0; i < n; i++){
            x = Math.max(sc.nextInt(), x);
        }
        for(int i = 0; i < m; i++){
            y = Math.min(sc.nextInt(), y);
        }
        if(y > x){
            System.out.println("No War");
        }else{
            System.out.println("War");
        }
        }
}

Measured memory_bytes: 22740
import sys

def main():
    S = [int(i) for i in input()]

    N = len(S)

    ol = [0] * N
    lo = [0] * N
    for i in range(N):
        if i % 2 ==0:
            ol[i] = 0
            lo[i] = 1
        else:
            ol[i] = 1
            lo[i] = 0

    ol_cnt = 0
    lo_cnt = 0
    for j in range(N):
        if ol[j] == S[j]:
            ol_cnt += 1
        if lo[j] == S[j]:
            lo_cnt += 1

    print(min(ol_cnt, lo_cnt))

main()

Measured memory_bytes: 5528
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

vector<ll> enumDivisor(ll n)
{
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++)
  {
    if (n % i)
      continue;
    res.push_back(i);
    if (i * i != n)
      res.push_back(n / i);
  }
  return res;
}
int main()
{
  ll n;
  cin >> n;
  int ans = 0;
  for (ll x : enumDivisor(n))
  {
    if (x == 1)
      continue;
    ll tmp = n;
    while (tmp % x == 0)
      tmp /= x;
    tmp %= x;
    if (tmp == 1)
      ++ans;
  }
  ans += enumDivisor(n - 1).size() - 1;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 632
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
        lines.append(input())
        lines.append(input())

    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    a = [int(e) for e in lines[1].split(" ")]
    b = [int(e) for e in lines[2].split(" ")]
    c = [int(e) for e in lines[3].split(" ")]

    return (n, a, b, c)


def solve(n, a, b, c):

    total = 0
    previous_dish_num = -1
    for i in range(n):
        dish_num = a[i]
        total = total + b[dish_num-1]
        if previous_dish_num + 1 == dish_num:
            total = total + c[previous_dish_num-1]
        previous_dish_num = dish_num

    return total


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
	

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

int main(){
    int m, f, r, sum;
    
    while(1){
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1) break;
        
        sum = m + f;
        
        if(m == -1 || f == -1 || sum < 30){
            cout << "F" << endl;
        }
        else if(sum >= 80){
            cout << "A" << endl;
        }
        else if(sum >= 65 && sum < 80){
            cout << "B" << endl;
        }
        else if(sum >= 50 && sum < 65){
            cout << "C" << endl;
        }
        else if(sum >= 30 && sum < 50){
            if(r >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

const int INF = 1e7;

int n;
int d[101][101];

void init(int n){
    rep(i, 0, n){
        rep(j, 0, n){
            d[i][j] = INF;
            if(i == j) d[i][j] = 0;
        }
    }
}

void warshall_floyd(){
    rep(k, 0, n){
        rep(i, 0, n){
            rep(j, 0, n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

signed main(){
    cin >> n;
    init(n);
    int r, k, t;
    rep(i, 0 ,n){
        cin >> r >> k;
        rep(j, 0, k){
            cin >> t;
            d[r - 1][t - 1] = 1;
        }
    }
    warshall_floyd();
    int fr, to, v, p;
    cin >> p;
    rep(i, 0, p){
        cin >> fr >> to >> v;
        if(d[fr - 1][to - 1] < v){
            cout << d[fr - 1][to - 1] + 1 << endl;
        }else{
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1236
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
inline int give(int x)
{
	return ((x)*(x+1))/2;
}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
    	vector<int> v;
    	for(int i=1;i<=100000;++i)
    	v.pb(give(i));
		int n;
		cin>>n;
		int ans = 0;
		for(int i=2;i*i<=n;++i)
		{
			int ct = 0;
			while(n%i==0)
			{
				ct++;
				n/=i;
			}
			if(ct!=0){
			auto it = upper_bound(all(v),ct) - v.begin();
			ans+= it;
			}
		}
		if(n>1)
		++ans;
		cout<<ans;    	
    }
    return 0;
}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=2e5+10;

int n;
vector <int> edge[maxn];
ll f[maxn],ans[maxn];
ll pre[maxn],suf[maxn];
int sz[maxn];
ll tmp[maxn];

ll inv(ll base,int p) {
	ll res=1;
	while (p) {
		if (p%2==1) (res*=base)%=mod;
		base=base*base%mod;
		p/=2;
	}
	return res;
}

void dfs1(int u,int fa) {
	ll tmp1=1,tmp2=1;
	sz[u]=0;
	f[u]=1;
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (v==fa) continue;
		dfs1(v,u);
		(f[u]*=f[v]*inv(tmp[sz[v]],mod-2)%mod)%=mod;
		sz[u]+=sz[v];
	}
	sz[u]++;
	f[u]=f[u]*tmp[sz[u]-1]%mod;
//	printf("f[%d]=%d\n",u,f[u]);
}

void dfs2(int u,int fa) {
	ans[u]=f[u]*inv(tmp[sz[u]-1],mod-2)%mod;
	if (fa!=-1) {
		ll cur=1;
		cur=ans[fa]*inv(tmp[sz[1]-1],mod-2)%mod;
		cur=cur*tmp[sz[u]]%mod*inv(f[u],mod-2)%mod;
//		printf("%d cur=%d %d %d %d %d\n",u,cur,fa,f[u],sz[1]-1,sz[u]);
		cur=cur*inv(sz[1]-sz[u],mod-2)%mod;
		ans[u]=ans[u]*cur%mod;
	}
	ans[u]=ans[u]*tmp[sz[1]-1]%mod;
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (v==fa) continue;
		dfs2(v,u);
	}
}

int main(){
	tmp[0]=1;
	for (int i=1;i<maxn;i++) tmp[i]=tmp[i-1]*(ll)i%mod,ans[i]=1;
	scanf("%d",&n);
	for (int i=0;i<n-1;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs1(1,-1);
	dfs2(1,-1);
	for (int i=1;i<=n;i++) 
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 22516
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,M = MI()

if N == 1:
    ans = -1
    for i in range(M):
        s,c = MI()
        if ans == -1:
            ans = c
        elif c != ans:
            print(-1)
            break
    else:
        if M != 0:
            print(ans)
        else:
            print(0)
    exit()


ANS = [-1]*N
for i in range(M):
    s,c = MI()
    if ANS[s-1] == -1:
        ANS[s-1] = c
    elif ANS[s-1] != c:
        print(-1)
        exit()

for i in range(N):
    if i == 0 and ANS[i] == 0:
        print(-1)
        exit()
    elif i == 0 and ANS[i] == -1:
        ANS[i] = '1'
    elif ANS[i] == -1:
        ANS[i] = '0'
    else:
        ANS[i] = str(ANS[i])

print(''.join(ANS))


Measured memory_bytes: 62168
#include <stdio.h>

int main(void)
{
  int N;
  scanf("%d", &N);
  int b = 0;
  for(int i = 0; i < N; i++){
    int a;
    scanf("%d", &a);
    b ^= a;
  }
  printf(b == 0 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int count = 0;
    rep(i, 2) {
      if (a >= b) {
        count += a;
        a--;
      } else {
        count += b;
        b--;
      }
    }

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
//MD. HASNAIN ALI (UNSOLVED)
#include <iostream>
#include <stddef.h>

#define ll long long
#define pii pair<int,int>

#define distance(a,b) (sq(a.x-b.x) + sq(a.y-b.y))
#define MAX3(a,b,c) max(a,max(b,c))
#define SQ(x) ((x) * (x))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define end "\n";



using namespace std;

int main()
{
    int x,y,a=0,i,j;
    cin>>x>>y;
    for(i=0;i<=x;i++)
    {
        j=x-i;
        if((j*4)+(i*2)==y)
        {
            a=1;
            break;
        }
    }
    if(a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
using namespace std;

int main() {

	string S;
	cin >> S;

	int count = 0;
	for (int i = 0; i < S.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D')
				count++;
		}
		if (i % 2 == 1)
		{
			if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D')
				count++;
		}
	}

	if (count == S.length())
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


def dfs(s, p, P, i):
    # 再帰
    # スイッチを順に見ていく
    if len(s) == i:
        return 1 if P == p else 0
    # 場合の数
    # そのスイッチを使用しなかった場合 + 使用した場合
    return dfs(s, p, P, i + 1) + dfs(s, p, P ^ s[i], i + 1)


def main():
    lines = stdin.readlines()
    N, M = map(int, lines[0].split())
    sn = [[int(j) for j in i.split()[1:]] for i in lines[1:-1]]
    pn = (int(i) for i in lines[-1].split())
    # s[スイッチ]
    # 二進法で表した数における各桁はそのスイッチを使用している電球
    s = [0] * N
    for i in range(M):
        for j in sn[i]:
            s[j - 1] |= (1 << i)
    # p
    # 二進法で表した数における各桁は電球
    # スイッチONの数 MOD 2 におけるゼロイチを二進法で表す
    # 一致する場合に 全ての電球が点灯
    p = 0
    for i, j in enumerate(pn):
        p |= (1 << i) if j == 1 else 0
    print(dfs(s, p, 0, 0))


main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(){
    int a,b,pasta[3],juse[2];
    for(int i = 0;i < 3;i++){
        cin >> pasta[i];
    }
    for(int i = 0;i < 2;i++){
        cin >> juse[i];
    }
    a = min(min(pasta[0],pasta[1]),pasta[2]);
    b = min(juse[0],juse[1]);
    cout << a + b -50 << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define MAX 100000
using namespace std;


void swap(int A[], int index1, int index2) {
    int temp;
    temp = A[index1];
    A[index1] = A[index2];
    A[index2] = temp;
}

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p -1;
    for(int j = p; j <= r-1; j++) {
        if(A[j] <= x) {
            i = i + 1;
            swap(A, i, j);
        }
    }
    swap(A, i+1, r);
    return i+1;
}

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

    int index = partition(A, 0, n-1);
    for(int i = 0; i < n; i++) {
        if(i == index)
            printf("[%d]", A[i]);
        else
            printf("%d", A[i]);
        if(i != n-1) printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; // assert(a[i]<n ) // if we want to check for special cond , used for debug                     
using namespace __gnu_pbds; // make less_equal in order to make a multiset pbds
#define INF (ll)1e18 
const ll Mod = (ll)1e9+7;
ll CaseN=1;
const ld PI = 22/7.0;

ll tst()
{
ll ans=0;

return ans;
}

void solve()
{	
		ll x;
		cin>>x;
		cout<<1-x<<endl;
		
		
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
	
return ;

}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	}
	
}


Measured memory_bytes: 3648
#include <iostream>

int main(){
	int N;
	double x;
	std::string u;
	double out=0;
	std::cin >> N;
	for (int i=0;i<N;i++){
		std::cin >> x >> u;
		if (u=="JPY"){
			out += x;
		}else{
			out += x*380000;
		}
	}
	std::cout << out;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int wakeup = sc.nextInt() * 60 + sc.nextInt();
    int sleep = sc.nextInt() * 60 + sc.nextInt();
    int studyTime = sc.nextInt();
    System.out.println(sleep - studyTime - wakeup);
  }
}


Measured memory_bytes: 35852
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int cnt = 0;
  while (1) {
    rep(i, n) {
      if (a[i] % 2 != 0) {
        cout << cnt << endl;
        return 0;
      }
      a[i] *= 0.5;
    }
    cnt++;
  }

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define INF 99999999
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long ans = 0;
    cin >> n;
    vector <vector<int>> v(n, vector<int>(3));
    int a, b, c;
    for (vector<int>& tmp : v) {
        cin >> a >> b;
        c = a+b;
        tmp[0] = c; tmp[1] = a; tmp[2] = b;
        ans -= b;
    }
  /*
    for(vector<int> tmp : v) {
        cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
    }
    */
    sort(v.begin(), v.end(), greater<>());
    for(int i = 0; i < n; i += 2) {
        ans += v[i][0];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	string s, t;
	cin >> s >> t;
	int dp[3010][3010];
	dp[0][0] = 0;
	//dp[i+1][j+1]でsのi文字目とtのj文字目までを見た時の最長の部分列
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j < t.size(); ++j) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	string res = "";
	int i = s.size(), j = t.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) {
			--i;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			--j;
		}
		else {
			res = s[i - 1] + res;
			--i, --j;
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int main(){
        long long int n; cin >> n;
        string s = "abcdefghijklmnopqrstuvwxyz";
        vector<long long int> v;
        while (n > 0){
            v.push_back((n%26)-1);
            if (n % 26 == 0) n--;
            n /= 26;
        }
        for (long long int x = v.size()-1; x >= 0; --x){
            if (v[x] == -1) cout << "z";
            else cout << s[v[x]];
        }
    return 0;
}



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



/*int LCS(string s,string t,int n,int m)
{
	if(n==0||m==0)
	return 0;
	
	if(dp[n][m]!=-1)
	return dp[n][m];
	
	else if(s[n-1]==t[m-1])
	return dp[n][m]= 1+LCS(s,t,n-1,m-1);
	
	else
	return dp[n][m]= max(LCS(s,t,n-1,m),LCS(s,t,n,m-1));
	
}*/

int main() {
	// your code goes here
	
	
	string s,t;
	
	cin>>s>>t;
	
	int n=s.length();
	
	int m=t.length();
	
	int dp[n+1][m+1];
	
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0||j==0)
			dp[i][j]=0;
			
			else if(s[i-1]==t[j-1])
			dp[i][j]=1+dp[i-1][j-1];
			
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	int i=n;
	
	int j=m;
	
	string s1="";
	
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			s1.push_back(s[i-1]);
			i--;
			j--;
			
		}
		
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
			i--;
			
			else
			j--;
		}
	}
	
	reverse(s1.begin(),s1.end());
	
	cout<<s1<<endl;
	
	

	return 0;
}

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

typedef long long ll;

ll a, b, n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> a >> b >> n;

    ll x = n / b * b - 1;
    if (n < b) {
        x = n;
    }
    cout << a * x / b - x / b * a << endl;

    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	a--;
	ll cnt=0;
	ll now=1;
	while(now<b){
		cnt++;
		now+=a;
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		double n = in.nextDouble();
		LinkedList<Double> list = new LinkedList<>();
		for ( int i = 0; i < n; i++ ) {
			list.add(in.nextDouble());
		}
		Collections.sort(list);

		while ( list.size() > 1 ) {
			double d0 = list.getFirst();
			list.removeFirst();
			double d1 = list.getFirst();
			list.removeFirst();

			list.addFirst((d0 + d1) / 2);
		}

		System.out.println(list.getFirst());
		in.close();
	}
}


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

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

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

long long f(long long N){
  string s = to_string(N);
  long long ret = 0;
  for (int i = 0; i < s.length();i++){
    ret += s[i] - '0';
  }
  return ret;
}

int main()
{
  long long A, B, C, X;
  cin >> A >> B >> C >> X;
  long long ans = 0;
  for (int a = 0; a <= A; a++)
  {
    for (int b = 0; b <= B; b++){
      for (int c = 0; c <= C; c++){
        if(500*a+100*b+50*c==X)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
  
  ll A ,X, Y, Z;
  cin >> X >> Y >> Z;
  
  for (ll i = 0; i<10000000000000; i++) {
    A=Y*i+Z*(i+1);
  if(A>X){cout<<i-1;break;}}
}
    
   

Measured memory_bytes: 3624
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');

        decimal min = 0, max = 0, sum = 0;
        decimal a;

        for (int i = 0; i < n; i++)
        {
            a = int.Parse(s[i]);

            if (i == 0)
            {
                min = a;
                max = a;
            }
            else
            {
                if (a < min) min = a;
                if (a > max) max = a;    
            }
            
            sum += a;
        }

        Console.WriteLine(string.Format("{0} {1} {2}", min, max, sum));
    }
}


Measured memory_bytes: 9908
#include <iostream>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

ll modpow(ll k, ll n, int mod) {
  ll ret = 1;
  while (n > 0) {
    if (n % 2 == 1) ret = k * ret % mod;
    k = k * k % mod;
    n /= 2;
  }

  return ret;
}

ll choose(ll n, ll k, int mod) {
  ll x = 1, y = 1;

  rep(i, k) {
    x *= n - i;
    x %= mod;
    y *= i + 1;
    y %= mod;
  }

  return x * modpow(y, mod - 2, mod) % mod;
}

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

  const int mod = 1000000007;

  ll ans = modpow(2, n, mod) - 1;

  ans -= choose(n, a, mod);
  ans = (ans + mod) % mod;
  ans -= choose(n, b, mod);
  ans = (ans + mod) % mod;

  cout << ans << '\n';
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int n;
string s;
ll dp[5005][5005];

ll powmod(ll n,ll k,ll mod){
    if (k==0) return 1;
    else if (k%2==0){
        ll tmp=powmod(n,k/2,mod);
        return tmp*tmp%mod;
    }
    else return powmod(n,k-1,mod)*n%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    int ls=s.length();
    dp[0][0]=1;
    rep(i,n)rep(j,n+1){
        if (j-1>=0){
            dp[i+1][j]+=(dp[i][j-1]*2+dp[i][j+1])%mod;
            dp[i+1][j]%=mod;
        }
        else{
            dp[i+1][0]+=(dp[i][0]+dp[i][1])%mod;
            dp[i+1][0]%=mod;
        }
    }
    cout << dp[n][ls]*(powmod(2,ls*(mod-2),mod))%mod << endl;
    return 0;
}

Measured memory_bytes: 195840
from decimal import Decimal
def waru(N,num):
  cnt = 0
  while N%num==0:
    N //= num
    cnt += 1
  return cnt
def solve():
  N = int(input())
  num = [[0]*101 for _ in range(101)]
  lis = [0]*N
  for i in range(N):
    a = input()
    b = a.split(".")
    if len(b)==1:
        a = int(a)*(10**9)
    else:
        a = int(b[0] + b[1] + (9-len(b[1]))*"0")
    two,five = waru(a,2)-9,waru(a,5)-9
    two -= 50
    five -= 50
    num[two][five] += 1
    lis[i] = [two,five]
  cum2 = [[0]*101 for _ in range(101)]
  for i in range(95,10,-1):
    for j in range(95,10,-1):
      cum2[i][j] = cum2[i+1][j]+cum2[i][j+1]-cum2[i+1][j+1]+num[i][j]
  ans = 0
  for i in range(N):
    two,five = lis[i]
    two2,five2 = -(two+50)-50,-(five+50)-50
    ans += cum2[two2][five2]
    if two+50>=0 and five+50>=0:
      ans -= 1
  return ans//2
print(solve())

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

#define LENGTH ((100))
int BubbleSort(int a[], int n)
{
    int flag = 1;
    int v, sw = 0;
    for (int i = 0; flag == 1; i++) {
        flag = 0;
        for (int j = n - 1; j >= i + 1; j--) {
            if (a[j] < a[j - 1]) {
                v = a[j];
                a[j] = a[j -1];
                a[j -1] = v;
                flag = 1;
                sw++;
            }
        }    
    }
    return sw;
}

int main()
{
    int n, sw;
    int a[LENGTH];

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

    for (int i = 0; i < n; i++)
    {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    return 0;
}


Measured memory_bytes: 2120
#include<iostream>
#include<string>
using namespace std;

int main(void){

    int n; cin >> n;
    string s; cin >> s;

    int count = 1;
    char prev = s[0];

    for(int i = 1; i < n; i++){
        if(prev == s[i]){
            //cout << i << "  : same" <<endl;
        }else{
            //cout << i << "  : diff" <<endl;
            prev = s[i];
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	private static final String SUNNY = "Sunny";
	private static final String CLOUDY = "Cloudy";
	private static final String RAINY = "Rainy";

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String r = null;
		switch (s) {
		case SUNNY:
			r = CLOUDY;
			break;
		case CLOUDY:
			r = RAINY;
			break;
		case RAINY:
			r = SUNNY;
			break;
		default:
			break;
		}
		System.out.println(r);
		sc.close();
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
typedef long long ll;

void solve(void){
    int n;
    ll pret, prea;
    scanf("%d\n", &n);
    prea = pret = 1;
    rep(n, i) {
        ll t, a;
        scanf("%lld %lld\n", &t, &a);
        ll k = max((prea+a-1)/a, (pret+t-1)/t);
        prea = a*k; pret = t*k;
        //printf("%lld %lld\n", pret, prea);
    }
    printf("%lld\n", pret+prea);
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
 
int main() {
  int H, W, dist[20][20] = {};
  char S[20][20];
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      int d[20][20] = {};
      int visited[20][20] = {};
      queue<P> q;
      d[i][j] = 0;
      q.push(P(i, j));
      visited[i][j] = 1;
      while (!q.empty()) {
        P pos = q.front();
        int x = pos.first;
        int y = pos.second;
        if (x - 1 >= 0) {
          if (S[x-1][y] == '.' && visited[x-1][y] == 0) {
            d[x-1][y] = d[x][y] + 1;
            q.push(P(x-1, y));
            visited[x-1][y] = 1;
          }
        }
        if (x + 1 < H) {
          if (S[x+1][y] == '.' && visited[x+1][y] == 0) {
            d[x+1][y] = d[x][y] + 1;
            q.push(P(x+1, y));
            visited[x+1][y] = 1;
          }
        }
        if (y - 1 >= 0) {
          if (S[x][y-1] == '.' && visited[x][y-1] == 0) {
            d[x][y-1] = d[x][y] + 1;
            q.push(P(x, y-1));
            visited[x][y-1] = 1;
          }
        }
        if (y + 1 < W) {
          if (S[x][y+1] == '.' && visited[x][y+1] == 0) {
            d[x][y+1] = d[x][y] + 1;
            q.push(P(x, y+1));
            visited[x][y+1] = 1;
          }
        }
        q.pop();
      }
      for (int a = 0; a < H; a++) {
        for (int b = 0; b < W; b++) {
          dist[i][j] = max(dist[i][j], d[a][b]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = max(dist[i][j], ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n")[0],t=r.length,n=[],o=0;o<t;o++)n.push(0);var u=function e(r,t,n,o){if(t==n-1){for(var u="",i=0;i<n;i++)u+=o[i],1==r[i]&&(u+="+");for(var f=u.split("+"),c=0,l=0;l<f.length;l++)c+=Number(f[l]);return c}var a=r.concat();var p=e(a,t+1,n,o);var d=r.concat();d[t]=1;var s=e(d,t+1,n,o);return p+s}(n,0,t,r);console.log(u)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define track(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15;
const ll N=2e5+10;
 

ll mod_expo(ll a,ll b, ll c)
{
	ll ans=1;
	while(b)
	{
		if(b & (ll)1) ans=(ans*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return ans;
}
ll invese(ll n)
{
	return mod_expo(n,mod-2,mod);
} 
ll fact[N]; 
ll ncr(ll n, ll k)
{
	if(n<k) return 0;
	ll ans=1;
	ans=(ans*fact[n])%mod;
	ans=(ans*invese(fact[k]))%mod;
	ans=(ans*invese(fact[n-k]))%mod;
	return ans;
} 
 
int main()
{
	boost;
	fact[0]=1;
	for(ll i=1;i<N;i++) fact[i]=(fact[i-1]*i)%mod;
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0,sum=0,ans1=0;
	for(ll i=1;i<=(n-1);i++)
	{
		sum+=i;
		sum%=mod;
		ans+=sum;
		ans%=mod;
	}
	ans*=m;
	ans%=mod;
	ans*=m;
	ans%=mod;	
	sum=0;	
	for(ll i=1;i<=(m-1);i++)
	{
		sum+=i;
		sum%=mod;
		ans1+=sum;
		ans1%=mod;
	}
	ans1*=n;
	ans1%=mod;
	ans1*=n;
	ans1%=mod;	
	ans+=ans1;
	ans%=mod;
	cout<<(ans*ncr(n*m-2,k-2))%mod;
  	return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(void) {
  string str;
  int k;
  set<string> s;
  cin >> str >> k;
  for (int i = 1; i <= 5; i++) {

    for (int j = 0; j < str.length(); j++) {
      
      if (str.length() - j < i)
        continue;
      s.insert(str.substr(j, i));
    }
  }
  auto itr = s.begin();
  if (k != 1) {
    for (int i = 0; i < k - 1; i++) {
      ++itr;
    }
  }

  cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 1664
n=int(input())
a=list(map(int,input().split()))
mini=float('inf')
sum1=0
sum2=sum(a)
t=0
while t<n:
    sum1=sum1+a[t]
    sum2=sum2-a[t]
    mini=min(mini,abs(sum1-sum2))
    t+=1
print(mini)

Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String, Long> h = new HashMap<>();
        h.put("M", 0L);
        h.put("A", 0L);
        h.put("R", 0L);
        h.put("C", 0L);
        h.put("H", 0L);
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (h.containsKey(s.substring(0, 1))) {
                h.put(s.substring(0, 1), h.get(s.substring(0, 1)) + 1L);
            }
        }
        sc.close();
        long ans = 0;
        ans += h.get("M") * h.get("A") * h.get("R");
        ans += h.get("M") * h.get("A") * h.get("C");
        ans += h.get("M") * h.get("A") * h.get("H");
        ans += h.get("M") * h.get("R") * h.get("C");
        ans += h.get("M") * h.get("R") * h.get("H");
        ans += h.get("M") * h.get("C") * h.get("H");
        ans += h.get("A") * h.get("R") * h.get("C");
        ans += h.get("A") * h.get("R") * h.get("H");
        ans += h.get("A") * h.get("C") * h.get("H");
        ans += h.get("R") * h.get("C") * h.get("H");
        System.out.println(ans);
    }
}

Measured memory_bytes: 45284
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int i = 0;
	for(int j = a;j <= b;j++)
	{
		if (c % j == 0)
			i++;
	}

	cout << i << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <queue>
#define ll long long
using namespace std;

int main()
{
	int k;
	ll lunlun;
	queue<ll> q;
	cin >> k;

	for (int i = 1; i < 10; i++)
		q.push(i);

	for (int i = 0; i < k - 1; i++)
	{
		lunlun = q.front();
		q.pop();

		if (lunlun % 10 != 0)
			q.push(10 * lunlun + (lunlun % 10) - 1);
		q.push(10 * lunlun + (lunlun % 10));
		if (lunlun % 10 != 9)
			q.push(10 * lunlun + (lunlun % 10) + 1);
	}

	cout << q.front() << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;

#define gettime printf("\nTime : %0.3lf\n",clock()*1.0/CLOCKS_PER_SEC);
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define Set(x,a) memset(x,a,sizeof(x));

#define vs vector<string>
#define vi vector<int>
#define ll long long
#define ff first
#define ss second

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    int a, b, c, x, ans = 0;
    scanf("%d %d %d %d", &a, &b, &c, &x);
    rep (i, 0, a) rep (j, 0, b) rep (k, 0, c) {
        if (i * 500 + j * 100 + k * 50 == x) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256