akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    ll D;
    cin>>N;
    D = N%10;
    N /= 10;
    C = N%10;
    N /= 10;
    B = N%10;
    N /= 10;
    A = N%10;
    ll ans;
    rep(i,8){
        ll temp = A+B+C+D;
        if(i&1) temp -= B*2;
        if((i>>1)&1) temp -= C*2;
        if((i>>2)&1) temp -= D*2;
        if(temp == 7){
            ans = i;
            break;
        }
    }
    cout<<A<<(ans&1 ? '-' : '+')<<B<<((ans>>1)&1 ? '-' : '+')<<C<<((ans>>2)&1 ? '-' : '+')<<D<<"=7"<<endl;
}

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

signed main(){
  int n,k;cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=k;i<n;i++){
    cout<<(v[i]>v[i-k]?"Yes":"No")<<endl;
  }

}


Measured memory_bytes: 4056
n, k = map(int, input().split())
dat_h = []
for i in range(n):
    dat_h.append(int(input()))
dat_h.sort(reverse=True)
res = 100000000000
for i in range(n-k+1):
    res = min(res, dat_h[i] - dat_h[i+k-1])
print(res)

Measured memory_bytes: 7384
import collections

def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]

        B.append(T)
    c = collections.Counter(B)

    for i in range(len(c)):
        k, v = c.popitem()
        for z in range(v):
            count += z

    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)

Measured memory_bytes: 44252
N,T=map(int,input().split())
a=list(map(int,input().split()))
max_profit=0
mini=a[0]
for i in range(1,N):
    max_profit=max(max_profit,a[i]-mini)
    mini=min(mini,a[i])
#print(max_profit)
mini=a[0]
ans=0
for i in range(1,N):
    if a[i]-mini==max_profit:
        ans+=1
    mini=min(mini,a[i])
print(ans)


Measured memory_bytes: 14244
input = gets.chomp.split(" ")
stack = []
input.each do |e|
    if e == "+"
        nums = stack.pop(2)
        stack.push(nums[0] + nums[1])
    elsif e == "-"
        nums = stack.pop(2)
        stack.push(nums[0] - nums[1])
    elsif e == "*"
        nums = stack.pop(2)
        stack.push(nums[0] * nums[1])
    else
        stack.push(e.to_i)
    end
end

