akhauriyash/Code-Regression huggingface dataset:
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : yash1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
# define ll  long long int 
# define TEST int t ; cin>>t; while(t--)
# define line cout<<endl;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define loop(i,a,b) for(long long int i=a;i<b;i++)
# define loopIn(i,a,b) for(long long int i=a;i<=b;i++)
#define MAX_SIZE 10000000
vector<bool> V(MAX_SIZE,false);
int main(){
      ll a,b,c;
      cin>>a>>b>>c;
      if(a+b+c >= 22) cout<<"bust";
      else cout<<"win";
      
      return 0;
}

Measured memory_bytes: 1408
X, N = map(int, input().split())
try:
    P = set((map(int, input().split())))
except:
    print(X)
    exit()
dif = 0
while X - dif in P:
    if not X + dif in P:
            print(X + dif)
            exit()
    dif += 1
print(X - dif)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n;
ll maxi(ll x,ll y)
{
	if(x<y)
		return y;
	else
		return x;
}
int main()
{
	ll k,x,y,z;
	cin>>n;
	vector<vector<ll>>h(n,vector<ll> (3,0));
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i][0]>>h[i][1]>>h[i][2];
	}
	std::vector<std::vector<ll>> dp(n,std::vector<ll> (3,0));
	dp[n-1][0]=h[n-1][0];
	dp[n-1][1]=h[n-1][1];
	dp[n-1][2]=h[n-1][2];
	for (int i = n-2; i >=0; --i)
	{
		dp[i][0]=maxi(dp[i+1][1],dp[i+1][2])+h[i][0];
		dp[i][1]=maxi(dp[i+1][2],dp[i+1][0])+h[i][1];
		dp[i][2]=maxi(dp[i+1][0],dp[i+1][1])+h[i][2];
	}
	sort(dp[0].begin(),dp[0].end());
	cout<<dp[0][2]<<"\n";
}

