akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
    FASTIO
//     ///*
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
// //*/
    int T;
    //scanf("%d", &T);
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        string s;
        cin >> n >> s;
        int ans = 0;
        s = "#" + s;
        for (int i = 0; i < n; i++) {
            if (s[i] != s[i + 1])ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<bitset>
#include<algorithm>
using namespace std;

int main(void)
{
    int N;
    cin >> N;

    const int init = -1;
    vector<vector<int>> v(N, vector<int>(N, init));
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        for (int j = 0; j < A; j++) {
            int x, y;
            cin >> x >> y;

            x--;
            v[i][x] = y;
        }
    }

    int ans = 0;
    for (int i = (1 << N) - 1; i > 0; i--) {
        bitset<15> bit(i);
        
        vector<int> vv(N, init);
        for (int j = 0; j < N; j++)
            if (bit[j] == true)
                vv[j] = 1;
            else
                vv[j] = 0;


        bool ok = true;
        for (int j = 0; ok && j < N; j++) {
            if (bit[j] == 0)
                continue;

            for (int k = 0; ok && k < N; k++) {
                if (v[j][k] == init)
                    continue;

                if (vv[k] != v[j][k])
                    ok = false;
            }
        }

        if (ok == true) {
            int cnt = 0;
            for (int j = 0; j < N; j++)
                if (bit[j] == true)
                    cnt++;

            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void a_abcxxx(void) {
	string n;
	cin >> n;

	cout << "ABC" << n << endl;
}

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


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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("a.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int m, d;
    cin >> m >> d;

    int cnt = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            if (j%10 >= 2)
            {
                if (j/10 >= 2)
                {
                    if ((j%10) * (j/10) == i)
                    {
                        //cout << "m:" << i << " d:" << j << endl;
                        cnt++;
                    }
                }
            }
        }
    }

    cout << cnt;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD = 1000000007ll;


ll modSum(ll a, ll b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


ll modProd(ll a, ll b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}


ll getPowMod(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}


vector<int> getKMP(string &s) {
  int len = (int)s.size();
  vector<int> ret (len, 0);
  for (int i = 1 ; i < len ; i++) {
    int at = ret[i-1];
    while (at > 0 && s[i] != s[at]) {
      at = ret[at-1];
    }
    if (s[i] == s[at]) {
      at++;
    }
    ret[i] = at;
  }
  return ret;
}


string getSubstring(string &s, int from, int to) {
  int l = to-from+1;
  if (l <= 0) {
    return "";
  }
  return s.substr(from, l);
}

















const int MAXN = 100002;


int H, W, N;
int a[MAXN], b[MAXN];
ll ans[10];
map< pair<int, int>, int> cells;


bool isInRange(int r, int c) {
  return (r >= 1) && (c >= 1) && (r <= H) && (c <= W);
}


void populate_cells(int r, int c) {
  for (int i = r-2 ; i <= r ; i++) {
    for (int j = c-2 ; j <= c ; j++) {
      if (isInRange(i, j) && isInRange(i+2, j+2)) {
        cells[{i, j}]++;
      }
    }
  }
}


void input() {
  cin >> H >> W >> N;
  for (int i = 1 ; i <= N ; i++) {
    cin >> a[i] >> b[i];
  }
}


void preprocess() {
}


void solve() {
  for (int i = 1 ; i <= N ; i++) {
    populate_cells(a[i], b[i]);
  }
  for (auto p : cells) {
    ans[p.second]++;
  }
  ans[0] = 1ll * (H-2) * (W-2);
  for (int i = 1 ; i <= 9 ; i++) {
    ans[0] -= ans[i];
  }
  for (int i = 0 ; i <= 9 ; i++) {
    cout << ans[i] << "\n";
  }
}


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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 57344
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define eps 1e-15
typedef long long ll;
int main(){
	int N,L;
	char s[101][101];
	scanf("%d %d",&N,&L);
	rep(i,N){
		scanf("%s",s[i]);
	}
	rep(i,N-1){
		for(int j=i+1;j<N;j++){
			if(strcmp(s[i],s[j])>0){
				char tmp[101];
				strcpy(tmp,s[i]);
				strcpy(s[i],s[j]);
				strcpy(s[j],tmp);
			}
		}
	}
	rep(i,N){
		printf("%s",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
x, y = map(int, input().split())
for tsuru in range(0, x+1): # (t, k) = (0, x), (1, x-1), (2, x-2) , ... (x-1, 1), (x, 0)
  kame = x - tsuru
  if (tsuru * 2 + kame * 4) == y:
    print("Yes")
    exit(0)

print("No")

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

using namespace std;

vector<int> dp;

vector<vector<int>> G; //隣接リスト

int rec(int v){
  if(dp[v] != -1){return dp[v];} //recを求めるための、メモ化再帰
  int res = 0;
  for( auto V:G[v]){
    res = max( res, rec(V) + 1);}//vから繋がるノードへ漸化式を作る
  
  return dp[v] = res; } //メモ化しながら値を返す

int main(){
  int N,M; cin >> N >> M;
  G = vector<vector<int>> (N);
  
  dp = vector<int> (N,-1);
  
  for(int i = 0; i < M; i++){
    int x,y; cin >> x >> y; x--; y--;
    G[x].push_back(y);}//リスト作成
  
  int res = 0;
  for(int i = 0; i < N; i++){
    res = max(res,rec(i));} //rec(i)が、iノードから始まる有向最長パスを表す
  
 cout << res << endl; return 0;}
  

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		if (N <1000){
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 22740
mod stdin_reader {
  use std::io::stdin;
  use std::io::Read;

  pub struct StdinReader {
    pub buf: Vec<String>,
    pub cursor: usize,
  }

  pub fn new() -> StdinReader {
    StdinReader::new()
  }

  impl StdinReader {
    pub fn new() -> Self {
      let mut s = String::new();
      let stdin = stdin();
      stdin.lock().read_to_string(&mut s).unwrap();
      let buf = s.split_whitespace().map(|s| s.to_string()).collect();
      return StdinReader { buf: buf, cursor: 0 }
    }

    pub fn read_all(&self) -> Vec<String> {
      return self.buf.clone()
    }

    pub fn next(&mut self) -> Option<String> {
      let val = self.buf.get(self.cursor).cloned();
      self.cursor += 1;
      return val
    }

    pub fn as_i64(&mut self) -> Option<i64> {
      self.next().and_then(|s| s.parse::<i64>().ok())
    }
  }
}

fn main() {
  let mut reader = stdin_reader::new();
  let n = reader.as_i64().unwrap();
  let a = reader.as_i64().unwrap();
  let b = reader.as_i64().unwrap();
  if (n * a) < b {
    println!("{}", n*a);
  } else {
    println!("{}", b)
  }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {}
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

const int MAX = 2010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s;
  cin >> s;
  vector<mint> dp(MAX);
  dp[0] = 1;
  rep(i, MAX) {
    for (int j = 3; j < MAX; j++) {
      if (i+j >= MAX)
        break;
      dp[i+j] += dp[i];
    }
  }
  cout << dp[s] << endl;
  return 0;
}

Measured memory_bytes: 3640
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
#print(c,a)
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  if M>1 and i//N==N-1:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')
           
    

Measured memory_bytes: 9296
var
 s1,s2:string;
 i,j:longint;
 ch:char;
begin
 readln(s1);
 readln(s2);
 for i:=1 to length(s1)-1 do
  for j:=i+1 to length(s1) do
   if s1[i]>s1[j] then
    begin
     ch:=s1[i]; s1[i]:=s1[j]; s1[j]:=ch;
    end; 
 for i:=1 to length(s2)-1 do
  for j:=i+1 to length(s2) do
   if s2[i]<s2[j] then
    begin
     ch:=s2[i]; s2[i]:=s2[j]; s2[j]:=ch;
    end; 
 if s1<s2 then writeln('Yes')
  else writeln('No');
end.

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

int main(){
	int n; cin>>n;
	for(int i=n; i>0; i--){
		double r=sqrt(i);
		if(r==(int)r) {cout<<i<<endl; return 0;}
	}
}

Measured memory_bytes: 3628
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x, y = na()
if y == 1 or x == y or x % y == 0:
    print(-1)
else:
    print(x)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  int ans = 0, max_v = 0, a[100002] = {0}, n;
  cin >> n;
  REP(i,0,n){
    int inter;
    cin >> inter;
    a[inter]++;
    a[inter+1]++;
    a[inter+2]++;
    max_v = max(inter+2, 0);
  }
  REP(i,0,max_v+1){
    ans = max(ans, a[i]);
  }
  cout << ans << endl;
  
  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 4028
import sys
a = int(input())
b = int(input())
c = int(input())
n = int(input())
 
count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==n:
        count += 1
print(count)

Measured memory_bytes: 3060
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
xy = []
for i in range(n):
    x,y = readInts()
    xy.append((x,y))
dist = 0
for x1,y1 in xy:
    for x2,y2 in xy:
        dist += ((x1-x2)**2 + (y1-y2)**2)**0.5
print(dist/n)


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  
  for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++){
          cin >> data.at(i).at(j);
      }
  }
  
  for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++){
          if (data.at(i).at(j) == '#'){
              cout << '#';
          }
          else {
              int a = 0;
              int b = 0;
              for (int k = 0; k < W; k++){
                  if (data.at(i).at(k) == '.'){
                      a++;
                  }
              }      
              if (a != W && a != 0){
                  for (int l = 0; l < H; l++){
                      if (data.at(l).at(j) == '.'){
                          b++;
                      }
                  }
              }
              if (b != H && b != 0){
                  cout << '.';
              }
          }
          if (j == W - 1){
              int c = 0;
              for (int k = 0; k < W; k++){
                  if (data.at(i).at(k) == '.'){
                      c++;
                  }
              }
              if (c != W){
                  cout << endl;
              }
          }
      }
  }  
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<int> w(n);
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
	}
	int ans = 1 << 30;
	for (int t = 1; t < 100; ++t) {
		int tot[2] = {};
		for (int i = 0; i < n; ++i) {
			tot[i <= t] += w[i];
		}
		ans = min(ans, abs(tot[0] - tot[1]));
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    ll l,r,d,c=0;
    cin>>l>>r>>d;
    for(ll i=l;i<=r;i++)
    {
        if(i%d==0)
           c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include<algorithm>

using namespace std;

int main(){
        int n;
        int v1[50010],v2[50010];

        cin>>n;
        for(int i=0; i<n/2; ++i) cin>>v1[i]>>v2[i];

        int cnt1=0,cnt2=0, temp1_cnt,temp2_cnt,mode1=0,mode2=0,keepcnt1=0,keepcnt2=0;

        for(int i = 0; i < n/2; i++){
                temp1_cnt = 1;
                temp2_cnt = 1;
                for(int j = i + 1; j < n/2; j++){
                        if( v1[i] == v1[j]){
                                temp1_cnt++;
                        }
                        if( v2[i] == v2[j]){
                                temp2_cnt++;
                        }
                }
                if( temp1_cnt >= cnt1){
                        keepcnt1=max(cnt1,keepcnt1);
                        cnt1 = temp1_cnt;
                        mode1 = v1[i];
                }else if(temp1_cnt>keepcnt1){
                        keepcnt1=temp1_cnt;
                }

                if( temp2_cnt >= cnt2){
                        keepcnt2=max(cnt2,keepcnt2);
                        cnt2 = temp2_cnt;
                        mode2 = v2[i];
                }else if(temp2_cnt>keepcnt2){
                        keepcnt2=temp2_cnt;
                }
        }

        if(mode1==mode2){
                int num=max(cnt1+keepcnt2,cnt2+keepcnt1);
                if(n/2<num) cout<<n-n/2<<endl;
                else cout<<n-num<<endl;
        }
        else cout<<n-cnt1-cnt2<<endl;

        return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int N;
int a[MAXN];
int b[MAXN];

void work(){
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%d",&a[i]);
    sort(a,a+N);
    LL ans=0,big=0,small=0;
    if(N%2==1){
        for(int i=0;i<(N+1)/2;i++) small+=a[i];
        for(int i=(N+1)/2;i<N;i++) big+=a[i];
        ans=big*2-small*2+a[(N+1)/2-2]+a[(N+1)/2-1];
        small=big=0;
        for(int i=0;i<N/2;i++) small+=a[i];
        for(int i=N/2;i<N;i++) big+=a[i];
        ans=max(ans,big*2-small*2-a[N/2]-a[N/2+1]);
        printf("%lld\n",ans);
    }
    else{
        for(int i=0;i<N/2;i++) small+=a[i];
        for(int i=N/2;i<N;i++) big+=a[i];
        printf("%lld\n",big*2-small*2-a[N/2]+a[N/2-1]);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}

















Measured memory_bytes: 4352
#include <iostream>

int main() {
    int a[5], k;
    std::string ans = "Yay!";
    for (auto &v : a) std::cin >> v;
    std::cin >> k;
    for (int i=0; i<4; ++i) {
        for (int j=i; j<5; ++j) {
            if (a[j] - a[i] > k) ans = ":(";
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int n,m;
Graph G;
vector<int> dp(100010,-1);

int rec(int v){
    if(dp.at(v) != -1) return dp.at(v);
    int res = 0;
    for(auto nv : G.at(v)){
        chmax(res,rec(nv)+1);
    }
    return dp.at(v) = res;
}

int main(){

    cin >> n >> m;
    G.assign(n,vector<int>());
    rep(i,m){
        int x,y; cin >> x >> y;
        x--;y--;
        G.at(x).push_back(y);
    }
    int res = 0;
    rep(i,n) chmax(res,rec(i));

    cout << res << endl;

    return 0;   

}


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

using namespace std;
typedef long long ll;

ll a,b,c,d;

ll func(ll x){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/(c/__gcd(c,d)*d);
    return res;
}

int main(){
    cin>>a>>b>>c>>d;

    ll ans = func(b) - func(a-1);
    cout<<ans;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
int main(){
	int a[3],n,i,j;
	a[2]=1;
	scanf("%d",&n);
	if(n==2){
		scanf("%d%d",&a[0],&a[1]);
		a[2]=a[1];
	}
	else scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(i=1,n=a[0];i<3;i++) if(n>a[i]) n=a[i];
	for(i=1;i<a[0];i++){
		if(!(a[0]%i)&&!(a[1]%i)&&!(a[2]%i)) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
    ll int jhogeo = 1;
    rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
    return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}

int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N,K; cin>>N>>K;
  vector<int> h(N);
  vector<int> a(N);
  rep(i,0,N){
    cin>>h[i];
    a[i]=INF;
  }
  a[0]=0;
  rep(i,0,N){

    rep(j,i+1,i+K+1){
      if(j==N) break;
      a[j]=min(a[j],a[i]+abs(h[i]-h[j]));
      //cout<<a[j]<<" "<<a[i]+abs(h[i]-h[j])<<endl;
    }
  }
  cout<<a[N-1];
  //rep(i,0,N) cout<<a[i];
        
  

    
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const ll N = 1e9;

ll s;

int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> s;
    if(s == 1000000000000000000ll){
        cout << "0 0 " << N << " 0 0 " << N << '\n';
        return 0;
    }
    cout << 0 << ' ' << 0 << ' ';
    cout << s/N+1 << ' ' << 1 << ' ';
    cout << N-s%N << ' ' << N << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;
 
  scanf("%s %s",s,p);
 
  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;
 
  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }
 
  if( t )
    printf("Yes\n");
  else
    printf("No\n");
 
  return 0;
}


Measured memory_bytes: 2092
#include <stdio.h>

  long fact(long n)
{
        if(n == 0)
                return 1;
        else
                return n * fact(n-1);
}
 
int main()
{
        long n;
        scanf("%ld", &n);
        printf("%ld\n", fact(n));
        return 0;
}

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

int main(){
  int t, a, b, pl1, pl2;
  cin >> t >> a >> b;
  
  pl1 = t * a;
  pl2 = b;
    
  if(pl1 < b) {
    cout << pl1 << endl;
  }else {
    cout << pl2 << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main()
{
	int N;
	struct data
	{
		int t;
		int x;
		int y;
	};

	scanf("%d", &N);
	data cur;

	for (int i = 1; i <= N; ++i)
	{
		scanf("%d %d %d", &cur.t, &cur.x, &cur.y);
		if (std::abs(cur.x + cur.y) > cur.t || ((cur.x + cur.y + cur.t) & 1) != 0)
		{
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int cnt=0;
    while(n--)
    {
        double x,y;
        scanf("%lf%lf",&x,&y);
        if(sqrt(x*x+y*y)<=m) cnt++;
    }
    cout<< cnt <<endl;
    return 0;
}

Measured memory_bytes: 3800
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 1000040
 
const int  m = 1000033;
//const int  m2= 1000003;
//7069 - 60
char stack[MAX][15];
int h1(long long);
int h2(long long);
int insert(long long,int);
long long sti(char *);
 
int main(){
  int val,i,j,n,dic=0,dicc=MAX,index2=0,vall;
  char op[15],s[15];
  int exist=-1,index=0;
 
  while(scanf("%d",&n) != EOF){
    dic=0,dicc=MAX;
    for(i=0;i<=MAX;i++)strcpy(&stack[i][0],"not");
    for(i=0;i<n;i++){
      exist=-1;
      scanf("%s %s",op,s);
      if(op[0] == 'i'){
    index=0;
    while(1){
      val = insert(sti(&s[0]),index);
      if(strcmp(&stack[val][0],"not") == 0){
        strcpy(&stack[val][0],&s[0]);
        break;
      }
      else index++;
      if(index == MAX)break;
    }
      }
      else if(op[0] =='f'){
    index2=0;
    while(1){
      vall=insert(sti(s),index2);
      if(strcmp(stack[vall],s) == 0){
        exist=1;
        break;
      }
      else if(strcmp(&stack[vall][0],"not") == 0){
        break;
      }
      index2++;
      if(index2 == MAX)break;
    }
    if(exist == 1)printf("yes\n");
    else printf("no\n");
      }
    }
  }
  return 0;
}
 
 
int h1(long long k){
  return k%m;
}
 
int h2(long long k){
  return 1+k%(m-1);
}
 
int insert(long long k,int i){
  return (h1(k) + i*h2(k))%m;
}
 
long long sti(char *s){
  long long i=0,sum=0;
  while(s[i] != '\0'){
    sum*=10;
    sum+=s[i]-'A'+1;
    i++;
  }
  return sum;
}



Measured memory_bytes: 17416
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int n, b[105];

bool Find(int num)
{
    bool flag = 0;
    rep(i, 1, n){
        if (b[i] == num){
            flag = 1;
            break;
        }
    }
    return flag;
}

int main()
{
    bool flag = 0;
    int a[5][5];
    rep(i, 1, 3){
        rep(j, 1, 3)
        cin >> a[i][j];
    }
    cin >> n;
    rep(i, 1, n){
        cin >> b[i];
    }
    rep(i, 1, 3){
        if (Find(a[1][i]) && Find(a[2][i]) && Find(a[3][i])){
            printf("Yes\n"); return 0;
        }
        if (Find(a[i][1]) && Find(a[i][2]) && Find(a[i][3])){
            printf("Yes\n"); return 0;
        }
    }
    if (Find(a[1][1]) && Find(a[2][2]) && Find(a[3][3])){
        printf("Yes\n"); return 0;
    }
    if (Find(a[1][3]) && Find(a[2][2]) && Find(a[3][1])){
        printf("Yes\n"); return 0;
    }
    printf("No\n");

    return 0;
}


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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    string S;
    cin >> S;

    if(S == "ARC"){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    

    return 0;
}



Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
using namespace std;
#define rep(i,a,b) for(i=a;i<=b;i++)
#define INF 2100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F1 second.first
#define F2 second.second
#define ub upper_bound
#define SS stringstream
#define sz(x) ((int)(x).size())
int main(void)
{
	int i,j,k;
	int sx,sy,tx,ty,wide,high;
	string ans="";
	cin>>sx>>sy>>tx>>ty;
	wide=tx-sx,high=ty-sy;
	for(i=0;i<high;i++) ans+='U';
	for(i=0;i<wide;i++) ans+='R';
	for(i=0;i<high;i++) ans+='D';
	for(i=0;i<wide;i++) ans+='L';
	ans+='L';
	for(i=0;i<high+1;i++) ans+='U';
	for(i=0;i<wide+1;i++) ans+='R';
	ans+='D',ans+='R';
	for(i=0;i<high+1;i++) ans+='D';
	for(i=0;i<wide+1;i++) ans+='L';
	ans+='U';
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

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

    if (a == b){
        cout << c << endl;
    }
    else if (b == c){
        cout << a << endl;
    }
    else{
        cout << b << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    boolean tf = s.replaceAll("[^a]", "").length() > 0 && s.replaceAll("[^b]", "").length() > 0 && s.replaceAll("[^c]", "").length() > 0;
    if(tf) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

       
        
        void solve(){
            cin >> str;
            int cnt = 0;
            int answer = 0;
            for(int i=0;i<3;i++){
                if(str[i] == 'R') cnt++;
                else {
                    answer = max(answer, cnt);
                    cnt = 0;
                } 
            }
            answer = max(cnt,answer);
            cout << answer << endl;

        }



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

            


            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

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

int main(){
	int N;
  	cin>>N;
  	if(N%1000 == 0){
      cout<<0<<"\n";
    }
  	else{
      cout<< 1000*(N/1000 + 1) - N<<"\n";
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  vector<int64_t> s(n + 1);
  for (int i = 0; i < n; i++) s.at(i + 1) = s.at(i) + a.at(i);
  vector<vector<int64_t>> dp(n, vector<int64_t>(n, 1l << 60));
  for (int i = 0; i < n; i++) dp.at(i).at(i) = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      for (int k = i - 1; k >= j; k--) {
        dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i).at(k + 1) + dp.at(k).at(j) + s.at(i + 1) - s.at(j));
      }
    }
  }
  cout << dp.at(n - 1).at(0) << endl;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int a,b,c; cin >>a >>b >>c;
  printf("%s",(a+b+c<22)?"win":"bust");
}

/// confirm df==0 ///


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

const int INF = 1e9;

vector<pair<int, int>> adj[100000];
vector<int> color(100000);
vector<bool> vis(100000, false);
int k = 0;

void dfs(int v, int cor_inc) {
    vis[v] = true;
    int cor = 1;
    for (pair<int, int> ui : adj[v]) {
        int u = ui.first;
        if (vis[u])
            continue;
        if (cor == cor_inc)
            cor++;
        color[ui.second] = cor;
        dfs(u, cor);
        cor++;
    }
    k = max(k, cor - 1);
}

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

    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back({b, i});
        adj[b].push_back({a, i});
    }
    dfs(0, 0);
    cout << k << endl;
    for (int i = 0; i < n - 1; i++) {
        cout << color[i] << endl;
    }
	return 0;
}

Measured memory_bytes: 11388
N = int(input())
L = list(map(int,input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] == L[j] or L[j] == L[k]: continue

            if L[k] < L[i] + L[j]:
                ans += 1

print(ans)

Measured memory_bytes: 9016
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

int N, K;

int main() {
    cin >> N >> K;
    int n = 1;
    for (int i = 0; i < N; i++) {
        int a = n * 2;
        int b = n + K;
        if (a < b) {
            n = a;
        }  else {
            n = b;
        }
    }
    cout << n << endl;
}


Measured memory_bytes: 256
from collections import deque

n,q=map(int,input().split())

tree=[[] for i in range(n)]
for i in range(n-1):
 i,j=map(int,input().split())
 tree[i-1].append(j-1)
 tree[j-1].append(i-1)

cnt=[0 for i in range(n)]
for i in range(q):
 p,x=map(int,input().split())
 cnt[p-1]+=x

seen=set([0])

dq=deque()
dq.append(0)

while dq:
 x=dq.popleft()
 for i in tree[x]:
#  if cnt[i]==-1:
  if i not in seen:
   seen.add(i)
   dq.append(i)
   cnt[i]+=cnt[x]

print(*cnt)

Measured memory_bytes: 62780
import java.util.Scanner;

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

		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i == 0 || i == H - 1) {
						System.out.printf("#");
					} else if (j == 0 || j == W - 1) {
						System.out.printf("#");
					} else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



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

class Cube {
public:
  int face[6];
  Cube() {}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}    
  
  void roll(int i, int j, int k, int l) {
    int t = face[i];
    face[i] = face[j];
    face[j] = face[k];
    face[k] = face[l];
    face[l] = t;
  }
  
};

bool eq(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    if (c1.face[i] != c2.face[i]) return false;
  }
  return true;

}

bool equal(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      if(eq(c1,c2)) return true;
      c1.roll_z();
    }
    if(i % 2 == 0) c1.roll_y();
    else c1.roll_x();
  }
  return false;

}

int main() {
  int n = 0;
  cin >> n;
  
  Cube c[1000];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) cin >> c[i].face[j];
  }

  int flag = 1;

  for (int i = 0; i < n-1; i++) {
    for (int j = i+1 ; j < n; j++) {
      if (equal(c[i],c[j])) flag = 0;
    }
  }
  
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3108
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
int main()
{
    int a, b;
    scanf("%d", &a);
    b=48-a;
    printf("%d", b);
}


Measured memory_bytes: 3804
// > <
#include <cstdio>
#include <algorithm>
#include <functional>
#include <set>
#include <utility>
typedef long long int64;
static const int MAXN = 52;

int n;
int64 a[MAXN];

inline bool check(int64 w)
{
    static int64 b[MAXN];
    for (int i = 0; i < n; ++i) b[i] = a[i] + w;
    std::set<std::pair<int64, int>, std::greater<std::pair<int64, int>>> s, g;
    int p = std::max_element(b, b + n) - &b[0];
    for (int i = 0; i < n; ++i)
        if (i != p) s.insert(std::make_pair(b[i], i));
    g.insert(std::make_pair(0, p));
    int64 gval = b[p], _w = w;

    while (w > 0 && g.size() < n) {
        auto q = *s.begin();
        s.erase(s.begin());
        int64 c = std::min<int64>(w / g.size(), std::max(0LL, (gval + g.begin()->first - q.first - (n + 1)) / (n + 1)));
        w -= c * g.size();
        gval -= c * (n + 1);
        while (w > 0 && g.begin()->first >= q.first - gval) {
            g.insert(std::make_pair(g.begin()->first - (n + 1), g.begin()->second));
            g.erase(g.begin());
            --w;
        }
        g.insert(std::make_pair(q.first - gval, q.second));
        //printf("After %lld step(s) enters #%d with delta=%lld\n", c, q.second, q.first - gval);
    }
    //for (auto q : s) b[q.second] = q.first;
    //for (auto q : g) b[q.second] = q.first + gval;
    //printf("%lld |", _w);
    //for (int i = 0; i < n; ++i) printf(" %lld", b[i]); putchar('\n');
    if (g.size() == n) {
        gval -= (w / n) * (n + 1);
        w %= n;
    }

    for (auto q : s) b[q.second] = q.first;
    for (auto q : g) b[q.second] = q.first + gval;
    while (w > 0) {
        p = std::max_element(b, b + n) - &b[0];
        b[p] -= (n + 1);
        --w;
    }
    //printf("%lld |", _w);
    //for (int i = 0; i < n; ++i) printf(" %lld", b[i]); putchar('\n');
    //printf("%lld ", *std::max_element(b, b + n));
    //puts(*std::max_element(b, b + n) < n ? "Yes" : "No");
    return (*std::max_element(b, b + n) < n);
}

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

    /*int64 lo = -1, hi = 5.1e17, mid;
    while (lo < hi - 1) {
        mid = (lo + hi) >> 1;
        if (check(mid)) hi = mid; else lo = mid;
    }
    printf("%lld\n", hi);*/
    int64 sum = -(n + 1) * (n + 1);
    for (int i = 0; i < n; ++i) sum += a[i];
    for (int64 i = std::max(sum, 0LL); ; ++i)
        if (check(i)) { printf("%lld\n", i); break; }

    return 0;
}


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


int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes";
		
	}
	else
	{
		cout<<"No";
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#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

/*全てのライブラリをインクルード*/
#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()
{
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout<<"vowel"<<endl;
    }
    else cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 3608
E = []
gets.to_i.times{
  E << gets.chomp.split(" ").map(&:to_i)
}

ans = E[0]
E.each{|t, a|
  w = ans[0].divmod(t)
  wk = w[0] + (w[1] == 0 ? 0 : 1)
  if (wk * a) < ans[1] then
    w = ans[1].divmod(a)
    wk = w[0] + (w[1] == 0 ? 0 : 1)
  end
  ans = [t*wk, a*wk]
}

puts ans[0] + ans[1]


Measured memory_bytes: 1916
# N A B C X
result = []

while(True):
    str = input().split()
    N = int(str[0])
    A = int(str[1])
    B = int(str[2])
    C = int(str[3])
    X = int(str[4])
    if N == A == B == C == X == 0:
        break

    str = input().split()
    Y = [int(str[i]) for i in range(N)]
    
    i = 0
    while(True):
        if not len(Y) > 0:
            i = i-1
            break
        elif not i <= 10000:
            i = -1
            break

        if X == Y[0]:
            Y.pop(0)
        i += 1
        X = (A * X + B) % C
    
    result.append(i)

for r in result:
    print(r)


Measured memory_bytes: 5640
import std.stdio;
import std.string, std.conv;
import std.algorithm, std.array;
import std.typecons;

void main() {
  const int P_MAX = 1000000;

  bool[] isp = new bool[P_MAX + 1];
  isp[] = true;
  isp[0] = isp[1] = false;
  for(int i = 2; i * i <= P_MAX; i++) {
    if(isp[i]) {
      for(int j = 2 * i; j <= P_MAX; j += i)
        isp[j] = false;
    }
  }

  bool[int] set;
  foreach(i; 2 .. P_MAX + 1)
    if(isp[i])
      set[i] = true;

  for(int N; N = readln.chomp.to!int, N; ) {
    int s = 0;
    foreach(i; set.keys) {
      if(i > N) continue;
      int rest = N - i;
      if(i <= rest) {
        if((rest in set) != null) s++;
      }
    }
    writeln(s);
  }
}

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


int A, B, C;

int main(){
    cin >> A >> B >> C;
    int M = max(A, max(B, C));
    int cnt = 0;
    while(A+2 <= M){
        A += 2;
        cnt++;
    }
    while(B+2 <= M){
        B += 2;
        cnt++;
    }
    while(C+2 <= M){
        C += 2;
        cnt++;
    }
    int mada = 0;
    if(A < M){
        mada++;
    }
    if(B < M){
        mada++;
    }
    if(C < M){
        mada++;
    }
    cnt += (3-mada)%3;
    cout << cnt << endl;
    

}


Measured memory_bytes: 256