akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
ll a[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
  	int n,x;cin>>n;
  	ll sum=0;
  	for(int i=0;i<n;i++)
  	{
  		cin>>x;
  		a[x]++;
  		sum+=x;
	}
  	int q,l,r;
  	cin>>q;
  	while(q--)
  	{
  		cin>>l>>r;
		if(l!=r){
			sum+=r*a[l]-a[l]*l;
			a[r]+=a[l];
			a[l]=0;
		}
		cout<<sum<<endl;
		  	
	}
  	
    return 0;
}


Measured memory_bytes: 4432
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();	
		long n1=0,n2=0,n3=0,n4=0,n5=0;
		String m[]=new String[n];
		String a[]=new String[n];
		String r[]=new String[n];
		String c[]=new String[n];
		String h[]=new String[n];
		for(int i=0;i<n;i++){
			String s=sc.next();
			if(s.charAt(0)=='M'){
				n1++;
			}
			if(s.charAt(0)=='A'){
				n2++;	
			}
			if(s.charAt(0)=='R'){
				n3++;
			}
			if(s.charAt(0)=='C'){
				n4++;
			}
			if(s.charAt(0)=='H'){
				n5++;
			}
		}
		long sum=0;
		sum+=n1*n2*n3;
		sum+=n1*n2*n4;
		sum+=n1*n2*n5;
		sum+=n1*n3*n4;
		sum+=n1*n3*n5;
		sum+=n1*n4*n5;
		sum+=n2*n3*n4;
		sum+=n2*n3*n5;
		sum+=n2*n4*n5;
		sum+=n3*n4*n5;
		System.out.println(sum);
	}

}


