akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}


ll mod=1000000007;
ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2==0){
        ll d=modpow(a,b/2);
        return d*d%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }
}

ll divide(ll a,ll b){
    return a*modpow(b,mod-2)%mod;
}

vecll perm;
void makePerm(int n){
    perm[0]=1;
    rep(i,n)perm[i+1]=(perm[i]*(i+1))%mod;
}

int n;
vector<vec> chi;
vec par,numChil;
vecll num;
vecll ans;
int func2(int r){
    if(r>0 && chi[r].size()==1){
        numChil[r]=0;
        return 0;
    }
    int res=0;
    REP(e,chi[r]){
        if(e==par[r])continue;
        numChil[e]=func2(e);
        res+=numChil[e]+1;
    }
    return res;
}
void makePar(int r){
    REP(e,chi[r]){
        if(e==par[r])continue;
        par[e]=r;
        makePar(e);
    }
}
ll func1(int r){
    REP(e,chi[r]){
        if(e==par[r])continue;
        num[e]=func1(e);
    }
    ll res = perm[numChil[r]];
    REP(e,chi[r]){
        if(e==par[r])continue;
        res = divide(res,perm[numChil[e]+1]);
        res = (res * num[e]) % mod;
    }
    return res%mod;
}

void func3(int k){
    if(k==0){
        ans[0]=num[0];
    }else{
        ll t = divide(ans[par[k]]*perm[numChil[k]+1]%mod,num[k]);
        t = divide(t*perm[n-2-numChil[k]]%mod,perm[n-1]);
        ans[k] = num[k]*t%mod*perm[n-1]%mod;
        ans[k]=divide(ans[k],perm[numChil[k]]);
        ans[k]=divide(ans[k],perm[n-1-numChil[k]]);
    }
    REP(e,chi[k]){
        if(e==par[k])continue;
        func3(e);
    }
}

