akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,h[200001];
  cin >> N >> K;
  REP(i,N)cin >> h[i];
  sort(h,h+N);
  int res=INF_INT;
  REP(i,N-K+1){
    res = min(h[K-1+i]-h[i],res);
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int ans = 700;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') {
            ans += 100;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

def euc(a,b):
    x = a*b
    if(a<b):
        t = b
        b = a
        a = t
    
    r = a%b
    while(r!=0):
        a = b
        b = r
        r = a%b
    
    return int(x/b)

w = euc(C,D)
    
nc = B//C-(A-1)//C
nd = B//D-(A-1)//D
ncd = B//w-(A-1)//w

nb = B - B//C - B//D + B//w
na = (A-1) - (A-1)//C - (A-1)//D + (A-1)//w

n = nc + nd - ncd

print(B - A + 1 - n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dp[100010],n,a[100010];
int solve(int i)
{
  if(i==n-1)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=0;
  if(i+1<n)
    m=abs(a[i]-a[i+1]);
  if(i+2<n)
  m=min(abs(a[i]-a[i+1])+solve(i+1),abs(a[i]-a[i+2])+solve(i+2));
  return dp[i]=m;
}
int main()
{
  memset(dp,-1,sizeof(dp));
  cin>>n;
  for(int i=0;i<=n;i++)
    cin>>a[i];
  cout<<solve(0)<<"\n";
  return 0;
}

Measured memory_bytes: 7376
N,M = map(int,input().split())
price = sorted([ [int(x) for x in input().split()] for _ in range(N)])

cnt = 0
cost = 0

for arr in price:
  p,n = arr
  if n+cnt <= M:
    cost+=p*n
    cnt+=n
  else:
    cost+=(M-cnt)*p
    break
    
print(cost)
  




Measured memory_bytes: 22376
#include <stdio.h>

typedef struct {
	int cur;
	int n;
	int s;
	int e;
	int w;
} Dice;

typedef enum {
	POSITIVE,
	NEGATIVE
} ROLL_DIR;

void v_index_change(int *cur, int *a, int *b)
{
	int tmp = *cur;
	*cur = *a;
	*b = tmp;
	*a = 7 - tmp;
}

void h_index_change(int *p1, int *p2, int *p3, int *p4)
{
	int tmp = *p1;
	*p1 = *p4;
	*p4 = *p3;
	*p3 = *p2;
	*p2 = tmp;
}

void v_roll(int num, char dir, Dice *dice)
{
	int i;
	for (i = 0; i < num; i++) {
		if (dir == 'N') {
			v_index_change(&dice->cur, &dice->s, &dice->n);
		}
		else if (dir == 'S') {
			v_index_change(&dice->cur, &dice->n, &dice->s);
		}
		else if (dir == 'E') {
			v_index_change(&dice->cur, &dice->w, &dice->e);
		}
		else if (dir == 'W') {
			v_index_change(&dice->cur, &dice->e, &dice->w);
		}
	}
}

void h_roll(char sp, int num, ROLL_DIR dir, Dice *dice)
{
	int i;
	for (i = 0; i < num; i++) {
		if (sp == 'N') {
			if (dir == POSITIVE) {
				h_index_change(&dice->n, &dice->w, &dice->s, &dice->e);
			}
			else if (dir == NEGATIVE) {
				h_index_change(&dice->n, &dice->e, &dice->s, &dice->w);
			}
		}
		else if (sp == 'S') {
			if (dir == POSITIVE) {
				h_index_change(&dice->s, &dice->e, &dice->n, &dice->w);
			}
			else if (dir == NEGATIVE) {
				h_index_change(&dice->s, &dice->w, &dice->n, &dice->e);
			}
		}
		else if (sp == 'E') {
			if (dir == POSITIVE) {
				h_index_change(&dice->e, &dice->n, &dice->w, &dice->s);
			}
			else if (dir == NEGATIVE) {
				h_index_change(&dice->e, &dice->s, &dice->w, &dice->n);
			}
		}
		else if (sp == 'W') {
			if (dir == POSITIVE) {
				h_index_change(&dice->w, &dice->s, &dice->e, &dice->n);
			}
			else if (dir == NEGATIVE) {
				h_index_change(&dice->w, &dice->n, &dice->e, &dice->s);
			}
		}
	}
}

int main(int argc, char** argv)
{
	Dice dice;
	int i, j, num[6], q, up, front, up_ind, front_ind;

	for (i = 0; i < 6; i++) {
		scanf("%d", &num[i]);
	}

	scanf("%d", &q);

	for (i = 0; i < q; i++) {
		scanf("%d %d", &up, &front);

		for (j = 0; j < 6; j++) {

			if (num[j] == up) {
				up_ind = j + 1;
			}
			else if (num[j] == front) {
				front_ind = j + 1;
			}
		}

		dice.cur = 1;
		dice.n = 5;
		dice.s = 2;
		dice.e = 3;
		dice.w = 4;

		if (up_ind == dice.cur) {
		}
		else if (up_ind == dice.n) {
			v_roll(1, 'S', &dice);
		}
		else if (up_ind == dice.s) {
			v_roll(1, 'N', &dice);
		}
		else if (up_ind == dice.e) {
			v_roll(1, 'W', &dice);
		}
		else if (up_ind == dice.w) {
			v_roll(1, 'E', &dice);
		}
		else {
			v_roll(2, 'S', &dice);
		}

		if (front_ind == dice.n) {
			h_roll('S', 2, POSITIVE, &dice);
		}
		else if (front_ind == dice.e) {
			h_roll('S', 1, NEGATIVE, &dice);
		}
		else if (front_ind == dice.w) {
			h_roll('S', 1, POSITIVE, &dice);
		}

		printf("%d\n", num[dice.e - 1]);
	}

	return 0;
}

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

int n, h[155];

double dp[155][305];

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) cin >> h[i];
	
	for (int i=0; i<=n; ++i) for (int p=0; p<305; ++p) dp[i][p] = -1;
	
	dp[0][1] = 0;
	for (int i=0; i<n; ++i) for (int p=1; p<305; ++p) {
		if (dp[i][p] < 0) continue;
		
		for (int q=1; q<305; ++q) {
			double add = 0;
		
			if (p <= h[i] && q <= h[i]) {
				add = h[i] - (p + q) / 2.0;
			}
			
			if (p > h[i] && q > h[i]) {
				int a = p - h[i];
				int b = q - h[i];
				add = (a + b) / 2.0;
			}
			
			if (p <= h[i] && q > h[i]) {
				int a = h[i] - p;
				int b = q - h[i];
				add = (double)(a * a + b * b) / (2 * (a + b));
			}
			
			if (p > h[i] && q <= h[i]) {
				int a = p - h[i];
				int b = h[i] - q;
				add = (double)(a * a + b * b) / (2 * (a + b));
			}
			
			if (dp[i+1][q] < 0) dp[i+1][q] = dp[i][p] + add;
			else dp[i+1][q] = min(dp[i+1][q], dp[i][p] + add);
		}
	}
	
	double ans = 1e9;
	for (int p=1; p<305; ++p) ans = min(ans, dp[n][p]);
	printf("%.9f\n", ans);
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define tc(t)  int t; cin>>t; while(t--) 
#define f(n)    for(int i=0;i<n;i++)

#define endl   "\n" 


void i_o_f()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
       freopen("give_input.txt", "r", stdin);
    freopen("give_output.txt", "w", stdout);
#endif
}



  int  miniumum_cost(int *arr,int n,int i,int *dp)
   {

            if(i==0) return 0;
            if(i==1) return abs(arr[1]-arr[0]);
            
         
             if(dp[i]!=-1) return dp[i];
            int small_ans1=miniumum_cost(arr,n,i-1,dp);
            int small_ans2=miniumum_cost(arr,n,i-2,dp);
            int c_v1=abs(arr[i]-arr[i-1]);
            int c_v2=abs(arr[i]-arr[i-2]);
             dp[i]= min(c_v1+small_ans1,c_v2+small_ans2);
      return dp[i];




               




   }