Measured memory_bytes: 48560
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	int n;
	while(true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		int sum = 0, cur;
		for (int i = 0; i < n/4; i++) {
			cin >> cur;
			sum += cur;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int N=0,W=0,S=0,E=0;
    string str;

    cin>>str;

    for(int i=0;i<str.length();i++){
        if(str[i]=='N')N=1;
        if(str[i]=='W')W=1;
        if(str[i]=='S')S=1;
        if(str[i]=='E')E=1;
    }

    if(N!=S||W!=E){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int par[100001];
Int sz[100001];

Int root(Int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
}

void unite(Int x, Int y) {
    Int rx = root(x);
    Int ry = root(y);
    if (rx == ry) return;
    par[ry] = rx;
    sz[rx] += sz[ry];
}

int main() {
    Int n, m, k;
    cin >> n >> m >> k;
    vector<Int> res(n);
    for (Int i = 0; i < n; i++) {
        par[i] = i;
        sz[i] = 1;
    }
    vector<Int> a(m), b(m);
    for (Int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        unite(a[i], b[i]);
    }
    for (Int i = 0; i < n; i++) {
        res[i] = sz[root(i)] - 1;
    }
    for (Int i = 0; i < m; i++) {
        res[a[i]]--, res[b[i]]--;
    }
    for (Int i = 0; i < k; i++) {
        Int c, d;
        cin >> c >> d;
        c--, d--;
        if (root(c) == root(d)) {
            res[c]--, res[d]--;
        }
    }
    for (Int i = 0; i < n; i++) {
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}


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

int main(){
  int n,array[100];
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> array[i];  
  }
  for (int i = n-1; i >= 0; i--)
  {
    if (i != n-1){
      cout << " ";
    }
    cout << array[i]; 
  }
  cout << endl;
  return 0;
}


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


void solve(long long A, long long B, long long K){
		int cnt = 0;
		for (int i = std::min({A,B}); i >= 1; i--) {
				if ((A % i == 0) && (B % i == 0)) {
						K--;
				}
				if (K == 0) {
						cout << i << endl;
						return;
				}
		}
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = Read();
            var k = Read();
            var x = Reads();
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                ans += Math.Min(2*x[i], 2*(k-x[i]) );
            }

            Console.WriteLine(ans);



            Console.Out.Flush();
        }
    }
}




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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    string a, b;
    int g;
    cin >> a >> b;
    g = stoi(a + b);
    rep(i, 1000) {
        if (i * i == g) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

vector<ll> v;
int K;

void run(int count){
    if(v.size() > K) return;
    ll n = v[count++];
    int last = n % 10;
    if(last == 0){
        v.push_back(n*10);
        v.push_back(n*10+1);
    }
    else if(last == 9){
        v.push_back(n*10+8);
        v.push_back(n*10+9);
    }else{
        v.push_back(n*10+last-1);
        v.push_back(n*10+last);
        v.push_back(n*10+last+1);
    }
    run(count);
}

int main(void){
    cin >> K;
    for (int i = 1; i < 10 ; i++)
        v.push_back(i);
    run(0);
    cout << v[K-1] << endl;
    return 0;
}



Measured memory_bytes: 5664
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,q,cnt,ans,f[2010],fa[1000],x1[10010],r[200010],vt[200010],va[200010];
int dis[210][1025],t,t1,inf=1e9,mo=1e6,l[1000010],l1[1000010],bi[10],pp[210];
bool vi[210][1025];
void adde(int a,int b,int k)
{
	r[++cnt]=x1[a];x1[a]=cnt,vt[cnt]=b;va[cnt]=k;
	r[++cnt]=x1[b];x1[b]=cnt,vt[cnt]=a;va[cnt]=k;
}
void spfa()
{
	int i,s,a,b,j,p;
	p=(1<<q);
	for(i=1;i<=n;i++)
		for(s=0;s<p;s++)dis[i][s]=inf;
	t=1;t1=0;
	for(i=1;i<=n;i++)
	{
		if(pp[i])j=bi[pp[i]-1];
		else j=0;
		dis[i][j]=0;
		vi[i][j]=1;
		l[++t1]=i;l1[t1]=j;
	}
	while(t<=t1)
	{
		s=l[t%mo];i=l1[t++%mo];a=x1[s];vi[s][i]=0;
		if(i==p-1)ans=min(ans,dis[s][i]);
		while(a)
		{
			b=vt[a];
			if(!pp[b])j=i;
			else j=(i|bi[pp[b]-1]);
			if(dis[b][j]>dis[s][i]+va[a])
			{
				dis[b][j]=dis[s][i]+va[a];
				if(!vi[b][j])vi[b][j]=1,l[++t1%mo]=b,l1[t1%mo]=j;
			}
			a=r[a];
		}
	}
}
int main()
{
	int i,s,a,b,j,k;
	scanf("%d%d%d",&n,&m,&q);
	bi[0]=1;for(i=1;i<=9;i++)bi[i]=bi[i-1]<<1;
	for(i=1;i<=q;i++)scanf("%d",&a),pp[a]=i;
	for(i=1;i<=m;i++)scanf("%d%d%d",&a,&b,&k),adde(a,b,k);
	ans=inf;spfa();printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8320
#include <stdio.h>
int main()
{
  int a, b, c, d, x, y;
  1 <= (a+b+c+d)/60 <= 59;
  0 <= (a+b+c+d)%60 <= 59;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  printf("%d\n",(a+b+c+d)/60);
  printf("%d\n",(a+b+c+d)%60);
  return 0;
}

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

const int N = 22;
const ll mod = 1e9 + 7;
ll dp[N][1 << N];
int n;
bool a[N][N];

ll solve(int m, int w) {
	if (m == n) {
		if (w == 0)
			return 1;
		return 0;
	}
	if (dp[m][w] != -1)
		return dp[m][w];
	ll tot = 0;
	for (int i = 0; i < n; i++) {
		int woman = 1 << i;
		bool available = ((woman & w) == 0)? false : true;
		if (available && a[m][i]) {
			tot = (tot + solve(m + 1, woman ^ w)) % mod;
		}
	}
	return dp[m][w] = tot;
}

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

	cin >> n;
	int x;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> x;
			if (x)
				a[i][j] = true;
		}
	}
	memset(dp, -1, sizeof(dp));
	ll answer = solve(0, ((1 << n) - 1));
	cout << answer;

	return 0;
}


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

class Program{
    static void Main(string[] args)
    {
        int[] nm = Scan.IntArray(2);
        int cnt = 0;
        int n, m;
        n = nm[0]; m = nm[1];
        int[] p = Scan.IntArray(n);
        for (int i = 0; i < n; i++)
        {
            p[i]--;
        }
        UnionFind uf = new UnionFind();
        uf.Init(n);
        for (int i = 0; i < m; i++)
        {
            int[] xy = Scan.IntArray(2);
            int x = xy[0] - 1;
            int y = xy[1] - 1;
            uf.Unite(x, y, 0);
        }

        for (int i = 0; i < n; i++)
        {
            if(uf.Same(i, p[i]))
            {
                cnt++;
            }
        }
        Out.Num(cnt);
    }
}

public class Scan
{
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }

    public static int[] IntArray(int t)
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] ar = new int[t];
        for (int i = 0; i < t; i++)
        {
            ar[i] = int.Parse(str[i]);
        }
        return ar;
    }
}