puts stack[0]


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

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const ll inf = 2e18;

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

	int n, w; cin >> n >> w;
	ll v[n], c[n]; rep(i, 0, n) cin >> c[i] >> v[i];

	ll dp[n + 1][w + 1];
	rep(x, 0, w + 1) dp[0][x] = 0;
	rep(i, 0, n) {
		rep(x, 0, w + 1) dp[i + 1][x] = dp[i][x];
		rep(x, c[i], w + 1)
				ckmax(dp[i + 1][x], dp[i][x - c[i]] + v[i]);
	}
	cout << dp[n][w];
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int total = 0;
		char c = line.charAt(0);
		for (int i = 1; i < line.length(); i++) {
			if (c != line.charAt(i)) {
				c = line.charAt(i);
				total++;
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 10964
#include <iostream>

using namespace std;

int main() {
	int X, Y, Z;

	cin >> X >> Y >> Z;

	int ans = 1;
	X -= Y + 2 * Z;
	while (X >= Y + Z) {
		ans++;
		X -= Y + Z;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;

    int A[m];
    for(int i=0; i<m; i++){
        cin >> A[i];
    }

    int total = 0;

    for(int i=0; i<m; i++){
        total = total + A[i];
    }

    if(n-total >= 0){
        cout << n-total << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3676
s = input()

cnt_max = 0

for i in range(len(s)):
    cnt = 0
    for j in range(i, len(s)):
        if s[j]!="A" and s[j]!="T" and s[j]!="C" and s[j]!="G":
            break
        cnt += 1
    if cnt_max < cnt:
        cnt_max = cnt

print(cnt_max)

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

using namespace std;
int main(int argc, char **argv)
{
    int n;
    cin>>n;
    vector<double> vec;
    double value;
    for(int i = 0 ; i < n;i++){
        cin>>value;
        vec.push_back(value);
    }
    sort(vec.begin(),vec.end());
    value = vec[0];
    
    for(int i = 1 ;i < vec.size();i++){
        value+=vec[i];
        value/=2;
    }
    
    cout<<value;

	return 0;
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);rep(i,N)cin>>A.at(i);


    vec_int numCount(N+1,0);

    rep(i,N){
        numCount.at(A.at(i))++;
    }

    int tot = 0;
    rep(i,N+1){
        tot+=(numCount.at(i)*(numCount.at(i)-1))/2;
    }

    rep(i,N){
        int temp = ((numCount.at(A.at(i)))*(numCount.at(A.at(i))-1))/2;
        int temp2 = ((numCount.at(A.at(i))-1)*(numCount.at(A.at(i))-2))/2;
        cout<<tot-temp+temp2<<endl;
    }




    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vi>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define mod             1000000007
#define inf             1e18
#define deb(x)          cout << #x << "=" << x << '\n';
#define ps(x,y)         fixed<<setprecision(y)<<x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n,ww,w,v, dp[100001];

void solve() {

    cin >> n >> ww;

    memset(dp, 0, ww+1);
    for(int i=0; i<n; i++) {
        cin >> w >> v;

        for(int j=ww; j>=w; j--) {
            dp[j] = max(dp[j-w]+v, dp[j]);
        }
    }
    cout << dp[ww];
}

int32_t main() {
    FIO;
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N; cin >> N;
    vector<int> A(N);
    map<int,int> M;
    rep(i, N) {
        cin >> A[i];
        M[i-A[i]]++;
    }

    ll sum = 0;
    rep(i,N) {
        if (M.count(i+A[i]) > 0) sum += M[i+A[i]];
    }
    cout << sum << endl;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int> p(n), c(n);
	REP(i, n) cin >> p[i];
	REP(i, n) p[i]--;
	REP(i, n) cin >> c[i];

	ll maxi = -1e18;
	REP(i, n) {
		ll score = c[i];
		vector<ll> t;
		t.push_back(score);
		for (int j = p[i]; j != i; j = p[j]) {
			score += c[j];
			t.push_back(score);
		}
		int len = t.size();
		REP(j, len) {
			ll rest = k - j - 1;
			if (rest < 0) break ;
			maxi = max(maxi, t[j] + (rest/len) * max(score, 0LL));
		}
	}

	cout << maxi << '\n';
    return 0;
}


Measured memory_bytes: 3792
#include<stdio.h>

int main(void) {
    
    // 変数定義
    int n;
    int array[100] = {};
    int i, j, minj, count, flag;

    // 入力の読み込み
    scanf("%d", &n);

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

    // 選択ソート
    count = 0;
    flag = 0;
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            // 配列要素の中で最小値を見つけ、indexをminjに保持
            if (array[j] < array[minj]) {
                minj = j;
            }
        }

        if (minj != i) {
            // 要素を交換する
             int tmp = array[i];
            array[i] = array[minj];
            array[minj] = tmp;

            // 交換回数をカウントアップ
            count++;
        }
    }

    // 結果を表示
    for (i = 0; i < n; i++) {
        printf("%d", array[i]);
        if (i != (n-1)) printf(" ");
    }
    printf("\n%d\n", count);

    return 0;
}



Measured memory_bytes: 2092
#include<stdio.h>
char s[5];
int main(void){
  scanf("%s",&s);
  int a=s[0]-'0';
  int b=s[1]-'0';
  int c=s[2]-'0';
  int d=s[3]-'0';
  if(a-b-c-d==7){
    printf("%d-%d-%d-%d=7",a,b,c,d);
  }else if(a-b-c+d==7){
    printf("%d-%d-%d+%d=7",a,b,c,d);
  }else if(a-b+c-d==7){
    printf("%d-%d+%d-%d=7",a,b,c,d);
  }else if(a-b+c+d==7){
    printf("%d-%d+%d+%d=7",a,b,c,d);
  }else if(a+b-c-d==7){
    printf("%d+%d-%d-%d=7",a,b,c,d);
  }else if(a+b-c+d==7){
    printf("%d+%d-%d+%d=7",a,b,c,d);
  }else if(a+b+c-d==7){
    printf("%d+%d+%d-%d=7",a,b,c,d);
  }else if(a+b+c+d==7){
    printf("%d+%d+%d+%d=7",a,b,c,d);
  }
  return 0;
}

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

int main(void)
{
	int a,b;
	int d,r;
	double f;
	
	cin >> a >> b;
	
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	
	cout << d << " " << r << " " << std::fixed << f << endl;
	
	return 0;
}


Measured memory_bytes: 3288
#include<stdio.h>
#include <stdbool.h>

int main(){
  int n= 0;
  bool judge = false;
  scanf("%d",&n);
  if(n%10 == 7){
     judge = true;
  }
  if(n/100 ==7){
     judge = true;
  }
  if((n/10)%10 == 7){
     judge = true;
  }
  if(judge){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}
    

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n,0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    long long comfort = 0;
    for (int i = 0; i < n; i++) {
        if (i == 1) {
            comfort += a[i-1];
        }
        if (i > 1) comfort += a[i/2];
    }
    cout << comfort;
}


Measured memory_bytes: 4760
#include<iostream>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define MAX 12
#define INFTY (1<<21)
int W, L[MAX], n;

double getL(int r1, int r2){
    double d = r1 - r2;
    return sqrt((r1+r2)*(r1+r2)-d*d);
}

void compute(){
    double T[1<<MAX][MAX];
    rep(i, 1<<n) rep(j, n) T[i][j] = INFTY;
    rep(i, n) T[1<<i][i] = L[i]*2;
    rep(i, 1<<n) rep(j, n) rep(l, n){
	if ( (1<<l) & i ) continue;
	T[(1<<l)|i][l] = min(T[(1<<l)|i][l], T[i][j] - L[j] + L[l] + getL(L[j], L[l]));
    }
    double minv = INFTY;
    rep(i, n) minv = min(minv, T[(1<<n)-1][i]);
    if ( minv > W ) cout << "NA" << endl;
    else cout << "OK" << endl;
}

main(){
    string line;
    int l;
    while( getline(cin, line) && !cin.eof() ){
	stringstream sin(line);
	n = 0;
	sin >> W; 
	while( sin >> l ) L[n++] = l;
	compute();
    }
}

Measured memory_bytes: 1308
#include <bitset>
#include <cstdio>
#include <cstdlib>

using namespace std;
const int Max_N(1050);

int N, Head[Max_N], Total, To[Max_N], Next[Max_N], X[Max_N], Y[Max_N];

inline void Add_Edge(const int &s, const int &t)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total;
}

inline void GG()
{
	puts("IMPOSSIBLE"), exit(0);
}

bitset<5050> F;
void dfs(const int &u)
{
	for (int i = Head[u];i;i = Next[i])
		dfs(To[i]);
	F.reset(), F.set(0);
	int Sum(0);
	for (int i = Head[u], v;i;i = Next[i])
		v = To[i], F = ((F << X[v]) | (F << Y[v])), Sum += X[v] + Y[v];
	for (int i = X[u];i >= 0;--i)
		if (F[i])
		{
			Y[u] = Sum - i;
			goto loop;
		}
	GG();
	loop :
	;
}

int main()
{
	scanf("%d", &N);
	for (int i = 2, fa;i <= N;++i)
		scanf("%d", &fa), Add_Edge(fa, i);
	for (int i = 1;i <= N;++i)
		scanf("%d", X + i);
	dfs(1);
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=100005;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, x, L, R, dp[2][3005];
	string s;
	cin>>n>>s;
	dp[1][1]=1;
	rep(len,2,n+1){
		vector<ll> pref(n+2,0);
		x=len&1;
		rep(i,1,len+1){
			pref[i]=add(pref[i-1],dp[x^1][i]);
			dp[x][i]=0;
		}
		rep(j,1,len+1){
			if(s[len-2]=='<'){
				L=1;
				R=j-1;
			} else {
				L=j;
				R=len-1;
			}
			dp[x][j]=add(dp[x][j],add(pref[R],hell-pref[L-1]));
		}
	}
	ll ans=0;
	rep(i,1,n+1)ans=add(ans,dp[n&1][i]);
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int n, a;

int main(){
    cin >> n >> a;

    cout << n * n - a << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

q, h,s,d, = map(int, input().split())

n = int(input())
ans = 0

qqqq = q*4
hh = h*2

best1 = min(qqqq,hh,s)

if n ==1:
    print(best1)
    exit()

if d >= best1*2:
    print(n*best1)
    exit()


else:
    d_ = n//2
    n -= d_*2
    ans += d*d_
    ans += n*best1
    print(ans)


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

class prog{
  static void Main(){
    
   int N = int.Parse(Console.ReadLine());
    int[] d = new int [N];
    for(int i = 0; i < N; i++){
      d[i] = int.Parse(Console.ReadLine());
    }
    
    int ans = d.Distinct().Count();
    Console.WriteLine(ans);
    
  }
}

Measured memory_bytes: 13152
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
inline int Inv(int x){
	return modpow(x,mod-2,mod);
}
int fact[110005],inv[110005];
inline ll C(int n,int m){
	return fact[n]*inv[m]%mod*inv[n-m]%mod;
}
inline ll get(int items,int sum){
	return C(items+sum-1,items-1);
}
signed main(){
	fact[0]=1;inv[0]=1;
	for(int i=1;i<=1e5+50;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=1;i<=1e5+50;i++)inv[i]=Inv(fact[i]);
	int n,m;
	cin>>n>>m;
	int ans=1;
	for(int i=2;i*i<=m;i++){
		int cnt=0;
		while(m%i==0){
			cnt++;m/=i;
		}
//		cerr<<cnt<<" "<<get(n,cnt)<<endl;
		if(cnt)(ans*=(ll)get(n,cnt))%=mod;
	}
	if(m!=1)(ans*=(ll)get(n,1ll))%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

//var dp []int = make([]int, n)

//func fib(n int) int {
//	dp[0] = 0
//	dp[1] = 1
//	for i := 2; i <= n; i++ {
//		dp[i] = dp[i-1] + dp[i-2]
//	}
//	return dp[n]
//}

func line(ii []int, bn []int) []int {
	var res []int = ii
	for i := 0; i < len(ii); i++ {
		for j := 0; j < len(bn); j++ {
			if ii[i] == bn[j] {
				fmt.Println("hit" + fmt.Sprint(ii[i]))
				if i == len(ii)-1 {
					res = ii[:i]
				} else {
					res = append(ii[:i], ii[i+1:]...)
				}
			}
		}
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt()
	b := nextInt()
	r := nextInt()
	bunch := n / (b + r)
	other := n % (b + r)
	if other > b {
		other = b
	}
	res := bunch*b + other

	fmt.Fprint(out, res)
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=4000+10;
struct EDGE {
	int to,nxt;
}e[maxn];
int n,m;
int tot=1,Ans;
int head[maxn],cnt[maxn],U[maxn],V[maxn],vis[maxn],Vis[maxn];
vector<int>Edge[maxn],Path[maxn];

inline void file() {
	freopen("AGC025E.in","r",stdin);
	freopen("AGC025E.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline void add(int from,int to) {
	e[++tot]=(EDGE){to,head[from]}; head[from]=tot;
	e[++tot]=(EDGE){from,head[to]}; head[to]=tot;
}

int dfs(int u,int fa,int t,vector<int>& E) {
	if (u==t) return 1;
	for (int i=head[u];i!=0;i=e[i].nxt) {
		int v=e[i].to;
		if (v==fa) continue;
		E.push_back(i);
		if (dfs(v,u,t,E)) return 1;
		E.pop_back();
	}
	return 0;
}

int main() {
//	file();
	n=read(); m=read();
	For (i,1,n-1) {
		int x=read(),y=read(); add(x,y);
	}
	For (i,1,m) {
		U[i]=read(); V[i]=read();
		dfs(U[i],0,V[i],Edge[i]);
		For (j,0,Edge[i].size()-1)
			++cnt[Edge[i][j]/2],Path[Edge[i][j]/2].push_back(i);
	}
	For (i,1,n-1) Ans+=min(2,cnt[i]);
	while (1) {
		int p=0;
		For (j,1,n-1)
			if (cnt[j]==1 && vis[j<<1]^vis[j<<1|1]) {
				p=vis[j<<1]?j<<1|1:j<<1; break;
			}
		if (!p) {
			For (j,1,n-1)
				if (cnt[j]) {
					p=vis[j<<1]?j<<1|1:j<<1; break;
				}
			if (!p) break;
		}
		int q=p/2;
		while (Vis[Path[q].back()]) Path[q].pop_back();
		int E=Path[q].back(),flag=0;
		Vis[E]=1;
		For (i,0,Edge[E].size()-1)
			if (Edge[E][i]/2==q) flag=(Edge[E][i]==p);
		if (!flag) {
			swap(U[E],V[E]);
			For (i,0,Edge[E].size()-1) Edge[E][i]^=1;
		}
		For (i,0,Edge[E].size()-1)
			--cnt[Edge[E][i]/2],vis[Edge[E][i]]=1;
	}
	printf("%d\n",Ans);
	For (i,1,m) printf("%d %d\n",U[i],V[i]);
	return 0;
}

Measured memory_bytes: 15744
import sys
input = sys.stdin.readline
from collections import deque

N, M = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
out_deg = [0]*N
for x, y in xy:
    graph[y-1].append(x-1)
    out_deg[x-1] += 1


dp = [0]*N
stack = deque([i for i in range(N) if out_deg[i]==0])
while stack:
    node = stack.popleft()
    for child in graph[node]:
        dp[child] = max(dp[child], dp[node]+1)
        out_deg[child] -= 1
        if out_deg[child] == 0:
            stack.append(child)
    
print(max(dp))

Measured memory_bytes: 42804
n=gets.to_i
s=gets.chomp
a=[0];b=[0]
n.times{|i|
a.push a[-1]+(s[i]==?W ? 1 : 0)
b.unshift b[0]+(s[n-i-1]==?E ? 1 : 0)
}
p (n+1).times.map{|i|a[i]+b[i]}.min

Measured memory_bytes: 10212
#include <stdio.h>

int main(void){
    int a[5],last,t,flag;
    last=9;
    t=0;
    flag=0;
    for(int i=0; i<5; i++){
        scanf("%d",&a[i]);
        
        if(a[i]%10==0){
            t+=a[i];
            flag++;
        }
        else{
            t+=a[i]+(10-a[i]%10);
            if(a[i]%10<last%10)
                last=a[i];
        }
    }
    if(flag==5)
        printf("%d",t);
    else
        printf("%d",t-(10-last%10));
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
  int N,X,T;
  cin >> N >> X >> T;
  int num = N/X;
  int res = N%X;
  if(res == 0){
    cout << T * num << endl;
  }else{
    cout << T * (num+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
n=int(input())
L=lambda:list(map(int,input().split()))
a,b,c=L(),L(),L()
s=b[a[0]-1]
for i in range(1,n):
  s+=b[a[i]-1]
  if a[i-1]+1==a[i]:s+=c[a[i]-2]
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
main()
{
	unsigned long long x,y,a,b,c,i,p,s=0;
	vector<unsigned long long>red,grn,no;
	cin>>x>>y>>a>>b>>c;
	for(i=0;i<a;i++){
		cin>>p;
		red.pb(p);
	}
	for(i=0;i<b;i++){
		cin>>p;
		grn.pb(p);
	}
	for(i=0;i<c;i++){
		cin>>p;
		no.pb(p);
	}
	sort(red.begin(),red.end(),greater<unsigned long long>());
	sort(grn.begin(),grn.end(),greater<unsigned long long>());
	sort(no.begin(),no.end(),greater<unsigned long long>());
	vector<unsigned long long>ans(no.begin(),no.end());
	for(i=0;i<y;i++){
		ans.pb(grn[i]);
	}
	for(i=0;i<x;i++){
		ans.pb(red[i]);
	}
	sort(ans.begin(),ans.end(),greater<unsigned long long>());
	for(i=0;i<x+y;i++) s+=ans[i];
	cout<<s<<'\n';
}

Measured memory_bytes: 7140
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int ans=0;
  int n;
  cin>>n;
  vector<string> v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  string temp;
  rep(j,n){
    if(temp!=v[j])ans++;
    temp=v[j];
  }
  cout<<ans;
  
}


Measured memory_bytes: 9600
#include <list>
#include <iostream>
#include <vector>
#include <sstream>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <map>
#include <sstream>
#include <set>
#include <cmath>
#include <iomanip>
#include <queue>

#define endl "\n"
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rr return 0

using namespace std;


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    for(int i = 1;i < n;i++){
        dp[i] = 1e18;
        for(int j = max<int>(0,i - k);j < i;j++){
            dp[i] = min(dp[i],dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n-1];
    rr;
}


Measured memory_bytes: 1792
n = int(input())
li = list(map(int,input().split()))

gu_li = []
ki_li = []
for i in range(0,n):
    if i%2 == 1:
        gu_li.append(li[i])
    else:
        ki_li.append(li[i])

ans = []
if n % 2 == 0:
    ans += list(reversed(gu_li)) + ki_li
else:
    ans += list(reversed(ki_li)) + gu_li
#print(ans)
print(*ans)

Measured memory_bytes: 101972
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll h;
    cin>>h;
    ll temp=0;
    while(h)
    {
        temp++;
        h/=2;
    }
    cout<<(1LL<<temp)-1<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
h=[int(i) for i in input().split()]

ans=[10**20 for i in range(N)]
ans[0]=0

for i in range(1,N):
    ans[i]=min(ans[i],ans[i-1]+abs(h[i]-h[i-1]))
    if i>=2: ans[i]=min(ans[i],ans[i-2]+abs(h[i]-h[i-2]))

print(ans[-1])


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

template<typename T>
vector<T> smallest_prime_factors(T n) {
    vector<T> spf(n+1);
    for (int i=0;i<=n;i++)spf[i]=i;
    for (T i=2;i*i<=n;i++){

        // 素数だったら
        if (spf[i]==i){
            for (T j=i*i;j<=n;j+=i){
                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j]==j) {
                    spf[j]=i;
                }
            }
        }
    }
    return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
        x /= spf[x];
    }
    sort(ret.begin(), ret.end());
    return ret;
}

const int MAX_N=10000000;
int N;
int ans;

signed main(){
    auto spf = smallest_prime_factors(MAX_N);
    cin>>N;
    for(int i=2;i<=N;++i){
        auto res=factolization(i,spf);
        int sum=1;
        int t=1;
        for(int j=1;j<res.size();++j){
            if(res[j]==res[j-1])t++;
            else {
                sum*=(t+1);
                t=1;
            }
        }
        sum*=(t+1);
        ans+=i*sum;
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 81192
INF = 1000000007

N = int(input())
S = input()

counts = {}
for s in S:
	counts[s] = counts.get(s, 0) + 1

pattern = 1
for count in counts.values():
	pattern *= 1 + count
	pattern %= INF
pattern -= 1
pattern %= INF

print(pattern)


Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
	int a,b;
	int num;
	int i;
	while(scanf("%d %d",&a,&b) != EOF)
	{
		num = a+b;
		i = 0;
		while(num)
		{
			num/=10;
			i++;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
N, M, K = map(int, input().split())
mod = 998244353
MAX = 510000

fac = [0]*MAX
facinv = [0]*MAX
inv = [0]*MAX


def modinv(a, mod):
    b = mod
    x, u = 1, 0
    while b:
        q = a//b
        a, b = b, a-q*b
        x, u = u, x-q*u
    x %= mod
    return x


def mod_nCr_init(n, mod):
    fac[0] = fac[1] = 1
    facinv[0] = facinv[1] = 1
    inv[1] = 1
    for i in range(2, n):
        fac[i] = fac[i-1] * i % mod
        inv[i] = -inv[mod % i] * (mod // i) % mod
        facinv[i] = facinv[i-1] * inv[i] % mod


def mod_nCr(n, r, mod):
    if n < r or n < 0 or r < 0:
        return 0
    return fac[n] * (facinv[r] * facinv[n-r] % mod) % mod


mod_nCr_init(MAX, mod)
ans = 0
for i in range(K+1):
    ans += mod_nCr(N-1, i, mod) * M * pow(M-1, N-i-1, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 69592
#include<iostream>
using namespace std;
int main(){
    int n, b, S[14], H[14], C[14], D[14];
    char a;
    cin >> n;
    for (int i=0; i < 14; i++) {
        S[i] = H[i] = C[i] = D[i] = 0;
    }
    for (int i=0; i < n; i++) {
        cin >> a >> b; 
        switch (a) {
            case 'S':
                S[b] = 1;
                break;
            case 'H':
                H[b] = 1;
                break;
            case 'C':
                C[b] = 1;
                break;
            case 'D':
                D[b] = 1;
                break;
        }
    }
    for (int i=1; i < 14; i++) {
        if (S[i] == 0) {
            cout << "S" << " " << i << endl;
        }
    }
    for (int i=1; i < 14; i++) {
        if (H[i] == 0) {
            cout << "H" << " " << i << endl;
        }
    }
    for (int i=1; i < 14; i++) {
        if (C[i] == 0) {
            cout << "C" << " " << i << endl;
        }
    }
    for (int i=1; i < 14; i++) {
        if (D[i] == 0) {
            cout << "D" << " " << i << endl;
        }
    }
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n; string s; stack<char>st;
	cin >> n >> s;
	rep(i, n) {
		if (st.empty())st.push(s[i]);
		else if (st.top() == '(' && s[i] == ')')st.pop();
		else st.push(s[i]);
	}
	int le = 0, ri = 0;
	while (st.size()) {
		if (st.top() == '(')le++;
		else ri++;
		st.pop();
	}
	rep(i, ri)cout << "("; cout << s; rep(i, le)cout << ")"; cout << endl;
}

Measured memory_bytes: 384
//https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define max3(x,y,z) max(x,max(y,z))
#define min(a,b) (a<b?a:b)
const int N = 1e5 + 5;
int n, a[N][3], cache[N][3];

int dp (int idx, int opt) {
    if (idx < 0)
        return 0;
    int &ans = cache[idx][opt];
    if (ans != -1)
        return ans;
    ans = a[idx][opt] + max(dp(idx-1, (opt+1)%3), dp(idx-1, (opt+2)%3));
    return ans;
}

int32_t main() {
    IOS;
    int i;
    memset(cache, -1, sizeof(cache));
    cin >> n;
    for(i = 0; i < n; i++) 
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    cout << max3(dp(n, 0), dp(n, 1), dp(n, 2));
    return 0;
}

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

int main(int argc, char **argv) {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

  int n; cin >> n;
  vector<int> a(n), b(n), c(n-1);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  for(int i=0; i<n-1; i++) cin >> c[i];

  int res = accumulate(b.begin(), b.end(), 0);
  for(int i=1; i<n; i++) {
    int x = a[i-1];
    int y = a[i];
    if(x+1 == y) res += c[a[i-1]-1];
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
 
int main() {
  int N; cin >> N;
  float t[N+2]={0}; for (int i=1; i<=N; i++) cin >> t[i];
  for (int i=1; i<=N+1; i++) t[i] += t[i-1];
  float v[N+2]={0}; for (int i=1; i<=N; i++) cin >> v[i];

  float v_min[2*(int)t[N+1]+1];
  memset(v_min, 0x7f, sizeof(v_min));

  for (int i=0; i<=2*(int)t[N+1]; i++) {
    float t_now = (float)i / 2;
    for (int j=0; j<=N+1; j++) {
      float s, e, v_tmp;
      if (j==0) s = t[j]; else s = t[j-1];
      e = t[j];
      if (s >= t_now) v_tmp = v[j] + ( s - t_now );
      else if (e <= t_now) v_tmp = v[j] + ( t_now - e );
      else v_tmp = v[j];
      v_min[i] = min(v_min[i], v_tmp);
    }
  }

  float result = 0;
  for (int i; i<ARRAY_LEN(v_min); i++) result += ( v_min[i] + v_min[i+1] ) * 0.25;
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 384
from itertools import combinations
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

if len(dist) == 1:
    print(dist[0])
else:
    dist_sum = 0
    dist_case = list(combinations(dist, N - 1))
    for d in dist_case:
        dist_sum += sum(d)

    print(dist_sum / len(dist_case))


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

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

	int max = 0;
	int diff = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			diff = abs(A[i] - A[j]);
			if (diff > max) max = diff;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	sort(p.begin(), p.end());

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += p[i];
	}

	sum -= p[n - 1] / 2;

	cout << sum << endl;
}


Measured memory_bytes: 3560
#include<stdio.h>

int main(void)
{
	int a[100];
	int n, i;

	scanf("%d", &n);

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

	for (i = n - 1; i >= 0; i--){
		if (i != n - 1)
		{
			putchar(' ');
		}
		printf("%d", a[i]);
	}
	putchar('\n');

	return 0;
}

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

int T, card[10];


bool is_same_number(int a, int b, int c){
    if(a == b && a == c)    return true;
    else return false;
}

bool is_sequence(int a, int b, int c){
    if(a+2 == c && b+1==c)  return true;
    else return false;
}

bool is_good_set(int a, int b, int c){
    return (is_same_number(a, b, c) || is_sequence(a, b, c));
}

bool is_all_good_set(){
    if(is_good_set(card[0],card[1],card[2]) && is_good_set(card[3],card[4],card[5]) && is_good_set(card[6],card[7],card[8]))
    return true;
    else    return false;
}

int win(){
    sort(card, card+9);
    do{
        if(is_all_good_set())
            return 1;
    }while(next_permutation(card, card+9));
    return 0;
}

int main(void){
    cin >> T;
    for(int t=0; t<T; t++){
        for(int i=0; i<9; i++){
            cin >> card[i];
        }
        string color;
        for(int i=0; i<9; i++){
            cin >> color;
            if(color == "G")    card[i] += 10;
            else if(color == "B")   card[i] += 20;
        }
        cout << win() << endl;
    }
    return 0;
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x, y ;
  cin >> x >> y ;
  ll ans1, ans2, ans3, ans4 ;
  ans1 = 2 ;
  ans2 = 1 ;
  ans3 = 1 ;
  ans4 = 0 ;
  
  if(-x<=-y){
    ans1 += -y+x ;
  }
  else{
    ans1 = LINF ;
  }
  
  if(-x<=y){
    ans2 += y+x ;
  }
  else{
    ans2 = LINF ;
  }
  
  if(x<=-y){
    ans3 += -y-x ;
  }
  else{
    ans3 = LINF ;
  }
  
  if(x<=y){
    ans4 += y-x ;
  }
  else{
    ans4 = LINF ;
  }
  
  cout << min({ans1,ans2,ans3,ans4}) <<endl ;
  
  
  
  
  
  return 0 ;
}



Measured memory_bytes: 256
parseInt(x) = parse(Int,x)

function f(i::Int,K::Int)
  a = Int(ceil(log(2,K/i)))
  return(0.5^a)
end

function main()
  (N,K) = map(parseInt,split(readline()))
  p = zeros(N+K)
  for i = 1:K
    p[i] = f(i,K)
  end
  for i = (K+1):N
    p[i] = 1.0
  end
  q = sum(p[1:N])/N
  println(q)
end

main()

Measured memory_bytes: 121672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        long K = long.Parse(Console.ReadLine());
        int x;
        for (x = 0; x < S.Length && S[x] == '1'; x++) ;
        if (K <= (long)x)
        {
            Console.WriteLine(1);
        }
        else
        {
            Console.WriteLine(S[x]);
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	//	String line = br.readLine();

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int ct=0;
		
		if(a==b && b==c)
		ct=1;
		else if(a==b || b==c || a==c)
			ct=2;
		else
			ct=3;
			System.out.println(ct);
		
}
}

Measured memory_bytes: 21332
n = int(input())
a = list(map(int,input().split()))

def allprint(a, n):
  for i in range(n):
    if i > 0:
      print(" ",end="")
    print(a[i],end="")
  print("")

def insertionSort(a, n):
  for i in range(1,n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
      a[j + 1] = a[j]
      j -= 1
    a[j + 1] = v
    allprint(a,n)

allprint(a,n)
insertionSort(a,n)


Measured memory_bytes: 6312
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;


int main(void) {
	int n, i = 0;
	int ans= 0;
	cin >> n;
	for (i = 1; i <= n; i +=2) {
		int count = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0)count++;
		}
		if (count == 8)ans++;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a - b >= 0) {
            System.out.println("delicious");
        } else {
            if (Math.abs(a - b) <= x) {
                System.out.println("safe");
            } else {
                System.out.println("dangerous");
            }
        }
    }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int ans = 0;
		for (int x = 1; x * x <= n; x++) {
			for (int y = x; y * y <= n; y++) {
				for (int z = y; z * z <= n; z++) {
					int res = x * x + y * y + z * z + x * y + y * z + z * x;
					if (res == i) {
						if (x == y && y == z) ans++;
						else if (x != y && y != z && z != x) ans += 6;
						else ans += 3;
					}
					else if (i < res) break;
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3528
# ABC081-B

read n
read -a a

for (( count = 0; ; count++ )); do
    for (( i = 0; i < n; i++ )); do
        (( a[i] % 2 != 0 )) && echo ${count} && exit
        a[i]=$(( a[i] / 2 ))
    done
done


Measured memory_bytes: 376
#include<bits/stdc++.h> 
#define MAXN 100100
#define LL long long
using namespace std;
LL A,B,C,minn=1e18+1;
int main() 
{
	cin>>A>>B>>C;
	minn=min(minn,(C&1)*A*B);
	minn=min(minn,(A&1)*B*C);
	minn=min(minn,(B&1)*A*C);
	cout<<minn<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}


signed main(){
    cout << fixed << setprecision(10);
    intl h,w;
    cin >> h >> w;
    intl a[h + 2][w + 2];
    rep(i,h + 2){
        rep(j, w + 2){
            if((i == 0)||(i == h + 1)||(j == 0)||(j == w + 1))a[i][j] = 0;
            else cin >> a[i][j];
        }
    }
    intl cnt = 0;
    vector<tuple<intl,intl,intl,intl> > t;
    repi(i,1,h + 1){
        repi(j,1,w + 1){
            if(a[i][j] % 2){
                if(a[i + 1][j] % 2){
                    a[i + 1][j]++;
                    t.pb(make_tuple(i,j,i + 1,j));
                    cnt++;
                }
                else if(a[i][j + 1] % 2){
                    a[i][j + 1]++;
                    t.pb(make_tuple(i,j,i,j + 1));
                    cnt++;
                }
                else{
                    if(i < h){
                        a[i + 1][j]++;
                        t.pb(make_tuple(i,j,i + 1,j));
                        cnt++;
                    }
                    else if(j < w){
                        a[i][j + 1]++;
                        t.pb(make_tuple(i,j,i,j + 1));
                        cnt++;   
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    for(auto i : t){
        cout << get<0>(i) << " " << get<1>(i) << " " << get<2>(i) << " " << get<3>(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 8304
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

struct sushi{
	int x, v;
};

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

	int odd = 0;
	int N;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if(tmp%2==1){
			odd++;
		}
	}

	YN(odd % 2 == 0);

	return 0;
}

Measured memory_bytes: 256