akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define req(i,n) for(int i = 1;i <= n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define fix  fixed << setprecision(10)
const int MOD = 1000000007;
const ll INF = (1LL << 60);
string t, u; ll n, h, num = 0, k, q, ans = 0, sum = 0, a, d, r = 0;
bool f = true;
int main() {
    cin >> n >> d >> a;
    vector<pair<ll, ll>> x(n), b(n); vector<int> s(n + 1);
    rep(i, n) {
        cin >> q >> k;
        x[i] = make_pair(q, k);
    }sort(ALL(x));
    rep(i, n) {
        x[i].second -= s[i];
        while (r < n && x[r].first <= x[i].first + 2 * d)++r;
        if (x[i].second > 0) {
            num = (x[i].second + a - 1) / a;
            ans += num;
            s[i] += num * a;
            s[r] -= num * a;
        }
        s[i + 1] += s[i];
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<int> ans;
    while (b.size()){
        vector<int> nb;
        bool flag = false;
        for (int i = b.size() - 1; i >= 0; i--){
            if (b[i] == i + 1){
                ans.push_back(b[i]);
                for (int j = 0; j < b.size(); j++) if (j != i) nb.push_back(b[j]);
                flag = true;
                break;
            }
        }
        if (!flag && b.size()){
            cout << - 1 << endl;
            exit(0);
        }
        b = nb;
    }
    for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a==b && b==c)
    {
        cout<<"No";
    }
    else if(a==b)
    {
        cout<<"Yes";
    }
    else if(a==c)
    {
        cout<<"Yes";
    }
    else if(b==c)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
int n,d[105][2];
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n;
	rep(i,1,n) std::cin>>d[i][0]>>d[i][1];
	rep(i,1,n-2){
		if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1])
			return std::cout<<"Yes\n",0;
	}
	std::cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3656
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = getLine >>= print . solve
solve :: String -> Int
solve s = go s days
  where
    go s (d:ds)
      | s == d = (length ds) + 1
      | otherwise = go s ds


days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

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

const int INF = 1e9 + 5;

int main() {
    int N, K; 
    scanf("%d%d", &N, &K);

    vector<int> h(N), dp(N, INF);

    for (int &x: h)
        scanf("%d", &x);

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j <= i+K; ++j) {
            if (j < N)
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

    printf("%d\n", dp[N-1]);
}

