akhauriyash/Code-Regression huggingface dataset:
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

constexpr ll base1 = 1007, base2 = 2009, mod1 = 1000000007, mod2 = 1000000009;

struct RollingHash {
    vector<ll> hash1, hash2, pow1, pow2;
    RollingHash (const string &S) {
        int length = sz(S);
        hash1.assign(length + 1, 0);
        hash2.assign(length + 1, 0);
        pow1.assign(length + 1, 1);
        pow2.assign(length + 1, 1);
        rep(i, length) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    pair<ll, ll> get(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return pair<ll, ll>{res1, res2};
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    
    int k = (sz(s) + sz(t) - 2) / sz(s) + 1;
    string s_;
    rep(i, k) s_ += s;
    RollingHash rs_(s_), rt(t);
    
    vector<bool> judge(sz(s), false);
    rep(i, sz(s)) {
        if (rs_.get(i, i + sz(t)) == rt.get(0, sz(t))) judge[i] = true;
    }
    vector<bool> searched(sz(s), false);
    int ans = 0;
    rep(i, sz(s)) {
        if (searched[i]) continue;
        if (!judge[i]) continue;
        int now = i, cnt = 0;
        do {
            now = (now + sz(t)) % sz(s);
            ++cnt;
            searched[now] = true;
        } while (now != i && judge[now]);
        if (now == i) ans = inf;
        else chmax(ans, cnt);
    }
    
    if (ans == inf) cout << -1 << "\n";
    else cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 68160
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#define MOD 1000000007
typedef  long long int  lli;
using namespace std;
int main() {
    string s; string t;
    cin>>s>>t;
    int n=s.length();
    lli ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
        {
            ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3904
#include <iostream>
#include <algorithm>
#define rgi register int
using namespace std;
const int a[]={0,9,90,900,9000,90000,900000};
int n,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	int n0=n;
	int indx=1;
	while(n>=10)
	{
		n/=10;
		if(indx&1)
			ans+=a[indx];
		++indx;
	}
	int k=1;
	for(rgi i=1;i<=indx-1;++i)
		k*=10;
	//cout<<k<<endl<<indx<<endl;
	if(indx&1)
		for(rgi i=k;i<=n0;++i)
			++ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
//---------------------------------------------------FUNCTIONS-------------------------------------------------------

void solve(){
	ll n ;
	cin >> n ;
	vector<double> ar(n+1) ;
	beg1(i , n+1) cin >> ar[i] ;
	vector<ld> dp(n+1) ;
	dp[0] = 1 ;
	beg1(i , n+1){
		for(ll j=i ; j>=0 ; j--){
			if(j==0) dp[j]*=(1-ar[i]) ;
			else dp[j] = dp[j-1]*ar[i] + dp[j]*(1 - ar[i]) ;
		}
	}
	ld ans=0 ;
	for(ll i=n/2+1 ; i<=n ; i++) ans+= dp[i] ;
	cout << setprecision(10) << ans ;
}
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int n = S.length();
    if (S[n - 1] == 's')
    {
        cout << S << "es" << endl;
    }
    else
    {
        cout << S << "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1: *ib++)
inline int read() {
  static int ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) {
    ans = ((ans << 2) + ans << 1) + (ch ^ 48);
    ch = gc();
  }
  return ans;
}
typedef long long ll;
typedef vector <int> poly;
#define pb push_back
#define rez resize
const int N = 5e5 + 5, inf = 0x3f3f3f3f;
int n, a[N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read();
  for (ri i = 1; i <= n; ++i) {
    a[i] = read();
  }
  ll x = 2, y = 2;
  for (ri i = n; i; --i) {
    if (x % a[i]) {
      x = (x / a[i] + 1) * a[i];
    }
    y = (y / a[i] + 1) * a[i] - 1;
  }
  if (x <= y) {
    cout << x << ' ' << y;
  } else {
    cout << -1;
  }
  return 0;
}

Measured memory_bytes: 4988
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String args[]) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x,cube;

		x = Integer.parseInt(br.readLine());
		cube = x * x * x;

		System.out.println(cube);

		br.close();

	}
}

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

fn main() {
    let s : String = read();
    println!("{}", s.chars().filter(|&c| c == '1').count());
}

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


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    string s;
    cin >> s;

    map<char, int> mp;

    irep(i, s.size()) {
        mp[s[i]]++;
    }

    for(auto ans : mp) {
        if(ans.second % 2 != 0) { 
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;
    return 0;
}
/** atcoder **/


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

class Disc{//~ÕÌîñð\·NX
public:
	int x,y,r,c;
	Disc(int x,int y,int r,int c): x(x),y(y),r(r),c(c){}
	Disc(){};
};

int n;//~ÕÌ
char memo[1<<24];//Dp
bool exist[24];//~ÕªcÁÄé©Ç¤©
Disc D[24];//~Õðüêézñ
int ans;//¦ðüêé

bool touch(Disc a,Disc b){//2Ì~ÕªdÈÁÄ¢é©@ñæÉ·êÎë·ðCÉµÈ­Äàæ¢
	return (a.r+b.r)*(a.r+b.r)>(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

bool top(int k){//kÔÚÌ~ÕÌãÉ¼Ì~ÕªæÁÄ¢È¢©
	for(int i=k-1;i>=0;i--){
		if(exist[i]){
			if(touch(D[k],D[i])){return false;}
		}
	}
	return true;
}

int dfs(int bit,int num){//»µÄ[³Dæ
	if(memo[bit]>=0) return memo[bit];
	int res=num;

	for(int i=0;i<n;i++){
		if(exist[i] && top(i)){
			for(int j=i+1;j<n;j++){//j=0 Éµ½çTLEµ½
				//jÔÚÌ~Õª¶ÝµÄCãÉ¼Ì~ÕªæÁÄÈ­ÄCiÔÚÌ~ÕÆFªê
				if(exist[j] && top(j) && i!=j && D[i].c==D[j].c){
					exist[i]=false;//æè­
					exist[j]=false;
					res=dfs((bit&(~(1<<i)))&(~(1<<j)),num+2);
					exist[i]=true;//ß·
					exist[j]=true;
				}
			}
		}
	}
	memo[bit]=res;//é
	ans=max(ans,res);
	return res;
}

int main()
{
	while(cin>>n && n!=0){
		memset(memo,-1,sizeof(memo));
		memset(exist,true,sizeof(exist));
		for(int i=0;i<n;i++){
			int x,y,r,c;
			cin>>x>>y>>r>>c;
		D[i]=Disc(x,y,r,c);
		}
		ans=0;
		dfs((1<<24)-1,0);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue

    flg = True
    for j in range(len(arr)):
        if s[arr[j][0]-1] != str(arr[j][1]):
            flg = False
            break

    if flg:
        print(i)
        exit()

print(-1)

Measured memory_bytes: 38256
n,k=map(int,input().split())
s=[int(i) for i in input()]
l1,l0=[],[]
b,c=1,0
for i in s:
  if b==i: c+=1
  else:
    if b: l1+=[c]
    else: l0+=[c]
    c=1
  b=i
if b:
  l1+=[c]
  l0+=[0]
else:
  l0+=[c]
S=[0]
for i,j in zip(l1,l0):
  S+=[S[-1]+i+j]
l1+=[0]
l0+=[0]
m=len(S)
if m<=k: print(n)
else:
  a=0
  for i in range(k,m):
    a=max(a,S[i]-S[i-k]+l1[i])
  print(a)

Measured memory_bytes: 12396
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CMultiplication3 {
public:
  static void solve(istream &cin, ostream &cout) {
    int A;
    double B;
    cin >> A >> B;
    B *= 100;
    int BB = (int)round(B);
    cout << A * BB / 100 << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  CMultiplication3 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3796
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
# 時間でソート
# 食べる料理が決まっている時、時間が最大のものを最後に頼むのが最適
AB.sort(key=lambda x: x[0])

# dp[i][j]=(i番目までの料理をj分以下で食べ切れるように選んだときの、美味しさの総和の最大値)
dp = [[0 for _ in range(T)] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(T):
        # i番目の料理を食べることができる場合
        if j - AB[i - 1][0] >= 0:
            # 実際に料理を食べる場合、食べない場合
            dp[i][j] = max(dp[i - 1][j - AB[i - 1][0]] + AB[i - 1][1], dp[i - 1][j])
        # i番目の料理を食べることができない場合
        else:
            dp[i][j] = dp[i - 1][j]

ans = 0
# k番目の料理を最後に食べると考える(T-1分に注文する)
# k-1番目までの料理をT-1分の間に最適に食べる + k番目を食べる
for k in range(1, N + 1):
    tmp = dp[k - 1][T - 1] + AB[k - 1][1]
    ans = max(ans, tmp)

print(ans)


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

int main(){
   int n;
   cin >> n;
   vector<string> s(n);
   int ans=0;
   rep(i,n){
      cin >> s.at(i);
   }
   int m;
   cin >> m;
   vector<string> t(m);
   rep(i,m){
      cin >> t.at(i);
   }
   vector<int> a(n);
   rep(i,n){
      repi(j,i+1,n){
         if(s.at(i)==s.at(j)){
           a.at(i)++;
         }
      }
      rep(k,m){
         if(s.at(i)==t.at(k)){
            a.at(i)--;
         }
      }
   }
   rep(i,n){
      a.at(i)++;
      ans=max(ans,a.at(i));
   }
   cout << ans << endl;
}

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

const int MAXN = 2010;
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int n, m, fa[MAXN], vis[MAXN];
std::vector<int> out[MAXN];
const int MAXP = MAXN * 5;
int ls[MAXP], rs[MAXP], bak, ansl[MAXP];
int decl[MAXP];
std::set<int> hav[MAXN];
int dep[MAXN];
void dfs(int u) {
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != fa[u]) {
			out[u].push_back(to[i]);
			dep[to[i]] = dep[u] + 1;
			fa[to[i]] = u;
			dfs(to[i]);
		}
}
int dc[MAXN];
int ans = 0;
int main() {
	std::cin >> n >> m; bak = m;
	for (int i = 1, t1, t2; i < n; ++i) {
		std::cin >> t1 >> t2;
		addedge(t1, t2);
	}
	dfs(1);
	for (int i = 1; i <= m; ++i) {
		std::cin >> ls[i] >> rs[i];
		hav[ls[i]].insert(i);
		hav[rs[i]].insert(i);
		int x = ls[i], y = rs[i];
		if (dep[x] < dep[y]) std::swap(x, y);
		while (dep[x] > dep[y]) ++dc[x], x = fa[x];
		while (x != y) ++dc[x], ++dc[y], x = fa[x], y = fa[y];
	}
	for (int i = 1; i <= n; ++i) ans += std::min(2, dc[i]);
	for (int i = 1; i < n; ++i) {
		int cho = 0;
		for (int j = 1; j <= n; ++j) if (!vis[j]) {
			int cx = 0;
			for (auto t : out[j]) cx += !vis[t];
			if (!cx) { cho = j; break; }
		}
		vis[cho] = true;
		std::vector<int> aq, dx;
		for (auto t : hav[cho]) {
			dx.push_back(t);
			if (ls[t] != rs[t]) aq.push_back(t);
		}
		for (auto t : dx) {
			hav[ls[t]].erase(t);
			hav[rs[t]].erase(t);
		}
	//	std::cout << "DBG " << cho << std::endl;
	//	for (auto t : aq) std::cout << '(' << ls[t] << ',' << rs[t] << ") ";
	//	std::cout << std::endl;
		while (aq.size() >= 2) {
			int tz = aq.size();
			int x = aq[tz - 1], y = aq[tz - 2];
			aq.erase(aq.end() - 2, aq.end());
			int now = ++bak;
			if (ls[x] == cho) {
				ls[now] = rs[x];
				decl[x] = -now;
			} else {
				ls[now] = ls[x];
				decl[x] = now;
			}
			if (rs[y] == cho) {
				rs[now] = ls[y];
				decl[y] = -now;
			} else {
				rs[now] = rs[y];
				decl[y] = now;
			}
			// std::cout << "MERGE " << ls[now] << ' ' << rs[now] << std::endl;
			hav[ls[now]].insert(now);
			hav[rs[now]].insert(now);
		}
		if (aq.size() == 0) continue;
		if (aq.size() == 1) {
			int t = aq[0], now = ++bak;
			ls[now] = ls[t], rs[now] = rs[t];
			decl[t] = now;
			if (ls[t] == cho) ls[now] = fa[cho];
			else if (rs[t] == cho) rs[now] = fa[cho];
			hav[ls[now]].insert(now);
			hav[rs[now]].insert(now);
		}
	}
	for (int i = bak; i; --i) if (decl[i])
		ansl[i] = decl[i] > 0 ? ansl[decl[i]] : 1 - ansl[-decl[i]];
	std::cout << ans << std::endl;
	for (int i = 1; i <= m; ++i) {
		if (ansl[i]) std::swap(ls[i], rs[i]);
		std::cout << ls[i] << ' ' << rs[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
//#define pr(x) cout<<#x<<": "<<x<<endl
#define kl k<<1
#define kr k<<1|1
using namespace std;
const int MAX_N=3e5+5;
vector<int> rec[MAX_N];
int H[MAX_N],W[MAX_N];

struct node{ int l,r; int mx; };
struct SegTree{//?????
	node tr[MAX_N<<2];
	void pushup(int k){ tr[k].mx=max(tr[kl].mx,tr[kr].mx); }
	void build(int k,int l,int r)
	{
		tr[k].l=l,tr[k].r=r;
		if(l==r) { tr[k].mx=W[l]; return; }//val?????
		int mid=(l+r)>>1; build(kl,l,mid),build(kr,mid+1,r); pushup(k);
	}
	void update_Point(int k,int pos,int val)//????
	{
		if(tr[k].l==tr[k].r){ tr[k].mx+=val; return; }
		int mid=(tr[k].l+tr[k].r)>>1;
		if(pos<=mid) update_Point(kl,pos,val);
		if(pos>mid) update_Point(kr,pos,val);
		pushup(k);
	} 	
}Tr;

int main()
{
	int h,w,m; si(h),si(w),si(m); ms(H),ms(W);
	repi(i,1,m){
		int x,y; si(x),si(y); 
		H[x]++,W[y]++,rec[x].pb(y);
	}
	int ans=0;
	Tr.build(1,1,w);
	repi(i,1,h){
		for(auto y:rec[i]) Tr.update_Point(1,y,-1);
		ans=max(ans,H[i]+Tr.tr[1].mx);
		for(auto y:rec[i]) Tr.update_Point(1,y,1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 34868
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int l,r,d,cnt = 0;
	cin >> l >> r >> d;

	int i;
	for (i = l; i <= r; i++)
	{
		if (i % d == 0)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

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

int main() {
	int x, y;
	cin >> x >> y;
	string str, temp[1001];
	for (int i = 0; i < x; i++) {
		cin >> str;
		temp[i] = str;
	}
	for (int i = 0; i < x; i++){
		cout << temp[i] << endl;
		cout << temp[i] << endl;
	}

}

Measured memory_bytes: 632
#include<iostream>
//#include<string>
using namespace std;
int main() {
	int n,k,s=1;
	cin >>n>>k;
	
	for (int i = 0; i < n; i++) {
		if (s * 2 < s + k) {
			s *= 2;
		}
		else {
			s += k;
		}
	}
	cout << s << endl;
	
	//system("pause");
}

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

#define ll               long long
#define nl               '\n'                             // NL - sign of new line

#define upc(str, c)      str[c] = toupper(str[c]);         // make single char uppercase
#define lowerc(str, c)   str[c] = tolower(str[c]);         // make single char lowercase

#define ups(str)       	 transform(str.begin(), str.end(), str.begin(), ::toupper); // make entire string uppercase
#define lowers(str)      transform(str.begin(), str.end(), str.begin(), ::tolower); // make entire string lowercase

#define ps(x,y)          fixed << setprecision(y) << x     // usage: t=1.1234; cout << ps(t,4); // it means it will print 4 decimal places.

#define vi               vector <int>                      //create vector of int numbers
#define vs               vector <string>                      //create vector of int numbers
#define eb               emplace_back
#define rev(v)		     reverse(v.begin(), v.end())       // reverse the vector

#define mii			     map <int,int>
#define mss			     map <string, string>

#define w(t)             unsigned int t; cin >> t; while(t--)      //  usage: create quickly number of test

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


//==================================
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	c_p_c();
	//--------------------------------

	string s;
	cin >> s;

	cout << s.substr(0, 3);
	 


	return 0;

}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

bool Solve() {
  string s;
  cin >> s;
  if (s[0] != s[s.size() - 1]) {
    return s.size() % 2 == 1;
  } else {
    return s.size() % 2 == 0;
  }
}

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

  if (Solve()) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
int main(void){
    uint_fast16_t n;
    scanf("%" SCNuFAST16 "",&n);
    uint_fast64_t a[n];
    for(uint_fast16_t i=0;i<n;i++){
        scanf("%" SCNuFAST64 "",&a[i]);
        if(!a[i]){puts("0");exit(0);}
    }
    uint_fast64_t p=1;
    for(uint_fast16_t i=0;i<n;i++)if(a[i]>UINT_FAST64_MAX/p){puts("-1\n");exit(0);}else p*=a[i];
    if(p>1000000000000000000)puts("-1");
    else printf("%" PRIuFAST64 "\n",p);
    exit(0);
}

Measured memory_bytes: 2488
#include <stdio.h>
#include <stdlib.h>

struct data{
  int h,p,q;
}b[1000];

int cmp(const void *a,const void *b){
  return ((struct data *)a)->h-((struct data *)b)->h;
}

int main(void) {
  int i=0,tmp,d[101];
  int n,m,a;
  
  while(scanf("%d%d%d",&n,&m,&a),n){
    for(i=0;i<m;i++){
     scanf("%d%d%d",&b[i].h,&b[i].p,&b[i].q);
    }
    qsort(b,m,sizeof(struct data),cmp);
    for(i=0;i<101;i++)d[i]=i;
    for(i=0;i<m;i++){
      tmp=d[b[i].p];
      d[b[i].p]=d[b[i].q];
      d[b[i].q]=tmp;
    }
    printf("%d\n",d[a]);
  }
  return 0;
}

Measured memory_bytes: 672
#include <bits/stdc++.h>//lcm of two given numbers//
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int sum=0;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
sum=sum+a[i]*a[j];
cout<<sum;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define REP(i,a,b) for (int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)
using namespace std;

int H, W;
int dw[] = {1,1,0,-1,-1,-1,0,1};
int dh[] = {0,1,1,1,0,-1,-1,-1};

int main(void){
    while (cin >> H >> W && H) {
        vector<string> S(H,"");
        rep(i, H) cin >> S[i];
        string ans = "";
        set<string> appear;
        
        rep(h, H) rep(w, W) rep(i, 8) {
            string s = "";
            s += S[h][w];
            int iw = w, ih = h;
            w = (w+dw[i]+W)%W; h = (h+dh[i]+H)%H;
            while (!(w == iw && h == ih)) {
                s.append(1, S[h][w]);
                if (s.length() >= ans.length() && appear.find(s) != appear.end()) {
                    if (s.length()  > ans.length()) ans = s;
                    if (s.length() == ans.length()) ans = min(ans, s);
                }
                appear.insert(s);
                w = (w+dw[i]+W)%W; h = (h+dh[i]+H)%H;
            }
        }
        cout << (ans.length() > 1 ? ans:"0") << endl;
    }
    return 0;
}

Measured memory_bytes: 33772
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def generate_adj_table(_edges):
    for edge in _edges:
        vx, vy = map(int, edge)
        init_adj_table[vx].add(vy)

    return init_adj_table


def graph_dfs(current, matching, visited):
    for target in range(y_num):
        if (not visited[target]) and (target in adj_table[current]):
            visited[target] = True
            # matching[target] = -1: target not assigned to any of x
            # graph_dfs(matching[target], matching, visited) = True
            # indicates that source in x has been already assigned to another target in y
            if matching[target] == -1 or graph_dfs(matching[target], matching, visited):
                matching[target] = current
                return True
    return False


def mbm():
    matching = [-1] * y_num
    res = 0
    for source in range(x_num):
        visited = [False] * y_num
        if graph_dfs(source, matching, visited):
            res += 1
    # print(matching)
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [set() for _ in range(x_num)]
    adj_table = generate_adj_table(edges)
    print(mbm())

Measured memory_bytes: 9224
#include<stdio.h>
int jud(int);
int main(){
  int a,num[10000],i,count=0;

  scanf("%d",&a);
  for(i = 0; i < a;i++){
    scanf("%d",&num[i]);
  }
  for(i = 0;i < a;i++){
    count += jud(num[i]);
  }
  printf("%d\n",count);
  return 0;
}

int jud(int num){
  int i;
  if(num == 2)return 1;
  if(num % 2 == 0)return 0;

  for(i = 3;i <= num /i; i+=2){
    if(num % i == 0)return 0;
  }
  return 1;
}

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

int factorial(int n){
    int res = 1;
    while(n>1){
        res*=n;
        n--;
    }
    return res;
}

int main(){
    int N;
    double ans = 0;
    cin >> N;
    vector<pair<int, int>>xy;
    rep(i, N){
        int x, y;
        cin >> x >> y;
        xy.push_back({x, y});
    }
    vector<int>num(N);
    rep(i, N) num[i]=i;
    do{
        rep(i, N-1){
            ans+=sqrt(pow(xy[num[i]].first-xy[num[i+1]].first, 2)+pow(xy[num[i]].second-xy[num[i+1]].second, 2));
        }
    }while(next_permutation(num.begin(), num.end()));
    cout <<(fixed) << setprecision(10) << ans/factorial(N) << endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(2001, 0);
    vector<int> pref(2001, 0);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v[x]++;
    }
    for (int i = 1; i <= 2000; ++i) {
        pref[i] = pref[i - 1] + v[i];
    }
    ll ans = 0;
    for (int i = 1; i <= 1000; ++i) {
        for (int j = 1; j < i; ++j) {
            ans += 1ll * v[i] * v[j] * (pref[i + j - 1] - pref[i]);
        }
        ans += (1ll * v[i] * (v[i] - 1) * (v[i] - 2)) / 6;
        ans += (1ll * v[i] * (v[i] - 1)) / 2 * (pref[2 * i - 1] - v[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
while 1:
  n=int(input())
  if n==0:
    break
  data=[[] for i in range(n+1)]
  for i in range(n+1):
    m=int(input())
    x,y=map(int,input().split())
    for j in range(m-1):
      _x,_y=map(int,input().split())
      data[i].append((abs(_x+_y-x-y),1 if x<_x else 3 if x>_x else 0 if y< _y else 2 ))
      x,y=_x,_y
  for i in range(1,n+1):
    d=[(e[0], (e[1]+(data[0][0][1]-data[i][0][1]))%4) for e in data[i]]
    f=[(e[0], (e[1]+(data[0][0][1]-data[i][-1][1]))%4) for e in data[i][::-1]]
    if data[0]==d:
      print(i)
    elif data[0]==f:
      print(i)
  print('+++++')



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

int main () {
  int a , b , c , d ;
  cin >> a >> b >> c >> d ;
  
  int x , y , z ;
  
  x = abs(a-b) ;
  y = abs(c-b) ;
  z = abs(c-a) ;
  
  if ( z <= d || ( x <= d && y <= d )) {
    cout << "Yes" << endl ;
  } else {
    cout << "No" << endl ;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  main(){
long long  A,B,C,D;
cin>>A>>B>>C>>D;
long long w=C/__gcd(C,D)*D;
long long data=w-(w/C+w/D-1);
long long j=B%w;
long long h=B/w*data;
if(j!=0){
h+=j-(j/C+j/D);
}
long long o=A%w;
long long p=A/w*data;
if(o!=0){
p+=o-(o/C+o/D);
}
if(A%C==0||A&D==0)
{}
  else{
       p--; 
  }
cout<<h-p<<endl;
}


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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

int step(int a, int m) {
    return (a*a)%m;
}

/* At less than m elements the seq repeats. */
void solve() {
    cini(n);
    cini(x);
    cini(m);

    vi first(m, -1);
    vi pre(2*m,0);

    int ans=0;
    for(int i=1; i<=n; i++) {
        if(first[x]>=0) {
            int loopsize=i-first[x];
            int loopsum=pre[i-1]-pre[first[x]-1];

            int loops=(n-i)/loopsize;
            ans+=loops*loopsum;
            i+=loops*loopsize;
            for(int j=0; j<(int)first.size(); j++)
                first[j]=-1;
        }

        if(i<(int)pre.size()) {
            pre[i]=pre[i-1]+x;
            first[x]=i;
        }

        ans+=x;
        x=step(x,m);
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}


Measured memory_bytes: 5544
#include <stdio.h>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int N = 100100;
char st[205];
bool isEven(int ri)
{
	if (ri % 2 == 0)
		return false;
	int mid = (ri + 1) / 2;
	for (auto i = 0; i < mid; i++)
	{
		if (st[i] != st[mid + i])
		{
			return false;
		}
	}
	return true;
}
int main()
{
	scanf("%s", st);
	int len = strlen(st);
	int ans = len-1;
	for (auto right = len - 2; right >= 0; right--)
	{
		if (isEven(right))
		{
			printf("%d\n", ans);
			return 0;
		}
		ans--;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    l=list(map(int,readline().split()))
    l.sort()

    s=[]
    indexs=[]
    for i in range(n-2):
        for j in range(i+1,n-1):
            s.append(l[i]+l[j])
            indexs.append(j+1)

    l=np.array(l,dtype=np.int64)
    s=np.array(s,dtype=np.int64)
    indexs=np.array(indexs,dtype=np.int64)
    ans=(np.searchsorted(l,s)-indexs).sum()
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 184684
/*************************************************************************
  > File Name: B.cc
  > Author: Riho.Yoshioka
  > Mail:   riho.yoshioka@yandex.com
  > Created Time: Sat 16 Jul 2016 08:19:30 PM CST
*************************************************************************/
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

LL solve(LL n, LL x) {
  if (n % x == 0) {
    return n + ((n - x) / x * 2 - 1) * x;
  }
  else {
    if (2 * x > n) {
      return solve(n, n - x);
    }
    else {
      LL ans = n + ((n - x) / x * 2 - 1) * x + n % x * 2;
      return ans + solve(x, x - n % x);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  LL n, x;
  cin >> n >> x;
  cout << solve(n, x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    int x = 1;
    rep(i, n){
        if(a[i] == x){
            x++;
            continue;
        }
        ans += (a[i] - 1) / x;
        if(i == 0){
            x++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
bool isprime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return true;
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	for (int i = N; i >= 0; --i) cin >> A[i];
	int g = abs(A[N]);
	for (int i = 0; i < N; ++i) g = gcd(g, abs(A[i]));
	vector<int> ps;
	for (int i = 2; i * i <= g; ++i) {
		if (g % i == 0) {
			ps.push_back(i);
			while (g % i == 0) g /= i;
		}
	}
	if (g > 1) ps.push_back(g);
	vector<int> ans;
	for (int i = 2; i <= N; ++i) {
		if (!isprime(i)) continue;
		vector<long long> poly(i);
		for (int j = 0; j <= N; ++j) {
			if (j % (i - 1) != 0) poly[j % (i - 1)] += A[j];
			else poly[j == 0 ? 0 : i - 1] += A[j];
		}
		bool ok = true;
		for (int j = 0; j < i; ++j) {
			if (abs(poly[j]) % i != 0) {
				ok = false;
				break;
			}
		}
		if (ok) ans.push_back(i);
	}
	for (int i : ps) {
		if (i > N) ans.push_back(i);
	}
	for (int i : ans) {
		cout << i << '\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b)
    {
        printf("a < b\n");
    }
    else if (a > b)
    {
        printf("a > b\n");
    }
    else if (a == b)
    {
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll,int,int,int,int,int,int,int>T;
#define PI 3.14159265358979
const int MAX = 510000;
const int MOD = 1000000007;
//この設定だとn<10^7が限界。maxの０を一個増やせば100msかかるが一桁増やせる。
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll>A(M);
  int use[10]={0,2,5,5,4,5,6,3,7,6};
  rep(i,M){
  	cin>>A[i];
  } 
  string dp[11000];
  rep(i,11000){dp[i]="-";}
  dp[0]="";
  for(int i=0;i<=N;i++){
    if(dp[i]=="-"){continue;}
  	for(auto a:A){
      if(dp[i+use[a]]=="-"){dp[i+use[a]]=dp[i]+(char)(a+'0');continue;}
      string p=dp[i+use[a]];
      string q=dp[i]+(char)(a+'0');
      if(p.size()<q.size()){dp[i+use[a]]=q;}
      else if(p.size()==q.size()){
      	if(p<q){dp[i+use[a]]=q;}
      }
    }
  }
  cout<<dp[N];
} 

Measured memory_bytes: 45056
#include <iostream>

using namespace std;


int main () {
	int max, sum;
	cin >> max >> sum;

	int counter = 0;
	for (int i = 0; i <= max; i++) {
		for (int j = 0; j <= max; j++) {
			if ((0 <= sum - i - j) & (sum - i - j <= max)) counter++;
		}
	}

	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
  
class city{
  public:
  long long id;
  long long P;
  long long X;
  long long Y;
  
  city(){
    id=0;P=0;X=0;Y=0;
  }
};
  
bool cmp_id(const city &a, const city &b)
{
    return a.id < b.id;
}

bool cmp_y(const city &a, const city &b)
{
    return a.Y < b.Y;
}
  
  
int main(){
  long long N,M;
  cin >> N >> M;
  vector<city> cities(M);
  long long i,j;
  for(i=0;i<M;i++){
    long long P,Y;
    cin >> P >> Y;
    cities[i].P=P;
    cities[i].Y=Y;
    cities[i].id=i;
  }
  vector<long long> xs(N,0);
  sort(cities.begin(),cities.end(),cmp_y);
  for(i=0;i<M;i++){
    xs[cities[i].P-1]++;
    cities[i].X = xs[cities[i].P-1];
  }
  sort(cities.begin(),cities.end(),cmp_id);
  for(i=0;i<M;i++){
    printf("%06lld%06lld\n",cities[i].P,cities[i].X);
  }
}


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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	ll T[1000], A[1000], P[1000];

	ll t, a;
	for (ll i = 0; i < N; i++)
	{
		cin >> T[i] >> A[i];

		if (i == 0) {
			t = T[i];
			a = A[i];
		}
		else {
			//ll b = (t - 1) / T[i] + 1;
			//ll c = (a - 1) / A[i] + 1;
			ll b = t / T[i] + (t % T[i] == 0 ? 0 : 1);
			ll c = a / A[i] + (a % A[i] == 0 ? 0 : 1);
			ll k = max(b, c);

			t = k * T[i];
			a = k * A[i];
		}
	}

	cout << t + a << endl;

	return 0;
}
//
//ll N;
//cin >> N;
//ll T[1000], A[1000], P[1000];
//
//ll t, a;
//for (ll i = 0; i < N; i++)
//{
//	cin >> T[i] >> A[i];
//
//	if (i == 0) {
//		P[i] = T[i] + A[i];
//	}
//	else {
//		ll CurrentT = P[i - 1] * T[i - 1] / (T[i - 1] + A[i - 1]);
//		ll CurrentA = P[i - 1] * A[i - 1] / (T[i - 1] + A[i - 1]);
//
//		ll b = CurrentT / T[i] + (CurrentT % T[i] == 0 ? 0 : 1);
//		ll c = CurrentA / A[i] + (CurrentA % A[i] == 0 ? 0 : 1);
//
//		ll k = max(b, c);
//
//		CurrentT = k * T[i];
//		CurrentA = k * A[i];
//
//		P[i] = CurrentT + CurrentA;
//	}
//}
//
//cout << P[N - 1] << endl;

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int mx[1<<18][2];
int fr[1<<18][2];
int ans[1<<18];
int a[1<<18];
void merge(int p,int v,int f)
{
	if(f==fr[p][0]||f==fr[p][1]||f==-1)
		return;
	if(v>mx[p][0])
	{
		mx[p][1]=mx[p][0];
		fr[p][1]=fr[p][0];
		mx[p][0]=v;
		fr[p][0]=f;
	}
	else if(v>mx[p][1])
	{
		mx[p][1]=v;
		fr[p][1]=f;
	}
}
int main()
{
	int n,nn;
	scanf("%d",&n);
	nn=(1<<n);
	for(int i=0;i<nn;i++)
		scanf("%d",&a[i]);
	memset(mx,0,sizeof(mx));
	memset(fr,-1,sizeof(fr));
	for(int i=0;i<nn;i++)
	{
		for(int j=0;j<n;j++)
			if(i&(1<<j))
				for(int k=0;k<2;k++)
					merge(i,mx[i^(1<<j)][k],fr[i^(1<<j)][k]);
		merge(i,a[i],i);
	}
	ans[0]=0;
	for(int i=1;i<nn;i++)
	{
		ans[i]=max(mx[i][0]+mx[i][1],ans[i-1]);
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("aab");
            WillReturn.Add("ccb");
            //6
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1");
            WillReturn.Add("Z");
            WillReturn.Add("Z");
            //3
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("52");
            WillReturn.Add("RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn");
            WillReturn.Add("RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn");
            //958681902
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S1 = InputList[1];
        string S2 = InputList[2];

        int UB_X = S1.Length - 1;
        int UB_Y = 1;

        char[,] BanArr = new char[UB_X + 1, UB_Y + 1];
        for (int LoopX = 0; LoopX <= UB_X; LoopX++) {
            for (int LoopY = 0; LoopY <= UB_Y; LoopY++) {
                if (LoopY == 0) BanArr[LoopX, 0] = S1[LoopX];
                if (LoopY == 1) BanArr[LoopX, 1] = S2[LoopX];
            }
        }

        //横並べをX、縦並べかY、として文字列で持つ
        var HaitiList = new List<char>();
        for (int LoopX = 0; LoopX <= UB_X; ) {
            if (BanArr[LoopX, 0] != BanArr[LoopX, 1]) {
                HaitiList.Add('X');
                LoopX += 2;
            }
            else {
                HaitiList.Add('Y');
                LoopX += 1;
            }
        }

        long Answer = 1;
        for (int I = 0; I <= HaitiList.Count - 1; I++) {
            char CurrHaiti = HaitiList[I];

            if (I == 0) {
                Answer = (CurrHaiti == 'X' ? 6 : 3);
            }
            else {
                char PrevHaiti = HaitiList[I - 1];
                if (PrevHaiti == 'X' && CurrHaiti == 'X') Answer *= 3;
                if (PrevHaiti == 'X' && CurrHaiti == 'Y') Answer *= 1;
                if (PrevHaiti == 'Y' && CurrHaiti == 'X') Answer *= 2;
                if (PrevHaiti == 'Y' && CurrHaiti == 'Y') Answer *= 2;
            }
            Answer %= 1000000007;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  map<char,int>mp;
  REP(i,N){
    string s;
    cin>>s;
    mp[s[0]]++;
  }
  vector<int> nums={0,0,1,1,1};
  vector<char> ch={'M','A','R','C','H'};
  ll ans=0;
  do {
    ll tmp=1;
    for(int i=0;i<5;i++){
      if(nums[i]) tmp*=mp[ch[i]];
    }
    ans+=tmp;
  } while (std::next_permutation(nums.begin(), nums.end()));
  cout<<ans<<endl;
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
g = []
from copy import deepcopy
for i in range(h):
    g.append(list(input()))
def count(g):
    result = 0
    for i in g:
        result += i.count('#')
    return result
ans = 0

for i in range(2 **(h+w)):
    ng = deepcopy(g)
    a = bin(i)[2:].zfill(h+w)
    for i, num in enumerate(a[:h]):
        if num == '1':
            for j in range(w):
                ng[i][j] = 'r'
    for j, num in enumerate(a[h:]):
        if num == '1':
            for i in range(h):
                ng[i][j] = 'r'
    if count(ng) == k:
        ans += 1
print(ans)



Measured memory_bytes: 79048
#include <stdio.h>
#include <set>
#include <utility>
#include <algorithm>
#include <map>

#define lli long long int
#define ll pair<lli, lli>
#define lll pair<lli, ll>
#define llll pair<ll, ll>
#define mp make_pair

using namespace std;

int main() {
	lli x, y, z, k, a[1010], b[1010], c[1010], total, temp;
	llll u;
	set<llll> s;
	set<llll>::iterator it;
	map<lll, bool> peta;
	lll v;
	scanf("%lld %lld %lld %lld", &x, &y, &z, &k);
	for (lli i = 0; i < x; i++)
		scanf("%lld", &a[i]);
	sort(a, a + x);
	for (lli i = 0; i < y; i++)
		scanf("%lld", &b[i]);
	sort(b, b + y);
	for (lli i = 0; i < z; i++)
		scanf("%lld", &c[i]);
	sort(c, c + z);
	total = a[x - 1] + b[y - 1] + c[z - 1];
	s.insert(mp(mp(0, x - 1), mp(y - 1, z - 1)));
	for (lli i = 0; i < k; i++) {
		it = s.begin();
		u = *it;
		s.erase(it);
		temp = u.first.first;
		x = u.first.second;
		y = u.second.first;
		z = u.second.second;
		v = mp(x, mp(y, z));
		if (peta.count(v) > 0) {
			i--;
			continue;
		}
		peta[v] = true;
		printf("%lld\n", total - temp);
		if (x > 0)
			s.insert(mp(mp(temp + a[x] - a[x - 1], x - 1), mp(y, z)));
		if (y > 0)
			s.insert(mp(mp(temp + b[y] - b[y - 1], x), mp(y - 1, z)));
		if (z > 0)
			s.insert(mp(mp(temp + c[z] - c[z - 1], x), mp(y, z - 1)));
	}
	return 0;
}

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

int main(){
  int n, m, sum;
  cin >> n >> m;
  int a[n];
  sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a+n, greater<>());
  bool flag = true;
  for(int i = 0; i < m; i++){
    if(4 * m * a[i] < sum) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> card(n);
  rep(i, n) cin >> card[i];
  sort(card.begin(), card.end(), greater<int>());
  int alice = 0, bob = 0;
  rep(i, n)
  {
    if(i&1) bob += card[i];
    else alice += card[i];
  }
  cout << (alice - bob) << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<bool> check(N);
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    if(a == b) check.at(i) = true;
    else check.at(i) = false;
  }
  
  if(check.at(0) == true &&
     check.at(1) == true &&
     check.at(2) == true){
      cout << "Yes";
      return 0;
  }
  
  for(int i = 0; i < N-3; i++){
    if(check.at(i) == true &&
       check.at(i+1) == true &&
       check.at(i+2) == true){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3624
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);
	auto K = to!ulong(tokens[1]);

	long[] h;
	foreach (token; split(my_readln()))
	{
		h ~= to!long(token);
	}

	ulong[] costs;
	costs.length = N;
	fill(costs, ulong.max);
	costs[0] = 0;
	foreach (i; 0..N)
	{
		foreach (j; 1..K+1)
		{
			if (i + j >= N) break;
			costs[i+j] = min(costs[i+j], costs[i] + abs(h[i] - h[i+j]));
		}
	}

	writeln(costs[N-1]);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    vector<int> n(3);
    cin >> n[0] >> n[1] >> n[2];
    sort(all(n));

    cout << n[0] << ' ' << n[1] << ' ' << n[2] << endl;
}



Measured memory_bytes: 3116