akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <vector>
#include <set>
using namespace std;

void read(int &x)
{
	char ch=getchar();bool f=0;x=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	if(f)x=-x;
} 

void read(long long &x)
{
	char ch=getchar();bool f=0;x=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	if(f)x=-x;
}


vector <int> graph[1001];

void addedge(int u,int v)
{
	graph[u].push_back(v);
}

int vis[1001][1001];
struct
{
	int first,second;
}edge[200001];
int mark[1001];
int times=1;
int tmp;

void dfs(int from,int now)
{
	vis[from][now]++;
	mark[now]=1;
	for(auto to:graph[now])
	{
		if(to==from)continue;
		if(vis[from][to]<2&&!mark[to])
		{
			dfs(from,to);
		}
	}
}

int main()
{
//	freopen("sep2_0.in","r",stdin);
//	freopen("sep.out","w",stdout);
	int n,m;
	read(n);read(m);
	for(int i=0;i<m;i++)
	{
		int from,to;
		read(from);read(to);
		addedge(from,to);
		edge[i].first=from;
		edge[i].second=to;
	}
	for(int i=1;i<=n;i++)
	{
		for(auto to:graph[i])
		{
			if(vis[i][to]<2)
			{
				memset(mark,0,sizeof(mark));
				dfs(i,to);
				
			}
		}
	}
	//return 0;
/*	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cout<<"("<<vis[i][j]<<","<<vis2[i][j]<<")";
		}
		cout<<endl;
	}*/
	for(int i=0;i<m;i++)
	{
		int from=edge[i].first,to=edge[i].second;
		if(vis[to][from])
		{
			if(vis[from][to]>1)
			{
				puts("same");
			}
			else
			{
				puts("diff");
			}
		}
		else
		{
			if(vis[from][to]>1)
			{
				puts("diff");
			}
			else
			{
				puts("same");
			}
		}
	}
	return 0;
}
/*
3 3
1 2
1 3
2 3

2 2
1 2
2 1
*/