Measured memory_bytes: 11136
import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	def gcd(A,B):
		if(B != 0):
			A,B=B,A%B
			return gcd(A,B)
		else:
			return A

	def factorization(n):
		arr = []
		temp = n
		for i in range(2, int(-(-n**0.5//1))+1):
			if temp%i==0:
				cnt=0
				while temp%i==0:
					cnt+=1
					temp //= i
				arr.append([i, cnt])
		if temp!=1:
			arr.append([temp, 1])
		if arr==[]:
			arr.append([n, 1])

		return arr

	A,B=max(A,B),min(A,B)
	gc = gcd(A,B)
	if(gc==1):
		print(1)
	else:
		print(len(factorization(gc))+1)

main()

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

int main() {
    int32_t x, y;
    cin >> x >> y;

    int32_t answer;
    if (!x) {
        answer = y >= 0 ? y : -y + 1;
    } else if (!y) {
        answer = x > 0 ? x + 1 : -x;
    } else {
        if (x > 0 && y > 0) {
            answer = x < y ? y - x : x - y + 2;
        } else if (x < 0 && y > 0) {
            answer = y > -x ? x + y + 1 : -x - y + 1;
        } else if (x < 0 && y < 0) {
            answer = x < y ? y - x : x - y + 2;
        } else {
            answer = x >= -y ? x + y + 1 : -x - y + 1;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,n,sum=0;
  
  scanf("%d %d",&a,&b);
  
  for(n=0;n<2;n++){
    if(a>=b){
      sum = sum + a;
      a = a - 1;
    }else{
      sum = sum + b;
      b = b - 1;
    }
  }
  
  printf("%d",sum);
  
  return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = INT_MAX;
  for(int i = k - 1; i < n; ++i){
    int hmax = h[i];
    int hmin = h[i - k + 1];
    ans = min(ans, hmax - hmin);
  }
  cout << ans << endl;
}

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

struct NUM {
	int cnt;
	int m;
	int G[100];
};

int InsertionSort(int A[], int n, int g) {
	int i, v, j, cnt = 0;
	for (i = g; i < n; i++) {
		v = A[i]; j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j]; j = j - g; cnt++;
		}
		A[j + g] = v;
	}
	return cnt;
}

int dev3(int N) {
	int i = 1;
	while (i < N) {
		if (3 * i + 1 > N)break;
		i = 3 * i + 1;
	}
	return i;
}

struct NUM ShellSort(int A[], int n) {
	struct NUM num;
	int cnt = 0;
	int m = 0;
	int G[100];
	for (int i = dev3(n); i > 0; i = (i - 1) / 3) {
		G[m] = i;
		m++;
	}
	for (int i = 0; i < m; i++) {
		cnt += InsertionSort(A, n, G[i]);
	}
	num.cnt = cnt; num.m = m; for (int i = 0; i < m; i++) num.G[i] = G[i];
	return num;
}


int main() {
	int N, A[1000000];
	struct NUM num;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	num = ShellSort(A, N);
	printf("%d\n", num.m);
	for (int i = 0; i < num.m; i++) {
		if (i == num.m - 1) {
			printf("%d\n", num.G[i]);
			break;
		}
		printf("%d ", num.G[i]);
	}
	printf("%d\n", num.cnt);
	for (int i = 0; i < N; i++) {
		printf("%d\n", A[i]);
	}
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

ll calc(ll x){
    ll ans;
    if(x%2==0){
        ans=(x/2)%2==0?0:1;
    }
    else {
        ans=calc(x-1)^(x-1);
    }
    return  ans;
}

int main(){
    ll a,b;cin >>a>>b;
    ll ans=calc(b+1)^calc(a);
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
    char s[220000];
    scanf("%s",s);
    int a,z,t=0;
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='A'&&t==0){a=i;t++;}
        if(s[i]=='Z')z=i;
    }
    printf("%d\n",z-a+1);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,b,a;

  scanf("%d\n",&n);
  if (n ==1){
    printf("Hello World\n");
  }else{
    scanf("%d\n",&a);
    scanf("%d\n",&b);
    printf("%d\n",a+b );
    return 0;
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    string s;
    cin >> s;
    int n =sz(s);
    forn (i, n) {
        forn (j, i) {
            if (s[i] == 'F' && s[j] == 'C') {
                cout << "Yes\n";
                return 0;
            }
        }
    }
                cout << "No\n";
}


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

int main() {
    int hp1, b1, hp2, b2;
    cin >> hp1 >> b1 >> hp2 >> b2;
    bool flag_win = false;
    bool flag_lose = false;

    while (true) {
        hp2 = hp2 - b1;
        if (hp2 <= 0) {
            flag_win = true;
            break;
        }
        hp1 = hp1 - b2;
        if (hp1 <= 0) {
            flag_lose = true;
            break;
        }
    }
    if (flag_win)
        cout << "Yes" << endl;
    if (flag_lose)
        cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
	x = 0; char tmp; bool key = 0;
	for (tmp = gc(); !isdigit(tmp); tmp = gc())
		key = (tmp == '-');
	for (; isdigit(tmp); tmp = gc())
		x = (x << 3) + (x << 1) + (tmp ^ '0');
	if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
	x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
	x = x < y ? y : x;
}

const int N = 3010;
int MOD;

inline void Add(int& x,int y) {
	x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
	x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b,int mod = MOD) {
	int ret = 1;
	while (b) {
		if (b&1) ret = 1ll * ret * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return ret;
}

int dp[N][N], n, comb[N][N], ans;
int main() {
	cin >> n >> MOD;
	rep (i, 0, n) dp[i][0] = 1;
	rep (i, 1, n) rep (j, 1, i) {
		dp[i][j] = 1ll * dp[i-1][j] * (j+1) % MOD;
		Add(dp[i][j], dp[i-1][j-1]);
	}
	rep (i, 0, n) comb[i][0] = 1;
	rep (i, 1, n) rep (j, 1, i)
		comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
	rep (a, 0, n) {
		int sgn = (a&1) ? MOD - 1 : 1;
		sgn = 1ll * sgn * comb[n][a] % MOD;
		sgn = 1ll * sgn * power(2, power(2, n-a, MOD - 1)) % MOD;
		int tmp = 0, val = power(2, n-a), t = 1;
		rep (j, 0, a) {
			Add(tmp, 1ll * dp[a][j] * t % MOD);
			t = 1ll * t * val % MOD;
		}
		sgn = 1ll * sgn * tmp % MOD;
		Add(ans, sgn);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 69632
<?php
  $N = intval(trim(fgets(STDIN)));
  
  $sorted_count = [];
  $ans = 0;
  
  for($i=0; $i<$N; $i++){
    # 文字列をアルファベット順にソートする
    $word = str_split(trim(fgets(STDIN)));
    sort($word);
    
    # 文字列に戻す
    $word = implode($word);
    
    # 既に出てきてる単語かチェック
    if (!array_key_exists($word, $sorted_count)) {
      # なければ初出なので、１個目としてカウント
      $sorted_count[$word] = 1;
    }else {
      # これまで出てきてる個数を答えにふやす。
      $ans += $sorted_count[$word];
      # 出現回数を一つふやす
      $sorted_count[$word] += 1;
    }
  }
  echo $ans;

?>


Measured memory_bytes: 13048
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=300000;
const int MAXM=100000;

int n,m;
int l[MAXN],r[MAXN];

int cnt[MAXM+1];

void inc(int a,int b) {
	if(a<=m) ++cnt[a];
	if(b<=m) --cnt[b+1];
}

void run() {
	scanf("%d%d",&n,&m); REP(i,n) scanf("%d%d",&l[i],&r[i]);
	memset(cnt,0,sizeof(cnt));
	REP(i,n) {
		//printf("processing %d..%d\n",l[i],r[i]);
		int lst=INT_MAX;
		for(int t=1;t*t<=n;++t) {
			int mn=(l[i]+t-1)/t; // (t+1)*mn>=l
			int mx=r[i]/t; // (t+1)*mx<=r
			//printf("\tt=%d => %d..%d\n",t,mn,mx);
			if(mx>=lst) mx=lst-1;
			if(mn<=mx) inc(mn,mx);
			lst=mn;
		}
		for(int x=1;x<lst;++x) {
			int t=r[i]/x; // t*x<=r
			//printf("\tx=%d => %lld\n",x,(ll)t*x);
			if((ll)t*t<=n) break;
			if(t*x>=l[i]) inc(x,x);
		}
	}
	REP(i,m) cnt[i+1]+=cnt[i];
	FORE(i,1,m) printf("%d\n",cnt[i]);
}

int main() {
	run();
	return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int> > ab(M, vector<int>(2));
  for (int i=0; i<M; i++) cin >> ab[i][0] >> ab[i][1];
  sort(ab.begin(), ab.end(), [](auto& x, auto& y){return x[0] < y[0];});
  int ans = 0;
  int minb = 100000000;
  int j = 0;
  for (int i=1; i<=N; i++){
    while((j<M) && (ab[j][0] <= i)){
      minb = min(minb, ab[j][1]);
      j++;
    }
    if (minb == i+1){
      ans++;
      minb = 100000000;
    }
  }
  cout << ans << endl;
}


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

int main(void) {

	char a, b, co;

	cin >> a >> b;

	if (a == 'H') {
		if (b == 'H') co = 0;
		else co = 1;
	}
	else {
		if (b == 'H') co = 1;
		else co = 0;
	}

	if (co == 0) cout << "H" << endl;
	else cout << "D" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll infi=1000000001;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

// ll gcd(ll a,ll b){
//     if(a==0)    return b;
//     gcd(b%a,a);
// }

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

ll bexpo(ll a,ll p){
    ll x=1;
    while(p){
    if(p&1){
        x=(x*a)%MOD;
    }
    a=(a*a)%MOD;
    p>>=1;
    }
    return x;
}
// int dx[8]{-1,0,0,1,-1,-1,1,1};
// int dy[8]{0,-1,1,0,-1,1,-1,1};


int main() {
    fastio
    int t=1;
    // cin>>t;
    ll n,m,i,l,a,b,c,d,bank,s,k,j,x,y,ans,q;

    while(t--){ans=0;
        cin>>n;

       if(n==1) cout<<0; 
       else{
           a=bexpo(10,n);
           b=bexpo(9,n);
           c=bexpo(8,n);
           cout<<(a + c - (2*b)%MOD + MOD)%MOD;
       }
       
    }
    
    
	return 0;
}


Measured memory_bytes: 3648
import numpy as np
n=int(input())
d_i = list(map(int, input().split()))  
d=np.array(d_i)
out=0
for i in range(1,n):
    a=d_i.pop(0)
    d_i.append(a)
    out+=np.dot(d,np.array(d_i))
print(int(out/2))

Measured memory_bytes: 26992
//sumitraj387
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define string str
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
main()
{
   int r;
   cin>>r;
   cout<<3*(r*r);
}


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

using ll = long long;
using ull = unsigned long long;

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

int f(int n, int m, string &a, string &b, vector<vector<int> > &dp) {
	if(n < 0 || m < 0) return 0;
	if(dp[n][m] != -1) return dp[n][m];
	int x = 0;
	if(a[n] == b[m]) {
		x = f(n - 1, m - 1, a, b, dp) + 1;
	} else {
		x = max(f(n - 1, m, a, b, dp), f(n, m - 1, a, b, dp));
	}
	dp[n][m] = x;
	return x;
}

void create(int n, int m, string &a, string &b, vector<vector<int> > &dp, string &ans) {
	if(n < 0 || m < 0) return;
	if(f(n, m, a, b, dp) == max(f(n - 1, m, a, b, dp), f(n, m - 1, a, b, dp))) {
		if(f(n - 1, m, a, b, dp) >= f(n, m - 1, a, b, dp)) {
			create(n - 1, m, a, b, dp, ans);
		} else {
			create(n, m - 1, a, b, dp, ans);
		}
	} else {
		ans += a[n];
		create(n - 1, m - 1, a, b, dp, ans);
	}
}

void solve() {
	string a, b;
	cin >> a >> b;
	int n = a.length(), m = b.length();
	vector<vector<int> > dp(n, vector<int>(m, -1));
	string ans;
	create(n - 1, m - 1, a, b, dp, ans);
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 38932
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a, b, t;

    cin >> a >> b >> t;

    cout << b * (t / a) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

int main(int argc, char **argv){
	int n;
	vector<int> v;
	int begin[] = { 1, 2, 4 };
	while (cin >> n && n > 0){
		v.clear();
		int count = 0;
		if (n <= 3) {
			count = begin[n - 1];
		} else {
			for (int i = 0; i < 3; i++) {
				v.push_back(begin[i]);
			}

			for (int i = 3; i < n; i++) {
				v.push_back(v[i - 3] + v[i - 2] + v[i - 1]);
			}
			count = v.back();
		}
		
		if (count % 3560 == 0) {
			cout << count / 3650 << endl;
		} else {
			cout << count / 3650 + 1 << endl;
		}
	}
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  int a=0;
  std::vector<int> v(26,0);
  for(int i=0;i<s.size();i++)v[(int)s[i]-97]++;
  for(int i=0;i<26;i++)if(v[i]>1)a=1;
  if(a)cout<<"no"<<endl;
  else cout<<"yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
	IOS;
	tihs;

	string s;
	cin>>s;
	ll n=sz(s);
	rep(i,0,n)cout<<"x";






	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, cnt = 0;
    cin >> N;
    vector<int> d(N);
    for (int& i : d) cin >> i;
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

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

int main(void)
{
   cin >> s;
   int n = s.size();
   for (int i = 0; i < n; ++i)
   {
      if (i % 2 == 0)
      {
       //  cout << s[i] << " kisuu" << endl;
         if (s[i] == 'L')
         {
            cout << "No" << endl;
            return 0;
         }
      }
      else
      {
    //     cout << s[i] << " guusuu" << endl;
         if (s[i] == 'R')
         {
            cout << "No" << endl;
            return 0;
         }
      }
   }
   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 256
n = int(input())
csf = [list(map(int, input().split())) for i in range(n-1)]
c,s,f=[],[],[]
for z in csf:
    c.append(z[0])
    s.append(z[1])
    f.append(z[2])
ans = []
t=0
for j in range(n):
    for i in range(j,n-1):
        if t<s[i]:
            t = s[i]
        elif t%f[i]!=0:
            t += f[i]-(t%f[i])
        t+=c[i]
    print(t)
    t=0

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

bool compP(pair<ll, ll> a, pair<ll, ll> b){

  if(a.first != b.first){
    return a.first > b.first;
  }else{
    return a.second > b.second;
  }
}

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

  int N;
  cin >> N;

  vector<pair<ll, ll>> vec(N);

  ll a;
  rep(i, N){
    cin >> a;
    vec[i] = make_pair(a, i+1);
  }
  vec.push_back(make_pair(0, 0));

  sort(vec.begin(), vec.end(), compP);

  vector<ll> ans(N+1);

  ll pre_max = vec[0].first;
  ll pre_ind = vec[0].second;
  ll cnt = 0;
  ll sum_kouho = pre_max;
  ll cnt_kouho = 1;

  for(int i = 1; i <= N; i++){

    if(vec[i].first <= pre_max && vec[i].second < pre_ind){

      ans[pre_ind] = cnt * (pre_max - vec[i].first) + sum_kouho - vec[i].first * cnt_kouho;
      cnt += cnt_kouho;
      sum_kouho = vec[i].first;
      cnt_kouho = 1;
      pre_ind = vec[i].second;
      pre_max = vec[i].first;

    }else{

      cnt_kouho++;
      sum_kouho += vec[i].first;

    }

  }

  for(int i = 1; i <= N; i++){

    cout << ans[i] << endl;

  }

  return 0;
}


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

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            var count = 0;
            var size = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            for (var i = 0; i < size; ++i) {
                var sort = false;
                for (var j = size - 1; j >= i + 1; --j) {
                    if (array[j] < array[j - 1]) {
                        var temp = array[j - 1];
                        array[j - 1] = array[j];
                        array[j] = temp;
                        ++count;
                        sort = true;
                    }
                }

                if (!sort) {
                    break;
                }
            }

            Console.WriteLine(string.Join(" ", array));
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 18308
#include<bits/stdc++.h>
using namespace std;
#define ff      first
#define ss      second
#define ll      long long
#define int     long long
#define ull     unsigned long long
#define mod     1000000007
#define vi      vector<ll>
#define ppi     pair<ll,pair<ll,ll>>
#define pb      push_back
#define mp      make_pair
#define str     string
#define pi      2*acos(0.0)
#define pr(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define p(a)    cout<<a;
#define sp(x,y) fixed<<setprecision(y)<<x
#define w(x)    ll x; cin>>x; while(x--)
#define e       cout<<'\n';
#define all(v)  v.begin(), v.end()
#define test    cout<<"LOL_ABHISHEK"<<endl;
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll k,s;
	cin>>k>>s;
	ll ans=0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			ll x=i+j;
			if((s-x)>=0 and (s-x)<=k){
				ans+=1;
			}
		}
	}
	cout<<ans;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  double N;cin>>N;vector<double> P(N),Q(N);
  rep(i,N)cin>>P[i]>>Q[i];
  vector<double> R(N);
  rep(i,N){
    R[i]=i;
  }

  sort(all(R));
  double cnt=0;
  
  do {
   
      rep(i,N-1){
        cnt+=sqrt( (P[R[i]]-P[R[i+1]])*(P[R[i]]-P[R[i+1]]) +(Q[R[i]]-Q[R[i+1]])*(Q[R[i]]-Q[R[i+1]]));
      }
   
  }while(next_permutation(R.begin(), R.end()));
  pri(cnt/kaijo(N)); 
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define rin(i,n,k) for(int i=0;i<n;i+=k)
//#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=100011;
std::vector<int> adj[maxn];
std::vector<int> v;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn][3];
bool mark[maxn],bpart[maxn];
string s,s1,s2;
map <string ,int> mp;
bool markchaild[maxn];

int32_t main() {
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
          dp[i][j]=max(dp[i][j],dp[i-1][(j+1)%3]+a[i][j]);
          dp[i][j]=max(dp[i][j],dp[i-1][(j+2)%3]+a[i][j]);
        }
    }
    ans=max(dp[n-1][2],max(dp[n-1][0],dp[n-1][1]));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int now=0; // 0-close 1-open
  string user[257];
  string visit[257];
  cin>>n;
  for(int i=0;i<n;i++)cin>>user[i];
  cin>>m;
  for(int i=0;i<m;i++)cin>>visit[i];
 
  for(int i=0;i<m;i++){
    int flag=0;
    for(int j=0;j<n;j++){
      if(user[j]==visit[i]){
	if(now==0){
	  cout<<"Opened by "<<visit[i]<<endl;
	  now=1;
	}else{
	  cout<<"Closed by "<<visit[i]<<endl;
	  now=0;
	}
	flag=1;
      }
    }
    if(!flag){
      cout<<"Unknown "<<visit[i]<<endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1228
N, D = [int(i) for i in input().split()]
xs = [[int(i) for i in input().split()] for _ in range(N)]

res = 0

for i in range(len(xs)):
    for j in range(i):
        d = (sum((xs[i][k] - xs[j][k])**2 for k in range(D)))**0.5
        if d.is_integer(): res+=1

print(res)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

const int INF = 0xfffffff;
const int MAX = 10000;

struct Edge {
	Edge() {};
	Edge(int v, int c) :v(v), c(c) {};
	bool operator < (const Edge& e)const {
		return c > e.c;
	}
	int v;
	int c;
};

int main() {
	int n;
	priority_queue<Edge> graph[MAX];
	vector<Edge> table;
	bool check[MAX] = { false };
	int ary[MAX] = { 0 };

	cin >> n;

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			Edge e;
			cin >> e.v >> e.c;
			graph[u].push(e);
		}
	}

	Edge e(0, 0);
	table.push_back(e);
	check[0] = true;

	for (int i = 1; i < n; i++) {
		Edge minv(0, INF);
		int erase = 0;

		for (int j = 0; j < table.size(); j++) {
			int v = table[j].v;
			int c = table[j].c;	
			while (!graph[v].empty() && check[graph[v].top().v])graph[v].pop();
			if (graph[v].empty())continue;
			if (c + graph[v].top().c < minv.c) {
				minv.c = c + graph[v].top().c;
				minv.v = graph[v].top().v;
				erase = v;
			}
		}
		table.push_back(minv);
		check[minv.v] = true;
		graph[erase].pop();
	}
	
	for (int i = 0; i < n; i++) {
		ary[table[i].v] = table[i].c;
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << ary[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7996
#include<iostream>
#include<cmath>

using namespace std;

long long modsum(long long, long long, long long);
long long modpow(long long, long long, long long);
long long modtime(long long, long long, long long);


int main() {
	int n, k;
	cin >> n >> k;
	const int base = (int)pow(10, 9) + 7;
	long long count = 0;
	long long* kosuu = new long long[k];
	for (int i = 0;i < k;i++) {
		kosuu[i] = 0;
	}
	for (int i = k;i > 0;i--) {
		kosuu[i-1] = modpow(k / i, n, base);
		for (int j = 2*i;j <= k;j+=i) {
			kosuu[i-1] = modsum(kosuu[i-1], -kosuu[j-1], base);
		}
		count = modsum(count, modtime(kosuu[i-1],i,base), base);
	}
	


	cout << count << "\n";
}

long long modsum(long long a, long long b, long long c) {
	if (a < 0)a += c;
	if (b < 0)b += c;
	return (a + b) % c;
}

long long modpow(long long a, long long b, long long c) {
	bool* bin;
	long long ans = 1;
	long long work;
	int n = 0;
	work = b;
	while (work > 0) {
		n++;
		work /= 2;
	}
	bin = new bool[n];
	work = b;
	for (int i = 0;i < n;i++) {
		bin[i] = work % 2;
		work /= 2;
	}
	for (int i = 0;i < n;i++) {
		if (!bin[i])continue;
		work = a;
		for (int j = 0;j < i;j++) {
			work =modtime(work,work,c);
		}
		ans =modtime(ans,work,c);
	}
	return ans;
}

long long modtime(long long a, long long b, long long c) {
	return (a * b) % c;
}




Measured memory_bytes: 7504
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll x, y;
	cin >> x >> y;
	ll n;
	cin >> n;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		if (x <= a and a < y) {
			cout << 1 << endl;
			return 0;
		}
		if (x < b and b <= y) {
			cout << 1 << endl;
			return 0;
		}
		if (y <= b and a <= x) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}



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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        string s; cin >> s;
        set<char> st;
        for (int i = 0; i < s.length(); ++i)
        {
                st.insert(s[i]);
        }
        char res = '0';
        for (int i = 0; i < 26; ++i)
        {
                if (st.find('a' + i) == st.end()) 
                {
                        res = (char)('a' + i);
                        break;
                }
        }
        if (res == '0') cout << "None";
        else cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3748
N = int(input())
C = [0]*4
for i in range(N):
  M = input()
  if M == "AC":
    C[0] += 1
  elif M == "WA":
    C[1] += 1
  elif M == "TLE":
    C[2] += 1
  elif M == "RE":
    C[3] += 1
    
print("AC x " + str(C[0]))
print("WA x " + str(C[1]))
print("TLE x " + str(C[2]))
print("RE x " + str(C[3]))


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

using ll=long long;
const ll z=0;

int main() {
  string S,p="";
  cin >> S;
  string str="";
  int ans=0;
  for(int i=0;i<S.size();i++){
    str +=S[i];
    if(p!=str){
      p=str;
      ans++;
      str="";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
<?php
  $input=explode(' ',trim(fgets(STDIN)));
  $K=intval($input[0]);
  $X=intval($input[1]);   //A,B,Cそれぞれを$a,$b,$cに格納

          if((1 <= $K)&&(100 >= $K)&&(0 <= $X)&&(100 >= $X)){
            $p = $X + $K;     //$sはAとBの和
            $q = $X - $K;     //$sはAとBの差
            $a = $K + 1;
            $b = $K - 1;
            for ($i=1; $i<$a; $i++){
              $r = $q + $i;
                echo $r.' ';
              } 
            for ($i=$b; $i>=1; $i--){
              $s = $p - $i;
                echo $s.' ';
              } 
            
          }
?>


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for(int i=2;i<n;i++){
    if(s[i]=='C'&&s[i-1]=='B'&&s[i-2]=='A') count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifndef MY_ALGORITHM
typedef long long ll;
template<typename T>
struct UnionFind
{
    vector<T> parents;
    vector<T> rank;
    UnionFind(T n);
    T root(T x);
    bool unite(T x, T y);
    bool same(T x, T y);
};
#endif

template<typename T>
UnionFind<T>::UnionFind(T n):parents(n),rank(n,0){
        for (T i=0;i<n;i++){
            parents[i] = i;
        }
    }


template<typename T>
T UnionFind<T>::root(T x){
        //再帰的に根をつけなおす//rootを返す
        return parents[x] == x ? x: parents[x] = root(parents[x]);
}

template<typename T>
bool UnionFind<T>::unite(T x, T y){
        if (x==y) return false;
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        parents[y] = x;
        return true;
}

template<typename T>
bool UnionFind<T>::same(T x, T y){
        if (x==y) return true;
        return root(x) == root(y);
}


void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, std::vector<long long> D){
    UnionFind<int> group(N);
    vector<int> block_count(N,0);
    for (int i=0;i<M;i++){
        group.unite(A[i]-1,B[i]-1);
    }
    for (int i=0;i<K;i++){
         if (group.same(C[i]-1,D[i]-1)){
             block_count[C[i]-1] -=1;
             block_count[D[i]-1] -=1;
         } 
    }
    for (int i=0;i<M;i++){
         if (group.same(A[i]-1,B[i]-1)){
             block_count[A[i]-1] -=1;
             block_count[B[i]-1] -=1;
         } 
    }
    map<int,int> counter;
    for (int i=0;i<N;i++){
        int p = group.root(i);
        if (counter.count(p)==0){
            counter.insert(make_pair(p,1));
        }else{
            counter[p]+=1;
        }
    }
    for (int i=0;i<N;i++){
        printf("%d",counter[group.root(i)] + block_count[i]-1);
        if (i<N-1) printf(" ");
    }
    printf("\n");

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, M, K, std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


Measured memory_bytes: 9344
#include<iostream>
#include<set>
using namespace std;
multiset<int> mys;
int main(){
  int N,K;
  cin>>N>>K;
  for(int i=0; i<N; i++){
    int t;
    cin>>t;
    mys.insert(t);
  }
  int sum=0;
  for(int i=0; i<K; i++){
    sum+=*(mys.begin());
    mys.erase(mys.begin());
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------

//F9でブレークポイントを付ける
/*
void _main() {
	int N[5], k;
	string answer = "Yay!";
	cin >> N[0] >> N[1] >> N[2] >> N[3] >> N[4] >> k;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; i < 4; i++) {
			int distance;
			if (N[i] > N[j]) {
				distance = N[i] - N[j];
			}
			else {
				distance = N[j] - N[i];
			}
			if (distance > k) {
				answer = ":(";
			}
		}
	}
	cout << answer << endl;
}
*/

void _main() {
	int a, b, c, d, e, k;
	string answer = "Yay!";
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k) {
		answer = ":(";
	}
	cout << answer << endl;
}

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

int main()
{
    int N; cin >> N;
    vector<int> C(13);
    C[0] = 1;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        C[d]++;
    }
    if (any_of(C.begin(), C.end(), [](int c){return c>=3;}) || C[0]==2 || C[12]==2) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for (int b = 0; b < (1<<12); b++) {
        vector<int> D;
        for (int i = 1; i <= 11; i++) {
            if (C[i] == 2) {
                D.push_back(i);
                D.push_back(24-i);
            } else if (C[i] == 1) {
                if (b & (1 << i)) {
                    D.push_back(24-i);
                } else {
                    D.push_back(i);
                }
            }
        }
        if (C[12] > 0) D.push_back(12);
        D.push_back(24);
        sort(D.begin(), D.end());
        vector<int> diffs(D.size());
        adjacent_difference(D.begin(), D.end(), diffs.begin());
        int mi = *min_element(diffs.begin(), diffs.end());
        ans = max(ans, mi);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(a,b,c)
print(ans)

Measured memory_bytes: 69560
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[][] a = new long[n][2];

		for (int i = 0; i < n; ++i) {
			a[i][0] = sc.nextLong();
			a[i][1] = i;
		}
		// 値の降順にソート
		Arrays.sort(a, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				if (o1[0] != o2[0]) {
					return -Long.compare(o1[0], o2[0]);
				} else {
					return Long.compare(o1[1], o2[1]);
				}
			}
		});
		long[] cnt = new long[n];
		int s = 0, t = 0;
		while (true) {
			if (s == n)
				break;
			while (t != n && a[s][1] <= a[t][1]) {
				++t;
			}
			cnt[(int) a[s][1]] += (a[s][0] - (t == n ? 0 : a[t][0])) * s;
			// [s:t-1]の範囲だけ考えれば良い
			for (int i = t - 1; i >= s; --i) {
				cnt[(int) a[s][1]] += (a[i][0] - (t == n ? 0 : a[t][0]));
			}
			s = t;
		}
		PrintWriter pw=new PrintWriter(System.out);
		for (int i = 0; i < cnt.length; ++i) {
			pw.println(cnt[i]);
		}
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int r = 0; R*r <= N; ++r) {
    for (int g = 0; G*g <= N; ++g) {
      int _R = R * r;
      int _G = G * g;
      int _B = (N - _R - _G);
      if (_B % B == 0 && _B >= 0 && _R + _G + _B == N) ++ans;
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INT_MAX 1000000000
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  int h[n+1];
  h[0] = 0;
  int ans[n+1] = {0};
  
  for(int i = 1; i <= n; ++i)
  {
    cin >> h[i];
    if(i == 1)
    {
        ans[1] = 0;
    }
    else if(i == 2)
    {
        ans[2] = abs(h[2]-h[1]);
    }
    else
    {
        ans[i] = min(ans[i-1]+abs(h[i-1]-h[i]), ans[i-2]+abs(h[i-2]-h[i])); 
    }
  }
  cout << ans[n];
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << endl;
}

Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n;cin>>n;
	string s;cin>>s;
	ll ans=1,f[26]={0};
	for(ll i=0;i<n;i++)f[s[i]-'a']++;
	for(ll i=0;i<26;i++){
		ans=ans*(f[i]+1)%hell;
	}
	cout<<(hell+ans-1)%hell<<endl;
}

Measured memory_bytes: 512
n = int(input())
t = [0]
x = [0]
y = [0]
for i in range(n):
    t_tmp, x_tmp, y_tmp = map(int, input().split())
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

r_init = [0, 0]
parity = 0 # 偶数
for i in range(1, n+1):
    t_diff = t[i] - t[i-1]
    x_diff = abs(x[i] - x[i-1])
    y_diff = abs(y[i] - y[i-1])
    d_diff = x_diff + y_diff

    if d_diff > t_diff:
        print('No')
        exit()
    
    if (x[i] + y[i]) % 2 == 0:
        current_parity = 0
    else:
        current_parity = 1

    
    if t_diff % 2 == 0:
        # パリティ同じ
        if current_parity != parity:
            print('No')
            exit()
    else:
        # パリティ違う
        if current_parity == parity:
            print('No')
            exit()

    parity = current_parity
    

print('Yes')

Measured memory_bytes: 11768
import sys

def comb(sum,c,s):
	if c>1:
		val=0
		for i in range(s,10):
			if sum-i>0:
				val+=comb(sum-i,c-1,i+1);
		return val
	else:
		return 1 if sum>=s and sum<10 else 0

while True:
	c,sum=map(int,raw_input().split(" "))
	if c:
		print comb(sum,c,0)
	else:
		break

Measured memory_bytes: 4212