akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=5e5+5,M=5e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
struct edge{int t,ne;}e[N];
int a[N],head[N],cnt,n;
void adde(int a,int b){
	e[++cnt]=(edge){b,head[a]};head[a]=cnt;
}
int d[N];
void fail(){puts("NO");exit(0);}
int gao(int x,int f){
	ll tmp=0;
	if(d[x]==1)return a[x];
	run(x)if(v!=f){
		int tt=gao(v,x);
		if(tt>a[x])fail();
		tmp+=tt;
	}
	if(tmp>a[x]*2)fail();
	if(tmp<a[x])fail();
	return a[x]*2-tmp;
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]);
	rep(i,1,n-1){
		int x,y;read(x,y);
		adde(x,y);adde(y,x);
		d[x]++;d[y]++;
	}
	if(n==2){
		if(a[1]!=a[2])fail();
	}else{
		int rt=1;while(d[rt]==1)rt++;
		if(gao(rt,0))fail();
	}
	puts("YES");
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 100001;

int a[N], t[N];

int main()
{
	fio;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		t[a[i]] = i;
	}
	for(int i=1; i<=n; i++)
		cout << t[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys

def solve(N: int, K: int, H: "List[int]"):
    sum_HP = sum(H)
    H = sorted(H, reverse=True)
    if K >= N:
        print('0')
        return
    for k in range(K):
        kth_HP = H[k]
        sum_HP -= kth_HP
    if sum_HP <= 0:
        print('0')
    else:
        print(sum_HP)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 30120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define H 510
ll n;
char m[H][H];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>m[i][j];
	bool th=0;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)th|=(m[i][j]=='#');
	if(th==0){
		cout<<-1<<endl;
		return 0;
	}
	ll ans=1e17;
	for(int i=0;i<n;i++){
		ll cnt=0;
		for(int j=0;j<n;j++)cnt+=(m[i][j]=='.');
		bool t=0;
		for(int j=0;j<n;j++)t|=(m[j][i]=='#');
		cnt+=t^1;
		ans=min(ans,cnt);
	}
	for(int i=0;i<n;i++){
		bool t=1;
		for(int j=0;j<n;j++)t&=(m[j][i]=='#');
		t^=1;
		ans+=t;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define NUM 100
int main(void){
    int n,i,v[NUM],c[NUM];//nは宝石の個数、vは宝石の価値、cは宝石に払うコスト
    int x=0,y=0;//xは宝石の価値の合計、yは支払ったコストの合計

//宝石の個数の入力
    scanf("%d",&n);
//宝石の価値の入力
    for(i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    //宝石に支払うコストの入力
    for(i=0;i<n;i++){
        scanf("%d",&c[i]);
    }

    for(i=0;i<n;i++){
        if(v[i]>c[i]){
            x=x+v[i];
            y=y+c[i];
        }
    }

    printf("%d\n",x-y);
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    rep(i, 8) {
        if (s.substr(0, i) + s.substr(i + n - 7) == "keyence") {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
W = map(int, raw_input().split())
s = min(W)
T = [0] * (max(W)+1)

def solve():
    ans = 0
    B = W[:]
    V = [False] * n

    B.sort()
    for i in xrange(n):
        T[B[i]] = i
    for i in xrange(n):
        if V[i]:
            continue
        cur = i
        S = 0
        m = max(W)+1
        an = 0
        while True:
            V[cur] = True
            an += 1
            v = W[cur]
            m = min(m, v)
            S += v
            cur = T[v]
            if V[cur]: break
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s)

    return ans

def main():
    ans = solve()
    print ans
    return 0

main()

Measured memory_bytes: 6584
/*
 * RD
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
//#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll inf=1e18;
const int mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//12367769,266916112,123798211
ll powm(ll a, ll b, ll m);

void solve()
{
	string s="keyence";
	string tt;
	cin>>tt;
	int yes=0;
	for(int i=0; i<=7; i++)
	{
		string lul=tt.substr(0, i);
		lul+=tt.substr((int)tt.length()-7+i, 7-i);
//		cout<<lul<<endl;
		if(lul==s)
			yes=1;
	}
	if(yes)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}
signed main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
ll powm(ll a,ll b, ll m) {
	ll te=1;
	while(b) {
		if(b&1) te=(te*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return te;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	string str;
	ll k;
	cin >> str >> k;
	if (k == 1) {
		cout << str[0] << endl;
		return 0;
	}
	for (ll i = 0; i < str.size(); i++) {
		if (str[i] > '1') {
			cout << str[i] << endl;
			return 0;
		}
		if (i == k - 1) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 1 << endl;
}


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

bool check(string s){
  if(s[0]!='A') return false;
  int C=0;
  for(int i=2;i<s.length()-1;i++){
    if(s[i]=='C'){
      C++;
    }
  }
  if(C!=1) return false;
  int upper=0;
  for(int i=0;i<s.length();i++){
    if(s[i]>='A' && s[i]<='Z'){
      upper++;
    }
  }
  if(upper!=2)return false;
  return true;
}
  
int main(){
  string s;
  cin>>s;
  if(check(s)){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
using namespace std;
typedef long long ll;
void fuk() { puts("NO"); exit(0); }

const int MAXN = 100055;

vector<int> G[MAXN];

ll A[MAXN];

int N;

ll f(int i, int p) {
	if(1 == sz(G[i])) return A[i];
	ll sum = 0, mx = 0;
	for(int v : G[i]) if(v != p) {
		ll t = f(v, i);
		sum += t;
		if(mx < t) mx = t;
	}
	ll ret = ll(A[i])*2 - sum;
	if(ret < 0) fuk();
	ll mt = sum - ret;
	if(mt < 0 || (mt&1)) fuk();
	mt >>= 1;
	if(min(sum >> 1, sum - mx) < mt) fuk();
	return ret;
}

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

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];
	if(2 == N) {
		puts(A[1] == A[2] ? "YES" : "NO");
		return 0;
	}
	for(int i = 1, a, b; i < N; i++) {
		cin >> a >> b;
		G[a].eb(b);
		G[b].eb(a);
	}
	for(int i = 1; i <= N; i++) if(1 < sz(G[i])) {
		if(f(i, -1)) fuk();
		break;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 13184
#include <stdio.h>

int main() 
{
    long long a,b,c,i,j,k;
    scanf("%lld%lld",&a,&b);
    if(a>b)
    {
    	if(a%b==0)
    	a=0;
    	else
    	{
    		k=a/b;
    		a=a-b*k;
			a=(b-a)>a?a:(b-a);
		}
	}
    else
    {
    	a=(b-a)>a?a:(b-a);
	}
    printf("%lld",a);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  vector<pair<ll, int> > D(N);
  for (int i = 0; i < N; ++i) {
    D[i] = make_pair(A[i], i);
  }
  
  sort(D.begin(), D.end());
  reverse(D.begin(), D.end());

  vector<vector<ll> > dp(N + 1, vector<ll>(N + 1));
  dp[0][0] = 0;
  for (int z = 1; z <= N; ++z) {  // z = x + y
    ll A = D[z - 1].first;
    int i = D[z - 1].second;
    for (int x = 0; x <= z; ++x) {
      int y = z - x;
      ll score1 = -1;
      ll score2 = -1;
      if (x - 1 >= 0) {
	score1 = dp[x - 1][y] + A * abs(i - (x - 1));
      }
      if (y - 1 >= 0) {
	score2 = dp[x][y - 1] + A * abs(i - ((N - 1) - (y - 1)));
      }
      dp[x][y] = max(score1, score2);
    }
  }

  ll max_score = 0;
  for (int x = 0; x <= N; ++x) {
    int y = N - x;
    max_score = max(max_score, dp[x][y]);
  }
  cout << max_score << endl;
  
  return 0;
}


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

using namespace std;

int main(){
  int N,M,L;
  cin>>N>>M>>L;
  int K[2000];
  for(int i=0;i<N;i++){
    cin>>K[i];
  }
  sort(begin(K),begin(K)+N);
  int S[100001];
  long long as[100001]={};
  for(int i=1;i<=M;i++){
    cin>>S[i];
    as[i]=as[i-1]+S[i];
  }
  static long long dp[2000][2000];
  fill(dp[0],dp[2000],1LL<<62);
  dp[0][0]=0;
  auto f=[&](int a,int b){
    return (as[K[b]]-as[K[a]-1])/L;
  };
  for(int i=0;i<N-1;i++){
    for(int j=0;j<N;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]+f(i,i+1));
      dp[i+1][i]=min(dp[i+1][i],dp[i][j]+f(j,i+1));
    }
  }
  long long m=1LL<<62;
  for(int i=0;i<N;i++){
    m=min(m,dp[N-1][i]+f(i,N-1));
  }
  cout<<m<<endl;
}

Measured memory_bytes: 33600
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
string S = "";

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	cout << C << " " << A << " " << B << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 101
#define MAX_W 10001
 
int x[MAX_N][MAX_W];

int main() {
    int N, W, v, w;
    scanf("%d%d", &N, &W);
    for(int i=1; i<=N; i++) {
        scanf("%d%d", &v, &w);
        for(int j=1; j<=W; j++) {
            if(j-w < 0) x[i][j] = x[i-1][j];
            else x[i][j] = (x[i-1][j-w] + v > x[i-1][j]) ? x[i-1][j-w] + v : x[i-1][j];
        }
    }
    printf("%d\n", x[N][W]);
}



Measured memory_bytes: 5664
class Solver(object):
    def __init__(self):
        self.l = int(input())
        self.n_nodes = None
        self.edges = []

    def solve(self):
        # No. of digit requires to contain biggest power of 2
        # that is still smaller than L
        n_digits = Solver.count_bin_digits(self.l) - 1
        self.initialize_graph(n_digits)
        next_num = 2**n_digits
        leftover = self.l - 2**n_digits
        while leftover > 0:
            n_digits = Solver.count_bin_digits(leftover) - 1
            self.edges.append((1, self.n_nodes - n_digits, next_num))
            leftover -= 2**n_digits
            next_num += 2**n_digits

        print(self.n_nodes, len(self.edges))
        for e in self.edges:
            print(e[0], e[1], e[2])

    def initialize_graph(self, n_digits):
        """
        Initialize a power of two graph which can represent
        2**n_digits value. This graph would have
        Total nodes: n_digits + 1
        Total edges: 2 * n_digits
        """
        self.n_nodes = n_digits + 1
        for i in range(n_digits):  # 0 .. n_digits - 1
            node = self.n_nodes - i  # n_digit + 1 .. 2
            self.edges.append((node-1, node, 0))
            self.edges.append((node-1, node, 2**i))

    @staticmethod
    def count_bin_digits(n):
        return len(bin(n)) - 2

if __name__ == "__main__":
    s = Solver()
    s.solve()

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

int main(int argc, char const *argv[])
{
    int arr[3];
    int count_five, count_seven;
    cin >> arr[0] >> arr[1] >> arr[2];

    for (int i=0; i<3; ++i) {
        if (arr[i] == 5)  count_five++;
        else if (arr[i] == 7)  count_seven++;
    }

    if (count_five == 2 && count_seven == 1){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    ll H; cin >> H;
    ll cnt = 1;
    ll ans = 0;
    while (H > 0){
        H /= 2;
        ans += cnt;
        cnt *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n,k;cin>>n>>k;
    vector<ll>v[n];
    rep(i,0,n-2){
        ll a,b;cin>>a>>b;a--;b--;
        v[a].pb(b);v[b].pb(a);
    }
    vector<ll>chi[n];
    queue<ll>q;
    q.push(0);
    bool used[n];memset(used,false,sizeof(used));
    used[0]=true;
    ll ans=k;
    while(!q.empty()){
        ll t=q.front();q.pop();
        ll po=k-2;
        if(t==0)po=k-1;
        for(auto x:v[t]){
            if(used[x]==false){
                used[x]=true;
                chi[t].pb(x);
                q.push(x);
                ans=mod(ans*po);
                if(po==0){
                    cout<<0<<endl;return 0;
                }
                po--;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 11264
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    int a[MAX_N+1];
    memset(a,0,sizeof a);
    for(int i = 0; i < N; i++) {
        int b;
        cin >> b;
        a[b]++;
    }
    int count = 0;
    for(int i = 1; i <= 100000-1; i++){
        count = max(count,a[i] + a[i-1] + a[i+1]);
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>

#define NUM 5

using namespace std;

int main(void)
{
  int a[NUM];

  int min_a = 0;
  for (int i = 0; i < NUM; i++) {
    cin >> a[i];
    if (a[i] % 10 == 0) {
      continue;
    }
    if ((a[i] % 10) < (a[min_a] % 10)) {
      min_a = i;
    }
  }

  int sum = 0;
  for (int i = 0; i < NUM; i++) {
    if (i != min_a) {
      if (a[i] % 10 == 0) {
        sum += a[i];
      }
      else {
        sum += (a[i] / 10 + 1) * 10;
      }
    }
    else {
      sum += a[i];
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#light "off"
open System;;
open System.IO;;

let reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))
let writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput ()))

let skipSpaces () = while reader.Peek () <= int ' ' do reader.Read () |> ignore done;;
let read f = skipSpaces (); [|while reader.Peek () > int ' ' do yield char (reader.Read ()) done |] |> System.String |> f;;
let readint () = skipSpaces (); let s = if reader.Peek() = int '-' then (ignore (reader.Read()); -1) else 1 in let mutable ans = 0 in while reader.Peek () > int ' ' do ans <- ans * 10 + (reader.Read () - int '0'); done; s * ans;;
let write (s : string) = writer.Write s;;
let writeln (s : string) = writer.WriteLine s;;

let MOD = 998244353;;
type Mint = Mint of int
  with
    static member (+) (Mint x, Mint y) = Mint (let z = x + y in if z < MOD then z else z - MOD)
    static member (-) (Mint x, Mint y) = Mint (let z = x - y in if z >= 0 then z else z + MOD)
    static member (*) (Mint x, Mint y) = int64 x * int64 y % int64 MOD |> int |> Mint
    override this.ToString() = match this with | Mint x -> x.ToString()
  end;;

type BIT = { dat : int [] }
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module BIT =
  begin
    let create n : BIT = { dat = Array.create (n + 1) 0 }
    let update ({dat=dat} : BIT) (k : int) (v : int) =
      let mutable i = k + 1 in
      while i < Array.length dat do dat.[i] <- dat.[i] + v; i <- i + (i &&& -i) done
    let query ({dat=dat} : BIT) (k : int) : int =
      let mutable i = k in
      let mutable ans = 0 in
      while i > 0 do ans <- ans + dat.[i]; i <- i - (i &&& -i) done;
      ans
  end;;

let N = readint ();;
let X, Y = Array.init N (fun _ -> readint (), readint ()) |> Array.sort |> Array.unzip;;
let YD = Y |> Array.distinct |> Array.sort |> Array.mapi (fun i x -> x, i) |> Map.ofArray;;
for i in 0..N-1 do Y.[i] <- YD.[Y.[i]] done;;
let L = BIT.create YD.Count;;
let R = BIT.create YD.Count;;
Array.iter (fun y -> BIT.update R y 1) Y;;

let two = Array.replicate N (Mint 2) |> Array.scan (*) (Mint 1);;
let sub (x : byref<Mint>) (y : Mint) = x <- x - y;;

let mutable ans = two.[N] * (Mint N);;
for i in 0..N-1 do
  BIT.update R Y.[i] (-1);
  let d = BIT.query L Y.[i] in
  let c = BIT.query R Y.[i] in
  let a = i - d in
  let b = (N-1-i-c) in
  sub &ans <| (Mint 1);
  sub &ans <| two.[a] - Mint 1;
  sub &ans <| two.[b] - Mint 1;
  sub &ans <| two.[c] - Mint 1;
  sub &ans <| two.[d] - Mint 1;
  sub &ans <| (two.[a] - Mint 1) * (two.[b] - Mint 1);
  sub &ans <| (two.[b] - Mint 1) * (two.[c] - Mint 1);
  sub &ans <| (two.[c] - Mint 1) * (two.[d] - Mint 1);
  sub &ans <| (two.[d] - Mint 1) * (two.[a] - Mint 1);
  BIT.update L Y.[i] 1;
done;;
printfn "%O" ans;;

reader.Close();;
writer.Close();;

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

int main()
{
    string str;
    getline(cin, str);

    for (int i=0; i<str.size(); ++i)
    {
        if (islower(str[i]))      str[i] = toupper(str[i]);
        else if (isupper(str[i])) str[i] = tolower(str[i]);
        cout << str[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

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

int main() {
	int N;

	cin >> N;

	vector<char> pick_arare;
	char temp;
	char kind_arare[4] = { -1, -1, -1, -1 };
	int flg = 0;

	for (int i = 0; i < N; i++) {
		cin >> temp;
		pick_arare.push_back(temp);

		for (int j = 0; j < 4; j++) {
			if (j == 3) {
				cout << "Four" << endl;
				flg++;
				i = N -1;
				break;
			}

			if (kind_arare[j] == -1) {
				kind_arare[j] = temp;
				break;
			}
			else if (kind_arare[j] == temp) {
				break;
			}
		}
	}

	if (flg == 0) {
		cout << "Three" << endl;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int D = scan.nextInt();
        int[][] original = new int[H*W+1][2];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int A = scan.nextInt();
                original[A][0] = i;
                original[A][1] = j;
            }
        }
        int[] s = new int[H*W+1];
        for (int i = 1; i <= H * W - D; i++) {
            s[i+D] = s[i]
                    + Math.abs(original[i+D][0]-original[i][0])
                    + Math.abs(original[i+D][1]-original[i][1]);
        }
        int Q = scan.nextInt();
        for (int i = 0; i < Q; i++) {
            int L = scan.nextInt();
            int R = scan.nextInt();
            System.out.println(s[R]-s[L]);
        }
    }
}


Measured memory_bytes: 97000
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

V,E=MI()
g=[[] for _ in range(V+1)]
for i in range(E):
    u,v,d=MI()
    g[u].append((v,d))
    g[v].append((u,d))

T=I()
order=[0]*T
for i in range(T):
    n=I()
    if n>0:
        oid,v=MI()
        order[i]=v

def rand_move():
    move=[]
    state=0 # on vertex
    cur=1
    
    for t in range(T//2):
        print(-1)
    for t in range(T//2,T):
        if state==0:
            r=len(g[cur])
            dest,dist=g[cur][random.randint(0,r-1)]
            state=1
            move.append(dest)
            dist-=1
            if dist==0:
                state=0
                cur=dest
        else:
            move.append(dest)
            dist-=1
            if dist==0:
                state=0
                cur=dest
    return move

for i in range(1,V+1):
    show(i,g[i])
move=rand_move()
for i in move:
    print(i)
    

Measured memory_bytes: 51544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	string s; cin>>s;
	ll n=s.size();
	ll k; cin>>k;
	set<string> st;
	rep(i,0,s.size()){
		string t;
		rep(j,i,min(i+6,n)){
			t.push_back(s[j]);
			st.insert(t);
		}
	}
	ll cnt=1;
	for(string c:st){
		if(cnt==k){
			cout<<c<<'\n';
			return 0;
		}
		cnt++;
	}



	return 0;
}

Measured memory_bytes: 5128
#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;

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

int N;
int A[210];

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];

    int ans = 0;
    while (true) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 != 0) {
                goto endloop;
            }
            A[i] /= 2;
        }
        ans++;
    }
    endloop:
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define     LL              long long int
#define     FOR(I,A,B)      for( int I = A; I < B; ++I )
#define     SFI(X)          scanf("%d",&X)
#define     SFL(X)          scanf("%lld",&X)
#define     CIN()           ios_base::sync_with_stdio(false), cin.tie(NULL)


int main() {

    int T;

    cin >> T;

    while(T--) {

        int N;

        SFI(N);

        vector<LL>V(N);

        for(auto &I:V) cin >> I;

        string S;

        cin >> S;

        vector<LL>B;

        bool Ans = false;

        for(int I = N - 1; I >= 0; --I) {

            for(auto It:B) if(V[I] > (V[I] ^ It)) V[I] ^= It;

            if(V[I]) {

                if(S[I] == '1') {
                    Ans = true;
                    break;
                } else {
                    B.emplace_back(V[I]);
                }
            }
        }

        cout << Ans << endl;

    }
}


Measured memory_bytes: 3588
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	char c[20];
	cin >> c;

	rep(i, 0, 20) {
		if (c[i] == ',') {
			cout << " ";
			continue;
		}
		cout << c[i];
		if (c[i + 1] == '\0') {
			break;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		vector<int>dp(3,0);
		for(int day=1;day<=n;day++){
			vector<int>c(3);
			vector<int>new_dp(3,0);
			for(int i =0 ;i <3;i++)cin >>c[i];
				for(int i =0 ;i < 3;i++){
					for(int j = 0;j  <3;j++){
						if(i!=j){
							new_dp[i]=max(new_dp[i],dp[j]+c[i]);
						}
					}
				}
				dp =new_dp;
		}
		cout << max({dp[0],dp[1],dp[2]});
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}
mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n-k,k);
}

int main() {
  init();
  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= k; i++) {
    mint blue = f(k,i);
    mint red = 0;
    {
      red += f(n-k,i-1);
      red += f(n-k,i);
      red += f(n-k,i);
      red += f(n-k,i+1);
    }
    mint ans = blue*red;
    printf("%lld\n", ans.x);
  }
  return 0;
}//お試し

Measured memory_bytes: 129056
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    D = list(map(int, input().split()))

    ans = 0
    for i in range(N - 1):
        x = D[i]
        for j in range(i + 1, N):
            y = D[j]
            ans += x * y
    print(ans)


main()


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll OFFSET = 10000;
vector<vector<bool>> xdp(8001, vector<bool>(OFFSET*2,false));
vector<vector<bool>> ydp(8001, vector<bool>(OFFSET*2,false));

signed main() {
    string s;
    ll x,y;
    cin>>s>>x>>y;

    ll cnt = 0;
    vector<ll> t;
    rep(i,0,s.size()){
        if (s[i]=='T'){
            if (cnt>0){
                t.push_back(cnt);
            }
            t.push_back(0);
            cnt = 0;
        } else {
            cnt++;
            if (i == s.size()-1)
                t.push_back(cnt);
        }
    }

    // cout<<"xops "; for(auto e: xops) cout<<e<<" "; cout<<endl;
    // cout<<"yops "; for(auto e: yops) cout<<e<<" "; cout<<endl;

    bool flag = false;
    bool isx=true;
    xdp[0][0 + OFFSET] = true;
    ydp[0][0 + OFFSET] = true;
    ll cnt_x = 0, cnt_y = 0;
    rep (i, 0, t.size()){
        if(t[i]==0){
            isx = !isx;
        }else if(isx){
            cnt_x++;
            rep(j, 0, OFFSET*2){
                if (xdp[cnt_x-1][j]){
                    if(j-t[i]>=0 && flag) xdp[cnt_x][j-t[i]] = true;
                    if(j+t[i]<OFFSET*2)   xdp[cnt_x][j+t[i]] = true;
                }
            }
        }else{
            cnt_y++;
            rep(j, 0, OFFSET*2){
                if (ydp[cnt_y-1][j]){
                    if(j-t[i]>=0 && flag) ydp[cnt_y][j-t[i]] = true;
                    if(j+t[i]<OFFSET*2)   ydp[cnt_y][j+t[i]] = true;
                }
            }
        }
        flag=true;
    }

    if (xdp[cnt_x][x+OFFSET] && ydp[cnt_y][y+OFFSET]){
        cout<<"Yes"<<endl;
        return 0;
    }

    cout<<"No"<<endl;
    return 0;
}


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

bool book[100005];
int ballNum[100005];
int main(int argc, char const *argv[])
{
	int n,m;

	cin >> n >> m;
	// memset(ballNum,1,sizeof(ballNum));
	memset(book,0,sizeof(book));
	fill(ballNum+1, ballNum+n+1, 1);// 初始化为其他值只能用fill！！！！！！
	book[1]=1;

	for (int i = 0; i < m; ++i)
	{
		int x,y;
		cin >> x >> y;
		if(book[x]) 
			book[y] = 1;

		--ballNum[x];
		++ballNum[y];

		if(ballNum[x]==0) 
			book[x] = 0;
	}
	int ans=0;
	for (int i = 1; i <= n; ++i)
	{
		ans += book[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 768
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  char c1; cin >> c1;
  char c2; cin >> c2;
  char c3; cin >> c3;
  if (c1 != c2 || c1 != c3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_f

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int lcs(const string& s1, const string& s2, int l, int r, vector<vector<int>>& dp) {
	if (l >= s1.size() || r >= s2.size()) {
		return 0;
	}

	if (dp[l][r] >= 0) return dp[l][r];

	lcs(s1, s2, l + 1, r, dp);
	lcs(s1, s2, l, r + 1, dp);
	lcs(s1, s2, l + 1, r + 1, dp);

	dp[l][r] = 0;
	if (s1[l] == s2[r]) {
		dp[l][r] = max(dp[l][r], (l + 1 < s1.size() && r + 1 < s2.size() ? dp[l + 1][r + 1] : 0) + 1);
	}
	if (l + 1 < s1.size()) dp[l][r] = max(dp[l][r], dp[l + 1][r]);
	if (r + 1 < s2.size()) dp[l][r] = max(dp[l][r], dp[l][r + 1]);
	return dp[l][r];
}

int main (int argc, char* argv[]) {
	string s1, s2;
	cin >> s1 >> s2;
	vector<vector<int>> dp(s1.size(), vector<int>(s2.size(), -1));
	lcs(s1, s2, 0, 0, dp);
	int l = 0; int r = 0;
	while (l < s1.size() && r < s2.size()) {
		int l_next = l + 1 < s1.size() ? dp[l + 1][r] : 0;
		int r_next = r + 1 < s2.size() ? dp[l][r + 1] : 0;
		if (s1[l] == s2[r]) {
			cout << s1[l];
			l++; r++;
		} else if (l_next > r_next) {
			l++;
		} else {
			r++;
		}
	}
	cout << endl;
}


Measured memory_bytes: 36096
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  if (n % 2 == 0) {
    print("0.5");
  } else {
    double ans = double(n / 2 + 1) / n;
    printf("%.9f\n", ans);
  }

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N / 1000;
        if (0 < N % 1000) {
            num++;
        }
        System.out.println(num * 1000 - N);
    }
}

Measured memory_bytes: 35792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a<b && a+v*t>=b+w*t )
    cout<<"YES"<<endl;
   else   if(a>b && a-v*t<=b-w*t ) cout<<"YES";
  else cout<<"NO";
  return 0;
} 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string op;
  cin >> N;
  int P=0,W=0,G=0,Y=0;
  
  for (int i = 0; i < N; i++) {
   cin >> op;
   if (op == "P") {
   	P = 1;
   }
   else if (op == "W") {
   	W = 1;
   }
   else if (op == "G") {
   	G = 1;
   }
   else if (op == "Y") {
   	Y = 1;
   }
  }
  if (P+W+G+Y == 3){
    cout << "Three" << endl;
  }
  if (P+W+G+Y == 4){
    cout << "Four" << endl;
  }
}

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

using namespace std;

int main(){    
    string S;

    cin >> S;

    int sum = 0;

    for(int i = 0; i < S.size()/2; i++){
        if(S[i] != S[S.size()-i-1]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

bool ng[1 << 8];
ll dp[101][1<<8];
string tagc = "TAGC";

bool haveAGC(string str){
	if(str.find("AGC") != string::npos)return true;
	REP(i, str.size() - 1){
		swap(str[i], str[i+1]);
		if(str.find("AGC") != string::npos)return true;
		swap(str[i], str[i+1]);
	}
	return false;
}

void makeNG() {
	REP(i, 1<<8){
		string str = "";
		int now = i;
		REP(j, 4){
			str += tagc[now % 4];
			now /= 4;
		}
		if(haveAGC(str))ng[i] = true;
	}
}

int main(){
	
	makeNG();
	int n;cin >> n;
		
	dp[0][0] = 1;
	REP(i, n){
		REP(j, 1<<8){
			REP(k, 4){
				int nxt = ((j << 2) + k) & ((1 << 8) - 1);
				if(!ng[nxt]){
					dp[i+1][nxt] += dp[i][j];
					dp[i+1][nxt] %= MOD;
				}
			}
		}
	}
		
	ll ans = 0;
	REP(i, 1<<8)ans = (ans + dp[n][i]) % MOD;
	cout << ans << endl;
	
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  in(ll, n, d);
  int ans = 0;
  rep(i, n) {
    in(ll, x, y);
    if (x * x + y * y <= d * d) {
      ++ans;
    }
  }
  out(ans);
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

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

Measured memory_bytes: 3600
#include<stdio.h>
#define MAX_SIZE 500001

int Left(int i){return i*2;}
int Right(int i){return i*2+1;}

void SwapElement(int *tree, int i, int j){
  int buffer;
  buffer = tree[i];
  tree[i] = tree[j];
  tree[j] = buffer;
}

void maxHeapify(int *tree, int i, int n){
  int left = Left(i);
  int right =  Right(i);
  int largest;
  
  if(left<=n && tree[left]>tree[i]){
    largest = left;
  }else{
    largest = i;
  }
  if(right<=n && tree[right]>tree[largest]){
    largest = right;
  }
  
  if(largest != i){
    SwapElement(tree,i,largest);
    maxHeapify(tree,largest,n);
  }
}

void BuildMaxHeap(int *tree, int n){
  int i;
  for(i=n/2; i>=1; i--){
        maxHeapify(tree,i,n);
  }
}

int main(){
  int tree[MAX_SIZE];
  int i,num;
  
  scanf("%d",&num);
  for(i=1; i<=num; i++){
    scanf("%d",&tree[i]);
  }
  
  BuildMaxHeap(tree,num);
  for(i=1; i<=num; i++){
    printf(" %d",tree[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3756
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */


  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9+7;


  int main()
  {
      int n;
      cin>>n;
      vector<int>arr(n);
      for(int i=0;i<n;i++)
        cin>>arr[i];
      int a=0;
      for(int i=0;i<n;i++){
        if(arr[i]==(a+1))
            a++;
      }
      if(a==0)
        cout<<-1;
      else
        cout<<n-a;
      return 0;
  }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define FORR(i, a, b)   for(ll i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define F first
#define S second
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

void OFFLINE(){
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
    #endif
}

int main(){

    IOS;
    // OFFLINE();
    //check for corner test cases

    int a;
    cin >> a;

    cout<<(a + a*a + a*a*a)<<"\n";


    //check for corner test cases
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

#define MAX 100000

using namespace std;

int collisionSearch(int *array,int key,int num){

  int i;

  for(i = 0;i < num;i++){
    if(array[i] == key){
      return -1;
    }
  }

  return 0;
}

int main(){

  int i;
  int j;
  int k;
  int n;
  int q;
  int S[MAX];
  int T[MAX];
  int alr[MAX];
  int cnt = 0;
  int flag = 0;
  int temp;

  cin >> n;

  i = 0;
  // origin array
  while(i != n){
    cin >> temp;
    if(collisionSearch(S,temp,i) != 0){
      n--;
      continue;
    }
    S[i] = temp;
    i++;
  }

  cin >> q;

  i = 0;
  // cmp array
  while(i != q){
    cin >> temp;
    if(collisionSearch(T,temp,i) != 0){
      q--;
      continue;
    }
    T[i] = temp;
    i++;
  }

  // saerch
  for(i = 0;i < n;i++){
    for(j = 0;j < q;j++){
      if(S[i] == T[j]){
	cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1172