akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(){
    long n;
    scanf("%ld",&n);
    long cpy=n;
    int sum=0,i;
    
    for(i=0;i<10;i++){
        sum+=cpy%10;
        cpy=cpy/10;
    }
    
    if(n%sum==0)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> updata(N), downdata(N);
  for(int i = 0; i < N; i++) {
    cin >> updata.at(i);
  }
  for(int i = 0; i < N; i++) {
    cin >> downdata.at(i);
  }
  int ans = 0, a = 0;
  for(int i = 0; i < N; i++) {
    a = 0;
    for(int j = 0; j <= i; j++) {
      a += updata.at(j);
    }
    for(int j = i; j < N; j++) {
      a += downdata.at(j);
    }
    if (a > ans) ans = a;
  }
  cout << ans << endl;
  return 0;
}


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

int n;
void dfs(string s, char mx) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= mx+1; c++) {
        string t = s;
        t += c;
        dfs(t, max(c, mx));
    }
}

int main() {
    cin >> n;
    dfs("", 'a'-1);
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
    int n,i,max,min;
    long long sum=0;
    int a[100001];
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
        sum=sum+a[i];
        if(i==1){
            max=a[i];
            min=a[i];
        }
        else{
            if(max<a[i]){
                max=a[i];
            }
            if(min>a[i]){
                min=a[i];
            }
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  string s;
  cin>>s;
  cout<<"2018";
  for(int i=4;i<s.length();i++)
  {
    cout<<s[i];
  }
 cout<<endl;
  
  
  

}
return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()

def S(n):
    if n==0: return 0
    else:
        l = len(str(n))
        s = n//(10**(l-1))
        return s+S(n%(10**(l-1)))
if n%S(n) == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
using Graph=vector<vector<int>>;

int main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<vector<ll>> sum(N+1,vector<ll>(4,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<4;j++){
      sum.at(i+1).at(j)=sum.at(i).at(j);
    }
    if(S.at(i)=='?'){
      sum.at(i+1).at(0)++;
    }else if(S.at(i)=='A'){
      sum.at(i+1).at(1)++;
    }else if(S.at(i)=='B'){
      sum.at(i+1).at(2)++;
    }else{
      sum.at(i+1).at(3)++;
    }
  }
  int Q=sum.at(N).at(0);
  ll num1=1,num2=1,num3=1,num4=1;
  for(int i=0;i<Q;i++){
    num1*=3;
    num1%=MOD;
  }
  for(int i=0;i<Q-1;i++){
    num2*=3;
    num2%=MOD;
  }
  for(int i=0;i<Q-2;i++){
    num3*=3;
    num3%=MOD;
  }
  for(int i=0;i<Q-3;i++){
    num4*=3;
    num4%=MOD;
  }

  ll ans=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='B'){
      ans+=sum.at(i).at(1)*(sum.at(N).at(3)-sum.at(i+1).at(3))%MOD*num1;
      ans%=MOD;
      ans+=sum.at(i).at(1)*(sum.at(N).at(0)-sum.at(i+1).at(0))%MOD*num2;
      ans%=MOD;
      ans+=sum.at(i).at(0)*(sum.at(N).at(3)-sum.at(i+1).at(3))%MOD*num2;
      ans%=MOD;
      ans+=sum.at(i).at(0)*(sum.at(N).at(0)-sum.at(i+1).at(0))%MOD*num3;
      ans%=MOD;
    }else if(S.at(i)=='?'){
      ans+=sum.at(i).at(1)*(sum.at(N).at(3)-sum.at(i+1).at(3))%MOD*num2;
      ans%=MOD;
      ans+=sum.at(i).at(1)*(sum.at(N).at(0)-sum.at(i+1).at(0))%MOD*num3;
      ans%=MOD;
      ans+=sum.at(i).at(0)*(sum.at(N).at(3)-sum.at(i+1).at(3))%MOD*num3;
      ans%=MOD;
      ans+=sum.at(i).at(0)*(sum.at(N).at(0)-sum.at(i+1).at(0))%MOD*num4;
      ans%=MOD;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 7424
#encoding utf-8

import numpy as np

H, W = map(int, input().split())

a = np.zeros((H,W))

for h in range(H):
    line = list(input())
    # print(line)
    for w in range(W):
        if line[w] == "#":
            line[w] = 1
        else:
            line[w] = 0
    a[h] = line


delete_line = 0
for h in range(H):
    h = h - delete_line
    if np.allclose(a[h,:], np.zeros(W)):
        a = np.delete(a, h, 0)
        delete_line += 1

delete_row = 0
for w in range(W):
    w = w - delete_row
    if np.allclose(a[:,w], np.zeros((1,H-delete_line))):
        a = np.delete(a, w, 1)
        delete_row +=  1

b = np.array(a, dtype = str)

for h in range(H-delete_line):
    for w in range(W-delete_row):
        if a[h,w] == 1:
            b[h,w] = "#"
        else:
            b[h,w] = "."

for i in range(H-delete_line):
    print("".join(b[i,:]))


Measured memory_bytes: 13788
from collections import deque

K = int(input())
que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

count = 0
while True:
    n = que.popleft()
    count += 1
    if count == K:
        print(n)
        exit()
    if 1 <= n%10 <= 8: 
        que.append(n*10 + n%10 - 1)
        que.append(n*10 + n%10)
        que.append(n*10 + n%10 + 1)
    elif n%10 == 0:
        que.append(n*10 + n%10)
        que.append(n*10 + n%10 + 1)
    else:
        que.append(n*10 + n%10 - 1)
        que.append(n*10 + n%10)

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

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var days = new List<long>();
            var prev = 201L;
            for (var i = 0; i < A.Length; i++)
            {
                if (days.Count % 2 == 0)
                {
                    var tmp = prev;
                    for (var j = i; j < A.Length; j++)
                    {
                        if (A[j] <= tmp) tmp = A[j];
                        else
                        {
                            i = j - 1;
                            break;
                        }
                    }
                }
                else
                {
                    var tmp = prev;
                    for (var j = i; j < A.Length; j++)
                    {
                        if (A[j] >= tmp) tmp = A[j];
                        else
                        {
                            i = j - 1;
                            break;
                        }
                    }
                }
                prev = A[i];
                days.Add(prev);
            }
            if (days.Count % 2 == 1) days.RemoveAt(days.Count - 1);
            var answer = 1000L;
            var stock = 0L;
            for (var i = 0; i < days.Count; i++)
            {
                if (i % 2 == 0)
                {
                    stock += answer / days[i];
                    answer -= stock * days[i];
                }
                else
                {
                    answer += stock * days[i];
                    stock = 0;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28160
# encoding=utf-8
n = int(raw_input())

min = int(raw_input())  
keep = int(raw_input()) 
diff = keep - min       
if keep > min:
    keep = min
n = n - 2

for i in range(n):
    v = int(raw_input())
    if v - keep > diff:
        diff = v - keep
        min = keep
    elif keep > v:
        keep = v

print diff

Measured memory_bytes: 12608
n, y = map(int, input().split())


for i in range(n + 1):
    for j in range(n -i + 1):
        k = n - i - j
        val = 10000*i + 5000*j + 1000*k
        if val == y:
            print(i, j, k)
            exit()
        elif i == n:
            print(-1, -1, -1)

Measured memory_bytes: 3060
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int R = I.nextInt();
		int G = I.nextInt();
		int B = I.nextInt();
		int N = I.nextInt();
		long ans = 0;
		for (int r = 0; r <= 3000; r++) {
			for (int g = 0; g <= 3000; g++) {
				long curBalls = r*R+g*G;
				long left = N-curBalls;
				if (left>=0) {
					if (left%B==0) ans++;
				}
			}
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}



Measured memory_bytes: 25912
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DXorSum4 solver = new DXorSum4();
        solver.solve(1, in, out);
        out.close();
    }

    static class DXorSum4 {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextLong();
            }
            int[][] nb = new int[n][60];
            for (int i = n - 2; i >= 0; i--) {
                for (int j = 0; j < 60; j++) {
                    nb[i][j] = nb[i + 1][j];
                    if ((a[i + 1] & 1L << j) > 0) {
                        nb[i][j]++;
                    }
                }
            }
            long ans = 0;
            int mod = (int) 1e9 + 7;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 60; j++) {
                    if ((a[i] & 1L << j) > 0) {
                        ans += (((1L << j) % mod) * (long) ((n - i - 1 - nb[i][j]) % mod)) % mod;
                    } else {
                        ans += (((1L << j) % mod) * (long) ((nb[i][j]) % mod)) % mod;
                    }
                    ans %= mod;
                }
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 128444
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
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 h1, h2, m1, m2, k;

int main() {
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h, m;
    if(m1 > m2) {
        m = m2 - m1;
        h = h2 - h1;
    }else {
        h2--;
        m2 += 60;
        m = m2 - m1;
        h = h2 - h1;
    }

    cout << max(0, h*60 + m - k) << endl;
}

Measured memory_bytes: 3592
dc = {
    "black":(0,0,0),
    "blue":(0,0,255),
    "lime":(0,255,0),
    "aqua":(0,255,255),
    "red":(255,0,0),
    "fuchsia":(255,0,255),
    "yellow":(255,255,0),
    "white":(255,255,255)
}
while 1:
    s = raw_input()
    if s=="0": break
    g = [int(s[2*i+1:2*i+3],16) for i in xrange(3)]
    m = 1000000; ans = "";
    for k,v in dc.items():
        d = sum((v[i]-g[i])**2 for i in xrange(3))
        if d<m:
            m = d; ans = k;
    print ans

Measured memory_bytes: 4248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
inline int read() {
	int f=1,x=0; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=200005;
int n,m,r,tot,v[MAXN],f[MAXN],ans[MAXN];
struct List{
	int l,lt[MAXN],nt[MAXN<<1],v[MAXN<<1];
	void clear() { l=0; memset(lt,0,sizeof(lt)); }
	void addedge(int x,int y) { nt[++l]=lt[x]; lt[x]=l; v[l]=y; }
}E;
struct Data{
	int x,y;
	bool operator <(const Data &B)const { return x<B.x; }
}A[MAXN];
int ask(int x) { if (f[x]==x) return x; f[x]=ask(f[x]); return f[x]; }
void dfs(int x) {
	v[x]=1; A[++tot].x=ask(x); A[tot].y=x;
	for (int i=E.lt[x];i;i=E.nt[i]) if (!v[E.v[i]]) dfs(E.v[i]);
}
int main() {
	int i,j,k,l;
	n=read(); m=read(); r=read();
	for (i=1;i<=n;++i) f[i]=i; E.clear();
	for (i=1;i<=m;++i) {
		j=read(); k=read();
		E.addedge(j,k); E.addedge(k,j);
	}
	for (i=1;i<=r;++i) {
		j=ask(read()); k=ask(read());
		if (j!=k) f[j]=k;
	}
	memset(v,0,sizeof(v));
	for (i=1;i<=n;++i)
	if (!v[i]) {
		tot=0; dfs(i); sort(A+1,A+1+tot);
		for (j=1;j<=tot;j=k+1) {
			for (k=j;k<tot&&A[k+1].x==A[j].x;++k);
			for (l=j;l<=k;++l) ans[A[l].y]=k-j+1;
		}
	}
	for (i=1;i<n;++i) printf("%d ",ans[i]); printf("%d\n",ans[n]);
	return 0;
}

/*
4 3 1
1 2
2 3
3 4
2 3

*/


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 6000000 + 10;
int inv[N],fac[N];
int n,m,l,r;
LL C(int x,int y){
    return 1LL*fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
LL F(int n,int S){
    ++ n;
    return C(S+n-1,n-1);
}
LL solve(int S,int x,int a,int y,int b) {
    // printf("solve S=%d, x=%d, a=%d, y=%d, b=%d\n", S,x,a,y,b);
    LL ans = 0;
    // x<=a, y>=b
    for(int i=0;i<=x;i++){
        // i >= a+1, y >= b
        LL rem = S - 1LL*(a+1)*i - 1LL*y*b;
        if(rem < 0) {
            // printf("! ans=%lld\n",ans);
            return ans * C(x+y,x) % MOD;
        }
        ans += (i%2?-1:1) * C(x,i) % MOD * F(x+y, rem);
        //printf("i=%d, ans=%lld\n", i,ans);
        ans = (ans % MOD + MOD) % MOD;
    }
   // printf("ans=%lld\n", ans);
    return ans * C(x+y,x) % MOD;
}
LL cac(int S) {
    // a1+a2+...+an <= S
    // m >= x 且下界可以取到 
    // n-m <= x-1
    LL ans=0;
    for(int x=1;x<=S;x++){
        ans=(ans-solve(S,n-m,x-1,m,x+1)+solve(S,n-m,x-1,m,x)+MOD)%MOD;
        // printf("ans = %lld\n", ans);
    }
    // printf("S = %d, ans = %lld\n", S, ans);
    return (ans%MOD+MOD)%MOD;
}
int main() {
    inv[1]=1;
    for(int i=2;i<N;i++){
        inv[i]=(MOD-(MOD/i))*inv[MOD%i]%MOD;
    }
    inv[0]=1;fac[0]=1;
    for(int i=1;i<N;i++){
        inv[i]=1LL*inv[i-1]*inv[i]%MOD;
        fac[i]=1LL*fac[i-1]*i%MOD;
    }
    scanf("%d%d%d%d",&n,&m,&l,&r);
    //return !printf("# %lld\n", cac(r));
    LL res=(cac(r)-cac(l-1)+MOD)%MOD;
    LL tot=(F(n,r)-F(n,l-1)+MOD)%MOD;
    // printf("%lld %lld\n", res, tot);
    res=(tot-res+MOD)%MOD;
    cout<<res<<endl;
}





Measured memory_bytes: 47104
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
    den=reduce(lambda x,y:x*y%mod,range(1,r+1))
    return num*pow(den,mod-2,mod)%mod
def main():
    n,a,b=map(int,input().split())
    mod=10**9+7
    print((pow(2,n,mod)-1-mod_comb4(n,a)-mod_comb4(n,b))%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 38896
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
ans = [i[0] for i in c.items() if i[1] >= 2]
ans.extend([i[0] for i in c.items() if i[1] >= 4])
ans.extend([0,0])
ans.sort(reverse=True)
print(ans[0]*ans[1])

Measured memory_bytes: 22192
def solve(s):
  while True:
    if s == '':
      return True
    else:
      if s[0:7] == 'dreamer'[::-1]:
        s = s[7:]
      elif s[0:5] == 'dream'[::-1]:
        s = s[5:]
      elif s[0:5] == 'erase'[::-1]:
        s = s[5:]
      elif s[0:6] == 'eraser'[::-1]:
        s = s[6:]
      else:
        return False
  
print('YES' if solve(input()[::-1]) else 'NO')

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

using namespace std;

long long n,a[100005],s,t,p,x[100005];

int main() {
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i],s+=a[i];
    s*=2; s/=n; s/=(n+1);
    for(int i=1;i<=n;i++){
        if(i==n)
            t=(s+a[i]-a[1])/n;
        else
            t=(s+a[i]-a[i+1])/n;
        x[i]=t;
        if(x[i]<0){
            cout << "NO";
            return 0;
        }
    }
    long long v=0;
    for(int i=1;i<=n;i++){
        v+=x[i]*(n-i+1);
    }
    for(int i=1;i<=n;i++){
        a[i]-=v;
        v+=s;
        v-=x[i]*n;
    }
    for(int i=1;i<=n;i++){
        if(a[i]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


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

int main(){
    int N;
    cin >> N;

    int ans[100];
    for (auto& e : ans) e = 100;

    int i=0;

    if (N==0) ans[0] = 0;

    while(N!=0){
        if(N>0){
            if (N%2 == 0) ans[i] = 0;
            else ans[i] = 1;  
            N = -(N/2);
        }else{
            if ((-N)%2 == 0) ans[i] = 0;
            else ans[i] = 1;
            N = ((-N+1)/2);
        }
        //cout << "N=" << N << " ans[" << i << "]=" << ans[i] << endl;
        i++;
    }

    for (int j=99; j>=0; j--){
        if (ans[j] > 1) continue;
        cout << ans[j];
    }
    cout << endl;
}

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


bool is_palindrome(string s)
{
    string t(s.rbegin(),s.rend());
    return s == t;
}

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2)))
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<int> A;
int Smax=0;

int shami(int n,int m){
    if(A[n-1]>m)return true;
    return false;
}

int monmo(int n,int m){
    int c=0;
    if(A[0]==m)return false;
    A[n-1]++;
    while(shami(n-c,m)){
        c++;
        A[n-1-c]++;
    }
    for(int i=n-c;i<n;i++){
        A[i]=A[n-c-1];
    }
    return true;
}

int main(void){
    int n,m,q;
    int a,b,c,d;
    int sum=0;
    vector<vector<int>> v;
    
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        v.emplace_back();
        cin>>a>>b>>c>>d;
        v[i].push_back(a);
        v[i].push_back(b);
        v[i].push_back(c);
        v[i].push_back(d);
    }
    for(int i=1;i<=n;i++){
        A.push_back(1);
        //配列Aを1,1,1,,1[n個]の形に初期化する
    }
    do{
        for(int i=0;i<q;i++){
            if(((A[v[i][1]-1])-(A[v[i][0]-1]))==v[i][2])sum+=v[i][3];
        }
        if(Smax<sum)Smax=sum;
        sum=0;
    }while(monmo(n,m));
    cout<<Smax;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;


int main(){
    int a;
    string s;
    cin >> a >> s;
    
    if(a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int n, m, q, ans, cur, val[15], cnt[15];
int ca[15][55], cc[15][55], cd[15][55];

void dfs(int u) {
    if (u == n + 1) {
        if (cur > ans) ans = cur;
        return;
    }
    for (int i = val[u - 1]; i <= m; i++) {
        val[u] = i;
        int tt = 0;
        for (int j = 1; j <= cnt[u]; j++)
            if (val[u] - val[ca[u][j]] == cc[u][j])
                tt += cd[u][j];
        cur += tt;
        dfs(u + 1);
        cur -= tt;
    }
}

int main() {
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        cnt[b]++;
        ca[b][cnt[b]] = a, cc[b][cnt[b]] = c, cd[b][cnt[b]] = d;
    }
    val[0] = 1;
    dfs(1);
    printf("%d\n", ans);
}

Measured memory_bytes: 1740
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    long long a = 1;
    long long b = 1;
    for(int i=0; i<n; ++i){
        long long x, y;
        cin >> x >> y;
        long long p = max((a + x - 1) / x, (b + y - 1) / y);
        a = x * p;
        b = y * p;
    }

    long long ans = a + b;
    cout << ans << endl;

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
//#define int long long int

#define M 1e18

void solve() {
	int a,b,c;
	cin >> a >> b >> c;
	
	if(a == b && a == c) {
		cout << 1 << endl;
	} else if(a == b && a != c) {
		cout << 2 << endl;
	} else if(a != b && a == c) {
		cout << 2 << endl;
	} else if(a != b && b == c) {
		cout << 2 << endl;
	} else {
		cout << 3 << endl;
	}
}
		
			
		

int32_t main() {
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return(0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

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

  int dp[100005][3] = {};
  rep(i, n) {
    rep(j, 3) {
      if (j == 0) {
        cmax(dp[i + 1][1], dp[i][j] + a[i]);
        cmax(dp[i + 1][2], dp[i][j] + a[i]);
      } else if (j == 1) {
        cmax(dp[i + 1][0], dp[i][j] + b[i]);
        cmax(dp[i + 1][2], dp[i][j] + b[i]);
      } else {
        cmax(dp[i + 1][0], dp[i][j] + c[i]);
        cmax(dp[i + 1][1], dp[i][j] + c[i]);
      }
    }
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vi A(N);
  cin >> A;
  i64 ans = 0;
  i64 l=-1, r=0;
  i64 sum = A[0], Xor = A[0];

  while(r<N){
    if(sum == Xor){
      ans += r - l;
      if(r+1<N and (sum+A[r+1]) == (Xor^A[r+1])){
        r++;
        sum += A[r];
        Xor ^= A[r];
        continue;
      } else {
        r++;
        l++;
        sum += A[r];
        sum -= A[l];
        Xor ^= A[r];
        Xor ^= A[l];
      }
    } else {
      l++;
      sum -= A[l];
      Xor ^= A[l];
    }
  }
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1792
import math

N = int(input())

d=[]

for i in range(1,int(math.sqrt(N))+1):
    if N%i == 0:
        d.append(N//i)
        d.append(i)
    
Fmin=10**10

for i in d:
    if N%i ==0:
        A = i
        B = N//i
        F = max(len(str(A)),len(str(B)))
        if F < Fmin:
            Fmin = F
print(Fmin)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
#include<stdio.h>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
#define read(a) scanf("%d",&(a))
#define write(a) printf("%d",(a))
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int main() {
	bool ok[30];
	rep(i,30) ok[i]=false;
	rep(i,28){
		int index;
		read(index);
		ok[index-1]=true;
	}
	rep(i,30) if(!ok[i]) printf("%d\n",i+1);
}

Measured memory_bytes: 1188
#include<iostream>
#include<cstdio>
using namespace std ;
int main(){
  int n,m,a;
  char c;
  cin>>n;  
  int cards[4][14]={0};
  for(int i=0;i<n;i++){
    cin>>c>>m;
    if(c=='S')a=0;
    if(c=='H')a=1;
    if(c=='C')a=2;
    if(c=='D')a=3;
    cards[a][m]=1;
 }
  char egara[4]={'S','H','C','D'};
  for(int x=0;x<4;x++){
    for(int j=1;j<14;j++){
    if(cards[x][j]==0){
      cout<<egara[x]<<" "<<j<<endl;
    }
    }
  }
 return 0;
}

Measured memory_bytes: 3024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int h,w;
  cin>>h>>w;
  if(h%3==0 || w%3==0)cout<<0<<endl;
  else{
    int ans=INF;
    loop(i,1,w){
      vi a(3);
      a[0]=h*i;
      a[1]=(h/2)*(w-i);
      a[2]=h*w-a[0]-a[1];
      sort(all(a));
      ans=min(ans,a[2]-a[0]);
      a[0]=h*i;
      a[1]=((i+w)/2-i)*h;
      a[2]=h*w-a[0]-a[1];
      sort(all(a));
      ans=min(ans,a[2]-a[0]);
    }
    loop(i,1,h){
      vi a(3);
      a[0]=w*i;
      a[1]=(w/2)*(h-i);
      a[2]=w*h-a[0]-a[1];
      sort(all(a));
      ans=min(ans,a[2]-a[0]);
      a[0]=w*i;
      a[1]=((i+h)/2-i)*w;
      a[2]=h*w-a[0]-a[1];
      sort(all(a));
      ans=min(ans,a[2]-a[0]);
    }

    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int ans = min(a, k), t = max(0, k - a - b);
	ans -= t;
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3624
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	double n;
	while (cin >> n) {
		double ans = n, mon = n;
		for (int i = 1; i < 10; ++i) {
			if (i % 2 == 1) { mon *= 2; }
			else { mon /= 3; }
			ans += mon;
		}
		cout << setprecision(20) << ans << endl;
	}
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) {
        cin >> a[i];
    }
    int ans = INF;
    for(int i = -100; i <= 100; i++) {
        int cost = 0;
        REP(j,n) {
            cost += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

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

int main() {

  int K;
  cin >> K;

  queue<int64_t> Q;

  for(int i = 1; i < 10; i++){
    Q.push(i);
  }

  int64_t tmp;
  int amari;

  for(int i = 0; i < K - 1; i++){
    tmp = Q.front();
    amari = tmp % 10;
    if(amari != 0){
      Q.push(tmp * 10 + amari - 1);
    }
    Q.push(tmp * 10 + amari);
    if(amari != 9){
      Q.push(tmp * 10 + amari + 1);
    }
    Q.pop();
  }
  cout << Q.front() << endl;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+1>=c)cout<<b+c<<endl;
  else if(a+b+1<c)cout<<b*2+a+1<<endl;
  return 0;
}


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

int main() {
  string s; cin >> s;
  if(s.substr(0,7)=="keyence"||s.substr(s.size()-7,7)=="keyence") { 
    cout << "YES" << endl;
    return 0;
  }  
  for(int i=1; i<=6; i++){
    if(s.substr(0,i)+s.substr(s.size()-(7-i),7-i)=="keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3624
A,B,C,K = map(int,input().split())
ans=0

if(K<=A):
  ans +=K
else:
  ans +=A
K= K-A
if(K>0):
  K = K-B
  if(K>0):
    if(K<=C):
      ans=ans-K
    elif(K>C):
      ans = ans-C
print(ans)



Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    int k = (n + 1000 - 1) / 1000 * 1000;
    cout << k - n << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, a[100005], b[100005];
int hs[100005], he[100005];
int main(){
	cin >> n;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	for(int i=1; i<=n; i++) scanf("%d",&b[i]);
	for(int i=1; i<=n; i++){
		if(a[i] != a[i-1]){
			hs[i] = he[i] = a[i];
		}
		else{
			hs[i] = 1;
			he[i] = a[i];
		}
	}
	for(int i=n; i; i--){
		if(b[i] != b[i+1]){
			if(max(hs[i], b[i]) > min(he[i], b[i])){
				puts("0");
				return 0;
			}
			hs[i] = he[i] = b[i];
		}
		else{
			he[i] = min(he[i], b[i]);
		}
	}
	lint ret = 1;
	for(int i=1; i<=n; i++){
		if(hs[i] > he[i]) ret = 0;
		ret *= he[i] - hs[i] + 1;
		ret %= 1000000007;
	}
	cout << ret << endl;
}


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

int main() {
  int A, B;
  scanf("%d%d", &A, &B);

  int ans = 0;
  for (int i = 0; i < 2; i++) {
    if (A > B) {
      ans += A;
      A--;
    } else {
      ans += B;
      B--;
    }
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(){
  long int A,B,C,X,Y;
  cin>>X>>Y>>A>>B>>C;
  vector<long int> p(A);
  vector<long int > q(B);
  vector<long int > r(C);
  vector<long int> all(X+Y+C);
  for(int i=0;i<A;i++)cin>>p[i];
  for(int i=0;i<B;i++)cin>>q[i];
  for(int i=0;i<C;i++)cin>>r[i];
  sort(p.begin(),p.end(),greater<long int>());
  sort(q.begin(),q.end(),greater<long int>());
  sort(r.begin(),r.end(),greater<long int>());


  for(int i=0;i<X;i++)all[i]=p[i];
  for(int i=0;i<Y;i++)all[i+X]=q[i];
  for(int i=0;i<C;i++)all[i+X+Y]=r[i];
  long long int result=0;
  sort(all.begin(),all.end(),greater<long int>());

  for(int i=0;i<X+Y;i++)result+=all[i];
  cout<<result<<endl;






}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,ans;

  cin >> A >> B;
  ans = max(max(A*2-1,A+B),B*2-1);
  cout << ans;
}

int max(int a, int b){
  if(a < b) return b;
  return a;
}

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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> a(n+1);
    for (int64_t i = 1; i <= n; i++) cin >> a[i];
    for (int64_t i = 0; i + 1 <= n; i++) a[i+1] += a[i];

    int64_t ans = 1e18;
    for (auto itr = begin(a) + 2; itr != end(a) - 2; itr++) {
        auto lh = lower_bound(begin(a), itr + 1, *itr / 2);
        auto gh = lower_bound(itr + 1, end(a), (*itr + a.back()) / 2);

        for (auto& litr : { lh, lh - 1 }) {
            for (auto& gitr : { gh, gh - 1 }) {
                vector<int64_t> pqrs{*litr, *itr - *litr, *gitr - *itr, a.back() - *gitr};
                ans = min(ans, *max_element(begin(pqrs), end(pqrs)) - *min_element(begin(pqrs), end(pqrs)));
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    L=list(map(str,input().split()))
    A,B=map(int,input().split())
    U=str(input())

    if U==L[0]:
        print(A-1,B)
    else:
        print(A,B-1)

resolve()

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> way(H);
    rep(i,H)cin>>way[i];

    vector<vector<int> >dist(H,vector<int>(W,-1));
    queue<pair<int,int> >que;
    rep(i,H){
        rep(j,W){
            if(way[i][j]=='#'){
                que.push(make_pair(i,j));
                dist[i][j]=0;
            }
        }
    }
    while(!que.empty()){
        int y=que.front().first;
        int x=que.front().second;
        que.pop();

        for(int i=0;i<4;i++){
            int ny=y+dy[i];
            int nx=x+dx[i];

            if(ny<0||ny>=H||nx<0||nx>=W)continue;

            if(dist[ny][nx]!=-1)continue;

            dist[ny][nx]=dist[y][x]+1;
            que.push(make_pair(ny,nx));
        }
    }
    int M=0;
    rep(i,H){
        rep(j,W)if(M<dist[i][j])M=dist[i][j];
    }
    cout<<M<<endl;
    return 0;
}

//a=97,z=122

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fst first
#define snd second

typedef long long ll;

int main() {
    string s; cin >> s;
    string y = s.substr(0, 4);
    string m = s.substr(5, 2);
    string d = s.substr(8, 2);
    int yy = stoi(y), mm = stoi(m), dd = stoi(d);
    if(yy < 2019) cout << "Heisei" << endl;
    else if(yy > 2019) cout << "TBD" << endl;
    else {
        if(mm < 4) cout << "Heisei" << endl;
        else if(mm > 4) cout << "TBD" << endl;
        else {
            if(dd <= 30) cout << "Heisei" << endl;
            else cout << "TBD" << endl;
        }
    }
    return 0;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, ans = 1e9;
	cin >> n;
	vector <int> a(n);
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	for (int i=1; i<=100; i++) {
		int res = 0;
		for (auto j:a) {
			res += (j-i)*(j-i);
		}
		ans = min(ans, res);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    char c;
    cin>>c;
    if(c>='a' && c<='z')
        cout<<'a';
    else
        cout<<'A';
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  map<char, int> mp;
  string ans = "yes";
  for (char c : s) {
    if (mp.count(c)) {
      ans = "no";
      break;
    } else {
      mp[c] = 1;
    }
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
import Control.Monad

main = do
    [n,m,c] <- map read . words <$> getLine :: IO [Int]
    bs <-  map read . words <$> getLine :: IO [Int]
    ass <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    print . sum $ map (solve c bs) ass

solve :: Int -> [Int] -> [Int] -> Int
solve c bs as = if (sum $ zipWith (*) as bs) + c > 0 then 1 else 0

Measured memory_bytes: 1020
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect
import statistics
mod = 10**9+7

N = int(input())
al = [[] for i in range(N+1)]

for i in range(N-1):
    a, b = list(map(int, input().split()))

    al[a].append(b)
    al[b].append(a)

b = [0 for i in range(N + 1)]
w = [0 for i in range(N + 1)]
seen = [0 for i in range(N + 1)]

@functools.lru_cache(None)
def bfs(u):
    seen[u] = 1

    b[u] = 1
    w[u] = 1

    for v in al[u]:
        if seen[v] == 0:
            seen[v] = 1
            bfs(v)
            b[u] = (b[u] * w[v]) % mod
            w[u] = (w[u] * ((b[v] + w[v]) % mod)) % mod

bfs(1)

print((b[1] + w[1]) % mod)






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

#define AB "AB"
#define B 'B'
#define A 'A'

int contain(string s);

int main() {
  int N, i, ct, b, a, ba;
  string s;
  cin >> N;
  ct = b = a = ba = 0;
  
  for(i=0; i<N; i++) {
    cin >> s;
    if (s[0] == B && s[s.length()-1] == A) { 
      ba++;
    } else if ( s[0] == B ) {
      b++;
    } else if ( s[s.length()-1] == A ) {
      a++;
    }
    ct += contain(s);
  }

  ct += ( ba != 0 ) ? ba-1 : 0;
  if ( b > 0 && a > 0 ) {
    if ( ba != 0 ) { ct += 2; a--; b--; }
    ct += ( b > a ) ? a : b;
  } else if ( !( b == 0 && a == 0 ) ) {
    if ( ba != 0 ) { ct++; }
  }

  cout << ct << endl;
  return 0;
}

int contain(string s) {
  int ct, pos;
  ct = 0;
  pos = s.find(AB);
  while ( pos != -1 ) {
    ct++;
    s.erase(s.begin(), s.begin()+pos+2);
    pos = s.find(AB);
  }
  return ct;
}

Measured memory_bytes: 256