public class Out
{
    public static void Num<T>(T a)
    {
        Console.WriteLine(a);
    }
}

public class UnionFind
{
    public int[] parent;
    public int[] rank;
    public long[] weightDiff;

    public void Init(int size)
    {
        parent = new int[size + 5];
        rank = new int[size + 5];
        weightDiff = new long[size + 5];
        for (int i = 0; i < size; i++)
        {
            parent[i] = i;
            rank[i] = 0;
            weightDiff[i] = 0;
        }
    }

    public int Root(int x)
    {
        if(parent[x] == x)
        {
            return x;
        }
        else
        {
            int r = Root(parent[x]);
            weightDiff[x] += weightDiff[parent[x]];
            return parent[x] = r;
        }
    }

    public bool Unite(int x, int y, long w) // Add edge x <- y (weight: w)
    {
        w = w + GetWeight(x) - GetWeight(y);
        x = Root(x);
        y = Root(y);
        if (x == y) return false;
        if(rank[x] < rank[y])
        {
            int tmp = x; x = y; y = tmp;
            w *= -1;
        }
        if(rank[x] == rank[y])
        {
            ++rank[x];
        }
        parent[y] = x;
        weightDiff[y] = w;
        return true;
    }
  
      public long GetWeight(int x)
    {
        Root(x);
        return weightDiff[x];
    }


    public bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }
}