int main(){
    n=in();
    perm.resize(n+2);
    makePerm(n+1);
    chi.resize(n);
    par.resize(n);
    numChil.resize(n);
    rep(i,n-1){
        int a=in()-1,b=in()-1;
        chi[a].pb(b);
        chi[b].pb(a);
    }
    par[0]=-1;
    makePar(0);
    numChil[0]=func2(0);
    num.resize(n);
    num[0]=func1(0);
    ans.resize(n);
    func3(0);
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 20212
#include<stdio.h>

int main()
{
    int d,n,x,nn=0;

    scanf("%d %d",&d,&n);

    if(n==100){
        n++;
        for(x=0;x<d;x++){
        nn*=100;
        }
    }
        

    for(x=0;x<d;x++){
        n*=100;
    }

    printf("%d\n",n+nn);



    return 0;
}


Measured memory_bytes: 128
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  for(int i=1;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  for(int i=1;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c = fac[n];
  c *= finv[k];c %= MOD;
  c *= finv[n-k];c %= MOD;
  return c;
}



int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(int i = 0; i < n; i++){
     cin >> a[i];
     a[i] %= k;
     a[i] -= 1;
  }
  ll s[n+1];
  s[0] = 0;
  for(int i=0;i<n;i++){
    s[i+1] = s[i]+a[i];
    s[i+1] %= k;
    s[i+1] = (s[i+1]+k)%k;
  }
  map<ll,ll> nums;
  nums[s[0]] += 1;
  ll temp;
  ll ans = 0;
  for(int i=1;i<n+1;i++){
    temp = s[i];
    nums[temp] += 1;
    ans += nums[temp]-1;
    if(i >= k-1){
      temp = s[i-k+1];
      nums[temp]--;
      nums[temp] = max(0ll,nums[temp]);
    }
  }
  if(k == 1) ans = 0;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

vector<int> z_algorithm(string s) {
	vector<int> res(s.size());
	
	res[0] = s.size();
	
	int i = 1, j = 0;
	
	while (i < s.size()) {
		while (i + j < s.size() && s[j] == s[i + j]) j++;
		res[i] = j;
		if (j == 0) { i++; continue; }
		int k = 1;
		while (i + k < s.size() && k + res[k] < j) res[i + k] = res[k], k++;
		i += k;
		j -= k;
	}
	
	return res;
}

int solve(string str, string T, string elem) {
	int tt = elem.size();
	vector<int> vs = z_algorithm(str);
	vector<int> dp(str.size() + 1, 0);
	FOR(i, tt, str.size() + 1) {
		if (i >= tt + tt && vs[i - tt] >= tt) chmax(dp[i], dp[i - tt] + 1);
	}
	int mx = *max_element(ALL(dp));
	int res = mx / (T.size() / tt);
	return res;
}

int main() {
	string S, T;
	cin >> S >> T;
	vector<int> vt = z_algorithm(T);
	
	int tt = 0;
	FOR(i, 1, T.size() + 1) if (T.size() % i == 0) {
		bool ok = true;
		for (int j = i; j < T.size(); j += i) ok &= vt[j] >= i;
		if (ok) {
			tt = i;
			break;
		}
	}
	
	string elem = T.substr(0, tt);
	
	// if (S.size() % tt == 0) {
	// 	string ctmp = "";
	// 	REP(i, S.size() / tt) ctmp += elem;
	// 	if (S == ctmp) {
	// 		puts("-1");
	// 		return 0;
	// 	}
	// }
	
	while (S.size() < T.size()) S += S;
	
	int ans = solve(elem + S + S + S, T, elem);
	if (ans < solve(elem + S + S + S + S, T, elem)) puts("-1");
	else cout << ans << endl;
	
	return 0;
}


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

int main()
{
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;

    // cout << s << endl;
    // cout << t << endl;

    string ans;

    for (int i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
s=string.gsub(io.read()," ","")
q=io.read("*n","*l")
should_reverse=0
left,right={},{}
for i=1,q do
    t=io.read("*n")
    if t==1 then
        should_reverse=should_reverse+1
    else
        f=io.read("*n")
        c=string.gsub(io.read()," ","")
        if f==1 then
            if should_reverse%2==1 then
                table.insert(right,c)
            else
                table.insert(left,c)
            end
        else
            if should_reverse%2==1 then
                table.insert(left,c)
            else
                table.insert(right,c)
            end
        end
    end
end
s=string.reverse(table.concat(left,""))..s..table.concat(right,"")
print(should_reverse%2==1 and string.reverse(s) or s)

Measured memory_bytes: 4500
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int L=0;
            int l[]=new int[2];
            int r[]=new int[2];
            boolean fin=false;
            boolean ans=true;
            Stack<Character> st=new Stack<Character>();
            while(true){
                String S=sc.nextLine();
                if(L==0 && S.equals(".")){
                    fin=true;
                    break;
                }
                int N=S.length();
                L+=N;
                char C[]=S.toCharArray();
                for(int i=0;i<N;i++){
                    if(C[i]=='('){
                        l[0]++;
                        st.push('(');
                    }
                    else if(C[i]=='['){
                        l[1]++;
                        st.push('[');
                    }
                    else if(C[i]==')'){
                        if(st.empty()){
                            ans=false;
                            break;
                        }
                        char la=st.pop();
                        if(la=='[') ans=false;
                        if(l[0]>0) l[0]--;
                        else ans=false;
                    }
                    else if(C[i]==']'){
                        if(st.empty()){
                            ans=false;
                            break;
                        }
                        char la=st.pop();
                        if(la=='(') ans=false;
                        if(l[1]>0) l[1]--;
                        else ans=false;
                    }
                }
                if(C[N-1]=='.'){
                    if(l[0]!=0 || l[1]!=0){
                        ans=false;
                        break;
                    }
                    else break;
                }
            }
            if(fin) break;
            if(ans) System.out.println("yes");
            else System.out.println("no");
        }
    }
}


Measured memory_bytes: 44272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int a[100010];

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

    int now = 1;
    int cou = 0;
    vector<bool> vis(n + 1,false);

    vis[now] = true;

    while(now != 2)
    {
        now = a[now];
        if(vis[now])
        {
            cout << -1 << endl;
            return 0; 
        }
        vis[now] = true;
        cou++;
    }

    cout <<cou << endl;

}

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

int x, y;

