akhauriyash/Code-Regression huggingface dataset:
N=raw_input()
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])

if A+B+C+D==7:
	print str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7"
elif A-B+C+D==7:
	print str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7"
elif A+B-C+D==7:
	print str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7"
elif A+B+C-D==7:
	print str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7"
elif A-B-C+D==7:
	print str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7"
elif A-B+C-D==7:
	print str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7"
elif A+B-C-D==7:
	print str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7"
elif A-B-C-D==7:
	print str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7"



Measured memory_bytes: 2696
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	long long int n,m,x,y,f = -1;
	vector<long long int> a,b,c,d,e;
	
	cin >> n >> m;
	
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	for(int i = 0; i < m; i++){
		cin >> x >> y;
		c.push_back(x);
		d.push_back(y);
	}
	
	for(int i = 0; i < n; i++){
		y = 0;
		for(int j =0; j < m; j++){
			x = abs(a[i] - c[j]) + abs(b[i] -d[j]);
			if(y == 0){
				e.push_back(j+1);
				f = x;
			}	
			if(f > x){
				e[i] = j+1;
				f = x;
			}
			y = 1;
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << e[i] << endl;
	}
	
	return 0;
}

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

int main()
{
	int N,A,B;

	cin >> N;

	if (N == 1) {
		cout << "Hello World" << endl;
	}

	else if (N == 2) {
		cin >> A >> B;
		cout << A + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if((z->key) < (x->key)) {
      x = x->left;
    }else {
      x = x->right;
    } 
  }

  z->parent = y;
  if(y == NIL) {
    root = z;
  }else {
    if((z->key) < (y->key)) {
      y->left = z;
    }else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    
    scanf("%s", com);
    
    if(strcmp(com,"insert") == 0) {
      scanf("%d", &x);
      insert(x);
    } else if (strcmp(com,"print") == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}




Measured memory_bytes: 25152
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int cc[100006];
int p;
int k;
char sss[28]="abcdefghijklmnopqrstuvwxyz";
int main()
{
	cin>>s;
	cin>>k;
	p=s.size();
	rep(i,p)
	{
		cc[i]=(int)(s[i]-'a');
	}
	rep(i,p)
	{
		if(cc[i]==0&&i!=p-1)continue;
		if(k>=26-cc[i])
		{
			k-=(26-cc[i]);
			cc[i]=0;
		}
		if(i==p-1)
		{
			cc[i]+=k;
			cc[i]%=26;
		}
	}
	rep(i,p)
	{
		cout<<sss[cc[i]];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (d1 < 28)
  {
    cout << 0 << endl;
    return 0;
  }
  if (m1 == 2)
  {
    if (d1 == 28)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  else if (m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11)
  {
    if (d1 == 30)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  else
  {
    if (d1 == 31)
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }

  return 0;
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;  

    string s;
    vector<string>v{"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin>>s;
    vector<string>::iterator it;
    it=find(all(v),s);
    x=distance(v.begin(),it);
    cout<<7-x<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

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

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#define max 100
int main()
{
    long int i,N;
    scanf("%d",&N);
    if(N>=1 && N<=999)
    {
        printf("ABC\n");
    }
    else if(N>999 && N<=1998)
    {
        printf("ABD\n");
    }
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, M = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

pair_list = []
for i in range(N):
    pair_list.append((A[i],B[i]))
pair_list.sort(key=lambda tup: tup[0],reverse=False)
sum_price = 0
sum_num = 0
for price, num in pair_list:
    if(sum_num + num >= M):
        sum_price += price * (M - sum_num)
        sum_num = N
        #print(sum_price)
        break
    else:
        sum_price += price * num
        sum_num += num
        #print(sum_price)
# 出力
print(sum_price)

Measured memory_bytes: 19804
#include <iostream>
#include <string>
#include <cstdio>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main(void){
    string A,B;
    bool n=0;
    cin >> A >> B;
    if(A.size()>B.size()){
        cout << "GREATER";
        n=1;
    }else if(A.size()<B.size()){
        cout << "LESS";
        n=1;
    }else{
        REP(i,A.size()){
            if(A[i]>B[i]){
                cout << "GREATER";
                n=1;
                break;
            }else if(A[i]<B[i]){
                cout << "LESS";
                n=1;
                break;
            }
            
        }
        if(n==0){cout << "EQUAL";}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <vector>
#include <complex>
#include <cstdio>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef complex<double> vec;

double cross(const vec& a, const vec& b) {
    return imag(conj(a)*b);
}

int dx1[] = {1,0,0,-1}; // tateyoko
int dy1[] = {0,1,-1,0};
int dx2[] = {1,1,-1,-1}; // naname
int dy2[] = {-1,1,-1,1};
inline bool in(int x, int y){
    return 0<=x && 0<=y && x<10 && y<10;
}

int main(){
    vvi g(10,vi(10));
    int x,y,s;
    while(scanf("%d,%d,%d", &x,&y,&s)!=EOF){
        g[y][x]++;
        if(s==3){
            rep(d,4){
                for(int t=1; t<=2; t++){
                    int px=x+dx1[d]*t;
                    int py=y+dy1[d]*t;
                    if(in(px,py)) g[py][px]++;
                }
                int px=x+dx2[d];
                int py=y+dy2[d];
                if(in(px,py)) g[py][px]++;
            }
        }else if(s==2){
            rep(d,4){
                int px=x+dx1[d];
                int py=y+dy1[d];
                if(in(px,py)) g[py][px]++;
                px=x+dx2[d];
                py=y+dy2[d];
                if(in(px,py)) g[py][px]++;

            }
        }else if(s==1){
            rep(d,4){
                for(int t=1; t<=1; t++){
                    int px=x+dx1[d]*t;
                    int py=y+dy1[d]*t;
                    if(in(px,py)) g[py][px]++;
                }
            }
        }
    }
    int z=0;
    int ans=-1;
    rep(i,10)rep(j,10){
        if(g[i][j]==0)z++;
        ans=max(ans,g[i][j]);
    }
    cout << z << "\n" << ans << endl;
}

Measured memory_bytes: 1228
def main(N, K):
    print(K * (K-1)**(N-1))

if __name__ == "__main__":
    N, K = [int(x) for x in input().split()]

    main(N, K)

def test1(capsys):
    inputs = [2, 2]
    out = 2
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test3(capsys):
    inputs = [1, 10]
    out = 10
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test4(capsys):
    inputs = [10, 8]
    out = 322828856
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test5(capsys):
    inputs = [1, 2]
    out = 2
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'


Measured memory_bytes: 3064
N,K = map(int,input().split())
A = list(map(int, input().split()))

X = list(range(1,N+1))
lo = 1
hi = max(A)

while hi-lo>=2:
    mid = (lo+hi)//2
    
    temp = list(map(lambda x:  x//mid - (x%mid==0) ,A))
    if sum(temp) <= K:
        hi = mid
    else:
        lo = mid

temp = list(map(lambda x:  x//lo - (x%lo==0) ,A))

if sum(temp) <= K:
    print(lo)
else:
    print(hi)

Measured memory_bytes: 40044
#include<bits/stdc++.h>
int n,as[300007];
struct pos{
	int w,p;
	bool operator<(const pos&w)const{return p<w.p;}
}ps[555];
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i){
		scanf("%d",&x);
		as[x]=i;
		ps[i]=(pos){i,x};
	}
	std::sort(ps+1,ps+n+1);
	int L=1,R=n*n;
	for(int i=1;i<=n;++i){
		for(int j=ps[i].w-1,p=ps[i].p;j;--j){
			while(L<=p&&as[L])++L;
			if(L>p)return puts("No"),0;
			as[L]=ps[i].w;
		}
	}
	for(int i=n;i;--i){
		for(int j=n-ps[i].w,p=ps[i].p;j;--j){
			while(R>=p&&as[R])--R;
			if(R<p)return puts("No"),0;
			as[R]=ps[i].w;
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;++i)printf("%d ",as[i]);
	return 0;
}

Measured memory_bytes: 2176
#include  <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int H,h,M,m,K;
  cin>>H>>M>>h>>m>>K;
  cout<<h*60+m-H*60-M-K<<endl;
  
  return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int N;
    int[] A;
    const int mod = (int)1e9 + 7;
    void Solve() {
        //input
        N = io.Int;
        A = new int[N];
        for (int i = 0; i < N; ++i)
            A[i] = io.Int;
        //cal
        var dic = new Dictionary<int, int>();
        foreach (var v in A) {
            if (!dic.ContainsKey(v)) dic[v] = 0;
            dic[v]++;
        }
        var isOdd = N % 2 != 0;
        var isValid = isOdd ? dic.Count(v => v.Value != 2) == 1 &&dic.Where(v=>v.Value==1).All(v=>v.Key==0): 
                              dic.All(v => v.Value == 2);
        var ans = 1L;
        if (isValid) {
            var n = isOdd ? dic.Keys.Count - 1 : dic.Keys.Count;
            for (int i = 0; i < n; ++i) {
                ans = (ans * 2) % mod;
            }
        } else {
            ans = 0;
        }
        //ret
        WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 19808
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++)cin>>a[i];
	int allgcd=a[1];
	for(int i=2;i<=n;i++)
	{
	    allgcd=__gcd(a[i],allgcd);
	    if(allgcd==1)break;
	}
	int high = 0; 
    for (int i = 1; i <= n; i++) 
        high = max(high, a[i]); 
  
    // Maintaining count array 
    int count[high + 1] = {0}; 
    for (int i = 1; i <= n; i++) 
        count[a[i]]++; 
  
    // Variable to store the 
    // multiples of a number 
    int counter = 0; 
  
    // Iterating from MAX to 1 
    // GCD is always between 
    // MAX and 1. The first 
    // GCD found will be the 
    // highest as we are  
    // decrementing the potential 
    // GCD 
    ll f=1;
    for (int i = high; i >= 1; i--) 
    { 
        int j = i; 
       counter = 0; 
    
        // Iterating from current 
        // potential GCD 
        // till it is less than 
        // MAX 
        ll g=0;
        while (j <= high) 
        { 
            // A multiple found 
  
            if(count[j] >=2) {
              g=1; f=j;break; }
  
           else if (count[j] == 1)          
                counter++;          
  
            // Incrementing potential 
            // GCD by itself 
            // To check i, 2i, 3i.... 
            j += i; 
  
            // 2 multiples found, 
            // max GCD found 
            if (counter == 2) {         
               g=1; f=i;break; }
        } 
        if(g)break;
    }
        if(f==1)cout<<"pairwise coprime";
        else if(allgcd==1)cout<<"setwise coprime";
        else cout<<"not coprime";
	return 0;
}


Measured memory_bytes: 11116
#include <iostream>
using namespace std;
int main() {
  char s, c;
  cin >> s >> c;
  if(s == 'H' && c == 'H' || s == 'D' && c == 'D') {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



bool coin[600][600];
int sx[600][601];
int sy[600][601];



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

	int h, w;
	cin >> h >> w;
	rep(i,h)rep(j,w) {
		char c;
		cin >> c;
		if (c=='#') {
			int y = i - j + w - 1;
			int x = i + j;
			coin[y][x] = true;
			sx[x][y+1]++;
			sy[y][x+1]++;
		}
	}

	rep(x, h+w)rep(y, h+w)sx[x][y + 1] += sx[x][y];
	rep(y, h+w)rep(x, h+w)sy[y][x + 1] += sy[y][x];



	long long ans1 = 0, ans2 = 0;
	rep(y, h+w)rep(x,h+w)if(coin[y][x]) {
		rep(y2, h+w) if (y != y2 && coin[y2][x]) {
			int ymi = min(y, y2), yma = max(y, y2);
			int d = yma - ymi;
			if (x - d >= 0) {
				ans1 += sx[x - d][yma] - sx[x - d][ymi+1];
				if (coin[y][x - d])ans2++;
				if (coin[y2][x - d])ans2++;
			}
			if (x+d < 600) {
				ans1 += sx[x + d][yma] - sx[x + d][ymi+1];
				if (coin[y][x + d])ans2++;
				if (coin[y2][x + d])ans2++;
			}
		}
		rep(x2, h+w) if (x != x2 && coin[y][x2]) {
			int xmi = min(x, x2), xma = max(x, x2);
			int d = xma - xmi;
			if (y - d >= 0) {
				ans1 += sy[y - d][xma] - sy[y - d][xmi+1];
				if (coin[y - d][x])ans2++;
				if (coin[y - d][x2])ans2++;
			}
			if (y + d < 600) {
				ans1 += sy[y + d][xma] - sy[y + d][xmi+1];
				if (coin[y + d][x])ans2++;
				if (coin[y + d][x2])ans2++;
			}
		}
	}

	cout << ans1/2 + ans2/4 << endl;


	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}

// ----------------------------------------------------------------------

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, M; cin >> N >> M;
  vector<vector<int>> nbr(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
  }
  int Q; cin >> Q;
  vector<int> V(Q), D(Q), C(Q);
  for (int i = 0; i < Q; i++) {
    int v, d, c; cin >> v >> d >> c; v--;
    V.at(i) = v;
    D.at(i) = d;
    C.at(i) = c;
  }
  vector<int> rad(N, -1), col(N);
  for (int i = Q-1; i >= 0; i--) {
    auto paint = fix([&](auto recF, int v, int d) -> void {
	if (rad.at(v) >= d) return;
	rad.at(v) = d;
	if (col.at(v) == 0) col.at(v) = C.at(i);
	if (d == 0) return;
	for (int w : nbr.at(v)) recF(w, d-1);
      });
    paint(V.at(i), D.at(i));
  }
  for (int i = 0; i < N; i++) {
    cout << col.at(i) << "\n";
  }

  return 0;
}



Measured memory_bytes: 8440
#インプットdataの格納
juge_letter = input().lower()
input_letter = list()
while True:
    input_letter_temp = input()
    if input_letter_temp == "END_OF_TEXT":
        break
    input_letter += input_letter_temp.lower().split()

#判定結果
print(input_letter.count(juge_letter))



Measured memory_bytes: 5548
#include <stdio.h>
int main(int argc, const char * argv[]) {

    int a,b=1;
    while(1){
        scanf("%d",&a);
        if(a==0){
            break;
        }
        printf("Case %d: %d\n",b,a);
        b++;
    }
    return 0;
}


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

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

int ans[200005];

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

	int n; cin >> n;
	rep(i, 1, n) {
		int t; cin >> t;
		ans[t]++;
	}
	rep(i, 1, n + 1) cout << ans[i] << endl;
}


Measured memory_bytes: 4424
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    int r, c, r_sum, c_sum;
    vector < vector<int> > sheet;
    std::cin >> c >> r;
    sheet.resize(c+1);
    for (int i=0; i<=c; ++i){
        sheet[i].resize(r+1);
    }
    for (int i=0; i<c; ++i){
        r_sum = 0;
        for (int j=0; j<=r; ++j){
            if (j != r){
                std::cin >> sheet[i][j];
                r_sum += sheet[i][j];
            }
            else {
                sheet[i][j] = r_sum;
            }
        }
    }
    for (int i=0; i<c; ++i){
        for (int j=0; j<=r; ++j){
            if (j == r){
                std::cout << sheet[i][j] << endl;
            }
            else {
                std::cout << sheet[i][j] << " ";
            }
        }
    }
    for (int j=0; j<=r; ++j){
        c_sum = 0;
        for (int i=0; i<=c; ++i){
            if (i != c){
                c_sum += sheet[i][j];
            }
            else {
                sheet[i][j] = c_sum;
                if (j == r){
                    std::cout << sheet[i][j] << endl;
                }
                else {
                    std::cout << sheet[i][j] << " ";
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3100
function Main(input) {
  var inputList = input.split("\n");
  var firstLine = inputList[0].split(" ");
  var N = Number(firstLine[0]);
  var M = Number(firstLine[1]);
  var checkedList = [];
  var neighbourVertices = [];
  var depth = 0;

  for (var i = 0; i < N; i++) {
    neighbourVertices[i] = [];
    checkedList[i] = false;
  }
  checkedList[0] = true;

  for (var i = 1; i < 1 + M; i++) {
    var line = inputList[i].split(" ");
    var a = Number(line[0]) - 1;
    var b = Number(line[1]) - 1;
    neighbourVertices[a].push(b);
    neighbourVertices[b].push(a);
  }

  function search(vertIndex, num, checkedList, depth) {
    var allTrue = true;

    for (var i = 0; i < checkedList.length; i++) {
      if (checkedList[i] == false) {
        allTrue = false;
        break;
      }
    }

    if (allTrue) {
      num++;
      return num;
    }

    var indexes = neighbourVertices[vertIndex];
    for (var i = 0; i < indexes.length; i++) {
      var n = indexes[i];
      if (checkedList[n]) {
        continue;
      }
      checkedList[n] = true;
      depth++;
      num = search(n, num, checkedList, depth);
      depth--;
      checkedList[n] = false;
    }
    return num;
  };

  console.log(search(0, 0, checkedList, depth))
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

ll dp[10010][110][2] = {1};
ll mod = 1e9 + 7;
string k;
int d;

int norm(int a, int b) {
    int r = a - b;
    while (r < 0)
        r += d;
    return r;
}

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

    cin >> k >> d;
    int n = k.size();

    rep(i, 0, n) {
        int c = k[i] - '0';
        rep(j, 0, d) {
            rep(l, 0, 10) dp[i + 1][j][1] += dp[i][norm(j, l)][1];
            rep(l, 0, c) dp[i + 1][j][1] += dp[i][norm(j, l)][0];
            dp[i + 1][j][1] %= mod;
            dp[i + 1][j][0] = dp[i][norm(j, c)][0];
        }
    }
    cout << (dp[n][0][0] + dp[n][0][1] + mod - 1) % mod << endl;
    return 0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int N;
pair <int, int> A[100005];
pair <pair <int, int>, int> Left[100005], Right[100005];
bool Use[100005];
int l, r, last, cnt;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> A[i].first >> A[i].second;
        Left[i] = Right[i] = make_pair(A[i], i);
        swap(Right[i].first.first, Right[i].first.second);
    }
    sort(Left + 1, Left + N + 1);
    sort(Right + 1, Right + N + 1);
    for(int i = 1; i <= N; i++)
        swap(Right[i].first.first, Right[i].first.second);
}
inline int mod(int a)
{
    return max(a, -a);
}
long long step(bool dir)
{
    int ans = 0;
    if(dir == 0)
    {
        while(r >= 1 && Use[Left[r].second] == 1)
            --r;
        if(r >= 1)
        {
            if(last >= Left[r].first.first)
                return 0;
            ans = mod(last - Left[r].first.first);
            last = Left[r].first.first;
            Use[Left[r].second] = 1;
            cnt++;
        }
    }
    else
    {
        while(l <= N && Use[Right[l].second] == 1)
            ++l;
        if(l <= N)
        {
            if(last <= Right[l].first.second)
                return 0;
            ans = mod(last - Right[l].first.second);
            last = Right[l].first.second;
            Use[Right[l].second] = 1;
            cnt++;
        }
    }
    return ans;
}
int main()
{
    Read();
    long long ans1 = 0, ans2 = 0;
    l = 1; r = N; cnt = 0;
    int start = 0;
    int stp = 0;
    while(cnt < N && stp <= N + 5)
    {
        ans1 += step(start);
        start = 1 - start;
        ++stp;
    }
    ans1 += mod(last);
    l = 1, r = N; cnt = 0;
    start = 1;
    stp = 0;
    last = 0;
    for(int i = 1; i <= N; i++)
        Use[i] = 0;
    while(cnt < N && stp <= N + 5)
    {
        ans2 += step(start);
        start = 1 - start;
        ++stp;
    }
    ans2 += mod(last);
    cout << max(ans1, ans2) << "\n";
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 924844033;
const int PRT = 5;

int power(int x, int t)
{
	int ret = 1;
	while(t > 0) {
		if(t & 1) ret = 1LL * ret * x % MOD;
		x = 1LL * x * x % MOD;
		t >>= 1;
	}
	return ret;
}

void DFT(int from[], int to[], int len, int dir)
{
	int cur = 0;
	rep(i, 1 << len) {
		to[cur] = from[i];
		for(int j = len - 1; j >= 0; j --) {
			cur ^= 1 << j;
			if((cur >> j) & 1) break;
		}
	}
	
	for(int d = 2; d <= (1 << len); d <<= 1) {
		int cr = power(PRT, MOD - 1 + (MOD - 1) / d * dir);
		for(int i = 0; i < (1 << len); i += d) {
			int rt = 1;
			for(int j = i; j < i + (d >> 1); j ++) {
				int ev = to[j], od = 1LL * to[j + (d >> 1)] * rt % MOD;
				to[j] = (ev + od) % MOD;
				to[j + (d >> 1)] = (ev - od + MOD) % MOD;
				rt = 1LL * rt * cr % MOD;
			}
		}
	}
	
	if(dir < 0) {
		int gr = power(1 << len, MOD - 2);
		rep(i, 1 << len) to[i] = 1LL * to[i] * gr % MOD;
	}
}

int _u[524288], _v[524288], _w[524288];
void poly_mul(int p0[], int p1[], int ret[], int n)
{
	int cl = 0;
	while((1 << cl) <= n) cl ++;
	cl ++;
	
	rep(i, 1 << cl) {
		_u[i] = i <= n ? p0[i] : 0;
		_v[i] = i <= n ? p1[i] : 0;
	}
	DFT(_u, _w, cl, 1);
	DFT(_v, _u, cl, 1);
	rep(i, 1 << cl) _v[i] = 1LL * _u[i] * _w[i] % MOD;
	DFT(_v, _w, cl, -1);
	
	for(int i = 0; i <= 2 * n; i ++) ret[i] = _w[i];
}

int inv[200005];
int fac[200005], ifac[200005];
void gen_fac(int n)
{
	inv[1] = 1;
	for(int i = 2; i <= n; i ++) inv[i] = MOD - 1LL * inv[MOD % i] * (MOD / i) % MOD;
	
	fac[0] = ifac[0] = 1;
	rep1(i, n) {
		fac[i] = 1LL * fac[i - 1] * i % MOD;
		ifac[i] = 1LL * ifac[i - 1] * inv[i] % MOD;
	}
}

int n;
vector<int> G[200005];

int sz[200005];
void dfs(int v, int par)
{
	sz[v] = 1;
	rep(i, G[v].size()) {
		int u = G[v][i];
		if(u == par) continue;
		dfs(u, v);
		sz[v] += sz[u];
	}
}

int poly0[400005], poly1[400005], poly2[400005];

int main()
{
	scanf("%d", &n);
	rep(i, n - 1) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, -1);
	
	poly0[n] = n;
	rep1(i, n) rep(j, G[i].size()) {
		int nj = G[i][j];
		if(sz[nj] > sz[i]) poly0[n - sz[i]] --;
		else poly0[sz[nj]] --;
	}
	
	gen_fac(n);
	rep1(i, n) poly0[i] = 1LL * (MOD + poly0[i]) * fac[i] % MOD;
	for(int i = 0; i <= n; i ++) poly1[i] = ifac[n - i];
	
	poly_mul(poly0, poly1, poly2, n);
	
	rep1(i, n) printf("%d\n", 1LL * poly2[n + i] * ifac[i] % MOD);
	return 0;
}

Measured memory_bytes: 40320
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int N,K,d,a,i,j,ans;

    cin >> N >> K;

    vector<bool> A(N,false);

    i = 0;
    while(i<K){
        cin >> d;
        j = 0;
        while(j<d){
            cin >> a;
            A[a-1] = true;
            j++;
        }
        i++;
    }

    ans = 0;

    for(i=0;i<N;i++){
        if(!A[i]){
        ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>


typedef long long ll;
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////



pair<int, int>p[112345];

int r;
int g;
int b;
int sum;

int main(){
  
  cin>>r>>g>>b;
  
  sum = 100*r+10*g+b;
  
  if( sum % 4 ){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
N=int(input())
v=[int(i) for i in input().split()]
if N==2:
    if v[0]==v[1]:
        print(1)
        exit()
    else:
        print(0)
        exit()
A=dict()
B=dict()
L=0
R=0
def inc(D,k):
    if k in D:
        D[k]+=1
    else:
        D[k]=1
for i in range(N):
    if i%2==0:
        L+=1
        inc(A,v[i])
    else:
        R+=1
        inc(B,v[i])
X=[(L,-1)]
Y=[(R,-2)]
for i in A:
    X.append((L-A[i],i))
for i in B:
    Y.append((R-B[i],i))
X.sort(reverse=True)
Y.sort(reverse=True)
if X[-1][1]!=Y[-1][1]:
    print(X[-1][0]+Y[-1][0])
else:
    vl=X[-1][0]+Y[-2][0]
    vr=X[-2][0]+Y[-1][0]
    print(min(vl,vr))

    


Measured memory_bytes: 23836
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define MAX 100005
#define NIL -1

using namespace std;

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

const long long INF = 1LL << 60;

int main() {
    string s;
    int cnt = 0;
    cin >> s;
    for(int i = 0; i < s.size() / 2; i++) {
        // cout << s[i] << " : " << s[s.size() - 1 - i] << endl;
        if(s[i] != s[s.size() - 1 - i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin >> a >> b;
	int ans = INT_MAX;
	ford(i, 1000, 1) {
		if(i*8/100 != a or i/10 != b) continue;
		ans = i;
	}
	if(ans == INT_MAX) println("-1");
	else println(ans);
}


Measured memory_bytes: 256
#include<iostream>
#define N 1000000
using namespace std;
void PrimeNum(int n,bool Primeif[]){
  for(int i = 2;i*i < n;i++){
    if(Primeif[i] == true){
      for(int k = 2;k * i < n;k++){
	Primeif[k*i] = false;
}
    }
  }
}
int main(){
  int n,num;
  bool Primeif[N+1];
  Primeif[1] = false;
  for(int i = 2;i < N;i++){
    Primeif[i] = true;
  }
  PrimeNum(N+1,Primeif);
  
  while(cin >> n){
    num = 0;
    for(int i = 0;i <= n;i++){
      if(Primeif[i] == true){
	num = num+1;
      }
    }
     cout << num << endl;
     
   } 
    
}   
       

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,N=1,M=1,ans,a=1000000007;
  cin >> n >> m;
  if(abs(n-m)>1){
    ans=0;
  }else{
    for(long long i=1;i<=n;i++){
      N*=i;
      if(N>=a){
        N%=a;
      }
    }
    for(long long i=1;i<=m;i++){
      M*=i;
      if(M>=a){
        M%=a;
      }
    }
    if(n==m){
      ans=(2*N*M)%a;
    }else{
      ans=(N*M)%a;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#define mp make_pair
#define INF 1e+9
using namespace std;

struct edge{ int to,cost,t,com; };
typedef pair<int,int> TV;//time,vertex
typedef pair<int,TV> P;//cost

int main(){
	int n,m,h,k,S,T,pp;
	while(1){
		int d[100][256][25],pc[256],pcom[256] = {};
		vector<edge> G[100];
		cin >> n >> m >> h >> k;
		if(!n) break;
		for(int i = 0;i < m;i++){
			int a,b,c,t,r;
			cin >> a >> b >> c >> t >> r; a--;b--;r--;
			G[a].push_back({b,c,t,r});
			G[b].push_back({a,c,t,r});
		}
		cin >> S >> T >> pp; S--;T--;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < (1 << k);j++) {
				for(int l = 0;l <= 24;l++){
					if(i == S && l == 0) d[i][j][l] = 0;
					else d[i][j][l] = INF;
				}
			}
		}
		for(int i = 0;i < pp;i++){
			int l;
			cin >> l >> pc[i];
			for(int j = 0;j < l;j++){
				int tt;
				cin >> tt;
				pcom[i] = pcom[i] | (1 << (tt - 1));
			}
		}
		for(int i = 0;i < (1 << k);i++){
			priority_queue<P,vector<P>,greater<P> > que;
			que.push(mp(0,mp(0,S)));
			while(!que.empty()){
				P p = que.top();que.pop();
				int cost = p.first,t = p.second.first,v = p.second.second;
				if(d[v][i][t] < cost) continue;
				for(int j = 0;j < (int)G[v].size();j++){
					edge e = G[v][j];
					int ec = e.cost;
					if((i >> e.com) & 1) ec = 0;
					if(t + e.t <= h && d[v][i][t] + ec < d[e.to][i][t + e.t]){
						d[e.to][i][t + e.t] = d[v][i][t] + ec;
						que.push(mp(d[e.to][i][t + e.t],mp(t + e.t,e.to)));
					}
				}
			}
		}
		int dp[257][256];
		for(int i = 0;i <= pp;i++){
			for(int j = 0;j < (1 << k);j++) dp[i][j] = INF;
		}
		dp[0][0] = 0;
		for(int i = 0;i < pp;i++){
			for(int j = 0;j < (1 << k);j++){
				dp[i + 1][j] = min(dp[i + 1][j],dp[i][j]);
				for(int l = 0;l < (1 << k);l++){
					dp[i + 1][j | (pcom[i] & l)] = min(dp[i + 1][j | (pcom[i] & l)],dp[i][j] + pc[i]);
				}
			}
		}
		int mi = INF;
		for(int i = 0;i < (1 << k);i++){
			//cout << d[T][i] << " " << dp[pp][i] << endl;
			for(int j = 0;j <= h;j++){
				mi = min(mi,d[T][i][j] + dp[pp][i]);
			}
		}
		if(mi != INF) cout << mi << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5948
import collections
N=int(input())
blue=[input() for _ in range(N)]
b = collections.Counter(blue)
M=int(input())
for i in range(M):
  a = input()
  if a in b:
    b[a] = b[a]-1
ans = max(b.values())
print(0 if ans<0 else ans)

Measured memory_bytes: 3444
n,m = map(int,input().split())
arr = list(map(int,input().split()))

kouho = [True for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    if arr[a-1] >= arr[b-1]:
        kouho[b-1] = False
    if arr[a-1] <= arr[b-1]:
        kouho[a-1] = False

# print(kouho)
print(sum(kouho))



Measured memory_bytes: 85092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  string str;
  cin >> str;
  for(int i=1; i<str.length(); i++){
    if((str.length()-i) % 2 != 0) continue;
    int half = (str.length()-i) / 2;
    bool found = true;
    rep(j, half){
      if(str[j] != str[half+j]) found = false;
    }
    if(found){
      cout << str.length()-i << endl;
      return 0;
    }
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int N,k;
    cin>>N>>k;
    vector <int> v(N);
    for(int &x : v)
		cin>>x;
		
	vector <int> cost(N);
	cost[0] = 0; cost[1] = abs(v[1] - v[0]);
	for(int i = 2; i < N ; i++ )
	{	int minCost = INT_MAX;
		for(int j = 1 ; i-j >= 0 && j <= k; j++)
			minCost = min(cost[i-j] + abs(v[i] - v[i-j]), minCost);
			
		cost[i] = minCost;
	}
		
	
	cout<<cost[N-1];
    return 0;
}



Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    sort(ALL(p));
    int ans = 0;
    rep(i, n - 1){
        ans += p[i];
    }
    cout << ans + p[n-1] / 2 << endl;

    return 0;
}


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


void solve(){
  int k,s,x,y,z;
  int count=0;
  scanf("%d %d",&k,&s);
  for (int i = 0; i <= k; i++)
  {
    for (int j = 0; j <= k; j++)
    {
      
      if(s-i-j<=k && i+j<=s)count++;      
    }
    
  }
  

  printf("%d\n",count);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
 le();
  */
  solve();

  return 0;
}

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

int main()
{
    int H,heap[251];
    cin>>H;
    for(int i=1;i<=H;i++)
        cin>>heap[i];
    for(int i=1;i<=H;i++)
    {
        cout<<"node "<<i<<": ";
        cout<<"key = "<<heap[i]<<", ";
        if(i/2>0)
            cout<<"parent key = "<<heap[i/2]<<", ";
        if(i*2<=H)
            cout<<"left key = "<<heap[i*2]<<", ";
        if(i*2+1<=H)
            cout<<"right key = "<<heap[i*2+1]<<", ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
	int n;
	vector<int> prt;
	public:
		disjoint_set (int n)
			: n(n), prt(n, -1)
			{
			}
			inline bool is_root (int x) const {
				return prt[x] < 0;
			}
			inline int size (int x) {
				return -prt[find(x)];
			}
			inline bool equiv (int x, int y) {
				return find(x) == find(y);
			}
			int find (int x) {
				return (is_root(x) ? x : (prt[x] = find(prt[x])));
			}
			inline bool unite (int x, int y) {
				x = find(x); y = find(y);
				if (x == y) return false;
				if (size(x) < size(y)) swap(x, y);
				prt[x] += prt[y];
				prt[y] = x;
				return true;
			}
};
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> grh(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		grh[--s].push_back(--t);
		grh[t].push_back(s);
	}
	vector<int> deg(n);
	for (int i = 0; i < n; i++) {
		deg[i] = (int) grh[i].size();
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] >= 6) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] >= 4) {
			disjoint_set djs(n);
			for (int j = 0; j < n; j++) if (i != j) {
				for (int k : grh[j]) if (i != k && j < k) {
					if (!djs.unite(j, k)) {
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s;
  while (cin >> n >> s) {
    const int N = 3000 + 5;
    static lli dp[N][N];
    fill(&dp[0][0], &dp[N - 1][N - 1] + 1, 0);
    for (int i = 0; i < n; ++i) {
      dp[0][i] = 1;
    }
    
    const lli mod = 1e9 + 7;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '<') {
        lli sum = 0;
        for (int j = 0; j <= s.size() - i; ++j) {
          (sum += dp[i][j]) %= mod;
          dp[i + 1][j] = sum;
        }
      }
      if (s[i] == '>') {
        lli sum = 0;
        for (int j = s.size() - i; 1 <= j; --j) {
          (sum += dp[i][j]) %= mod;
          dp[i + 1][j - 1] = sum;
        }        
      }
    }

    cout << dp[s.size()][0] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 70912
import numpy as np

N=int(input())
n=[int(i) for i in str(N)]
K=int(input())
L=len(n)
dp=np.zeros((L+1,K+1,2),dtype=int)
dp[0,0,0]=1

for i in range(L):
  for j in range(K+1):
    for smaller in range(2):
      m=10 if smaller else n[i]+1
      for x in range(m):
        if int(j+(x!=0))>K:
          continue
        #i桁目がxだったときにdp[i][smaller][j]をどこに足しますか？
        dp[i+1,j+(x!=0),smaller or x<n[i]]+=dp[i,j,smaller]
        #print(i+1,j+(x!=0),int(smaller or x<n[i]),i,j,smaller)
        
print(dp[L,K].sum())

Measured memory_bytes: 12500
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

int main() {

	int N, T;
	cin >> N >> T;

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

	ll m = 0;
	ll sa = 0;
	ll count = 0;
	for (int i = N - 1; 0 <= i; --i) {
		if (sa < m - A[i]) {
			sa = m - A[i];
			count = 1;
		}
		else if (sa == m - A[i]) {
			count++;
		}
		if (m < A[i]) m = A[i];
	}

	cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <list>

using namespace std;



int main(void){
    long long A,B,N;
    long long X;
    long long ans;

    cin>>A>>B>>N;

    X=min(N,B-1);

    ans=A*X/B - A*(X/B);

    cout<<ans<<endl;




    return 0;
}



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

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

    //freopen("in.txt", "r", stdin);
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe\n";
    }else{
        cout<<"safe\n";
    }



    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }
inline long long tonum(string s) {long long v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string tostr(T x) {ostringstream sout;sout<<x;return sout.str();}



string str;

int main() {
    while (cin >> str) {
        int res = 0;
        for (int i = 0; i <= str.size(); ++i) {
            string sub1 = str.substr(0, i), sub2 = str.substr(i);
            
            //cout << sub1 << ", " << sub2 << endl;
            
            if (sub2[0] == '0') continue;
            
            int n1 = tonum(sub1), n2 = tonum(sub2);
            if (sub1 == "") n1 = 0;
            if (sub2 == "") n2 = 0;
            if (n1 > n2) continue;
            int s = (n1 - n2);
            if (s % 2 == 0) ++res;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include<vector>
#include<cmath>
using namespace std;
#include<set>
int main()
{
        long long int arr[4];
        for(int i=0;i<4;i++)
        {
            cin>>arr[i];
        }
        long long int a=arr[0]*arr[2];
        long long int b=arr[0]*arr[3];
        long long int c=arr[1]*arr[3];
        long long int d=arr[1]*arr[2];
        long long int e=max(a,max(b,max(c,d)));
        cout<<e;
        
        
}

    
        
        
        
        
        
        
        
    
    

Measured memory_bytes: 3476