Measured memory_bytes: 8192
#include<iostream>
using namespace std;
int reabs(int x)
{
    if(x<0)return -x;
    else return x;
}
int main()
{
    int n,i,now=0,a[100005],les[100005];
    cin>>n;
    a[0]=0;
    for(i=1;i<=n;i++)
        cin>>a[i];
    a[n+1]=0;
    for(i=1;i<=n;i++)
    {
        now=now+reabs(a[i]-a[i-1]);
        les[i]=reabs(a[i+1]-a[i-1])-reabs(a[i]-a[i-1])-reabs(a[i+1]-a[i]);
    }
    now=now+reabs(a[n+1]-a[n]);
    for(i=1;i<=n;i++)
        cout<<now+les[i]<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

vector<int> a[200010];
vector<int> ans(200010,0);

void solve(int x, int p){
    for(auto u : a[x]){
        if(u==p) continue;
        ans[u]+=ans[x];
        solve(u,x);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int  x,y;
        cin>>x>>y;
        x--;y--;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    //cout<<
    solve(0,-1);
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 23424
<?php

$input = explode(
    " ",
    fgets(STDIN)
);

$A = (int)$input[0];
$B = (int)$input[1];
$C = (int)$input[2];

$addition = $B + $C;
$result = $addition - $A;

if (0 <= $result) {
    echo $addition - $A;
} else {
    echo '0';
}

Measured memory_bytes: 15876
#include<bits/stdc++.h>
using namespace std;
  int main(){
    vector<int>c(3);
    for(int i=0;i<3;i++){
        cin >> c.at(i);
    }
   sort(c.begin(),c.end());
    cout << c.at(0)+c.at(1) << endl;
  }


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	string a, b;cin >> a >> b;
	ll aa, bb;cin >> aa >> bb;
	string seica;cin >> seica;
	if(seica == a)aa--;
	else bb--;

	cout << aa << " " << bb << endl;

	return 0;
}


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


int main() {
	string s;
	cin >> s;
	int counter = 0;
	for (auto it = s.begin(); it != s.end(); it++)
	{
		if (*it == 'o')
		{
			counter++;
		}
	}
	cout << counter*100 + 700;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int A,B;
    string s;
    while(cin>>A>>s)
    {
        B=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
        cout<<B*A/100<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3600
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    static final int MAX_NUM = 4;
    static final int B = 8;
     static final int TARGET = 7;

    static int[] num = new int [MAX_NUM];
    static char[] op = new char[MAX_NUM - 1];

    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        for (int i = 0; i < s.length(); i++)
            num[i] = s.charAt(i) - '0';

        for (int i = 0; i < B; i++) {
            int tmp = num[0];

            for (int j = 0; j < MAX_NUM - 1; j++) {
                op[j] = '+';

                if ((i >> j & 1) == 1) {
                    op[j] = '-';
                    tmp -= num[j + 1];
                } else tmp += num[j + 1];
            }

            boolean flg = false;

            if (tmp == TARGET) {
                for (i = 0; i < MAX_NUM; i++) {
                    out.print(num[i]);

                    if (i == MAX_NUM - 1) {
                        flg = true;
                        break;
                    }

                    out.print(op[i]);
                }
            }

            if (flg) break;
        }

        out.println("=" + String.valueOf(TARGET));

        out.flush();
    }
}


Measured memory_bytes: 22484
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i=1;i<=9;i++){
      if(n%i==0&&n/i<=9){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 23124
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;

const double pi = M_PI;
const Int MOD = 1000000007;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
vector<int> color;
Graph G;

void dfs(int v, int nc) {
    color[v] = nc;

    for (auto nv : G[v]) {
        if (color[nv.second] != -1) {
            continue;
        }

        dfs(nv.second, (nc + nv.first) & 1);
    }
}

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

    Int n;
    cin >> n;
    G.assign(n, vector<Edge>());
    for (Int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        w = 1 & w;

        G[u].push_back(Edge(w, v));
        G[v].push_back(Edge(w, u));
    }

    // 0から各頂点への累積和の偶奇を取る
    color.assign(n, -1);
    dfs(0, 0);

    // 偶奇で色を付けて出力
    for (Int i = 0; i < n; i++) {
        cout << color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    ll sum = 0;
    rep(i,n)sum += a[i];
    ll su = 0;
    ll ans = pow(10,15);
    rep(i,n-1){
        su += a[i];
        ll x = abs((sum - su) - su);
        ans = min(ans,x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); 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 inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
#define M 1000000007
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
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...);
}
int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
int modInverse(int b, int m) 
{ 
    int x, y; // used in extended GCD algorithm 
    int g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
  
    // m is added to handle negative x 
    return (x%m + m) % m; 
} 

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i,0,n) cin>>v[i];
    int sum = 0;
    int nov,nole;
    rep(i,0,n){
        nov=0;
        nole=0;
        rep(j,i+1,n){
            if(v[j]<v[i]) nov++;
        }
        rep(j,0,n){
            if(v[j]<v[i]) nole++;
        }
        sum = (sum + (k*nov)%M + (((((k*(k-1))%M)*nole))%M)*modInverse(2,M))%M;
    }
    cout<<sum<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
 
    if((b-a)%2==0){
        cout<<(b-a)/2<<"\n";
        return 0;
    }
    else{
        cout<<min(a-1,n-b)+1+(b-a-1)/2<<"\n";
        return 0;
    }
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x, ll y)
{
	return y==0 ? x:gcd(y,x % y);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main()
{
    int A,B;
    cin >> A >> B;
    cout << lcm(A,B) << endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	string a, b, c;
	cin >> a >> b >> c;
	char x = a[0];
	x += 'A' - 'a';
	cout <<x <<char(b[0]+ 'A' - 'a') <<char(c[0] + 'A' - 'a') << endl;

	return 0;

}




Measured memory_bytes: 256
import math
x, k, d = map(int, input().split())
x = abs(x)
# math.floor(x/d)+1回!absの方向に行く
# k>x/dのときx-math.floor(x/d)*dとx-(math.floor(x/d)+1)*dのうち小さいほうが答え
if k > x/d:
    if (k-math.floor(x/d)) % 2 == 0:
        print(abs(x-math.floor(x/d)*d))

# ここがちがうよ
    else:
        print(abs(x-math.floor(x/d+1)*d))
#     if x-math.floor(x/d)*d < abs(x-(math.floor(x/d)+1)*d):
#         print(x-math.floor(x/d)*d)
#     else:
#         print(abs(x-(math.floor(x/d)+1)*d))
else:
    print(x-k*d)


Measured memory_bytes: 9072
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<cmath>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll ans = LINF;
    partial_sum(begin(a), end(a), begin(a));
    for(int i = 0; i < n - 1; i++){
        ll d = abs(a[n - 1] - a[i]);
        ans = min(ans , abs(d - a[i]));
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    unsigned long N, M;
    cin >> N >> M;
    class union_find{
        vector<long> val;
    public:
        union_find(unsigned long _n) : val(_n + 20, -1){}
        long find(long x){
            return val[x] < 0 ? x : val[x] = find(val[x]);
        }
        bool marge(long a, long b){
            a = find(a);
            b = find(b);
            if(a == b)return false;
            if(val[a] > val[b])swap(a, b);
            val[a] += val[b];
            val[b] = a;
            return true;
        }
    };
    union_find tapi{N};
    unsigned long ans{N};
    for(unsigned long i = 0, a, b, c; i < M; ++i){
        cin >> a >> b >> c;
        ans -= tapi.marge(a - 1, b - 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

    long long int n;
    cin >> n;

    long long int tmp = n;
    long long int s = 0;

    while(tmp != 0){

        s += tmp%10;
        tmp /= 10;

    }

    if(n%s == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

#define M 1046527
#define L 14

char H[M][L];

int get_char(char ch)
{
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long get_key(char str[])
{
    long sum = 0;
    long p = 1;
    for(int i = 0; i < strlen(str); i++)
    {
        sum += p * get_char(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key)
{
    return key % M;
}

int h2(int key)
{
    return 1 + (key % (M - 1));
}

bool find(char str[])
{
    long key = get_key(str);
    int h;
    bool flag = false;
    for(int i = 0; ; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0)
        {
            flag = true;
            break;
        }
        else if(strlen(H[h]) == 0)
            break;
    }
    return flag;
}

void insert(char str[])
{
    long key = get_key(str);
    int h;
    for(int i = 0; ; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) break;
        else if(strlen(H[h]) == 0)
        {
            strcpy(H[h], str);
            break;
        }
    }
}

int main()
{
    for(int i = 0; i < M; i++)
        H[i][0] = '\0';
    int n;
    scanf("%d", &n);
    char str[L];
    char command[16];
    for(int i = 0; i < n; i++)
    {
        scanf("%s %s", command, str);
        if(command[0] == 'i')
            insert(str);
        else
        {
            if(find(str))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
}


Measured memory_bytes: 17472
n = int(input())
ans = ""
for i in range(1, n+1):
  if i % 3 == 0:
    ans += " " + str(i)
  else:
    x = i
    while x:
      if x % 10 == 3:
        ans += " " + str(i)
        break
      x //= 10
print(ans)



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

int main() {
    int h, n, s;
    cin >> h >> n;
    s = 0;
    vector<int> vec(n);

    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
        s += vec.at(i);
    }

    if (h <= s) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
from sys import stdin, stdout
input = stdin.readline
print = stdout.write 
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]
i, j, z = 0, m, 0
while i <= n and a[i] <= k:
    while b[j] > k - a[i]:
        j -= 1
    z = max(z, i + j)
    i += 1
print(str(z))

Measured memory_bytes: 119984
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
cout << std::setprecision(8);
cout << std::fixed;
ll n,k;
cin>>n>>k;
ll a[n];
ll pref[n+1];
pref[0]=0;
for(ll i=0;i<n;i++)
{
cin>>a[i];
pref[i+1]=pref[i]+a[i];
}
long double ans=0;
for(int i=0;i+k<=n;i++)
{
ans=max(ans,(long double)(pref[i+k]-pref[i]+k)/2);
}
cout<<ans<<endl;
}

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

int main(void){
	char turn = 'a';

	char a[110];
	char b[110];
	char c[110];
	int al,bl,cl;
	int ia,ib,ic;

	char win = '0';

	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);

	al = strlen(a);
	bl = strlen(b);
	cl = strlen(c);

	ia = 0;
	ib = 0;
	ic = 0;
	

	while(win == '0'){
		switch(turn){

		case 'a':
			if( al != ia ){
				turn = a[ia];
				ia++;
			}else{
				win = 'A';
			}
			break;

		case 'b':
			if( bl != ib ){
				turn = b[ib];
				ib++;
			}else{
				win = 'B';
			}
			break;

		case 'c':
			if( cl != ic ){
				turn = c[ic];
				ic++;
			}else{
				win = 'C';
			}
			break;

		default :
			// No Ope
			break;

		}

	}

	printf("%c\n",win);

	return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  //map<char, char> st;
  map<char, char> st;
  map<char, char> ts;
  bool flag = true;
  for ( int i = 0; i < s.length(); i++){
    if (st[s[i]] && st[s[i]] != t[i]){flag = false;break;}
    else {
      st[s[i]] = t[i];
    }
    if (ts[t[i]] && ts[t[i]] != s[i]){flag = false;break;}
    else {
      ts[t[i]] = s[i];
    }
  }
  if (flag){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 776
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
V = {'r': P, 's': R, 'p': S}
ans = 0

for i in range(K):
    check = T[i]
    ans += V[check]
    while True:
        i += K
        if i >= N:
            break
        if check == T[i]:
            check = '-1'
        else:
            ans += V[T[i]]
            check = T[i]
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, tmp, *array, tmp2;
	
	while(cin >> n){
		array = (int *)calloc(10, sizeof(int));
		tmp2 = 0;
		while(n > 0){
			tmp = 1;
			while(n >= tmp){
				tmp *= 2;
			}
			tmp /= 2;
			array[tmp2++] = tmp;
			n -= tmp;
		}
		tmp2--;
		cout << array[tmp2];
		for(int i = tmp2 - 1; i >= 0; i--){
			cout << " " << array[i];
		}
		cout << endl;
		free(array);
	}
	
	return 0;
}

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

using namespace std;

int main()
{
int N; cin>>N;
vector<int> h(N),dp(N,1100000000);
for(int i=0;i<N;i++) cin>>h[i];
dp[0]=0;
for(int i=0;i<N;i++){
if(i+1<N)dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
if(i+2<N)dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
}
cout<<dp[N-1]<<endl;
return 0;
}

Measured memory_bytes: 1024
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

S = S[::-1]
T = T[::-1]

left = 0
right = W - 1
for i in range(N):
  if T[i] == "L":
    right = min(right + 1, W - 1)
  if T[i] == "R":
    left = max(left - 1, 0)
  if S[i] == "L":
    left = left + 1
  if S[i] == "R":
    right = right - 1
  if left > right:
    print("NO")
    exit()

if left <= sc - 1<= right:
  1
else:
  print("NO")
  exit()
  
up = 0
down = H - 1
for i in range(N):
  if T[i] == "U":
    down = min(down + 1, H - 1)
  if T[i] == "D":
    up = max(up - 1, 0)
  if S[i] == "U":
    up = up + 1
  if S[i] == "D":
    down = down - 1
  if up > down:
    print("NO")
    exit()
  
if up <= sr - 1 <= down:
  print("YES")
else:
  print("NO")



Measured memory_bytes: 45744
#include<stdio.h>

int main(){
	long long n;
	scanf("%lld",&n);
	int M=1,m=0;
	for(long long i=2;i*i<=n;i++)if(n%i==0){
		int cnt=0;
		while(n%i==0)n/=i,cnt++;
		M*=cnt+1;
		m++;
	}
	if(n!=1)M*=2,m++;
	printf("%d %d\n",m,M-1);
}


Measured memory_bytes: 2088
s=gets.chomp

n=s.length
if s[0]!="A"
    puts "WA"
    return
end

if s[2..n-2].count("C")!=1
    puts "WA"
    return
end

count=0
("a".ord).upto("z".ord) do |i|
    count+=s.count(i.chr)
end
if count!=n-2
    puts "WA"
    return
end
puts "AC"


Measured memory_bytes: 14272
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string a, b, c; int n;
	cin>>n>>a>>b>>c;
	int ans=0;
	for(int i=0; i<n; i++){
		set<char> st;
		st.insert(a[i]);
		st.insert(b[i]);
		st.insert(c[i]);
		ans+=((int)st.size()-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() {
	string a;
	cin >> a;
	
	if (a.at(2)== a.at(3) && a.at(4) == a.at(5)){
	cout << "Yes" << endl;
		}
	else {
		cout << "No" << endl;
	}
	return 0;
}

  

Measured memory_bytes: 256
#include <stdio.h>
#define o 100
#define X 100000000

int G[o+1][o+1], care[o+1], size[o+1];

void dfs(int pi, int t)
{
  int i;
  care[pi] = t;
  for(i=1; i<=size[pi]; ++i)
    if(t+1 < care[G[pi][i]])
      dfs(G[pi][i], t+1);
}


int main(){
  int x,n;
  int i,j;
  scanf("%d", &n);

  for(i=1; i<=n; ++i)
    {
      care[i] = X;
      scanf("%d", &x);
      scanf("%d", &size[x]);
      for(j=1; j<=size[x]; ++j) scanf("%d", &G[x][j]);
    }

  dfs(1, 0);

  for(i=1; i<=n; ++i)
    printf("%d %d\n", i, (care[i] == X) ? -1 : care[i]);

  return 0;
}




Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define vll vector<ll>
#define nloop(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define fill(i,n) memset(i,n,sizeof i)
#define all(a) a.begin(),a.end()
#define pb(x) push_back(x)
#define sz() size()
#define T(n) while(n--)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define endl '\n'
#define nfs  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll bin_expo(ll a, ll b, ll m){ll res = 1LL;while (b > 0){if(b % 2 == 1){res = (res * a) % m;}a = (a * a) % m; b = b/ 2;}return res;}

const  int MAXn= 3e5+5;
const  long long INF= 1e18;

int main(){
    int t=1;
    //cin>>t;
    T(t){
    int n; cin>>n;
    vll v(n),dp(n,INF);
    for(ll &x: v) cin>>x;
    dp[0]=0; 
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=i+2;j++){
                if(j<n) dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
            }
        }
        cout<<dp[n-1];
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
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;}

int main () {
  rrep(i,10000) {
    int x = in();
    if (x == 0) return 0;
    printf("Case %d: %d\n", i, x);
  }
  return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		if(S.contains("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}

	}

}

Measured memory_bytes: 35600
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn main() {
    let x: i64 = read_ints()[0];
    if x == 3 || x == 5 || x == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

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

	string s; read(s);
	for (char &c : s) if (c == '?') c = 'D';
	die(s);
}


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

int main(){
  int n,a;
  cin>>n;
  int count0=0,count1=0,count2=0;
  lp(i,n){
    cin>>a;
    a%=3;
    if(a==0) count0++;
    if(a==1) count1++;
    if(a==2) count2++;
  }
  int ccount00=count0;
  int ccount11=count1;
  int ccount22=count2;
  int ans=0,ans2=0;
  if(count1!=0||count2!=0) {
    ans+=count0;
    ans2+=count0;
  }
  if(count1!=0){
    count1--;ans++;
    while(1){
      if(count1!=0&&count2!=0) {
	ans+=2;
      count1--;count2--;
      }
      else break;
    }
    if(count1>0) ans++;
    if(count1>1) ans++;
    if(count2>0) ans++;
  }
  count0=ccount00;
  count1=ccount11;
  count2=ccount22;
  if(count2!=0){
    count2--;ans2++;
    while(1){
      if(count1!=0&&count2!=0) {
	ans2+=2;
	count1--;count2--;
      }
      else break;
    }
    if(count2>0) ans2++;
    if(count2>1) ans2++;
    if(count1>0) ans2++;
  }
  if(ans==0) ans=1;
  if(ans2==0) ans2=1;
  cout<<max(ans,ans2)<<endl;
  return 0;
}




Measured memory_bytes: 3088
N=int(input())
M,A,R,C,H=0,0,0,0,0
for i in range(N):
    s=input()[0]
    if s=='M':
        M+=1
    elif s=='A':
        A+=1
    elif s=='R':
        R+=1
    elif s=='C':
        C+=1
    elif s=='H':
        H+=1

print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + \
      M*C*H + A*R*C + A*R*H + A*C*H + R*C*H)

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

using namespace std;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int n, m, cnt, a[N], b[N];
int tmpx[N], tmpy[N], c1, c2;

struct node {
	int x, y;
	bool operator < (const node &T) const {
		return x == T.x ? y > T.y : x < T.x;
	}
}A[N];

struct Fenwick_Tree {
	int s[N];
	void update(int x, int y) {for(; x <= c2; x += x & -x) (s[x] += y) %= mod;}
	int query(int x) {int res = 0; for(; x; x -= x & -x) (res += s[x]) %= mod; return res;}
}T;

void Init() {
	int x; priority_queue<int, vector<int>, greater<int>> q;
	cin >> n >> m;
	for(int i = 1; i <= n; ++ i) cin >> x, q.push(x);
	for(int i = 1; i <= m; ++ i) cin >> b[i]; n = 0;
	while(!q.empty()) {
		int k = q.top(), pos = lower_bound(b + 1, b + m + 1, k) - b; q.pop();
		if(k <= b[1] || k >= b[m] || b[pos] == k) continue;
		A[++ cnt].x = b[pos] - k; A[cnt].y = k - b[pos - 1];
		tmpx[++ c1] = A[cnt].x, tmpy[++ c2] = A[cnt].y;
	}
	sort(tmpx + 1, tmpx + c1 + 1), sort(tmpy + 1, tmpy + c2 + 1);
	c1 = unique(tmpx + 1, tmpx + c1 + 1) - tmpx - 1;
	c2 = unique(tmpy + 1, tmpy + c2 + 1) - tmpy - 1;
	for(int i = 1; i <= cnt; ++ i) {
		A[i].x = lower_bound(tmpx + 1, tmpx + c1 + 1, A[i].x) - tmpx;
		A[i].y = lower_bound(tmpy + 1, tmpy + c2 + 1, A[i].y) - tmpy;
	}
	sort(A + 1, A + cnt + 1);
}

void Solve() {
	int ans = 1;
	for(int i = 1; i <= cnt; ++ i) {
		if(A[i].y == A[i - 1].y && A[i].x == A[i - 1].x) continue;
		int now = T.query(A[i].y - 1) + 1;
		(ans += now) %= mod;
		T.update(A[i].y, now);
	}
	cout << ans << endl;
}

int main() {
	Init();
	Solve();
	return 0;
}

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

#define int long long 
#define dou double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,m,k;
	cin >> n >> m >> k;
	if(n>k){
		double t=n/(double)k;
		if(t<=m)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else{
		double t=n/(double)k;
		if(t<=m)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

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


Measured memory_bytes: 3628
def guu(s):
    if len(s)%2==1:
        return 0
    a=len(s)//2
    if s[0:a]==s[a:]:
        return 1
    else:
        return 0
s=list(input())
s.pop(-1)
while guu(s)==0:
    s.pop(-1)
print(len(s))

Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
struct Obj{
    int a, b, c, d;
};
int n, m, q;
vector<Obj> vec;
int ans = 0;
void dfs(int now, vector<int> a){

    if(a.size() == n){
        int tmpans = 0;
        rep(i, q){
            if(a[vec[i].b] - a[vec[i].a] == vec[i].c){
                tmpans += vec[i].d;
            }
        }
        ans = max(ans, tmpans);
        return;
    }

 
    for(int i = now; i < m; i++){
        vector<int> nexta = a;
        nexta.push_back(i);
        dfs(i, nexta);
    }
}
int main(void){

    cin >> n >> m >> q;

    rep(i, q){
        Obj tmp;
        cin >> tmp.a >> tmp.b >> tmp.c >> tmp.d;
        tmp.a--, tmp.b--;
        vec.push_back(tmp);
    }

    vector<int> emp;
    dfs(0, emp);

    cout << ans << endl;
}


Measured memory_bytes: 3632
program ABC052B
    implicit none
    integer(8)::N,i
    integer(8)::calc=0
    integer(8)::result=0
    character(100)::S
    read(5,*)N,S
    do i=1,N
        if(S(i:i)=="I")then
            calc=calc+1
        else
            calc=calc-1
        end if
        if(calc>result)result=calc
    end do
    print'(i0)',result
end program ABC052B

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans,a[100000];
struct Edge { Pll to; LL cost; };
bool f;
vector<Edge>vec[100][100];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n)
		cin >> a[i];
	sort(a,a+n);
	rep(i, n) {
		if(i%2==0)
		ans += a[i];
		else ans -= a[i];
	}
	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 640
#C
s=input()
n=len(s)
count1=0
for i in range(n):
    if i%2==0:
        if s[i]=="1":
            count1+=1
    else:
        if s[i]=="0":
            count1+=1
count2=0
for i in range(n):
    if i%2==0:
        if s[i]=="0":
            count2+=1
    else:
        if s[i]=="1":
            count2+=1
print(min(count1,count2))

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int x,y,z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << endl;
}	
/*  Benq's (modified)
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,a,b;

int main(){
	read(n,a,b);
	if((b-a)&1)puts("Borys");else puts("Alice");
	return 0;
}


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


int main() {
   string str;
   cin >> str;
   int flag = 1;
   for(int i = 0 ; str[i]; i++){
       if(str[i] >= 'A' && str[i] <= 'Z')
       {
        flag = 0;
        break;
       }
   }
   if(flag == 0)
   {
    cout << "No" << endl;
     return 0 ;
   }
   if(str.size() == 6){
       if(str[2] == str[3] && str[4] == str[5])
           cout << "Yes" <<endl;
       else
           cout << "No"<<endl;
   } 
  else
       cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	deque<int>que;
	while(n--){
		string cm;int x;cin>>cm;
		if(cm=="insert"){cin>>x;que.puf(x);}
		if(cm=="delete"){cin>>x;
			auto itr=find(que.begin(),que.end(),x);
			if(itr!=que.end()){que.erase(itr);}
		}
		if(cm=="deleteFirst"){que.pof();}
		if(cm=="deleteLast"){que.pob();}
	}
	n=que.size();
	for(int i=0;i<n;i++){cout<<que[i]<<(i+1<n?" ":"\n");}
	
	return 0;
}


Measured memory_bytes: 6924
import kotlin.comparisons.compareBy
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next() }
    val M = S.groupBy { it }.mapValues { it.value.size }.toList().sortedWith(compareBy({ -it.second }, { it.first }))
    val max = M[0].second
    println(M.filter { it.second == max }.map { it.first }.sorted().joinToString(separator="\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 131612
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
typedef vector<int> vi;
typedef pair<int,int> vii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

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

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18+9;
const int N=1001;
int a[no]={},b[no]={},cc[no]={},suma[no]={},mat[N][N]={{0}};
stack<int> S;
stack<int> ma;

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

int poww(int x, int y, int modulo) {x %= modulo;int res=1;while (y > 0) {if (y & 1){res = res * x % modulo;}x = x * x % modulo;y >>= 1;}return res;}

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
int n=0,m=0,q=0,x=0,w=0,y=0,z=0,t=1;
void solve(){
    cin>>n>>m;
    while(n--){
        cin>>x>>y;
        int kk=ceil(sqrt(x*x+y*y));
        if(kk<=m)z++;
    }
    cout<<z;
}

void runn(){
    #ifndef ONLINE JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

signed main()
{
    night_rider
    //runn();
    //cin>>t;q=t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//char a[100][100];

int main(){
    ll n,x;
    cin>>n>>x;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll val;
        cin>>val;
        a.push_back(val);
    }
    ll sum=0;
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1]>x){
            ll f = a[i-1];
            ll s = a[i];
            ll fin = a[i]+a[i-1]-x;
            ll val2=0;
            ll val1 = min(a[i],fin);
            a[i]-=(min(a[i],fin));
            fin-=val1;
            if(fin>0)
            val2 = min(fin,a[i-1]);
            //a[i-1]-=val2;
            sum  += (val1+val2);
        }
    }
    //for(auto qw:a)cout<<qw<<" ";
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int main(){
	int b[3];
	cin>>b[0]>>b[1]>>b[2];
	if(b[0]==1&&b[1]==1&&b[2]==0)cout<<"Open"<<endl;
	else if(b[0]==0&&b[1]==0&&b[2]==1)cout<<"Open"<<endl;
	else cout<<"Close"<<endl;
	return 0;
}

Measured memory_bytes: 1156
dif_list = []
tmp = 0
n = gets.to_i
list = gets.split.map(&:to_i)
sum = list.inject(:+)

n.times do |i|
    tmp += list[i]
    dif_list.push((sum/2.0-tmp).abs*2)
end

p dif_list.min.to_i

Measured memory_bytes: 1788
n,m = map(int,input().split())

import heapq

def dijkstra(s):
    d = 1
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for u in e[v]:
            tmp = 1 + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost

e = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a,b = a-1, b-1
    e[a].append(b)
    e[b].append(a) # 有向グラフでは削除

d = dijkstra(0)
# print(d)
# print(e)
ans = [0]*(n)
for i in range(1,n):
    for j in e[i]:
        # print(i,j)
        if d[j] == d[i] - 1:
            ans[i] = j + 1
            continue

print("Yes")
print(*ans[1:], sep="\n")

Measured memory_bytes: 105196