int main(void){
  cin >> x >> y;
  int gx, gy;
  if(x == 2){
    gx = 3;
  }
  else if(x == 4 or x == 6 or x == 9 or x == 11){
    gx = 2;
  }
  else{
    gx = 1;
  }
  if(y == 2){
    gy = 3;
  }
  else if(y == 4 or y == 6 or y == 9 or y == 11){
    gy = 2;
  }
  else{
    gy = 1;
  }

  if(gx == gy){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
use std::io::*;
fn read<T: std::str::FromStr>() -> T {
    stdin()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
        .parse()
        .ok()
        .unwrap()
}

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut v = vec![0_usize; 200_001];
    for _ in 0..n {
        let i: usize = read();
        v[i] += 1;
    }

    v.sort();
    v.reverse();
    let mut sum = 0_usize;
    for i in 0..k {
        sum += v[i];
    }
    println!("{}", n - sum);
}


Measured memory_bytes: 6396
#include <stdio.h>

int main(void){
	int H,W;
	char *p[51];
	char s[51][51];
	int i,j;
	
	scanf("%d",&H);
	scanf("%d",&W);
	
	for(i=0;i<H;i++){	//各行の開始アドレスの代入
		p[i]=s[i];
	}	
	for(i=0;i<H;i++){	//ポインタ配列を使った文字列の入力
		scanf("%s",p[i]);
	}
	
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(s[i][j]=='#'){
				if(s[i][j+1]=='#' || s[i+1][j]=='#' ||s[i][j-1]=='#'||s[i-1][j]=='#'){
					//ok
				}else{
					printf("No");
					goto result;
				}
			}
		}
	}
	printf("Yes");
	
	result:
	
	return 0;}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T, class S> void Unique_L(int &N, T A[], S B[], int sorted=0){
  int i;
  int k = 0;
  if(!sorted){
    sortA_L(N, A, B);
  }
  for(i=(0);i<(N);i++){
    if(!k || A[k-1]!=A[i]){
      A[k] = A[i];
      B[k] = B[i];
      k++;
    }
    else{
      B[k-1] += B[i];
    }
  }
  N=k;
}
int N;
string S[200000];
int cnt[200000];
int main(){
  wmem = memarr;
  int i;
  int k;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  sort(S,S+N);
  for(i=(0);i<(N);i++){
    cnt[i] = 1;
  }
  Unique_L(N,S,cnt,1);
  {
    int RZTsC2BF;
    int FmcKpFmN;
    if(N==0){
      FmcKpFmN = 0;
    }
    else{
      FmcKpFmN = cnt[0];
      for(RZTsC2BF=(1);RZTsC2BF<(N);RZTsC2BF++){
        FmcKpFmN = max_L(FmcKpFmN, cnt[RZTsC2BF]);
      }
    }
    k =FmcKpFmN;
  }
  for(i=(0);i<(N);i++){
    if(cnt[i]==k){
      wt_L(S[i]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// int N;
// string S[2d5];
// int cnt[2d5];
// {
//   int i, k;
//   rd(N,S(N));
// 
//   sort(S,S+N);
//   rep(i,N) cnt[i] = 1;
//   Unique(N,S,cnt,1);
// 
//   k = max(cnt(N));
//   rep(i,N) if(cnt[i]==k) wt(S[i]);
// }


Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n, k, sum=0, ans=0;
	cin >> n >> k;
	long long a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
 
	sort(a, a+n, greater<int>());
 
	for(int i=0; i<n; i++){
		sum += a[i];
		if(sum < k) ans++;
		else sum -= a[i], ans=0;
	}
 
	cout << ans;
 
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()
A = {}
for s in S:
    if s not in A:
        A[s] = 1
    else:
        A[s] += 1

B = [(a, A[a]) for a in A]
# print(B)
B.sort(reverse=True, key=lambda x: x[1])
# print(B)
count = B[0][1]
ans = []
for b in B:
    if b[1] == count:
        ans.append(b[0])

ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 116168
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll bit[N];
void upd(int idx, ll val){
    for(; idx < N; idx += idx & -idx){
        bit[idx] += val;
    }
}
ll sum(ll idx){
    ll res = 0;
    for(; idx > 0; idx -= idx & -idx){
        res += bit[idx];
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        upd(x, 1);
        int cnt = sum(N - 1) - sum(x - 1);
        if(cnt == i){
            ans++;
        } 
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>

const int mod = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//const int dx[8] = {};
//const int dy[8] = {};

using namespace std;

template <class myType>
void p(vector<myType>& v)
{
    for(myType i: v) cout<<i<<" ";
    cout<<endl;
}

template <class myType>
void pv(vector<vector<myType>>& vv)
{
    for(auto& v: vv)
        p(v);
}

template <class myType>
void GetInputV(vector<myType>& v, int n)
{
    v.resize(n);
    for(myType& i: v) cin>>i;
}

template <class myType>
void GetInputVV(vector<vector<myType>>& vv, int m, int n)
{
    vv.resize(m);
    for(vector<myType>& v: vv) GetInputV(v, n);
}

template <class myType>
myType gcd(myType x, myType y)
{
    myType t;
    while(y > 0)
    {
        t = x % y;
        x = y;
        y = t;
    }
    return x;
}

unordered_map<int, int> m;

void divisor(int n) 
{ 

    for (int i=1;i<=sqrt(n);i++) 
        if (n%i==0)
        {
            m[i]++;
            m[n/i]++;
        }
} 

void smalldivisor(int n)
{
    for(auto& p: m)
    {
        int i = p.first;
        if (n%i==0)
        {
            m[i]++;
        }
    }
}

int main()
{

    int n;
    cin>>n;
    vector<int> v;

    GetInputV(v, n);

    divisor(v[0]);
    divisor(v[1]);

    for(int i = 2; i < n; i ++) smalldivisor(v[i]);

    int res = 1;

    for(auto& p: m)
    {
        if(p.second >= n-1)
        {
            res = max(res, p.first);
        }
    }

    cout<<res<<endl;
    

    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val A = mutableListOf<Int>()
    for (i in 0 until readLine()!!.toInt()) {
        val p = readLine()!!.split(" ").map { n -> n.toInt() }.toMutableList()
        when (p[0]) {
            0 -> A.add(p[1])
            1 -> println(A[p[1]])
            2 -> A.removeAt(A.lastIndex)
        }
    }
}


Measured memory_bytes: 114212
#include<iostream>
    #include<algorithm>
    #include<string>
    #include<cstdlib>
    #include<vector>
    #include<queue>
    #include<cmath>
    using namespace std;
     
    int main()
    {
        char n[3];
     
        cin >> n;
     
        if((n[0]=='7') ||(n[1]=='7') || (n[2]=='7')) {
            cout << "Yes";
        } else {
            cout << "No";
        }
     
        cout << endl;
     
        return 0;
    }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N_MAX = 2000000;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
ll spf[N_MAX]; // smallest prime factors
void prepare_factorize(){
  rep(i,N_MAX) spf[i] = i;
  for(int p=2; p*p <= N_MAX; p++){
    for(int i=p; i<N_MAX; i+=p){
      if(spf[i]==i) spf[i] = p;
    }
  }
}

// 素因数分解
// その素因数が何個あるかのmapを返す
map<ll, ll> factorize_fast(ll n){
    if(spf[1]==0){
    //   p("please initialize");
      exit(0);
    }
    map<ll, ll> mp;
    while(n!=1){
      ll p = spf[n];
      mp[p]++;
      n/=p;
    }
    return mp;
}
ll yaku(ll n){
  auto mp = factorize_fast(n);
  ll ret = 1;
  for(auto pa : mp){
    ret *= (pa.second+1);
  }
  return ret;
}

ll f(ll v){
  return v - yaku(v);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    prepare_factorize();
    int ans = 0;
    for(int i = 1; i < n; i++){
        ans += yaku(i);
    }
    cout << ans << endl;
    return 0;
}

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


void swap(int i,int j){
	static int temp=0;
	temp=i;
	i=j;
	j=temp;
}

int main() {
	// your code goes here
	int n,counter=0,temp;
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++){
		num[i]=0;
	}
	for(int i=0; i<n;i++){
		cin>>num[i];
	}
	for(int i=0;i<n-1;i++){
		for(int j=n-1;i<j;j--){
			if(num[j]<num[j-1]){
				temp=num[j];
				num[j]=num[j-1];
				num[j-1]=temp;
				counter++;
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<num[i];
		if(i==n-1){
			break;
		}
		cout<<" ";
	}
	cout<<endl<<counter<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
    int i,j,tmp;
    int max[3] = {0};



    for( i = 0 ; i < 10 ; i++ ){
        scanf( "%d" , &tmp );
        if( max[0] < tmp ){
            max[2] = max[1];
            max[1] = max[0];
            max[0] = tmp;
        }else if( max[1] < tmp ){
            max[2] = max[1];
            max[1] = tmp;
        }else if( max[2] < tmp ){
            max[2] = tmp;
        }
    }
    
    for( i = 0 ; i < 3 ; i++ ){
        printf("%d\n" , max[i]);
    }
}



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

using namespace std;

int main(){
	string s,t;
	int ans = 0;
	cin >> s >> t;

	for(int i = 0;i < s.length();i++){
		if(s[i] != t[i])ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;

  vector<int >dp(n,INT_MAX),v(n,0);
  dp[0]=0;
  for(int i=0;i<n;i++)
     cin>>v[i];
  
    for(int i=0;i<n;i++)
    {
      for(int j=i+1;j<=i+k &&j<n;j++)
      {
        dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
      }
    }   
    

cout<<dp[n-1];
}

Measured memory_bytes: 1024
// a code about cooties
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;}
template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;}
template<typename T, typename U> ostream& operator<<(ostream& s, pair<T, U> t) {s << "(" << t.first << "," << t.second << ")"; return s;}
template<typename T, typename U> istream& operator>>(istream& s, pair<T, U> &t) {s >> t.first >> t.second; return s;}
typedef long long ll;
typedef pair<ll, ll> pt;
#define x first
#define y second
const ll INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pt> a(n);
    cin >> a;
    rep(i, 0, n) if (a[i].y > a[i].x) swap(a[i].x, a[i].y);
    ll mxx = 0, mxy = 0, mnx = INF, mny = INF;
    rep(i, 0, n) {
        mnx = min(mnx, a[i].x);
        mny = min(mny, a[i].y);
        mxx = max(mxx, a[i].x);
        mxy = max(mxy, a[i].y);
    }
    ll res = (mxx - mnx) * (mxy - mny);
    mnx = mny;
    sort(a.begin(), a.end(), [](const pt & pa, const pt & pb) {
        return pa.y < pb.y;
    });
    set<pt> s;
    rep(i, 0, n) s.insert({a[i].y, a[i].x});
    while (true) {
        pt cur = *s.begin();
        if (cur.second <= cur.first) break;
        s.erase(s.begin());
        s.insert({cur.second, cur.first});
        mny = s.begin()->first;
        mxy = (--s.end())->first;
        
        //cout << mny << " " << mxy << endl;
        res = min(res, (mxx - mnx) * (mxy - mny));
        
    }
    
    cout << res << endl;
}


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N,X,MAX=50;
int x[51],p[51];

int f(int N,int X) { // NバーガーのX層以下の数
    if(N==0) return 1;
    if(X==1) {
        return 0;
    }else if(1<X and X<=1+x[N-1]) {
        return f(N-1,X-1);
    }else if(X==2+x[N-1]) {
        return p[N-1]+1;
    }else if(2+x[N-1]<X and X<=2+2*x[N-1]) {
        return p[N-1]+1+f(N-1,X-2-x[N-1]);
    }else{
        return p[N];
    }
}



signed main() {
    cin>>N>>X;

    x[0]=1;
    p[0]=1;
    x[1]=5;
    p[1]=3;
    rep(i,1,N) {
        x[i+1]=x[i]*2+3;
        p[i+1]=p[i]*2+1;
    }

    cout<<f(N,X)<<endl;
    return 0;
}
    




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

using namespace std;

int A,B,K,i,j,k;

int main()
{
  cin>>K>>A>>B;
  
  for(i=A;i<=B;i++)
  {
    if(i%K==0)
    {
      cout <<"OK";
      return 0;;
    }
  }
  
  cout<<"NG";
  
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

class Main {
    // static {
    //     try {
    //         System.setOut(new PrintStream(new File("output.txt")));
    //         new File("input.txt").createNewFile();
    //         System.setIn(new FileInputStream(new File("input.txt")));
    //     } catch (Exception e) {
    //         e.printStackTrace();
    //     }
    // }
    static FastReader fastReader = new FastReader();
    static BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuffer stringBuffer = new StringBuffer();

    public static void main(String[] args) throws Exception {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long a[]=new long[n];
                long b[]=new long[n];
                long c[]=new long[n];
                for(int i=0;i<n;i++){
                    a[i]=fastReader.nextInt();
                    b[i]=fastReader.nextInt();
                    c[i]=fastReader.nextInt();
                }
                long dp[][]=new long[n][3];
                dp[0][0]=a[0];
                dp[0][1]=b[0];
                dp[0][2]=c[0];
                for(int i=1;i<n;i++){
                    dp[i][0]=a[i]+Math.max(dp[i-1][1], dp[i-1][2]);
                    dp[i][2]=c[i]+Math.max(dp[i-1][0], dp[i-1][1]);
                    dp[i][1]=b[i]+Math.max(dp[i-1][0], dp[i-1][2]);
                }
                System.out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
                
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 62152
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e18;

template<typename T>
struct SegmentTree{
    const T INF = 1e18;
    int n, width;
    vector<T> dat;

    void init(int x){
        n = x;
        width = 1;
        while (width < n) width *= 2;
        dat.assign(2*width-1, INF);
    }

    void update(int i, T x){
        i += width - 1;
        dat[i] = x;
        while (i > 0){
            i = (i - 1) / 2;
            dat[i] = min(dat[i*2+1], dat[i*2+2]);
        }
    }

    T query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return dat[k];
        T vl = query(a, b, k*2+1, l, (l+r)/2);
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return min(vl, vr);
    }

    // [l, r)
    T query(int l, int r){
        return query(l, r, 0, 0, width);
    }
};

int main() {
    ll n, e, t;
    cin >> n >> e >> t;
    VL x(n + 1);
    REP(i,n) x[i] = in();
    VL dp(n + 1, INF);
    dp[0] = 0;
    SegmentTree<ll> seg1, seg2;
    seg1.init(n + 1);
    seg2.init(n + 1);
    seg1.update(0, 0);
    seg2.update(0, -2 * x[0]);
    int i = 0;
    REP(j,n){
        while (2 * (x[j] - x[i]) > t) i++;
        chmin(dp[j + 1], seg1.query(i, j + 1) + t);
        chmin(dp[j + 1], seg2.query(0, i) + 2 * x[j]);
        seg1.update(j + 1, dp[j + 1]);
        seg2.update(j + 1, dp[j + 1] - 2 * x[j + 1]);
    }
    // REP(i,n+1) cout << dp[i] << endl;
    ll ans = e + dp[n];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=(1<<31)-1;
const double pi=acos(-1);

int n;
vi num(5);

int main(){
	for(int i=0;i<5;i++) cin>>num[i];
	for(int i=0;i<5;i++) num[i]*=-1;
	sort(num.begin(),num.end());
	for(int i=0;i<4;i++) cout<<num[i]*-1<<' ';
	cout<<num[4]*-1<<endl;
}

Measured memory_bytes: 1208
<?php
  list($x) = explode(" ", trim(fgets(STDIN)));

  $pow5 = [];
  for($i=0; $i<200; $i++){
    $pow5[$i] = pow($i, 5);
  }
//  var_dump($pow5);

  for($i=0; $i<200; $i++){
    for($j=0; $j<200; $j++){
      if($x == ($pow5[$i]-$pow5[$j])){
        echo $i." ".$j;
        exit;
      }
    }
  }

  for($i=0; $i<200; $i++){
    for($j=0; $j<200; $j++){
      if($x == ($pow5[$i]+$pow5[$j])){
        echo $j." ".$i*-1;
        exit;
      }
    }
  }

Measured memory_bytes: 16080
n,m=map(int,input().split())
class UnionFind:
    def __init__(self, n):
        self.par =[i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
A=UnionFind(n)
for i in range(m):
    a,b,c=map(int,input().split())
    A.union(a,b)
List=A.par
counter=0
for j in range(n+1):
    if List[j]==j:
        counter+=1
print(counter-1)


Measured memory_bytes: 7908
#include<stdio.h>
 
int island[50][50];
int W,H;

void dfs(int y,int x){
  int i,j,nx,ny;
  island[y][x]=0;
 
  for(i=-1;i<2;i++){
    for(j=-1;j<2;j++){
      if(i==0 && j==0)
	continue;
      ny=y+i;
      nx=x+j;
      if(nx < 0 || ny < 0 || nx > W-1 || ny > H-1)
	continue;
      if(island[ny][nx]!=1)
	continue;
      dfs(ny,nx);
    }
  }
   
}
 
int main(){
  int ans=0;
  int i,j;
   
  while(scanf("%d %d",&W,&H),H+W!=0){
 
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	scanf("%d",&island[i][j]);
      }
    }
 
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
    if(island[i][j]==0)
      continue;
    ans++;
    dfs(i,j);
      }
    }
 
    printf("%d\n",ans);
    ans=0;
  }
   
  return 0;
}

Measured memory_bytes: 788
#include <iostream>
using namespace std;
#define int long long

signed main()

{
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	if (a>b) swap(a,b);

	if ((b-a)%2==0) cout<<(b-a)/2<<endl;
	else cout<<min((a+b-1)/2,(n-a+n-b+1)/2)<<endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string X;
  cin >> X;
  int s = 0, t = 0;
  for (char c : X) {
    if (c == 'S') s++;
    if (c == 'T') {
      if (s > 0) {
        s--;
      } else {
        t++;
      }
    }
  }
  cout << s + t << '\n';
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	ll a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<endl;
}


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

using namespace std;

#define l long long int
#define vl vector<l>

int main()
{
  l n;
  cin>>n;
  vl ar(n+1,0);
  l x;
  for(l i=0;i<n-1;i++)
  {
    cin>>x;
    ar[x]++;
  }
  for(l i=1;i<=n;i++)
    cout<<ar[i]<<"\n";
  return 0;
}


Measured memory_bytes: 4748
#include"bits/stdc++.h"
using namespace std;
#define ff first.first
#define fs first.second
#define se second
typedef pair<int,int> P;
typedef pair<P,int> PP;
int Map[1000][1000];
int main(void)
{
	queue<PP> que;
	clock_t start, end;
	int q;
	int h,w,n,x,y,sum;
	int cnt; //ねずみの体力
	int OP,TT;
	int i,j;
	int A[2][4]={{1,0,-1,0},{0,1,0,-1}};
	char T[1000][1000];
	
	cin>>h>>w>>n;
	cnt=1; sum=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>T[i][j];
			if(T[i][j]=='S') x=i,y=j; //スタート地点
		}
	}
	
	//現在日時を取得
	//start=clock();
	
	//map作成
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(T[i][j]=='X') Map[i][j]=-1;
			else Map[i][j]=0;
		}
	}

	que.push(PP(P(0,x),y));
	while(!que.empty()){
		PP q=que.front(); que.pop();
		//printf("q.fs=%d q.se=%d\n",q.fs,q.se);
		for(i=0;i<4;i++){
			OP=q.fs+A[0][i],TT=q.se+A[1][i];
			//printf("OP=%d TT=%d\n",OP,TT);
			//printf("OP=%d h=%d TT=%d w=%d Map[OP][TT]=%d\n",OP,h,TT,w,Map[OP][TT]);
			if(OP<h&&0<=OP&&TT<w&&0<=TT&&
				Map[OP][TT]!=-1&&Map[OP][TT]!=cnt){//進んだとき範囲を超えずXでない場合
				//Map[q.fs][q.se]=cnt;
				Map[OP][TT]=cnt;
				que.push(PP(P(q.ff+1,OP),TT));
				if(T[OP][TT]-48==cnt){
					sum+=q.ff+1; cnt++;
					que.push(PP(P(0,OP),TT));
					while(que.size()!=1) que.pop();
					break;
				}
			}
		}
		//map確認
		/*for(int k=0;k<h;k++){
			for(int l=0;l<w;l++) cout<<Map[k][l]<<" ";
			cout<<endl;
		}
		cout<<endl;*/
		if(cnt>n) break;
	}
	
	  //経過時間を取得
	//end = clock();
	//printf("time=%f\n",(double)(end-start)/CLOCKS_PER_SEC);
	
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 7992
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  char c[n];
  int sum[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(i==0){
      if(c[i]=='R') sum[i]=1;
      else sum[i]=0;
    }
    else{
      if(c[i]=='R') sum[i]=sum[i-1]+1;
      else sum[i]=sum[i-1];
    }
  }
  if(sum[n-1]==0 or sum[n-1]==n){
    cout<<0<<endl;
    return 0;
  }
  cout<<sum[n-1]-sum[sum[n-1]-1]<<endl;
  return 0;
}


Measured memory_bytes: 4564
using System;
using System.Linq;

namespace AtCoder20200328_2
{
    class Program
    {
        static void Main(string[] args)
        {
            // Coffee();
            // GoldCoin();
            travelling();
        }

        public static void Line()
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int X = int.Parse(inputs[0]);
            int Y = int.Parse(inputs[1]);
            int A = int.Parse(inputs[2]);
            int B = int.Parse(inputs[3]);
            int C = int.Parse(inputs[4]);

            int[] p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] q = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(p);
            Array.Sort(q);
            Array.Sort(r);
            int p_index = A - 1;
            int q_index = B - 1;
            int r_index = C - 1;
            int[,] dp = new int[X+1, Y+1];
            int[,][] cond = new int[X + 1, Y + 1][];
            dp[0, 0] = 0;
            cond[0, 0] = new int[] { A, B, C };


            

        }

        public static void Coffee()
        {
            char[] inputs = new char[6];
            inputs = Console.ReadLine().Select(c => c).ToArray();
            if(inputs[2] == inputs[3] && inputs[4] == inputs[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

        public static void GoldCoin()
        {
            long X = long.Parse(Console.ReadLine());
            long num_500 = X / 500;
            long num_5 = (X - num_500 * 500) / 5;

            Console.Write(num_500*1000 + num_5*5);
        }

        public static void travelling()
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int K = int.Parse(inputs[0]);
            int N = int.Parse(inputs[1]);
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] dist = new int[N];
            int max = 0;
            for (int i = 0; i < N; i++)
            {
                // dist[n] : distance between A(n+1) and A(n)
                if(i != N-1)
                { 
                    dist[i] = A[i + 1] - A[i];
                }
                else
                {
                    dist[i] = K + A[0] - A[i];
                }
                if(max < dist[i])
                {
                    max = dist[i];
                }

            }

            Console.WriteLine(K-max);
        }
    }
}


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