int32_t main()
{
	int n;
  cin>>n;
  int*arr=new int[n];
  for(int i=0;i<n;i++) cin>>arr[i];
        int *dp=new int[n];
        for(int i=0;i<n;i++) dp[i]=-1;
    cout<<miniumum_cost(arr,n,n-1,dp)<<endl;





}

Measured memory_bytes: 9600
from collections import defaultdict as dd
from itertools import count
N, K = map(int, input().split())
Cnt = dd(lambda:0)
for _ in range(N):
    a, b = map(int, input().split())
    Cnt[a] += b

num = 0
for i in count(1,1):
    num += Cnt[i]
    if num >= K:
        print(i)
        break

Measured memory_bytes: 21728
//JSD
#include<iostream>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define ll long long 
using namespace std;
ll calc(ll a,ll c){
	return (a/c);
}
int main(){
	ll n;
	cin>>n;
	vector<pair<ll ,ll > > v;
	for(ll i=0;i<n;i++){
		ll p,q;
		cin>>p>>q;
		v.push_back({q,p});
	}
	sort(v.begin(),v.end());
	ll left=v[0].first-v[0].second,prev=0;;
	bool res=1;
	if(left<0) res=0;
	for(ll i=1;i<n;i++){
		left+=(v[i].first-v[i-1].first);
		if(v[i].second<=left){
			left-=v[i].second;
			prev=i;
		}
		else{
			res=0;
		}
	}
	if(res){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	return  0;
}


Measured memory_bytes: 6512
import { readFileSync } from "fs";

const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]/);
  let count = 0;
  const cin = () => inputs[count++];
  return [cin, () => Number(cin()), () => BigInt(cin())];
})() as [() => string, () => number, () => bigint];

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