Measured memory_bytes: 1024
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
x=i2()
x.sort()
c=0
c+=x[2]-x[1]
if (x[2]-x[0]-c)%2==0:
   print(c+(x[2]-x[0]-c)//2)
else:
   print(c+(x[2]-x[0]-c)//2+2)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int n;
    cin >> n;
    pair<pair<string ,int>,int> r[n];
    rep(i,n){
        string s;   int p;
        cin >> s >> p;
        r[i] = make_pair(make_pair(s,-p),i);
    }

    sort(r,r+n);

    rep(i,n){
        cout << r[i].second+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    in(n);
    n/=200;n--;
    cout<<9-n<<endl;
    return 0;
}

Measured memory_bytes: 3616
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  list<int64_t> B;
  bool is_inv = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    if (!is_inv) {
      B.push_back(a);
    } else {
      B.push_front(a);
    }
    is_inv = 1 - is_inv;
  }
  if (!is_inv) {
    bool is_first = true;
    auto itr = B.begin();
    while (itr != B.end()) {
      if (!is_first) {
        cout << " ";
      }
      cout << *itr;
      is_first = false;
      ++itr;
    }
    cout << endl;

  } else {
    bool is_first = true;
    auto itr = B.rbegin();
    while (itr != B.rend()) {
      if (!is_first) {
        cout << " ";
      }
      cout << *itr;
      is_first = false;
      ++itr;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 9852
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {

    vl a(7);
    rep(i, 7) {
        cin >> a[i];
    }
    
    ll ans;
    if(a[0] > 0 && a[3] > 0 && a[4] > 0) {
        ans = max( 2*(a[0]/2 + a[3]/2 + a[4]/2), 3 + 2*((a[0] - 1)/2 + (a[3] - 1)/2 + (a[4] - 1)/2) ) + a[1];
    }
    else {
        ans = 2*(a[0]/2 + a[3]/2 + a[4]/2) + a[1];
    }

    out(ans);
    re0;
}

Measured memory_bytes: 3604
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

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

    let H = buf_it.next().unwrap().parse::<usize>().unwrap();
    let W = buf_it.next().unwrap().parse::<usize>().unwrap();
    
    let AZ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect::<Vec<_>>();

    for i in 1..H+1{
        for j in 0..W{
            let s = buf_it.next().unwrap();
            if s=="snuke"{
                println!("{}{}",AZ[j],i);
                return;
            }
        }
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && A != C) {
        cout << "Yes";
    } else if (A == C && A != B) {
        cout << "Yes";
    } else if (B == C && A != B) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

int n, m, p[1000];

int main(){
    for(; scanf("%d%d", &n, &m), n||m;){
        for(int x = 0; x < n; x++){
            scanf("%d", p+x);
        }
        sort(p, p+n, greater<int>());
        int ans = 0, z;
        for(int x = 0; x < n; x++){
            if((x+1)%m) ans += p[x];
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define N 100005
#define F first
#define S second
using namespace std;
typedef pair<int,int> PR;

int n, mx, mi;
PR a[N];
vector<PR> gr[N];
queue<PR> qu;

int main() {
	int i, k, no, u, v;
	cin >> n;
	for(i=1; i<=n-1; i++) {
		scanf("%d%d", &u, &v);
		a[i].F = i;
		gr[u].push_back({v, i});
		gr[v].push_back({u, i});
	}
	for(i=1; i<=n; i++) {
		if(gr[i].size() > mx) {
			mx = gr[i].size();
			mi = i;
		}
	}
	qu.push({mi, 0});
	while(!qu.empty()) {
		PR t = qu.front(); qu.pop();
		no = a[t.S].S;
		k = 0;
		for(auto x:gr[t.F]) {
			if(x.S == t.S) continue;
			++k;
			if(k==no) ++k;
			a[x.S].S = k;
			qu.push(x);
		}
	}
	cout << mx << endl;
	for(i=1; i<n; i++) printf("%d\n", a[i].S);
	return 0;
}

Measured memory_bytes: 7424
#include<stdio.h>
int main(){
    char S[10];
    int N,K;
    scanf("%d",&N);
    scanf("%s",S);
    scanf("%d",&K);
    for(int i=0;i<N;i++){
        if(S[i]!=S[K-1]){
            S[i]='*';
        }
    }
    printf("%s\n",S);
}

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

using namespace std;
using llint = long long;

int a, b;

int main() {
    // Input
    cin >> a >> b;

    // Solve
    if (a <= 8 && b <= 8)
    {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int k,x;
  cin >> k >> x;
  for(int i=max(-1000000,x-k+1); i<=min(1000000,x+k-1); i++) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"*(max_len-len(t))+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
try:
    for i in range(n):
        if len(a[i])<max_len:
            a[i]="0"*(max_len-len(a[i]))+a[i]
except:
    sys.exit()


ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):  
            if a[j][i]==t[i]:
                ans[j].append("0")
            else:
                ans[j].append("1")

for i in ans:
    print(int("".join(i), 2))


Measured memory_bytes: 235864
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="SUN"){
		cout<<7<<endl;
		return 0;
	}else if(s=="MON"){
		cout<<6<<endl;
		return 0;
	}else if(s=="TUE"){
		cout<<5<<endl;
		return 0;
	}else if(s=="WED"){
		cout<<4<<endl;
		return 0;
	}else if(s=="THU"){
		cout<<3<<endl;
		return 0;
	}else if(s=="FRI"){
		cout<<2<<endl;
		return 0;
	}else{
		cout<<1<<endl;
		return 0;
	}
	return 0;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  
  int ans = 1;
  for (int i = 0; i < N; ++i)
  {
    ans = min(ans + K, 2*ans);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
    sys.exit()
if w % 2 == 0:
    a = (w//2) * 2
    b = (w//2)
else:
    a = (w//2) * 2 + 1
    b = (w//2) + 1
if h % 2 == 0:
    print(a * (h//2))
else:
    print(a * (h//2) + b)


Measured memory_bytes: 3060
#include <iostream>

int main(){
   int N, Q;
   std::cin >> N >> Q;
   std::string S;
   std::cin >> S;
   int l[Q], r[Q];
   for(int iq=0; iq<Q; ++iq)
      std::cin >> l[iq] >> r[iq];

   int count[N];
   count[0] = 0;
   for(int i=1; i<N; ++i){
      int add = 0;
      if(S[i-1]=='A' && S[i]=='C') add = 1;
      count[i] = count[i-1] + add;
   }


   for(int iq=0; iq<Q; ++iq){
      std::cout << count[r[iq]-1] - count[l[iq]-1] << std::endl;
   }

   return 0;
}


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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;


lli md = 1e9 + 7;
const int M = (1<<21) + 5;
lli dp[M][22], n, a[22][22];


void solve(){
    cin>>n;

    fori(i, 0, n-1){
        fori(j, 0, n-1)
        cin>>a[i][j];
    }

    fori(i, 0, n-1)
    dp[(1<<i)][0] = a[i][0];

    fori(i, 1, n-1){
        fori(p, 0, (1<<21)-1){
            if(__builtin_popcount(p) == i){
                fori(j,0, n-1){
                    if((p&(1<<j)) == 0 && a[j][i]){
                        dp[p^(1<<j)][i] += dp[p][i-1];
                        dp[p^(1<<j)][i] %= md;
                    }
                }
            }
        }
    }

    lli ans = 0;

    fori(p, 0, (1<<21)-1){
        ans += dp[p][n-1];
        ans %= md;
    }

    cout<<ans;
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 360704
class dice:
    def __init__(self, pip):
        self.pip = pip
        
    def move(self,dir):
        if str(dir) == "E":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]
        elif str(dir) == "W":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]
        elif str(dir) == "N":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]
        elif str(dir) == "S":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]

d = dice(list(map(int,input().split())))
n = int(input())

for i in range(n):
    
    top, front = map(int,input().split())
    
    for op in "EEENEEENEEESEEESEEENEEEN":
        if d.pip[0] == top and d.pip[1] == front:
            break
        d.move(op)    
    print(d.pip[2])

Measured memory_bytes: 7804
let cnt = ref 0

let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let bubble_sort a n =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let rec bubble j flag =
    if j <= 0 then doit flag
    else if a.(j - 1) <= a.(j) then bubble (j - 1) flag
    else (swap j (j - 1); incr cnt; bubble (j - 1) true)
  and doit flag =
    if flag then bubble (n - 1) false
  in
  doit true

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  bubble_sort a n;
  print_array a;
  Printf.printf "%d\n" !cnt

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const int MOD = 1000000007;

ll dp[2005][2005];

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

  vector<int> S(N + 1), T(M + 1);
  S[0] = T[0] = 0;
  rep (i, N) cin >> S[i + 1];
  rep (i, M) cin >> T[i + 1];

  dp[0][0] = 1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      if (i + j == 0) continue;
      if (S[i] == T[j]) dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
      else {
        if (i > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        if (j > 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
        if (i > 0 && j > 0) dp[i][j] = (dp[i][j] + MOD - dp[i - 1][j - 1]) % MOD;
      }
    }
  }

  cout << dp[N][M] << endl;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> cnts(n, 0);
  int ma = -1;
  bool is_valid = true;
  for (int i = 0; i < n; ++i) {
    int d;
    cin >> d;
    if (i == 0 && d != 0) is_valid = false;
    cnts[d]++;
    ma = max(d, ma);
  }

  if (!is_valid) {
    puts("0");
    return 0;
  }
  if (cnts[0] > 1) {
    puts("0");
    return 0;
  }
  ll ans = 1;
  for (int i = 0; i < ma; ++i) {
    if (cnts[i] == 0) {
      puts("0");
      return 0;
    }
    ll ad = (ll)cnts[i];
    for (int j = 0; j < cnts[i + 1] - 1; ++j) {
      ad *= (ll)cnts[i];
      ad %= MOD;
    }
    ans *= ad;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}



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

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

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

    vector<int> a(N);
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int s; cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    for (int i = 0; i < M; i++) {
        int tmp; cin >> tmp;
        p |= tmp << i;
    }

    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        int tmp = 0;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) tmp ^= a[j];
        }
        if (p == tmp) ans++;
    }

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


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

using namespace std;

long powerful_discount_tickets(int n, int m, int a[]){
  priority_queue<int> que;
  for(int i=0;i<n;i++) {
    que.push(a[i]);
  }

  while(m!=0) {
    int price = que.top();
    que.pop();
    int discounted_price = price / 2;
    que.push(discounted_price);
    m--;
  }
  unsigned long ans = 0;

  while(!que.empty()) {
    ans += que.top();
    que.pop();
  }
  return ans;
}

int main () {
  int n, m;
  cin >> n >> m;
  int a[n];

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


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

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      
      cout<<"Four"<<endl;
      break;
    }
    if(i==N-1){
     
      cout<<"Three"<<endl;
      break;
    }
  }
}
    
    
    


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

int main() {
  int a, b, c, x;
  int cnt = 0;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  for (int i=0; i <= a && i <= 50; i++) {
    for (int j=0; j <= b && j <= 50; j++) {
      int d = x - 500 * i - 100 * j;
      cnt += (d >= 0 && d / 50 <= c ? 1 : 0);
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

int main()
{
  unsigned long long n;
  cin >> n;
  
  unsigned long long ans = 0;
  
  if (((unsigned long long) n % 2) == 1)
  {
    cout << 0;
    return 0;
  }
  n /= 2;
  unsigned long long temp = n;
  while ((temp /= 5) != 0 )
  {
    ans += temp;
  }
  cout << ans;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int ans = 0;
  cin >>a>>b;
  for (int i=a; i<b+1; i++){
    int q1,q2,q3,q4,q5,r1,r2,r3,r4;
    q5 = i/10000;r4 = i%10000;
    q4 = r4/1000;r3 = r4%1000;
    q3 = r3/100;r2 = r3%100;
    q2 = r2/10;r1 = r2%10;
    if (q5==r1 && q4==q2){
      ans++;
    }
  }
  cout << ans << endl;
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END
v<v<int>> g ;
int n, m ;
void init(){
    g.resize( n + 1 ) ;
}
void addEdge( int &f, int &t ){
    g[f].push_back( t ) ;
    g[t].push_back( f ) ;
}
void dfs( int x, v<bool> &vis ){
    vis[x] = true ;
    for( int c : g[x] ){
        if( !vis[c] ){
            dfs( c, vis ) ;
        }
    }
}

signed main(){
    cin >> n >> m ;
    int f, t ;
    init() ;
    for( int edge = 1 ; edge <= m ; edge++ ){
        cin >> f >> t ;
        addEdge( f, t ) ;
    }
    // return 0 ;
    v<bool> vis( n + 1, false ) ;
    int cnt = 0 ;
    for( int i = 1 ; i <= n ; i++ ){
        if( !vis[i] ){
            dfs( i, vis ) ;
            cnt++ ;
        }
    }
    cout << cnt - 1  ;
    return 0 ;   
}          

Measured memory_bytes: 10388
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

string to_string(string s) { return '\"' + s + '\"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A,B> p)
{ return "(" + to_string(p.F) + ", " + to_string(p.S) + ")"; }
template <typename T> string to_string(T v) {
	int f = 0; string res = "{";
	for (const auto &x: v)
		res += (f++ ? ", " : "") + to_string(x);
	return res + "}";
}
void debug_out() { cerr << "]\n"; }
template <typename T, typename... V>
void debug_out(T a, V... v)
{ cerr << to_string(a); if (sizeof...(v)) cerr << ", "; debug_out(v...); }

#ifdef LOCAL // add -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = [", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif // debug(var1, var2, ...);

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll a; string s;
	cin >> a >> s;
	s.erase(SIZE(s)-3, 1);
	ll x = a * stoi(s);
	cout << x/100;
	return 0;
}

Measured memory_bytes: 3672
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

  static class DSumOfDivisors {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] d = new int[n + 1];
      for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
          ++d[j];
        }
      }
      long ans = 0;
      for (int i = 1; i <= n; i++) {
        ans += i * (long) d[i];
      }
      out.println(ans);
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }
  }
}


Measured memory_bytes: 71840
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var list = new List<Vec2>();
            for (int i = 0; i < N; i++)
            {
                var buffer = Console.ReadLine().Split();
                list.Add(new Vec2(int.Parse(buffer[0]), int.Parse(buffer[1])));
            }

            var cnt = 0;
            foreach (var v in list)
            {
                if (v.X == v.Y) cnt++;
                else cnt = 0;

                if (cnt == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }

    class Vec2
    {
        public int X;
        public int Y;
        public Vec2(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
}


Measured memory_bytes: 27616
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int n;
	while(cin >> n, n)
	{
		set<int> t[2];
		for(int i = 0; i < n; i++)
		{
			int x;
			cin >> x;
			t[0].insert(x);
		}
		for(int i = 1, j = 0; i <= 2 * n; i++)
		{
			if(t[0].find(i) == t[0].end())
			{
				t[1].insert(i);
			}
		}

		int turn = 0;
		int field = 0;
		while(!t[0].empty()&&!t[1].empty())
		{
			bool flag = false;
			for(set<int>::iterator it = t[turn].begin(); it != t[turn].end(); it++)
			{
				if(field > *it)
				{
					continue;
				}
				field = *it;
				t[turn].erase(it);
				flag = true;
				break;
			}
			turn = 1 - turn;
			if(!flag)
			{
				field = 0;
			}
		}
		cout << t[1].size() << endl << t[0].size() << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 500005
long long a[maxn],b[maxn];
int d[maxn];

int main()
{
	int i,j,k;
	int n,D,q;
	scanf("%d%d",&n,&D);
	for(i=1;i<=n;i++) scanf("%d",d+i);

	a[0]=D;
	for(i=1;i<=n;i++)
		if(d[i]<=2*a[i-1])
			a[i]=abs(a[i-1]-d[i]);
		else
			a[i]=a[i-1];
    b[n+1]=1;
	for(i=n;i>=1;i--)
		if(d[i]<2*b[i+1])
			b[i]=d[i]+b[i+1];
		else
			b[i]=b[i+1];

	scanf("%d",&q);
	for(i=1;i<=q;i++){
		scanf("%d",&j);
		if(a[j-1]>=b[j+1]) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string s,p;
cin>>s;
int a='A';
for(int i=0;i<s.size();i++)
{
	int t=(int(s[i])-a+n)%26;
	cout<<(char)(t+a);
}
return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 13;

int n;
char res[N];
string s;
map<char, char> rh;

bool check()
{
	for (int i = 1; i < n - 2; i ++ )
		if (res[i] == 'S')  // sheep
		{
			if (s[i] == 'o') res[i + 1] = res[i - 1];
			else res[i + 1] = rh[res[i - 1]];
		}
		else  // wolf
		{
			if (s[i] == 'x') res[i + 1] = res[i - 1];
			else res[i + 1] = rh[res[i - 1]];
		}
		
	for (int i = n - 2; i < s.size(); i ++ )
		if (res[i] == 'S')
		{
			if (s[i] == 'o' && res[i - 1] != res[(i + 1) % n]) return false;
			else if (s[i] == 'x' && res[i - 1] == res[(i + 1) % n]) return false;
		}
		else
		{
			if (s[i] == 'x' && res[i - 1] != res[(i + 1) % n]) return false;
			else if (s[i] == 'o' && res[i - 1] == res[(i + 1) % n]) return false;
		}
	return true;
}

bool solve(char c)
{
	res[0] = c;
	if (c == 'S')  // sheep
	{
		if (s[0] == 'o')  // same
		{
			res[1] = res[n - 1] = 'S';
			if (check()) return true;
			res[1] = res[n - 1] = 'W';
			if (check()) return true;
		}
		else  // dif
		{
			res[1] = 'W', res[n - 1] = 'S';
			if (check()) return true;
			res[1] = 'S', res[n - 1] = 'W';
			if (check()) return true;
		}
	}
	else  // wolf
	{
		if (s[0] == 'o')  // dif
		{
			res[1] = 'W', res[n - 1] = 'S';
			if (check()) return true;
			res[1] = 'S', res[n - 1] = 'W';
			if (check()) return true;
		}
		else  // same
		{
			res[1] = res[n - 1] = 'S';
			if (check()) return true;
			res[1] = res[n - 1] = 'W';
			if (check()) return true;
		}
	}
	return false;
}

int main()
{
	cin >> n >> s;
	
	rh['W'] = 'S', rh['S'] = 'W';
	
	if (solve('S') || solve('W')) cout << res << endl;
	else puts("-1");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		ans += a[i] - 1;
	}
	cout << ans;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  vector<char> s(3);
  for(int i=0; i<3; i++){
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  string ans;
  if(s[0]=='a'&&s[1]=='b'&&s[2]=='c') ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


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

using namespace std;


int main()
{
	int n;
	int x[100000] = {};
	int y[100000] = {};

	cin >> n;

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

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

	for(int p = 1; p < 4; p++)
	{
		double sum = 0;

		for (int i = 0; i < n; i++)
		{
			sum += pow( (double)abs(x[i] - y[i]), (double)p);
		}

		sum = pow(sum, 1.0 / (double)p);

		cout << setprecision(20) << sum << endl;
	}

	int max = 0;

	for (int i = 0; i < n; i++)
	{
		int result = abs(x[i] - y[i]);

		if(result > max)
		{
			max = result;
		}
	}

	cout << setprecision(20) << max << endl;
}


Measured memory_bytes: 4280
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

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

	int x, y; //y<xとする。
	if (a > b)
	{
		x = a;
		y = b;
	}
	else
	{
		x = b;
		y = a;
	}

	while (true)
	{
		if (x % y == 0)
		{
			cout << y << endl;
			break;
		}
		else
		{
			int q = x % y;
			x = y;
			y = q;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);
  int A[MAX];
  rep(i, 0, N) scanf("%d", &A[i]);

  int ans = (N - 2) / (K - 1) + 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    int h,w;
    cin>>h>>w;

    vector<string> s(h+2);
    REP(i,h+2){
        if(i==0|| i==h+1){
            REP(j,w+2){
                s[i]+="N";
            }
        }else{
            cin>>s[i];
            s[i].insert(0,"N");
            s[i].insert(w+1,"N");
        }
    }

    vector<vector<int>> count(h+2,vector<int>(w+2));
    for(int i=1; i<h+1; i++){
        for(int j=1; j<w+1; j++){
            if(s[i][j]=='#'){
                count[i][j]=-1;
                continue;
            }
            // 上の列
            REP(k,3){
                if(s[i-1][j+k-1]=='#'){
                    count[i][j]++;
                }
            }
            // 下の列
            REP(k,3){
                if(s[i+1][j+k-1]=='#'){
                    count[i][j]++;
                }
            }
            // 左右
            if(s[i][j-1]=='#'){
                count[i][j]++;
            }
            if(s[i][j+1]=='#'){
                count[i][j]++;
            }
        }
    }

    for(int i=1; i<h+1; i++){
        for(int j=1; j<w+1; j++){
            if(count[i][j]==-1){
                cout<<"#";
            }else{
                cout<<count[i][j];
            }
            if(j==w){
                cout<<endl;
            }
        }
    }  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n,k;
    cin>>n>>k;
    vp e(n-1);
    REP(i,n-1)e[i]={0,i+1};
    int a=(n-2)*(n-1)/2;
    if(a<k){
        cout<<-1;
        return 0;
    }
    REP(i,e.size()){
        cerr<<e[i].F+1<<' '<<e[i].S+1<<endl;
    }dprint("===");
    REP(i,1,n){
        if(a==k)break;
        REP(j,i+1,n){
            e.emplace_back(i,j);
            --a;
            if(a==k)break;
        }
    }
    print(e.size());
    REP(i,e.size()){
        cout<<e[i].F+1<<' '<<e[i].S+1<<endl;
    }
}


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

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 = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g;  cin >> r >> g;
    cout << g * 2 - r << '\n';

    return 0;
}


Measured memory_bytes: 256
n = int(input())
AB = [tuple(map(int, input().split())) for i in range(n)]
X = sorted(AB, key=lambda x: x[0])
Y = sorted(AB, key=lambda x: x[1])
if n % 2 == 0:
    print((Y[n // 2 - 1][1] + Y[n // 2][1]) -
          (X[n // 2 - 1][0] + X[n // 2][0]) + 1)
else:
    print(Y[n // 2][1] - X[n // 2][0] + 1)


Measured memory_bytes: 42044
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  cout << n << ":";

  map<ll,ll> mp;
  {
    ll i = 2;
    while (i*i <= n) {
      while (n%i == 0) {
        ++mp[i];
        n/=i;
      }
      ++i;
    }
    if (n>1) {
      ++mp[n];
    }
  }

  for (auto& p : mp) {
    ll d = p.first;
    ll cnt = p.second;
    rep(i, cnt) {
      cout << " " << d;
    }
  }
  cout << endl;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  string S;
  cin >> N >> S;
  int result = 0;
  int x = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'I') x++;
    else x--;
    result = max(result, x);
  }
  cout << result << 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 FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  string s;
  cin >> s;
  if(s.size()==26){
    reverse(s.begin(), s.end());
    char now = s[0];
    int idx = 0;
    for (int i = 1; i <= s.size() - 1; i++)
    {
      if (s[i] > now)
      {
        idx++;
        now = s[i];
      }
      else
        break;
    }
    if (idx == 25)
    {
      cout << -1 << endl;
      return 0;
    }
    char mini = 'z';
    REP(i, idx + 1)
    {
      if (s[i] > s[idx + 1])
        mini = min(mini, s[i]);
    }
    reverse(s.begin(), s.end());
    REP(i, s.size() - idx - 2) cout << s[i];
    cout << mini << endl;
    return 0;
  }
  for (int i = 0; i < 26; i++)
  {
    char c = i + 'a';
    bool t = true;
    REP(j, s.size())
    {
      char a = s.at(j);
      if(a==c){
        t = false;
      }
    }
    if(t){
      cout << s << c << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 100000;

bool P[MAX+1] = {false, false};

void sieve(int n) {
	fill(P+2, P+n+1, true);
	for (int i = 2; i*i <= n; ++i) {
		if (P[i]){
			for (int j = i*i; j <= n; j += i) {
				P[j] = false;
			}
		}
	}
}

int main() {
	sieve(MAX);
	int a[MAX+1] = {};
	for (int i = 3; i <= MAX; i += 2) {
		if (P[i] && P[(i+1) / 2]) a[i] = 1;
	}
	for (int i = 0; i < MAX; i++) {
		a[i+1] += a[i];
	}
	int Q;
	cin >> Q;
	for (int q = 0; q < Q; q++) {
		int l, r;
		cin >> l >> r;
		int ans = a[r] - a[l-1];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3548
import java.util.*;

public class Main {
    public static void main(String[] args) {
		Scanner sca01 = new Scanner(System.in);
		String something = sca01.next();

		if(something.endsWith("s") == true){
			something = something + "es";
		}else{
			something = something + "s";
		}
		System.out.println(something);

	}
}


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

int main(){
  string s;
  cin >> s;
  bool p=false;
  for(int i=0;i<s.size();i++){
    if((i+1)%2!=0){
      if(s.at(i)=='R' || s.at(i)=='U')
        continue;
      else if(s.at(i)=='D')
        continue;
      else{
        p=true;
        break;
      }         
    }else{
      if(s.at(i)=='L' || s.at(i)=='U')
        continue;
      else if(s.at(i)=='D')
        continue;
      else{
        p=true;
      break;
      }
    }  
  }
  if(p)
    cout << "No";
  else
    cout << "Yes";
}

Measured memory_bytes: 256