int main(void) {
  char O[52],E[52];
  int i,sio,sie;
  scanf("%s",&O);
  scanf("%s",&E);
  sio = strlen(O);
  sie = strlen(E);
  if (sio == sie) {
    for (i = 0;i < sio;i++) {
      fputc(O[i],stdout);
      fputc(E[i],stdout);
    }
  } else {
    for (i = 0;i < sio;i++) {
      if (i == sio - 1) {
        fputc(O[i],stdout);
      } else {
        fputc(O[i],stdout);
        fputc(E[i],stdout);
      }
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
def solve():
    S = [int(_) for _ in raw_input()]
    S12 = S[0] * 10 + S[1]
    S34 = S[2] * 10 + S[3]
    YYMM = False
    MMYY = False
    if S34 >= 1 and S34 <= 12:
        YYMM = True
    if S12 >= 1 and S12 <= 12:
        MMYY = True
    if YYMM:
        if MMYY:
            ret = 'AMBIGUOUS'
        else:
            ret = 'YYMM'
    else:
        if MMYY:
            ret = 'MMYY'
        else:
            ret = 'NA'
    print ret

if __name__ == '__main__':
    solve()


Measured memory_bytes: 27884
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun dprint(v: Any?, indent: Int = 0) {
    val indentStr = (1..indent).joinToString("") { " " }
    when (v) {
        is Iterable<*> -> {
            System.err.println("$indentStr[")
            v.forEach { dprint(it, indent + 1) }
            System.err.println("$indentStr]")
        }
        is Array<*> -> {
            System.err.println("$indentStr[")
            v.forEach { dprint(it, indent + 1) }
            System.err.println("$indentStr]")
        }
        is IntArray -> System.err.println(indentStr + "[" + v.joinToString(",") + "]")
        is LongArray -> System.err.println(indentStr + "[" + v.joinToString(",") + "]")
        is DoubleArray -> System.err.println(indentStr + "[" + v.joinToString(",") + "]")
        else -> System.err.println(indentStr + v)
    }
}

fun <A : Comparable<A>> min(a: A, b: A) = if (a < b) a else b
fun <A : Comparable<A>> minOf(vararg a: A) = a.reduce { acc, x -> min(acc, x) }
fun <A : Comparable<A>> max(a: A, b: A) = if (a > b) a else b
fun <A : Comparable<A>> maxOf(vararg a: A) = a.reduce { acc, x -> max(acc, x) }

////////////////////////////////////////////////////////////////////////

// Greatest Common Divisor
fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
fun gcd(numbers: Iterable<Long>): Long = numbers.reduce { acc, n -> gcd(acc, n) }

// Least Common Multiple
fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b
fun lcm(numbers: Iterable<Long>): Long = numbers.reduce { acc, n -> lcm(acc, n) }

////////////////////////////////////////////////////////////////////////

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solveMulti(sc: Scanner, pw: java.io.PrintWriter) {
        for (t in 1..sc.next().toInt()) {
            solve(sc, pw)
        }
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toLong()
        val A = LongArray(N) { sc.next().toLong() }
        val n2 = A.map {
            var i = it
            var n = 0
            while (i % 2 == 0L) {
                n++
                i /= 2
            }
            n
        }
        if (n2.distinct().count() > 1) {
            pw.println("0")
            return
        }
        val l = lcm(A.toList())
        pw.println(M / (l / 2) - M / l)
    }
}


Measured memory_bytes: 47356
#include <stdio.h>
#include <string.h>
int main(void) {
  char S[11];
  char T[12];
 
  scanf("%s", &S);
  scanf("%s", &T);
  int l = strlen(S);
  int cnt = 0;
  for (int i = 0; S[i] != '\0'; i++) {
    if (S[i] != T[i]) {
      cnt++;
    }
  }
  if (cnt == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

int main()
{
    string s, t;

    cin >> s;
    cin >> t;

    const int MAX_S = s.length();
    const int MAX_T = t.length();

    int tbl[MAX_S + 1][MAX_T + 1];
    for (int i = 0; i < MAX_S + 1; ++i)
    {
        for (int j = 0; j < MAX_T + 1; ++j)
        {
            tbl[i][j] = 0;
        }
    }

    for (int i = 1; i <= MAX_S; ++i)
    {
        for (int j = 1; j <= MAX_T; ++j)
        {
            if (s[i - 1] == t[j - 1])
            {
                tbl[i][j] = tbl[i - 1][j - 1] + 1;
            }
            else
            {
                tbl[i][j] = max(tbl[i - 1][j], tbl[i][j - 1]);
            }
            //            cout << tbl[i][j] << " ";
        }
        //        cout << endl;
    }

    string ans = "";
    int x = MAX_S;
    int y = MAX_T;

    while (x > 0 && y > 0)
    {
        if (tbl[x][y] == tbl[x - 1][y])
        {
            x--;
        }
        else if (tbl[x][y] == tbl[x][y - 1])
        {
            y--;
        }
        else
        {
            x--;
            y--;
            ans.push_back(s[x]);
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

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

int main() {
  ll n,d;cin >> n >> d;
  ll ans = 0;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    if( x*x  + y*y <= d*d ) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	string s;
	cin >> s;
	int ans = s.length();
	for (int i = 0; i < (int) s.length(); ++i) {
		if (s[i] == 'A')
			break;
		--ans;
	}
	for (int i = (int) s.length() - 1; i >= 0; --i) {
		if (s[i] == 'Z')
			break;
		--ans;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
from sys import stdin
input = stdin.readline

x, k, d = map(int, input().split())
x = abs(x)
if x // d > k:
	print(x - d * k)
else:
	k -= x // d
	if k & 1 == 0:
		print(x % d)
	else:
		print(d - (x % d))


Measured memory_bytes: 61912