Measured memory_bytes: 25696
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,x,a[20][20],c[20],tmp[20],cost,ans=1000000000;
int main()
{
	scanf("%d%d%d",&n,&m,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int tot=(1<<n);
	for(int i=0;i<tot;i++)
	{
		for(int k=1;k<=m;k++) tmp[k]=0;
		cost=0;
		for(int j=1;j<=n;j++)
		{
//			printf("i=%d j=%d (i>>(j-1))%2=%d\n",i,j,(i>>(j-1))%2);
			if(!((i>>(j-1))%2)) continue;
			for(int k=1;k<=m;k++) tmp[k]+=a[j][k];
			cost+=c[j];
		}
		bool flag=false;
		for(int k=1;k<=m;k++)
		{
//			if(i==6) printf("tmp[%d]=%d\n",k,tmp[k]);
			if(tmp[k]<x) flag=true; 
		}
//		if(i==6) printf("cost=%d\n",cost);
		if(!flag) ans=min(ans,cost);
	}
	if(ans==1000000000) printf("-1\n");
	else printf("%d\n",ans);
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    ll a, b, n;
    cin>>a>>b>>n;
    ll x = min(b-1ll, n);
    ll res = (a*x)/b - a*(x/b);
    cout<<res;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,a,b,ans=0;
    cin >> n >> a >> b;
    for(int i=0;i<n+1;i++){
        int sum=0,x=i;
        while(x){
            sum+=x%10;
            x/=10;
        }
        if(a<=sum&&sum<=b) ans+=i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  string s;
  int a = 'a'%26;
  char t[26];
  REP(i,26){
    t[(i+a)%26] = 'a'+i;
  }
  /*
  REP(i,26){
    cout << t[i] << "  " ;
  }
  cout << endl;
  */
  cin >> s;
  int k;
  cin >> k;
  int np = 0;
  REP(i,k){
    int b = s[np]%26;
    int sa = 0;
    if(a < b)
      sa = 26 - (b-a);
    else
      sa = a-b;
    if(s.size() == 1 ){
      sa = k-i;
      s[0] = t[(s[0]+sa)%26];
      break;
    }
    if((k-i) >= sa && s.size() != 1){
      s[np] = t[(s[np]+sa)%26];
      np++;
      i += sa-1;
    }
    else if((k-i) < sa && s.size() != 1){
      np++;
      i--;
    }
    if(np == s.size()-1){
      i++;
      s[np] = t[(s[np]+ (k-i))%26];
      np++;
    }
    if(np == s.size())
      break;
    
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    string S;
    cin >> S;
    ll N = S.length() + 1;
    vi A(N);
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == '<') {
            A[i + 1] = A[i] + 1;
        }
    }
    for (int i = N - 2; i >= 0; i--) {
        if (S[i] == '>') {
            A[i] = max(A[i], A[i + 1] + 1);
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    int D;
    ll score = 0;
    vector<ll> c(26);
    
    
    cin >> D;
    for(int i = 0; i < 26; i++){
        cin >> c.at(i);
    }

    vector<vector<ll>> s(D, vector<ll> (26));
    vector<ll> last(26);
    fill(last.begin(), last.end(), 0);

    for(int i = 0; i < D; i++){
        for(int j = 0; j < 26; j++){
            cin >> s.at(i).at(j);
        }
    }

    vector<int> t(D);
    for(ll i = 0; i < D; i++){
        cin >> t.at(i);
        t.at(i)--;
        //cout << "-----" << endl;
        last.at(t.at(i)) = i + 1;
        score += s.at(i).at(t.at(i));
        //cout << score << endl;
        for(int number = 0; number < 26; number++){
            score = score - (ll)(c.at(number) * (i + 1 - last.at(number)));
        }
        cout << score << endl;
        //cout << "-----" << endl;
    }
    
}

Measured memory_bytes: 30496
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;

int main() {
	cin >> N;
	vector<LL>A;
	LL sum = 0;
	for (int i = 0; i < N; ++i) {
		LL a;
		cin >> a;
		A.push_back(a);
		sum += a;
	}
	LL ans = sum;
	LL par = 0;
	for (int i = 0; i < N; ++i) {
		par += A[i];
		ans = min(ans, abs(par - (sum - par)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

if a[0] != 0:
    print(0)
    exit()

a.sort()

a = s(a)
count = 1

for i in range(1,len(a)):
    if i == 1 and a[i-1][1] != 1:
        print(0)
        exit()
    if a[i][0]-1 != a[i-1][0]:
        print(0)
        exit()
    count *= (pow(a[i-1][1],a[i][1]))%998244353  
    count %= 998244353
print(count)
 


Measured memory_bytes: 65516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n)  for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define ld long double
#define ull unsigned long long int

void rayhhan_solve()
{
	int a;
	cin>>a;
	cout<<pow(a,1)+pow(a,2)+pow(a,3)<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

rayhhan_solve();

	return 0;
}

Measured memory_bytes: 4308
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
using ll = long long;

bool is_palindrome(const string& str) {
  return equal(str.begin(), str.end(), str.rbegin());
}

int main() {
  string str;
  cin >> str;

  cout << (is_palindrome(str) && is_palindrome(str.substr(0, str.size() / 2))
               ? "Yes"
               : "No")
       << endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	string s,t;

	cin >> s;
	cin >> t;

	int j = s.size();

	int k = 0;
	
	for (int i = 0; i < j;i++) {
		if (s[i] != t[i]) {
			k++;
		}
	}

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 3828
<?php

fscanf(STDIN, "%s", $s);
$word = "keyence";
$len = strlen($s);
if (substr($s, 0, 7) == $word) {
	echo "YES";
	exit;
}else if (substr($s, -7) == $word) {
	echo "YES";
	exit;
}
for ($i=1; $i < 7; $i++) { 
	$key  = substr($word, 0, $i);
	$ence = substr($word, $i-7);
	if (substr($s, 0, $i) == $key && substr($s, $i-7) == $ence) {
		echo "YES";
		exit;
	}
}

echo "NO";



Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int a, b;
    cin  >> a >> b;
    cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
idx_com = 0
idx_x = 1
idx_y = 2
idx_z = 3

n, nq = map(int, input().split())
parents = list(range(n))
ranks = [0] * n
weights = [0] * n

def find(x):
    if parents[x] == x:
        return x
    y = find(parents[x])
    weights[x] += weights[parents[x]]
    parents[x] = y
    return y

def unite(x, y, w):
    root_x = find(x)
    root_y = find(y)

    if ranks[root_x] < ranks[root_y]:
        parents[root_x] = root_y
        weights[root_x] = -w - weights[x] + weights[y]
    else:
        parents[root_y] = root_x
        weights[root_y] = +w - weights[y] + weights[x]
        if ranks[root_x] == ranks[root_y]:
            ranks[root_x] += 1

def same(x, y):
    return find(x) == find(y)

def diff(x, y):
    return weights[y] - weights[x]

for _ in range(nq):
    q = list(map(int, input().split()))
    if q[idx_com] == 0:
        unite(q[idx_x], q[idx_y], q[idx_z])
    else:
        if same(q[idx_x], q[idx_y]):
            print(diff(q[idx_x], q[idx_y]))
        else:
            print("?")



Measured memory_bytes: 11808
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main(void)
{
	char c1[33]=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char c2[33]="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
	string s1[32]={
		"101",
		"000000",
		"000011",
		"10010001",
		"010001",
		"000001",
		"100101",
		"10011010",
		"0101",
		"0001",
		"110",
		"01001",
		"10011011",
		"010000",
		"0111",
		"10011000",
		"0110",
		"00100",
		"10011001",
		"10011110",
		"00101",
		"111",
		"10011111",
		"1000",
		"00110",
		"00111",
		"10011100",
		"10011101",
		"000010",
		"10010010",
		"10010011",
		"10010000"
	};
	char s2[32][6];
	for(int i=0;i<32;i++){
		int n=i;
		for(int j=0;j<5;j++){
			if(n%2==0) s2[i][4-j]='0';
			else s2[i][4-j]='1';
			n/=2;
		}
		s2[i][5]='\0';
	}

	map<char,string> m1;
	map<string,char> m2;

	for(int i=0;i<32;i++){
		m1[c1[i]]=s1[i];
		m2[s2[i]]=c2[i];
	}

	string str;

	while(getline(cin,str)){
		string s3="";
		for(int i=0;i<str.size();i++){
			s3+=m1[str[i]];
		}
		while(s3.size()%5!=0){
			s3+='0';
		}
		string s4;
		for(int i=0;i<s3.size();i++){
			if(i%5==0){
				s4=s3[i];
			}
			else{
				s4+=s3[i];
			}
			if(i%5==4){
				cout<<m2[s4];
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1204
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/21
// =====================================================
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vvi;

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) { return b ? "true" : "false"; }
str ts(vector<bool> v) { str res; F0R(i,sz(v)) res += char('0'+v[i]); return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res; F0R(i,SZ) res += char('0'+b[i]); return res; }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

const ll MOD = 1e9+7; // 998244353;
const int MX = 3e5+5;

void solve() {
    str s;
    cin >> s;
    ll sum = 0;
    for (int i = 0; i < s.size(); ++i) {
        sum += s[i]-'0';
    }
    if (sum%9 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <bitset>
#include <climits>
#include <algorithm>
using namespace std;

#define pb push_back
#define ll long long

int main(void){
	int n, W;
	cin >> n >> W;
	vector<vector<int> > wv(n, vector<int>(2)); 
	for(int i = 0;i < n;i++){
		cin >> wv[i][0];
		cin >> wv[i][1];
	}
	vector<ll> V(100001, -1);
	V[0] = 0;
	for(int i = 0;i < n;i++){
		int v = wv[i][1];
		for(int j = 100000;j >= v;j--){
			if(V[j-v] != -1){
				if(V[j] == -1)
					V[j] = V[j-v] + (ll)wv[i][0];
				else
					V[j] = min(V[j], V[j-v] + (ll)wv[i][0]);
			}
		}
	}
	ll ans = -2;
	for(int i = 100000;i >= 0;i--){
		if(V[i] != -1 && V[i] <= W){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n, x, sum=0;
    cin >> n >> x;

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    x = x - accumulate(a.begin(), a.end(), sum);
    sort(a.begin(),a.end());
    int count = 0;
    while(x>=a[0]){
        x = x - a[0];
        count++;
        
    }
    cout << count+n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000001
using ll=long long;

void gcl(int& x,int& y){
    if(y>x) swap(x,y);
    while(y>0){
        int t=x%y;
        x=y;
        y=t;
    }
    return;
}

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

    sort(a.begin(),a.end());
    for(int i=1;i<n;i++){
        gcl(a[i],a[i-1]);
    }
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define M 200005
#define mo 1000000007
#define ll long long
int n,m,L;
char s[M];
ll ans,f[M],g[M];
ll dp[M][2];
void work() {
    while(s[m]==s[1]) m--;
    L=1e9;
    char ch=s[1];
    for(int i=2,l=1,tp=1;i<=m;i++)
	{
	    if(s[i]==ch) l++;
	    else
		{
		    if(l&1) L=min(L,l);
		    else if(tp) L=min(L,l+1);
		    l=tp=0;
		}
	}
    if(L==1e9)
	{
	    dp[1][0]=1;
	    for(int i=2;i<=n;i++)
		{
		    dp[i][0]=(dp[i-1][0]+dp[i-1][1])%mo;
		    dp[i][1]=dp[i-1][0];
		}
	    ans=(dp[n][1]+dp[n][0])%mo;
	    memset(dp,0,sizeof(dp));
	    dp[1][1]=1;
	    for(int i=2;i<=n;i++)
		{
		    dp[i][0]=(dp[i-1][0]+dp[i-1][1])%mo;
		    dp[i][1]=dp[i-1][0];
		}
	    ans=(ans+dp[n][0])%mo;
	    cout<<ans<<'\n';
	}
    else
	{
	    f[1]=g[1]=1;
	    for(int i=2;i<=n;i++)
		{
		    if(i<=L&&(i&1)) f[i]=1;
		    //for(int j=i-2;j>=max(i-L-1,0);j-=2) f[i]=(f[i]+f[j])%mo;
		    f[i]=(f[i]+g[i-2]-(i-L-3>=0?g[i-L-3]:0)+mo)%mo;
		    g[i]=(g[i-2]+f[i])%mo;
		}
	    for(int i=3;i<=L+2&&i<=n;i+=2) ans=(ans+f[n-i]*(i-1)%mo)%mo;
	    if(n-1<=L&&((n-1)&1)) ans=(ans+n)%mo;
	    cout<<ans<<'\n';
	}
}
int main()
{
    cin>>n>>m;
    scanf("%s",s+1);
    work();
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int dp[100005][3];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    rep(i, n) {
        dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i+1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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


#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;


void solve() {
    int x;
    cin >> x;
    if (x>=30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    FAST_INPUT;
    
    solve();
    
    return 0;
}


Measured memory_bytes: 3604
<?php
list($s) = strs();
$a = ['KIH', 'B', 'R'];
for ($i = 0; $i < 2 ** 4; ++$i) {
    $t = '';
    for ($j = 0; $j < 4; ++$j) {
        if ($i >> $j & 1) $t .= 'A';
        $t .= ($a[$j] ?? '');
    }
    if ($t === $s) exit('YES' . PHP_EOL);
}
echo 'NO' . PHP_EOL;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16188
N = int(input())
S = input()
ans = 0
for x in range(10):
    for y in range(10):
        for z in range(10):
            for i in range(N):
                if x != int(S[i]):
                    continue
                for j in range(i+1, N):
                    if y != int(S[j]):
                        continue
                    for k in range(j+1, N):
                        if z != int(S[k]):
                            continue
                        ans += z == int(S[k])
                        break
                    break
                break
print(ans)


Measured memory_bytes: 84748
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>
#include<queue>
#include<string>

using namespace std;
typedef long long ll;

int main(void){
    int number;
    cin>>number;
    int first;
    int second;
    int num1=number/100;
    int num2=number%100;
    if(num1<=12&&num1>=1){
        if(num2<=12&&num2>=1){
            cout<<"AMBIGUOUS"<<endl;
        }
        else{
            cout<<"MMYY"<<endl;
        }
    }
    else{
        if(num2<=12&&num2>=1){
            cout<<"YYMM"<<endl;
        }
        else{
            cout<<"NA"<<endl;
        }
    }

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    ll n, k, s;
    cin >> n >> k >> s;
    vector<ll> v(n, 1e9-1);
    for(int i = 0; i < k; i++){
        v[i] = s;
    }
    rep(i, n){
        cout << v[i] << " ";
    }
    cout << endl;
    system("pause");
}

Measured memory_bytes: 2296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)

int main()
{
  //input
  inputInt2(N,M);
  inputIntArray(a,M);
  
  //main
  long mod = 1e9+7;
  bool isBroken[N+1] = {false}; //0段目は壊れていない。
  fN(i,M) isBroken[a[i]] = true; //a[i]段目が壊れているかを格納
  
  long memo[N+10]={0};//DPのメモ
  memo[0] = 1;
  if(!isBroken[1]) memo[1]=1;
  
  for(int i=0; i<N; i++){
    if(!isBroken[i+2]) memo[i+2] += (memo[i]%mod + memo[i+1]%mod) % mod;
  }
  
  // 出力
  //fN(i,N+1) output(memo[i]);
  output(memo[N]);
    
  return 0;
}

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

int main() {
	int n;cin>>n;
	int arr[n][2];
	for (int i = 0; i < n; i++) {
	    
	   for (int j = 0; j< 2; j++) {
	       cin>>arr[i][j];
	   }
	}
	int t=0;
	for (int i = 0; i <n-2; i++) {
	    int count=0;
	    for(int j=i;j<i+3;j++){
	        if(arr[j][0]==arr[j][1]){
	            count+=1;
	        }
	    }
	    if(count>= 3){
	        t=1; break;
	    } 
	}
	if(t==1) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3592
import Control.Applicative
main = solve

solve = do
    n <- words <$> getLine
    let a = read $ n !! 0 :: Int
        op = n !! 1
        b = read $ n !! 2 :: Int
    printResult a op b

printResult :: Int -> String -> Int -> IO ()
printResult a op b
    | op == "+" = (printA $ a + b) >> solve
    | op == "-" = (printA $ a - b) >> solve
    | op == "*" = (printA $ a * b) >> solve
    | op == "/" = (printA $ a `div` b) >> solve
    | op == "?" = return ()

printA x = putStrLn $ show x

Measured memory_bytes: 3980
n,a,b,c=gets.split.map(&:to_i)
l = n.times.map {gets.to_i}
m = 1/0.0
[0,1,2,3].repeated_permutation(n) do |bi|
  ca, cb, cc = 0, 0, 0
  la, lb, lc = 0, 0, 0
  n.times do |i|
    if bi[i] == 1
      ca += 1
      la += l[i]
    elsif bi[i] == 2
      cb += 1
      lb += l[i]
    elsif bi[i] == 3
      cc += 1
      lc += l[i]
    end
  end
  next if ca * cb * cc == 0
  s = (la - a).abs + (ca - 1) * 10 + (lb - b).abs + (cb - 1) * 10 + (lc - c).abs + (cc - 1) * 10
  m = s if s < m
end
p m

Measured memory_bytes: 2172
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n,k,s;
    scanf("%d%d%d",&n,&k,&s);
    vi a(n);
    forn(i,k)
    {
        a[i]=s;
    }
    for(int i=k;i<n;i++)
    {
        a[i]=s<1000000000?s+1:s-1;
    }
    forn(i,n)printf("%d ",a[i]);
    printf("\n");   
    return 0;
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)


cost = sorted(map(int, input().split()))
m = 0
ans = [None]*n


def dfs(v, parent):
    ans[v] = cost.pop()
    if parent != -1:
        global m
        m += min(ans[v], ans[parent])
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v)


dfs(0, -1)
print(m)
print(*ans)


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) cout << a - 1 << endl;
    else  if (a <= b) cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ui unsigned int
#define li long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    li x,y;
    cin >> x;
    cin >> y;
    /* 
        x total animals 
        a * 2 
        b * 4
        y == (a * 2) + (b * 4)

     */
    string ans = "No";
    for(li i=0;i<=x;i++) {
        li b = x - i;
        if(((2*i)+(4*b))==y) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

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

//--n1m5


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)

int b[101];
int main() {
    int n; cin >> n;
    for(int i=0; i<n-1; i++) cin >> b[i];
    int res = b[0];
    for(int i=0; i<n-2; i++) {
        res += min(b[i], b[i+1]);
    }
    res += b[n-2];
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int x = fs.nextInt();
		int y = fs.nextInt();
		if (y % 2 == 1 || y < 2 * x || y > 4 * x) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 32544
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes";
	else cout << "No";
}



Measured memory_bytes: 256
N=int(input())
S=list(input())
n=0
s=S[::-1]
for i in range(len(S)):
    if s[i]=="#":
        n+=1
    else:
        break
#print(n)

B=0
W=0
Flag=0
L=[]
P="#"
CNT=0
for i in range(len(S)-n):
    if S[i]=="#":
        Flag=1
    if Flag==1:
        if S[i]=="#":
            if P=="#":
                CNT+=1
            else:
                L.append(CNT)
                P="#"
                CNT=1
        else:
            if P==".":
                CNT+=1
            else:
                L.append(CNT)
                P="."
                CNT=1
L.append(CNT)
#print(L)
#print(S)
if len(L)<2:
    print(0)
elif len(L)>=2:
    
    E=[0]
    O=[0]
    for  i in range(len(L)):
        if i%2==0:
            E.append(E[len(E)-1]+L[i])
        else:
            O.append(O[len(O)-1]+L[i])
    
    #print(E,O)
    #for i in range(len(E)):
    MIN=10**20
    for i in range(len(E)):
        if MIN>(E[i]+O[len(O)-1]-O[i]):
            MIN=(E[i]+O[len(O)-1]-O[i])
    print(MIN)
        

Measured memory_bytes: 63472
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner a = new Scanner(System.in);
        String s = "";
        for(int i = 0;i < 3;i++){
            String t = a.next();
            s += t.substring(i, i+1);
        }
        System.out.println(s);
    }
}

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

using namespace std;

int A[200005];
pair<int, int> B[200005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> A[i] >> B[i].first;
		B[i].second = i;
	}
	sort(B, B + n);
	int t = 0;
	for (int i = 0; i < n; ++i) {
		t += A[B[i].second];
		if (t <= B[i].first) continue;
		else {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

int main(void){
	int y,m,d;
	while(~scanf("%d%d%d",&y,&m,&d)){
		if(y<1868 || y==1868 && m<9 || y==1868 && m==9 && d<8)printf("pre-meiji\n");
		else if(y<1912 || y==1912 && m<7 || y==1912 && m==7 && d<=29)printf("meiji %d %d %d\n",y-1868+1,m,d);
		else if(y<1926 || y==1926 && m<12 || y==1926 && m==12 && d<=24)printf("taisho %d %d %d\n",y-1912+1,m,d);
		else if(y<1989 || y==1989 && m==1 && d<=7)printf("showa %d %d %d\n",y-1926+1,m,d);
		else printf("heisei %d %d %d\n",y-1989+1,m,d);
	}
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;

int main(){
  long long N;
  cin >> N;
  long long A;
  long long tmp;
  cin >> tmp;
  int updown = 0; // 1:up, -1:down, 0:?
  long long result = 1;
  for(int i=1;i<N;i++){
    cin >> A;
    if(updown == 1 && A < tmp){
      result++;
      updown = 0;
    }else if(updown == -1 && A > tmp){
      result++;
      updown = 0;
    }else if(updown == 0){
      if(A > tmp){
        updown = 1;
      }else if(A < tmp){
        updown = -1;
      }
    }

    tmp = A;
  }

  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    char S[105];
    ins(S);
    ll len = strlen(S);
    printf("%c%lld%c\n", S[0], len-2, S[len-1]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll N,K;
  ll h[210000];
  ll res=0;
  cin >> N>>K;

  rep(i,N) cin >> h[i];

  sort(h,h+N, greater<int>());

  rep(i,N){
    if(i<K) continue;
    res += h[i];
  }

  cout << res << endl;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include <cstdio>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>
#include <boost/multiprecision/cpp_int.hpp>


namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// 最大公約数
ll GCD(ll a, ll b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

// 最小公倍数
ll LCM(ll a, ll b)
{
    ll g = GCD(a, b);
    return a / g * b;
}

int main()
{
    string i;
    cin >> i;
    switch (i[i.length() - 1])
    {
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
        cout << "hon";
        break;
    case '0':
    case '1':
    case '6':
    case '8':
        cout << "pon";
        break;
    case '3':
        cout << "bon";
    default:
        break;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
using System;

namespace AtCoderBeginner122A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Line = Console.ReadLine().Split(' ');
            string b = Line[0];
            switch (b[0])
            {
                case 'A':
                    Console.WriteLine('T');
                    break;
                case 'T':
                    Console.WriteLine('A');
                    break;
                case 'G':
                    Console.WriteLine('C');
                    break;
                case 'C':
                    Console.WriteLine('G');
                    break;
            }
            //int N = int.Parse(Line[0]);
        }
    }
}


Measured memory_bytes: 11092
// AOJ 2014

#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int dy[] = {0, 0, 1, -1}, dx[] = {1, -1, 0, 0};
string field[60];
int h, w;
int type, cnt;
bool done[60][60];

typedef pair <int, int> P;

void dfs(int y, int x)
{
	cnt++;
	for (int i = 0; i < 4; i++){
		int ny = y + dy[i], nx = x + dx[i];
		if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
		// puts("*");
		if (!done[ny][nx] && field[ny][nx] == '.'){
			done[ny][nx] = true;
			// puts("*");
			dfs(ny, nx);
		}
		if (field[ny][nx] == 'B'){
			type |= 1;
		}
		if (field[ny][nx] == 'W'){
			type |= 2;
		}
	}
}

int main(void)
{
	while (cin >> w >> h, w && h){
		for (int i = 0; i < 60; i++){
			field[i].clear();
		}
		for (int i = 0; i < 60; i++){
			for (int j = 0; j < 60; j++){
				done[i][j] = false;
			}
		}

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

		int ret[128] = {0};
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (!done[i][j] && field[i][j] == '.') {
					done[i][j] = true;
					type = cnt = 0;
					dfs(i, j);
					// cout << cnt << " ";
					ret[type] += cnt;
					/*
					if (type == 1) cout << 'w';
					if (type == 0) cout << 'b';
					*/
				}
				// else cout << field[i][j];
			}
			// puts("");
		}
		// puts("");
/*
		for (int i = 0; i < 20; i++){
			cout << ret[i] << " ";
		}
		puts("");
*/
		cout << ret[1] << " " << ret[2] << endl;
	}
}

Measured memory_bytes: 1408