akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define vvbool vector<vector<bool>>
#define INF 100000009

int main(){
    int n;
    cin >> n;
    vvint summer(n,vint(3));
    cin >> summer[0][0] >> summer[0][1] >> summer[0][2];
    for(int i = 1;i<n;i++){
      cin >> summer[i][0] >> summer[i][1] >> summer[i][2];
        rep(j,3){
            int temp = -INF;
            rep(s,3){
                if(j != s){
                    temp = max(summer[i][j] + summer[i-1][s],temp);
                }
            }
            summer[i][j] = temp;
        }
    }
    int ans = -INF;
    rep(i,3) ans = max(ans,summer[n-1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 5760
n = int(input())
a = list(map(int, input().split()))
upper = 10 ** 18
res = 1

a.sort()
a.reverse()

if a[-1] == 0:
    print(0)
    exit(0)

for aa in a:
    res *= aa
    if res > upper:
        print(-1)
        exit(0)

print(res)


Measured memory_bytes: 84652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    ll X[100002];
    ll L[100002];
    ll S[100002];
    ll T[100002];  
    pair<ll, ll> itv[100002];
    cin >> N;
    for(ll i = 0; i < N; i++) {
        cin >> X[i] >> L[i];
        S[i] = X[i]-L[i];
        T[i] = X[i]+L[i];
    }
    for(ll i = 0; i < N; i++) {
        itv[i].first = T[i];
        itv[i].second = S[i];
    }
    sort(itv, itv + N);

    ll ans = 0;
    ll t = -10000000002;
    for(ll i = 0; i < N; i++) {
        if(t <= itv[i].second) {
            ans++;
            t = itv[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int A,B;
    cin >> A >> B;
    if(B%A == 0){
        cout << A + B << endl;
    }
    else{
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,k;
  cin>>n>>k;
  ll count=0;
  while(n>0){
    count++;
    n/=k;
  }
  putout(count);
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}
int bigN(Vi V, int key){RSORT(V);int max_num=V[0];int counter = 1;if(key==1){return max_num;}else{REP(i,V.size()){if(V[i]==max_num){continue;}else{max_num = V[i];counter++;if(counter==key){return max_num;}}}}}

signed main() {
  RAPID;
  // デフォルト変数定義
  double n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi X(n);
  VIN(X)
  Vb TEST(n, false);
  Vi X2(n);
  X2 = X;
  SORT(X2);
  double mid = (X2[n/2] + X2[n/2-1])/2;
  //前処理
  REP(i,n){
    if(X[i] <= mid) TEST[i] = true;
  }
  int up = X2[n/2];
  int down = X2[n/2-1];
  REP(i,n){
    if(TEST[i]) OUT(up);
    else OUT(down);
  }
}

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

const int M=55;

int main()
{
	int n;
	cin>>n;
	int p;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		cin>>p;
		if(p!=i) cnt++;
	}
	cout<<(cnt<=2?"YES":"NO")<<endl;
	return 0;
}

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

int main( )
{
    int i, j, k, h, w;
    string s;
    cin >> h >> w;
    for (i = 1; i <= h; i++) {
        cin >> s;
        cout << s << '\n';
        cout << s << '\n';
    }
    return 0;
}


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


int main()
{
int n;
cin>>n;
int a1,b1,c1;
cin>>a1>>b1>>c1;
int A[3][n];
A[0][0] = a1,A[1][0]=b1,A[2][0]=c1;
int maxi=INT_MIN;
for(int j=1;j<n;j++)
{    int a,b,c;
    cin>>a>>b>>c;
  for(int i=0;i<3;i++)
  {
      if(i==0) A[i][j] = max(A[1][j-1]+a,A[2][j-1]+a);
      else if(i==1) A[i][j] = max(A[0][j-1]+b,A[2][j-1]+b);
      else
      A[i][j] = max(A[0][j-1]+c,A[1][j-1]+c);
      
      maxi = max(A[i][j],maxi);
  }
  
}
if(n==1) cout<<max(a1,max(b1,c1));
else
cout<<maxi;

return 0;   
}





Measured memory_bytes: 1408
N, M = map(int, input().split())
H = list(map(int, input().split()))
check = [0 for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        check[b-1] = 1
    elif H[a-1] == H[b-1]:
        check[a-1] = 1
        check[b-1] = 1
    else:
        check[a-1] = 1

ans = 0

for i in range(N):
    if check[i] == 0:
        ans += 1
print(ans)




Measured memory_bytes: 20120
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
T = True
for i in range(1, N-1):
  if H[i-1]==H[i] and H[i]<=H[i+1]:
    continue
  elif H[i-1]<H[i] and H[i]-1<=H[i+1]:
    H[i] -= 1
    continue
  else:
    T = False
    break
print("Yes" if T else "No")


Measured memory_bytes: 20672
n,k = map(int, input().split())
lst_p=list()
tot=0

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

def sort(my_list):
    size = len(my_list)
    for i in range(size):
        for j in range(size-i-1):
            if(my_list[j] > my_list[j+1]):
                tmp = my_list[j]
                my_list[j] = my_list[j+1]
                my_list[j+1] = tmp
    return my_list

lst_p = sort(lst_p)

for i in range(k):
    tot += lst_p[i]
print(tot)


Measured memory_bytes: 9208
#include <stdio.h>
const MAX = 1000001;
const MIN = -1000001;

int max(a,b){
    if(a > b) return a;
    else return b;
}

int min(a,b){
    if(a < b) return a;
    else return b;
}

int main(int argc,char *args[]){
    long total,min_d,max_d,input_d,i,n;
    total = 0;
    max_d = MIN;
    min_d = MAX;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%ld",&input_d);
        total += input_d;
        min_d = min(min_d,input_d);
        max_d = max(max_d,input_d);
    }
    printf("%ld %ld %ld\n",min_d,max_d,total);
    return 0;
}



Measured memory_bytes: 2108
// 2020-08-02 20:54:45
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int x;
  cin >> x;
  if(x >= 30) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
 
int main(void){
 
  int i;
 
  
  char moji;
 
 
 
  scanf("%c", &moji);
 
  
  if((moji>= 'a') && (moji<='z')){
    printf("a");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A");
  }
 
 
  return 0;
}

Measured memory_bytes: 1596
/**
 * author: stein
 * created: 2020.08.23 20:08:54
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x, t;
  cin >> n >> x >> t;
  cout << ((n+x-1)/x) * t << endl;

  return 0;
}

Measured memory_bytes: 3580
use std::io::*;
use std::str::FromStr;

#[test]
fn test() {
    assert_eq!(build_stairs(5, [1, 2, 1, 1, 3].to_vec()), "Yes");
    assert_eq!(build_stairs(4, [1, 3, 2, 1].to_vec()), "No");
    assert_eq!(build_stairs(5, [1, 2, 3, 4, 5].to_vec()), "Yes");
    assert_eq!(build_stairs(4, [5, 4, 3, 2].to_vec()), "No");
    assert_eq!(build_stairs(1, [1000000000].to_vec()), "Yes");
    assert_eq!(build_stairs(3, [1, 3, 5].to_vec()), "Yes");
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn build_stairs(n: usize, mut v: Vec<i32>) -> String {
    v.reverse();
    for i in 0..n {
        if (i + 1) >= n {
            break;
        }
        if v[i + 1] - v[i] == 1 {
            if v[i + 1] <= 0 {
                return "No".to_string();
            }
            v[i + 1] = v[i + 1] - 1;
        } else if v[i + 1] - v[i] > 1 {
            return "No".to_string();
        }
    }
    "Yes".to_string()
}
fn main() {
    let n: usize = read();
    let v: Vec<i32> = (0..n).map(|_| read()).collect();
    println!("{}", build_stairs(n, v));

}



Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int k, x;
	cin >> k >> x;
	k--;
	for (int i = x - k; i <= x + k; i++) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

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

using namespace std;

typedef long long Int;

const Int INF = 2000000000ll;

Int x_min[128], y_min[128], x_max[128], y_max[128];

double f(double t)
{
  if (t < 0) return 1e18;
  double x_ma = max({(double)max(x_max['U'], x_max['D']), x_max['R'] + t, x_max['L'] - t});
  double x_mi = min({(double)min(x_min['U'], x_min['D']), x_min['R'] + t, x_min['L'] - t});
  double y_ma = max({(double)max(y_max['L'], y_max['R']), y_max['U'] + t, y_max['D'] - t});
  double y_mi = min({(double)min(y_min['L'], y_min['R']), y_min['U'] + t, y_min['D'] - t});
  return (x_ma - x_mi) * (y_ma - y_mi);
}

int main()
{
  int N;
  
  scanf("%d", &N);
  
  for (int i = 0; i < 128; i++) {
	x_min[i] = y_min[i] = INF;
    x_max[i] = y_max[i] = -INF;
  }
  
  for (int i = 0; i < N; i++) {
    Int x, y;
    char s[2];
    scanf("%lld %lld %s", &x, &y, s);
    
    char c = s[0];
    x_min[c] = min(x_min[c], x);
    x_max[c] = max(x_max[c], x);
    y_min[c] = min(y_min[c], y);
    y_max[c] = max(y_max[c], y);
  }
  
  vector<double> cand;
  cand.push_back(0);
  cand.push_back(x_max['L'] - max(x_max['U'], x_max['D']));
  cand.push_back((x_max['L'] - x_max['R']) * 0.5);
  cand.push_back(max(x_max['U'], x_max['D']) - x_max['R']);
  
  cand.push_back(x_min['L'] - min(x_min['U'], x_min['D']));
  cand.push_back((x_min['L'] - x_min['R']) * 0.5);
  cand.push_back(min(x_min['U'], x_min['D']) - x_min['R']);
  
  cand.push_back(y_max['D'] - max(y_max['L'], y_max['R']));
  cand.push_back((y_max['D'] - y_max['U']) * 0.5);
  cand.push_back(max(y_max['L'], y_max['R']) - y_max['U']);
  
  cand.push_back(y_min['D'] - min(y_min['L'], y_min['R']));
  cand.push_back((y_min['D'] - y_min['U']) * 0.5);
  cand.push_back(min(y_min['L'], y_min['R']) - y_min['U']);
  
  double ans = 1e18;
  for (int i = 0; i < cand.size(); i++) {
    ans = min(ans, f(cand[i]));
  }
  
  printf("%.10lf\n", ans);
  return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	
	vector<pair<int,int>> ans;
	if(N%2==0){
		for(int i=1;i<=N;i++){
			for(int j=i+1;j<=N;j++){
				if(i+j==N+1)	continue;
				ans.push_back(make_pair(i,j));
			}
		}
	}
	else{
		for(int i=1;i<=N;i++){
			for(int j=i+1;j<=N;j++){
				if(i+j==N)	continue;
				ans.push_back(make_pair(i,j));
			}
		}
	}
	
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();i++){
		cout << ans.at(i).first << " " << ans.at(i).second << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        var input = ReadLine().Split();
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int[] a = Array.ConvertAll(ReadLine().Split(), int.Parse);

        Dictionary<long,long> dic = new Dictionary<long,long>();
        dic.Add(0,0);
        long[] sum = new long[n+1];

        foreach(int i in EnumerableCommon.Range(n))
        {
            sum[i + 1] = (sum[i] + a[i]) % m;
        }

        long ans = 0;
        foreach(int i in EnumerableCommon.Range(sum.Length))
        {
            if (dic.ContainsKey(sum[i]))
            {
                ans += dic[sum[i]];
            }
            else dic.Add(sum[i], 0);
                dic[sum[i]]++;
        }

        WriteLine(ans);
    }
    public static partial class EnumerableCommon
    {
        public static IEnumerable<int> Range(int count)
        {
            return Enumerable.Range(0, count);
        }
    }
}

Measured memory_bytes: 21600
def judge(num):
  if num>n+m:
    return False
  for i in range(max(0,num-m),min(n,num)+1):
    if a_cumsum[i] + b_cumsum[num-i]<=k:
      return True
  return False
 
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
 
a_cumsum = [0]
b_cumsum = [0]
for i in a:
  a_cumsum.append(a_cumsum[-1]+i)
for i in b:
  b_cumsum.append(b_cumsum[-1]+i)
  
left = 0
right = k+1
 
while right-left>1:
  mid = (right+left)//2
  
  if judge(mid):
    left = mid
  else:
    right = mid
 
print(left)

Measured memory_bytes: 132716
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<#x<<" " <<x<<endl;
const long long  N=2e5+10,big=1e18,mod=1e9+7;
const double pi=acos(-1);

long long n,m,k,mini=N,maxi=-N;
int main()
{
    string s;
    cin>>s;
    n=10*(s[0]-'0')+(s[1]-'0');
    m=10*(s[2]-'0')+(s[3]-'0');

    if(!m && !n )
        cout<<"NA";
    else if(!m)
    {
        if(n<=12)
            cout<<"MMYY";
        else
            cout<<"NA";
    }
    else if( !n)
    {

        if(m<=12)
            cout<<"YYMM";
        else
            cout<<"NA";
    }
    else if(n>12 && m>12)
        cout<<"NA";
    else if(n>12 && m<=12)
        cout<<"YYMM";
    else if(m>12 && n<=12)
        cout<<"MMYY";
    else
        cout<<"AMBIGUOUS";

}



Measured memory_bytes: 384
x = input()
kaisu =int(input())

for i in range(0, kaisu):
    y = input()
    y = y.split()

    a = int(y[1])
    b = int(y[2]) + 1

    if y[0] == "print":
        print(x[a:b])

    elif y[0] == "replace":
        x = x[0:a] + y[3] + x[b:]

    elif y[0] == "reverse":
        c = x[a:b]
        c = c[::-1]
        x = x[0:a] + c + x[b:]


Measured memory_bytes: 5616
#include <cstdio>
#include <cassert>
#include <complex>

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

using namespace std;

const double EPS=1e-5;
const double PI=acos(-1);
const complex I(0,1); // 虚数単位

const int N_MAX=1024;
const int D_MAX=2*N_MAX*N_MAX;

complex operator*(complex z,double r){ return complex(z.real()*r,z.imag()*r); }
complex operator/(complex z,double r){ return complex(z.real()/r,z.imag()/r); }

complex e[N_MAX];

void FFT_rec(int n,const complex *f,int s,complex *res){
	if(n==1){
		res[0]=f[0];
		return;
	}

	FFT_rec(n/2, f ,2*s,  res  ); // even part
	FFT_rec(n/2,f+s,2*s,res+n/2); // odd part

	rep(k,n/2){
		complex x=res[  k  ];
		complex y=res[k+n/2]*e[s*k]; // e[s*k] = exp(-2*PI*I*k/n)
		res[  k  ]=x+y;
		res[k+n/2]=x-y;
	}
}

complex tmp[2*N_MAX];
void FFT(int n,complex *f){
	FFT_rec(n,f,1,tmp);
	rep(i,n) f[i]=tmp[i];
}

void IFFT(int n,complex *f){
	rep(i,n) if(i%2!=0) f[i]*=-1; // f[n/2] を中心にするための trick
	FFT_rec(n,f,1,tmp);
	rep(i,n) f[i]=tmp[i]/n;
}

void FFT_2D(int n,complex f[2*N_MAX][2*N_MAX]){
	rep(i,n) FFT(n,f[i]);
	rep(i,n) rep(j,i) swap(f[i][j],f[j][i]); // transpose
	rep(i,n) FFT(n,f[i]);
	rep(i,n) rep(j,i) swap(f[i][j],f[j][i]);
}

void IFFT_2D(int n,complex f[2*N_MAX][2*N_MAX]){
	rep(i,n) IFFT(n,f[i]);
	rep(i,n) rep(j,i) swap(f[i][j],f[j][i]);
	rep(i,n) IFFT(n,f[i]);
	rep(i,n) rep(j,i) swap(f[i][j],f[j][i]);
}

int main(){
	int n; scanf("%d",&n);
	static int dat[N_MAX][N_MAX];
	rep(i,n) rep(j,n) scanf("%d",dat[i]+j);

	for(;(n&(n-1))!=0;n++); // n を 2 のべきまで増やす

	rep(k,n) e[k]=exp(-2*PI*I*k/(2*n));

	static complex f[2*N_MAX][2*N_MAX];
	static complex g[2*N_MAX][2*N_MAX];
	const int OFS=n; // offset
	rep(i,n) rep(j,n) {
		f[ i+OFS][ j+OFS]=dat[i][j];
		g[-i+OFS][-j+OFS]=dat[i][j];
	}

	FFT_2D(2*n,f);
	FFT_2D(2*n,g);

	rep(i,2*n) rep(j,2*n) f[i][j]*=g[i][j];

	IFFT_2D(2*n,f);

	rep(i,2*n) rep(j,2*n) {
		assert(abs(f[i][j].real()-round(f[i][j].real()))<EPS);
		assert(abs(f[i][j].imag())<EPS);
	}

	static long long ans[D_MAX];
	rep(i,2*n) rep(j,2*n) ans[(i-OFS)*(i-OFS)+(j-OFS)*(j-OFS)]+=(int)(f[i][j].real()+0.5);

	// 非順序対を数えたいので /2
	rep(d,D_MAX) if(d>0) {
		assert(ans[d]%2==0);
		ans[d]/=2;
	}

	// 距離 0 だけ例外
	ans[0]=0;
	rep(i,n) rep(j,n) ans[0]+=dat[i][j]*(dat[i][j]-1)/2;

        long double aved = 0.0;
        long double cnt = 0.0;
        rep(d,D_MAX) {
          aved += sqrt(d) * ans[d];
          cnt += ans[d];
        }
        aved /= cnt;
        printf("%.10Lf\n", aved);

        int index = 0;
        rep(d,D_MAX) {
          if(ans[d]>EPS) {
            index++;
            printf("%d %lld\n",d,ans[d]);
            if (index == 10000) { break; }
          }
        }

	return 0;
}

Measured memory_bytes: 152692
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

string data[4]={"dream","dreamer","erase","eraser"};

int main(){
  for(int i=0;i<4;i++){
    reverse(data[i].begin(),data[i].end());
  }
  bool ans=true;
  string s;
  cin>>s;
  int k;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();){
    for(k=0;k<4;k++){
      if(s.substr(i,data[k].size())==data[k]) {
        i+=data[k].size();
        break;
      }
    }
    if(k==4){
      ans=false; break;
    }

  }
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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


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

    vector<int> d(n);
    REP(i,n) cin >> d[i];
    sort(all(d));

    pl(d[n/2]-d[n/2-1])  

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	double n, m, d, p;
	cin >> n >> m >> d;
	p = min(2 * d, n) / n;
	if (d == 0)exact_say(((m - 1) / n));
	else exact_say((m - 1)*((p / n) + (1 - p) * 2 / n));
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if ((abs(a - b) <= d && abs(c - b) <= d )||abs(a-c)<=d)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n){
        if(i == 0){
            int r = a.back() - a[0];
            int l = a[0] + k - a[1];
            ans = min(r, l);
        }else if(i == n-1){
            int r = k - a[i] + a[i-1];
            int l = a[i] - a[0];
            int t = min(r, l);
            ans = min(t, ans);
        }else{
            int r = k - a[i] + a[i-1];
            int l = a[i] + k - a[i+1];
            int t = min(r, l);
            ans = min(t, ans);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1152
nk, *values = readlines.map(&:chomp)
values = values.map {|v| v.split(' ').map(&:to_i)}
x = values.reduce(Hash.new {|h, k| h[k] = 0}) do |result, e|
  result[e.first] += e.last
  result
end
k = nk.split(' ').last.to_i
y = x.keys.sort.each do |key|
  break key if x[key] >= k
  k -= x[key]
end
p y

Measured memory_bytes: 22104
import heapq

n, k = map(int, input().split())
li = list(map(int, input().split()))
li = list(map(lambda x: x * (-1), li))


def attack():
    if n <= k:
        return (0)
    heapq.heapify(li)
    for i in range(k):
        heapq.heappop(li)
    return - 1 * sum(li)


print(attack())


Measured memory_bytes: 25768
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: たてなが / Thin
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    cout << s << endl << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
	ll a,b;
	cin >> a >> b;

	if (a * b <= 0) {
		cout << "Zero" << "\n";
		return 0;
	}else if ((a<0) and (b < 0)){
		if ((b-a) % 2 == 0){
			cout << "Negative" << "\n";
		return 0;
		}
	}

	cout << "Positive" << "\n";
	return 0;	
}


Measured memory_bytes: 256
for e in iter(input,'0 0'):
 a,b=map(int,e.split())
 m=[[0]*b for _ in[0]*a]
 for _ in[0]*int(input()):
  i,j=map(int,input().split())
  m[~-i][~-j]=-1
 for s in range(a):
  for t in range(b):
   u,v=m[s-1][t],m[s][t-1]
   m[s][t]=(u*(u>0)+v*(v>0))*(m[s][t]!=-1)+(s+t==0)
 print(m[~-a][~-b])


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

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

  vector<int> y(n);
  rep(i, n) y[i] = x[i];
  sort(y.begin(), y.end());
  int m1 = y[n / 2 - 1];
  int m2 = y[n / 2];
  vector<int> b(n);
  rep(i, n) {
    if (x[i] <= m1) b[i] = m2;
    else b[i] = m1;
  }
  rep(i, n) cout << b[i] << endl;
  return 0;
}

Measured memory_bytes: 5612
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

map<P,int> ids;
template<class T>
bool chmin(T &a,const T& b) {
    if(a>b) {
        a=b;
        return true;
    }
    return false;
}

int w,h;
string room[21];
int dist[12][12];
int to_id(P p) {
    if(!ids.count(p)) ids[p]=ids.size();

    return ids[p];
}

void bfs(P p) {
    int d[21][21];
    rep(i,21) rep(j,21) d[i][j]=INF;
    int s=to_id(p);
    queue<P> que;
    que.push(p);
    d[p.fr][p.sc]=0;

    while(que.size()) {
        int y=que.front().fr;
        int x=que.front().sc;
        que.pop();
        rep(i,4) {
            int ny=y+dy[i];
            int nx=x+dx[i];
            if(ny<0||nx<0) continue;
            if(h<=ny||w<=nx) continue;
            if(d[ny][nx]!=INF) continue;
            if(room[ny][nx]=='x') continue;

            if(chmin(d[ny][nx],d[y][x]+1)) {
                if(room[ny][nx]=='*') {
                    //printf("%d,%d -> %d,%d : %d\n",p.fr,p.sc,ny,nx,d[ny][nx]);
                    dist[s][to_id(P(ny,nx))]=d[ny][nx];
                    dist[to_id(P(ny,nx))][s]=d[ny][nx];
                }
                que.push(P(ny,nx));
            }
        }
    }
}

void solve() {
    ids.clear();
    P s;
    vector<P> vec;
    rep(i,12) rep(j,12) dist[i][j]=INF;
    rep(y,h) cin>>room[y];
    rep(y,h) rep(x,w) {
        if(room[y][x]=='*') {
            vec.pb(P(y,x));
            bfs(P(y,x));
        }
        if(room[y][x]=='o') {
            s=P(y,x);
            bfs(s);
        }
    }
    sort(all(vec));

    int ans=INF;
    do {
        int t=dist[to_id(s)][to_id(vec[0])];
        rep(i,vec.size()) if(i) t+=dist[to_id(vec[i-1])][to_id(vec[i])];
        chmin(ans,t);
    }while(next_permutation(all(vec)));

    if(ans==INF) ans=-1;

    cout<<ans<<endl;
}
int main() {
    while(cin>>w>>h) {
        if(!w) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;

char c[55][55];
int d[55][55],h,w;

bool ok(int px,int py){
    return (0<=px&&px<h&&0<=py&&py<w);
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int black=0,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
    cin>>h>>w;
    rep(i,0,h){
        rep(j,0,w){
            cin>>c[i][j];
            if(c[i][j]=='#'){black++;}
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            d[i][j]=INF;
        }
    }
    d[0][0]=0;
    queue<P> q;
    q.push({0,0});
    while(!q.empty()){
        P p = q.front();
        q.pop();
        int x = p.first,y=p.second;
        if(x==h-1&&y==w-1){break;}
        rep(i,0,4){
            int px = x+dx[i],py=y+dy[i];
            if(!ok(px,py)||c[px][py]=='#'||d[px][py]!=INF){continue;}
            d[px][py]=d[x][y]+1;q.push({px,py});
        }
    }
    if(d[h-1][w-1]==INF){
        cout<<-1<<endl;
    }
    else{int ans = h*w-black-d[h-1][w-1]-1;
        cout<<ans<<endl;
        }
}


Measured memory_bytes: 256
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

res = -float('inf')
for i in range(1, 2 ** 10):
    profit = 0
    for j in range(n):
        cnt = 0
        for k in range(10):
            if (i >> (9 - k)) & 1 and f[j][k]:
                cnt += 1
        profit += p[j][cnt]
    res = max(res, profit)

print(res)

Measured memory_bytes: 68668
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let c: String = read();
    let alphabet = vec!['a'.to_string(),'b'.to_string(),'c'.to_string(),'d'.to_string(),'e'.to_string(),'f'.to_string(),'g'.to_string(),'h'.to_string(),'i'.to_string(),'j'.to_string(),'k'.to_string(),'l'.to_string(),'m'.to_string(),'n'.to_string(),'o'.to_string(),'p'.to_string(),'q'.to_string(),'r'.to_string(),'s'.to_string(),'t'.to_string(),'u'.to_string(),'v'.to_string(),'w'.to_string(),'x'.to_string(),'y'.to_string(),'z'.to_string()];

    println!("{}", alphabet.get(alphabet.binary_search(&c).unwrap()+1).unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		map<int,int> m;
		rep(i,n){
			int temp; scanf("%d",&temp);
			m[temp]++;
		}
		bool flg=false;
		foreach(i,m)
			if(i->second*2>n){
				printf("%d\n",i->first);
				flg=true;
			}
		if(!flg)
			puts("NO COLOR");
	}
	
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	int res = h[0];
	rep(i, n) {
		if (res <= h[i])ans++;
		res = max(res, h[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

const int MAX = 200000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int N, K;   cin >> N >> K;
    vector<ll> A(N);
    for(ll i=0; i<N; i++)  cin >> A[i];
    sort(all(A));
    COMinit();
    
    ll ans = 0;
    for(ll i=K-1; i<N; i++){
        ans = (ans + COM(i,K-1)*A[i]%MOD) % MOD;
    }
    for(ll i=0; i<N-K+1; i++){
        ans = (ans - COM(N-i-1,K-1)*A[i]%MOD) % MOD;
    }
    ans = (ans + MOD)%MOD;
    cout << ans;
}

Measured memory_bytes: 8744
#include <stdio.h>
#include <string.h>

int main() {
    
    int n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; ++i) {
        char p[4];
        scanf("%s", p);
        
        if (strcmp(p, "AC") == 0)
            ++ac;
        else if (strcmp(p, "WA") == 0)
            ++wa;
        else if (strcmp(p, "TLE") == 0)
            ++tle;
        else if (strcmp(p, "RE") == 0)
            ++re;
    }   
    
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    
    return 0;
}

Measured memory_bytes: 1732
//***Because people who are crazy enough to think that they can change the world are the ones who do it***
//Think different
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[10002];

ll fun(ll x,ll y,ll z){
  return(x*x+y*y+z*z+x*y+y*z+z*x);
}

int main(){
  ll n;
  cin>>n;
  ll k=110;
  for1(i,k){
    for1(j,k){
      for1(p,k){
        ll b=fun(i,j,p);
        if(b<=n) a[b]++;
      }
    }
  }
  for1(i,n) cout<<a[i]<<endl;
}

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

int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n),memo(n+10);
    rep(i,m){
        int b;
        cin>>b;
        a[b]=1;
    }
    memo[0]=1;
    if(a[1]==0){
        memo[1]=1;
    }
    for(ll i=2;i<=n+3;i++){
        if(a[i]==1) continue;
        memo[i]=memo[i-1]+memo[i-2];
        memo[i]%=1000000007;
    }
    cout<<memo[n];
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i; string S, T, U=""; cin >> N >> S >> T; N=2*N;
for(i=0; i<N; i++){ U+=(i%2)?T[i/2]:S[i/2]; }
cout << U << "\n";
}

Measured memory_bytes: 256
def North(ls):
    ls[1-1],ls[2-1],ls[5-1],ls[6-1] = ls[2-1],ls[6-1],ls[1-1],ls[5-1]
def East(ls):
    ls[1-1],ls[3-1],ls[4-1],ls[6-1] = ls[4-1],ls[1-1],ls[6-1],ls[3-1]
def West(ls):
    ls[1-1],ls[3-1],ls[4-1],ls[6-1] = ls[3-1],ls[6-1],ls[1-1],ls[4-1]
def South(ls):
    ls[1-1],ls[2-1],ls[5-1],ls[6-1] = ls[5-1],ls[1-1],ls[6-1],ls[2-1]
def Right(ls):
    ls[2-1],ls[3-1],ls[4-1],ls[5-1] = ls[3-1],ls[5-1],ls[2-1],ls[4-1]
def Left(ls):
    ls[2-1],ls[3-1],ls[4-1],ls[5-1] = ls[4-1],ls[2-1],ls[5-1],ls[3-1]

while True:
    try:
        n = int(raw_input())
        if n==0:
            break
        dice = [1,2,3,4,5,6] 
        # top, south, east, west, north, bottom
        direction = ""
        total = 1
        for k in range(n):
            direction = str(raw_input())
            if direction=="North":
                North(dice)
            elif direction=="East":
                East(dice)
            elif direction=="West":
                West(dice)
            elif direction=="South":
                South(dice)
            elif direction=="Right":
                Right(dice)
            elif direction=="Left":
                Left(dice)
            total += dice[0]
        print total
    except EOFError:
        break

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

void solve(long long N)
{   
    long long res = 0, den = 10;
    if (N % 2 == 1) {
        res = 0;
    } else if (N == 0) {
        res = 0;
    } else {
        while(den <= N) {
            res += static_cast<long long>(N / den);
            den *= 5;
        }
    }
    cout << res << endl;
}

void solve2(long long N)
{
    long long res = 0;
    long long M = 0;
    while (N >= 10)
    {
        M = N;
        while (M % 10 == 0 && M > 1)
        {
            res += 1;
            M = M / 10;
        }
        N = N - 2;
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    // solve2(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;


int main(){
  string s;
  cin >> s;
  int c = s.size();
  vector<bool> v(26, true);
  for(int i = 0; i < c; i++){
    for(int j = 0; j < 26; j++){
      if(s[i] == j + 97){
        v[j] = false;
        break;
      }
    }
  }
  bool f = true;
  for(int i = 0; i < 26; i++){
    if(v[i]){
      char k = i + 97;
      cout << k << endl;
      f = false;
      break;
    }
  }
  if(f){ cout << "None" << endl;}
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest20191101
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int i = 1;
            int count = 0;
            while(true)
            {
                if(b <= i)
                {
                    break;
                }
                count++;
                i--;
                i += a;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int X, A;
  	cin >> X >> A;
  	int ans;
  	if(X < A){
  		ans = 0;
  	}else{
  		ans = 10;
  	}
  	cout << ans <<endl;
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

constexpr int SIZE = 1e6+1;

int main(){
    int n; cin >> n;
    int cnt[SIZE] = {0};
    int a[n];
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    loop(i, 1, SIZE)for(int j = 2*i; j < SIZE; j += i) cnt[j] += cnt[i];

    int ans = 0;
    for(int num : a) if(cnt[num] == 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8332
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define 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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int k, x; cin >> k >> x;
    for(int i = x-k+1;i<(x+k); i++){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3624