const getName = (n: bigint): string => {
  const alphabets = range(26).map((i) => String.fromCharCode("a".charCodeAt(0) + i));
  const getName = (n: bigint, l: bigint): string => {
    const m = 26n ** l;
    return n <= m
      ? range(l).reduce(
          ({ num, str }, _) => ({
            num: num / 26n,
            str: alphabets[Number(num % 26n)] + str,
          }),
          { num: n - 1n, str: "" }
        ).str
      : getName(n - m, l + 1n);
  };
  return getName(n, 1n);
};

{
  const N = biCin();
  console.log(getName(N));
}


Measured memory_bytes: 29616
s = input()
ans = 0
now = s[0]
MAX = 1
n = 1
for i in s[1:]:
  if now != i:
    if i == ">":
      ans += n*(n-1)//2
      MAX = n
    else:
      ans += n*(n-1)//2 + max(MAX,n)
      MAX = 1
    n = 1
    now = i
  else:
    n += 1

MAX = max(MAX,n)
ans += n*(n-1)//2 + max(MAX,n)
print(ans)
  

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

int main(){
    int n;cin>>n;
    vector<int>p(n);
    vector<int>q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
 int ans1=0;
 int ans2=0;
     do{
   ans1++;
 
  }while(next_permutation(p.begin(),p.end()));

  do{
   ans2++;
 
  }while(next_permutation(q.begin(),q.end()));
cout<<abs(ans1-ans2);
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std; 
int main()
{
    int A,B,C,D;
    int a,b;
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>D;
    if(A>B) a=B;else a=A;
    if(C>D) b=D;else b=C;
    cout<<a+b;
    return 0;
}

Measured memory_bytes: 256
def next_permutation(case):
    for index in range(1, len(case)):
        Px_index = len(case) - 1 - index
        # Start travelling from the end of the Data Structure
        Px = case[-index - 1]
        Px_1 = case[-index]

        # Search for a pair where latter the is greater than prior
        if Px < Px_1:
            suffix = case[-index:]
            pivot = Px
            minimum_greater_than_pivot_suffix_index = -1
            suffix_index = 0

            # Find the index inside the suffix where ::: [minimum value is greater than the pivot]
            for Py in suffix:
                if pivot < Py:
                    if minimum_greater_than_pivot_suffix_index == -1 or \
                            suffix[minimum_greater_than_pivot_suffix_index] >= Py:
                        minimum_greater_than_pivot_suffix_index = suffix_index
                suffix_index += 1
            # index in the main array
            minimum_greater_than_pivot_index = minimum_greater_than_pivot_suffix_index + Px_index + 1

            # SWAP
            temp = case[minimum_greater_than_pivot_index]
            case[minimum_greater_than_pivot_index] = case[Px_index]
            case[Px_index] = temp

            # Sort suffix
            new_suffix = case[Px_index + 1:]
            new_suffix.sort()

            # Build final Version
            new_prefix = case[:Px_index + 1]
            next_permutation = new_prefix + new_suffix
            return next_permutation
        elif index == (len(case) - 1):
            # This means that this is at the highest possible lexicographic order
            return False


s = input()
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) != 26:
    used = [False] * 26
    for i in range(len(s)):
        used[ord(s[i]) - ord("a")] = True
    for i in range(26):
        if used[i] is False:
            s += chr(ord("a") + i)
            print(s)
            break
else:
    dat = []
    for i in range(len(s)):
        dat.append(ord(s[i]) - ord("a"))
    #print(dat)
    #print(next_permutation(dat))
    dat = next_permutation(dat)
    res = ""
    t = "".join(list(map(lambda x: chr(ord("a") + x), dat)))
    for i in range(26):
        print(t[i], end="")
        if s[i] != t[i]:
            break
    print("")



Measured memory_bytes: 62256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y) {
  if(x>y) swap(x,y);
	if (y % x == 0) return x;
	else return gcd(y%x, x);
}

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = a[0];
	for (int i = 0; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  ll a, b;
  int k;
  cin >> a >> b >> k;
  ll la, ra, lb, rb;
  la = a;
  ra = min(a + k, b);
  lb = max(ra, b - k + 1);
  rb = b;
  for(int i = la; i < ra; i++) cout << i << endl;
  for(int i = lb; i < rb; i++) cout << i << endl;
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000000;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll s;
  cin>>s;
  cout<<"0 0 1000000000 1 "<<(MOD-s%MOD)%MOD<<' '<<(s+(MOD-s%MOD)%MOD)/MOD<<endl;
}

Measured memory_bytes: 256
n, m = map(int, raw_input().split())
a = []
cnt = 0
for _ in range(m):
  c, d = map(int, raw_input().split())

  if c >= n:
    cnt += 1
  else:
    a.append(c)

a.sort(reverse=True)

ans = 0
for i in range(m-1-cnt):
  ans += n-a[i]

print ans

Measured memory_bytes: 6460
#include<bits/stdc++.h>
#define SC scanf
using namespace std;

int tong[200001];
bool you[200001];

int main()
{
	int n,m,x,y,ans = 0;
	scanf("%d %d",&n,&m);
	for(int i = 1; i <= n; i++) tong[i] = 1;
	you[1] = true;
	for(int i = 1; i <= m; i++)
	{
		SC("%d %d",&x,&y);
		if(you[x])
		{
			if(tong[x] == 1)
			{
				tong[x]--;
				you[x] = false;
				tong[y]++;
				you[y] = true;
			}
			else
			{
				tong[x]--;
				tong[y]++;
				you[y] = true;
			}
		}
		else
		{
			tong[x]--;
			tong[y]++;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(you[i]) ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();

        long[] c = new long[100001];
        for (int i = 0 ; i < n ; i++) {
            int a = sc.nextInt();
            c[a] += sc.nextLong();
        }
        long t = 0;
        for (int i = 1 ; i <= 100000 ; i++) {
            t += c[i];
            if (t >= k) {
                System.out.println(i);
                return;
            }
        }
    }

}

Measured memory_bytes: 65728
#include <algorithm>
#include  <iterator>
#include  <iostream>
#include   <cstring>
#include   <cstdlib>
#include   <iomanip>
#include    <bitset>
#include    <cctype>
#include    <cstdio>
#include    <string>
#include    <vector>
#include     <stack>
#include     <cmath>
#include     <queue>
#include      <list>
#include       <map>
#include       <set>
#include   <cassert>

using namespace std;
#define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue



typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 bll;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
typedef pair<int,pii> p3;
typedef pair<ll,int>pli;
//priority_queue<int> q;//这是一个大根堆q
//priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
#define fi first
#define se second
//#define endl '\n'

#define OKC ios::sync_with_stdio(false);cin.tie(0)
#define FT(A,B,C) for(int A=B;A <= C;++A)  //用来压行
#define REP(i , j , k)  for(int i = j ; i <  k ; ++i)
#define max3(a,b,c) max(max(a,b), c);
#define min3(a,b,c) min(min(a,b), c);
//priority_queue<int ,vector<int>, greater<int> >que;

const ll mos = 0x7FFFFFFF;  //2147483647
const ll nmos = 0x80000000;  //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f; //18
const int mod = 1e9+9;
const double esp = 1e-8;
const double PI=acos(-1.0);
const double PHI=0.61803399;    //黄金分割点
const double tPHI=0.38196601;


template<typename T>
inline T read(T&x){
    x=0;int f=0;char ch=getchar();
    while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
    while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x=f?-x:x;
}
/*-----------------------showtime----------------------*/
            const int maxn = 1e5+9;
            pll  a[maxn];
int main(){
            int n;
            scanf("%d", &n);
            for(int i=1; i<=n; i++)
            {
                int u,v;
                scanf("%d%d", &u, &v);
                a[i].fi = u + v;
                a[i].se = u;
            }
            sort(a +1, a+1+n);
            ll res = 0,flag = 1;
            for(int i=n; i>=1; i--){
                if(flag) {
                    res += a[i].se;
                    flag = 0;
                }
                else {
                    res += a[i].se - a[i].fi;
                    flag = 1;
                }

            }
            cout<<res<<endl;
            return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  int res = 0;
  for(int i = 1;i <= sqrt(m) + 1;i++){
    if(m % i == 0 && i <= m / n)res = max(res,i);
    if(m % i == 0 && m / i <= m / n)res = max(res,m / i);
  }
  if(n == 1)res = m;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main(){ 
  int K;
  string S;
  cin >> K >> S;
  
  if(S.size() <= K){
  cout << S << endl;
  }
  else if(S.size() > K){
    for(int i=0;i<K;i++){
  cout << S.at(i);
  }
    cout << "..." << endl;
  }
 }


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

using namespace std;

const int MaxN = 100005;

int n, m;
vector<int> adj[MaxN];
int Pd[MaxN], Count[MaxN];
queue<int> q;

void BFS(int x)
{
    Pd[x] = 0;
    q.push(x);
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (auto v : adj[u])
        {
            Count[v]--;
            if (Count[v] == 0)
            {
                q.push(v);
                Pd[v] = u;
            }
        }
        
    }
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    int u, v;
    for (int i = n+m-1; i > 0; i--)
    {
        cin >> u >> v;
        Count[v]++;
        adj[u].push_back(v);
    }
    int Root = -1;
    for (int i = 1; i <= n; i++)
    {
        if (Count[i] == 0)
        {
            Root = i;
            break;
        }
    }
    BFS(Root);
    for (int i = 1; i <= n; i++)
    {
        cout << Pd[i] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int n;
    cin >> n;
    vector<int>a(n);
    int mx = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mx = max(mx,a[i]);
    }
    sort(a.begin(),a.end());
    int ABS = INF;
    int ans = 0;
    for(int i = n-2; i >= 0; i--) {
        if(abs(mx/2-a[i]) < ABS) {
            ABS = abs(mx/2-a[i]);
            ans = i;
        }
    }
    cout << mx << " " << a[ans] << endl;
}


Measured memory_bytes: 4036
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
const int maxn = 1e6;
 

ll  n ,m ,res;

int main(){FAST;
          
    cin >> n >> m;
    if(n > m)swap(n ,m);

    if(n == 1 && m == 1)
        return cout << 1 ,0;
    else if(n == 1)
        return cout << m - 2 ,0;

        res = (m - 2) * (n - 2);

        cout << res;
   return 0;
}
 












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

int main(){
	
  int a,b;
  cin>>a>>b;
  int s= a+b;
  int d=a-b;
  int m=a*b;
  
  int f=max(s,d);
  cout<<max(f,m)<<"\n";

}

Measured memory_bytes: 256
"use strict";
function main(input) {
  const args = input.split('\n');
  const vars = args[0].split(' ');
  let a = parseInt(vars[0], 10);
  let b = parseInt(vars[1], 10);
  let c = parseInt(vars[2], 10);
  const k = parseInt(args[1], 10);
  for (let i = 0; i < k; i++) {
    if (a > b && a > c) {
      a *= 2;
    } else if (b > a && b > c) {
      b *= 2;
    } else {
      c *= 2;
    }
  }
  console.log(a + b + c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		long n = Long.parseLong(input);
		int len = input.length();
		int max = 0;

		if(len == 1){
			max = (int)n;
		}
		else {
			int numOf9 = 0;

			for(int i = 1; i < len; i++){
				if(input.charAt(i) == '9'){
					numOf9++;
				}
			}

			if(numOf9 == len - 1){
				max = (int)(input.charAt(0) - '0') + 9 * (len - 1);
			}
			else {
				max = (int)(input.charAt(0) - '0') - 1 + 9 * (len - 1);
			}

		}
//		for(int i = 1; i <= n; i++){
//			int num = i;
//
//			int tmpSum = 0;
//			while(num > 0){
//				tmpSum += num%10;
//				num /= 10;
//			}
//
//			max = Math.max(max, tmpSum);
//		}

		System.out.println(max);
	}

}


Measured memory_bytes: 21332
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <cctype>

using namespace std;

const int64_t INF=10000000000000000;
int main(){
    int32_t a,b;
    cin>>a>>b;
    if(a>=13){
        cout<<b<<endl;
    }else if(a>=6){
        cout<<b/2<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> pi;
const int inf=(1ll<<31)-1;
const double INF=1e12,EPS=1e-9;

int h, w, q, H, W, W_;
int y1, x1, y2, x2, *g, sz;
 
int rec(int Y1, int X1, int Y2, int X2, int y, int x){
	if(y2 <= Y1 || y1 >= Y2 || x2 <= X1 || x1 >= X2) return inf;
	if(y1 <= Y1 && Y2 <= y2 && x1 <= X1 && X2 <= x2) return g[y*W_ + x];
	int res = inf;
	 
	//if(y < 0 || x < 0) assert(0);
	if(Y1+1 == Y2)
		res = min(res,
			min(
				rec(Y1, X1, Y2, (X1+X2) / 2, y, x*2 + 1),
				rec(Y1, (X1+X2) / 2, Y2, X2, y, x*2 + 2)
			));
	else if(X1+1 == X2)
		res = min(res,
			min(
				rec(Y1, X1, (Y1+Y2) / 2, X2, y*2 + 1, x),
				rec((Y1+Y2) / 2, X1, Y2, X2, y*2 + 2, x)
			));
	else{
		res = min(res,
			min(
				rec(Y1, X1, (Y1+Y2) / 2, (X1+X2) / 2, y*2 + 1, x*2 + 1),
				rec((Y1+Y2) / 2, X1, Y2, (X1+X2) / 2, y*2 + 2, x*2 + 1)
			));
		res = min(res,
			min(
				rec(Y1, (X1+X2) / 2, (Y1+Y2) / 2, X2, y*2 + 1, x*2 + 2),
				rec((Y1+Y2) / 2, (X1+X2) / 2, Y2, X2, y*2 + 2, x*2 + 2)
			));
	}
	return res;
}
 
int main(){
	g = NULL;
	while(scanf("%d%d%d", &h ,&w, &q), w){
		for(H = 1; H < h; H *= 2);
		for(W = 1; W < w; W *= 2);
		W_ = 2*W - 1;
		if(sz < (2*H-1) * (2*W-1)){
			sz = (2*H-1) * (2*W-1);
			g = (int*) realloc(g, sizeof(int) * sz);
		}
		rep(i, (2*H-1) * (2*W-1)) g[i] = inf;
		rep(i,h) rep(j,w)
			scanf("%d", g + (i+H-1) * W_ + j+W-1);
		for(int i = 2*H - 2; i >= 0; i--){
			for(int j = 2*W - 2; j >= 0; j--){
				if(i < H-1 && j < W-1)
					g[i*W_ + j] = min(min(g[(i*2+1) * W_ + j*2 + 1], g[(i*2+2) * W_ + j*2+2]),
						min(g[(i*2+2) * W_ + j*2+1], g[(i*2+1) * W_ + j*2+2]));
				if(i < H-1) 
					g[i*W_ + j] = min(g[i*W_ + j], min(g[(i*2+1) * W_ + j], g[(i*2+2) * W_ + j]));
				if(j < W-1)
					g[i*W_ + j] = min(g[i*W_ + j], min(g[i*W_ + j*2+1], g[i*W_ + j*2+2]));
			}
		}
		rep(i, q){
			scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
			y2++; x2++;
			printf("%d\n", rec(0, 0, H, W, 0, 0));
		}
	}
	if(g) free(g);
	return 0;
}

Measured memory_bytes: 0
use std::io;
use std::io::Result;
use std::cmp::min;

fn main() -> Result<()> {
    let mut s = String::new();
    let ls = io::stdin().read_line(&mut s)? - 1;
    let mut t = String::new();
    let lt = io::stdin().read_line(&mut t)? - 1;

    let mut m = 1001;
    for i in 0..= (ls - lt) {
        let mut res = 0;
        for (x, y) in t.chars().zip(s[i..i+lt].chars()) {
            if x != y {
                res += 1;
            }
        }
        m = min(m, res);
    }
    println!("{}", m);

    Ok(())
}

Measured memory_bytes: 2168
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n;
ll E, T;

ll a[300000];
int S;

ll it[300000];
ll d[300000];
ll e[300000];

void update(int x)
{
	for(x/=2;x>0;x/=2) it[x]=min(it[x*2], it[x*2+1]);
}

ll getmin(int x, int y)
{
	ll mi=MAX2;
	while(x <= y)
	{
		if(x%2 == 1) mi=min(mi, it[x++]);
		if(y%2 == 0) mi=min(mi, it[y--]);
		x/=2, y/=2;
	}
	return mi;
}

int main()
{
	int i, j, k, l;
	cin>>n>>E>>T;
	for(i=0;i<n;i++) scanf("%lld", &a[i]);
	for(S=1;S<n;S*=2);
	d[0]=a[0]+T;
	e[0]=0-2*a[0]-0;
	for(i=1;i<n;i++)
	{
		ll u=a[i]-T/2;
		int x=lower_bound(a, a+n, u)-a;
		d[i]=MAX2;
		if(x > 0) d[i]=min(d[i], e[x-1]+3*a[i]);
		d[i]=min(d[i], getmin(S+x, S+i-1)+a[i]+T);
		d[i]=min(d[i], d[i-1]+a[i]-a[i-1]+T);
		e[i]=min(e[i-1], d[i-1]-2*a[i]-a[i-1]);
		it[S+i]=d[i-1]-a[i-1];
		update(S+i);
	}
	cout<<d[n-1]+E-a[n-1]<<endl;
	return 0;
}
//*/

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

int main() {
	double a, b, c, d, e, f, x, y;

	while (cin >> a >> b >> c >> d >> e >> f) {
		y = (c * d - f * a) / (b * d - e * a);
		x = (c - b * y) / a;
		cout << fixed;
		cout << setprecision(3) << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define N 100005
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n,m,ans;
struct node {
	int a,b;
	bool operator <(const node &c)const {
		return b>c.b;
	}
} k[N];
int fa[N];
int gf(int k) {
	return fa[k]==k?fa[k]:fa[k]=gf(fa[k]);
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++)fa[i]=i;
	for(int i=1; i<=n; i++)scanf("%d%d",&k[i].a,&k[i].b);
	sort(k+1,k+1+n);
	for(int i=1; i<=n; i++) {
		if(k[i].a>m)continue;
		int f=gf(m-k[i].a+1);
		if(f==0)continue;
		ans+=k[i].b;
		fa[f]=f-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1408
S=input()
length=len(S)
ans='NO'
if S[0:7]=='keyence':
    ans='YES'
elif S[-7:]=='keyence':
    ans='YES'
elif S[0]=='k' and S[-6:]=='eyence':
    ans='YES'
elif S[0:2]=='ke' and S[-5:]=='yence':
    ans='YES'
elif S[0:3]=='key' and S[-4:]=='ence':
    ans='YES'
elif S[0:4]=='keye' and S[-3:]=='nce':
    ans='YES'
elif S[0:5]=='keyen' and S[-2:]=='ce':
    ans='YES'
elif S[0:6]=='keyenc' and S[-1:]=='e':
    ans='YES'

print(ans)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a.at(i);
        a.at(i)--;
    }

    map<ll, ll> mp;
    ll count = 0;

    ll curr = 0;
    mp[curr] = 0;

    while (true) {
        curr = a[curr];
        count++;
        if (count == k) {
            cout << curr + 1 << endl;
            return 0;
        }
        if (mp.count(curr)) {
            break;
        }
        mp[curr] = count;
    }

    ll loop_begin = curr;
    ll loop = count - mp[loop_begin];

    k = k - mp[loop_begin];
    k = k % loop;

    curr = loop_begin;
    for (int i = 0; i < k; i++) {
        curr = a[curr];
    }

    cout << curr + 1 << endl;
}


Measured memory_bytes: 14808
import sys
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if  4*h*n > N*n + N*h and  (N*h*n) % (4*h*n - N*n - N*h) == 0:
            print(str(h) + " " + str(n) + " " + str((N*h*n)//(4*h*n - N*n - N*h) ))
            sys.exit()

Measured memory_bytes: 3064
n, p = map(int, input().split())
a = list(map(lambda x: x & 1, map(int, input().split())))

b, c = a.count(1), a.count(0)
d = 2 ** b // 2  * 2 ** c 
if p == 1:
    print(d)
else:
    print(2 ** n - d)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



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

    int H, W, A, B; cin >> H >> W >> A >> B; H--; W--;
    make();
    ll all = comb(W+H, W);
    rep(i,B) {
		ll part = comb( H - A + i,  i );
		ll part2 = comb( W - i + A - 1, A - 1 );
		all -= part * part2 % MOD;
		if(all < 0) all += MOD;
	}


    cout << all << endl;
    
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
static const int INFTY=2147483647;
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 300005
int n,color[MAX],d[MAX];
vector <pair<int,int> > adj[MAX];
void dijkstra(int s,int t){
    priority_queue <pair<int,int> > PQ;
    d[3*s]=0;
    color[3*s]=GRAY;
    PQ.push(make_pair(0,3*s));
    while(!PQ.empty()){
        pair<int,int> f=PQ.top();
        PQ.pop();
        int u=f.second;
        color[u]=BLACK;
        if(d[u]<f.first*(-1)) continue;

        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }
    cout<<(d[3*t]==INFTY ? -1:d[3*t]/3)<<endl;
}
int main(){
    int u,v,s,t,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        adj[3*(u-1)].push_back(make_pair(3*(v-1)+1,1));
        adj[3*(u-1)+1].push_back(make_pair(3*(v-1)+2,1));
        adj[3*(u-1)+2].push_back(make_pair(3*(v-1),1));
    }
    for(int i=0;i<3*n;i++){
        color[i]=WHITE;
        d[i]=INFTY;
    }
    cin>>s>>t;
    dijkstra(s-1,t-1);
    return 0;
}

Measured memory_bytes: 18944
/*
 * FileName:     D
 * CreatedDate:  2020-04-12 22:07:32 +0900
 * LastModified: 2020-04-12 22:36:42 +0900
 */

#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    long int r_c=0,g_c=0,b_c=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r_c++;
        }
        else if(s[i]=='G'){
            g_c++;
        }
        else{
            b_c++;
        }
    }
    long int all_c=r_c*g_c*b_c;
    for(int i=0;i<n;i++){
        for(int loop=1;i+2*loop<n;loop++){
//            printf("%c,%c,%c\n",s[i],s[i+loop],s[i+2*loop]);
            if( (int)s[i]+(int)s[i+loop]+(int)s[i+2*loop]==219 ){
                all_c--;
            }
        }
    }
    printf("%ld\n",all_c);
    return 0;
}


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

int main()
{
	int a,b;
	cin >> a >> b;
	int f1 = 0,f2 = 0;
	if(a % 2 == 1)
		f1 = 1;
	if(b % 2 == 1)
		f2 = 1;
	if(f1*f2)
		cout<<"Odd"<<endl;
	else
		cout<<"Even"<<endl;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a, b;
	float c;
	scanf("%d %d", &a, &b);
	c = (a + b) / 2.0;
	if(c - ((a + b) / 2) < 0.5)
	{
		printf("%d\n", (a + b) / 2);
	}
	else
	{
		printf("%d\n", ((a + b) / 2) + 1);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a, b, c;
cin>>a>>b;
if((a!=1)&&(b!=1))
{
if((a*b)%2==0)
cout<<(a*b)/2;
else
cout<<((a*b)/2)+1;
}
else
cout<<1;
return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int x[2], y[2];
    cin >> x[0] >> x[1] >> y[0] >> y[1];
    int ans = -INF;
    rep(i, 2) {
        rep(j, 2) {
            chmax(ans, x[i] * y[j]);
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main() {
	
	int n;
	int *elm;
	int sum,total;
	
	while(cin>>n,n){
		
		elm = new int[n*n];
		
		for(int i=0;i<n*n;++i){
			cin >> elm[i];
		}
		
		
		
		for( int i=0;i<n;++i){
			sum = 0;
			for(int j=0;j<n;++j){
				cout << setw(5) << elm[j+i*n];
				sum += elm[j+i*n];
			}
			cout << setw(5) << sum;
			cout << endl;
		}
		
		total = 0;
		for(int i=0;i<n;++i){
			sum = 0;
			for(int j=0;j<n;++j){
				sum += elm[j*n+i];
			}
			cout<<setw(5)<<sum;
			total += sum;
		}
		cout<<setw(5)<<total<<endl;
		delete[]elm;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define MAX 1000000
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

int main()
{
	int n;
  	cin >> n;
	vector<int> a(n);
	vector<int> check((n+1)/2);
	bool even = (n%2 == 0) ? true: false;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(even &&( a[i]%2 == 0) || (!even) &&(a[i] %2 == 1)) {
			cout << 0 << endl;
			return 0;
		}
		check[a[i]/2]++;
	}
	if((!even) && check[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < check.size(); i++) {
		if((!even) && i== 0)
			continue;
		if(check[i] != 2) {
			cout << 0 << endl;
			return 0;
		}
	}
	long count = 1;
	for(int i = 0; i < n/2; i++) {
		count *= 2;
		count %= (long)1E9+7;
	}
	cout << count << endl;
	
	
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>

int main()
{
	int d;

	while(std::cin >> d)
	{
		int s = 0;

		for(int i=0;i<(600/d);++i)
		{
			s+=(i*d)*(i*d)*d;
		}

		std::cout << s << '\n';
	}
}

Measured memory_bytes: 1160
N=int(input())
h=list(map(int, input().split()))
dp=[10000000000000]*(N+2)
#初期状態
dp[0]=0
#配るDP
for i in range(N):
    try:
        dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    except IndexError:
        pass
    try:
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    except IndexError:
        pass
print(dp[N-1])

Measured memory_bytes: 84852
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
ll kol[N];
ll sum = 0;
void solve () {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		ll x;
		cin >> x;
		kol[x] ++;
		sum += x;
	}
	int q;
	cin >> q;
	while (q --) {
		ll x, y;
		cin >> x >> y;
		sum -= kol[x] * x;
		sum += kol[x] * y;
		kol[y] += kol[x];
		kol[x] = 0;
		cout << sum << endl;
	}

}   	

 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 4400
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f;
struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};
const int MAX_V=10010;
int V,dist[MAX_V],prevv[MAX_V],preve[MAX_V];
vector<edge> G[MAX_V];
void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}
int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill(dist,dist+V,INF);
        dist[s]=0;
        bool update=1;
        while(update){
            update=0;
            for(int v=0;v<V;v++){
                if(dist[v]==INF)continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=1;
                    }
                }
            }
        }
        if(dist[t]==INF)return -1;
        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            d=min(d,G[prevv[v]][preve[v]].cap);
        }f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d; 
        }
    }return res;
}
void clear(){for(int i=0;i<V;i++)G[i].clear();}
const int MAX_N=120; 
int N,M;
int in[MAX_N],out[MAX_N],tot;
void solve(){
    int s=N,t=N+1;V=t+1;tot=0;
    clear();
    memset(in,0,sizeof(in));
    memset(out,0,sizeof(out));
    for(int i=0;i<M;i++){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        add_edge(x,y,INF,-z);
        out[x]++;in[y]++;
        tot+=z;
    }int max_f=0;
    for(int i=0;i<N;i++){
        if(in[i]>out[i]){
            add_edge(s,i,in[i]-out[i],0);
            max_f+=in[i]-out[i];
        }else{
            add_edge(i,t,out[i]-in[i],0);
        }
    }min_cost_flow(0,N-1,1);
    add_edge(N-1,0,INF,-dist[N-1]);
    printf("%d\n",min_cost_flow(s,t,max_f)-tot);
}
int main(){
     while(~scanf("%d%d",&N,&M)){
         solve();
     }return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
main() {
  int a[10];
  for(int i=0;i<10;i++) scanf("%d",&a[i]);
  sort(a,a+10,greater<int>());
  printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int sumE[n + 1] = {}, sumW[n + 1] = {};
    rep(i, 0, n) {
        if (s[i] == 'E') {
            sumE[i + 1] += sumE[i] + 1;
            sumW[i + 1] = sumW[i];
        }
        if (s[i] == 'W') {
            sumE[i + 1] = sumE[i];
            sumW[i + 1] += sumW[i] + 1;
        }
    }

    int ans = INF;
    rep(i, 1, n + 1) {
        int sum = 0;
        sum += sumW[i - 1];
        sum += sumE[n] - sumE[i];
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
import sys
input = sys.stdin.readline
MOD = 10**9 + 7


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


N = int(input())
ans = 1
for prime in primes(N):
    count = 0
    for i in range(1, N + 1):
        while not i % prime:
            count += 1
            i /= prime

    ans *= (count + 1)

print(ans % MOD)


Measured memory_bytes: 3188