akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    sort(S.begin(), S.end());
    if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
        cout << YES << "\n";

    } else{
        cout << NO << "\n";
    }
}

int main(){

    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

template <typename T>
struct segtree{
    int n;
    T UNIT;
    vector<T> dat;
    segtree(int n_, T unit){
        UNIT = unit;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n);
        for(int i = 0; i < 2*n; i++) dat[i] = UNIT;
    }

    T calc(T a, T b){
        T ans;
        ans = max(a, b);
        return ans;
    }
    void insert(int k, T a){
        dat[k+n-1] = a;
    }
    void update_all(){
        for(int i = n-2; i >= 0; i--){
            dat[i] = calc(dat[i*2+1], dat[i*2+2]);
        }
    }
    //k番目の値(0-indexed)をaに変更
    void update(int k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = calc(dat[k*2+1], dat[k*2+2]);
        }
    }

    //[a, b)
    //区間[a, b]へのクエリに対してはquery(a, b+1)と呼ぶ
    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        if(r <= a || b <= l) return UNIT;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return calc(vl, vr);
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, q;
    cin >> n >> q;
    segtree<int> sgt(n, 0);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        sgt.update(i, a);
    }
    for(int i = 0; i < q; i++){
        int t; cin >> t;
        if(t == 1){
            int x, v; cin >> x >> v; x--;
            sgt.update(x, v);
        }
        if(t == 2){
            int l, r; cin >> l >> r; l--; r--;
            cout << sgt.query(l, r+1) << endl;
        }
        if(t == 3){
            int x, v; cin >> x >> v; x--;
            if(sgt.query(x, x+1) >= v){
                cout << x+1 << endl;
                continue;
            }
            if(sgt.query(x, n) < v){
                cout << n+1 << endl;
                continue;
            }
            int l = x, r = n-1;
            while(r-l > 1){
                int c = (l+r)/2;
                if(sgt.query(x, c+1) >= v) r = c;
                else l = c;
            }
            cout << r+1 << endl;
        }
    }
}

Measured memory_bytes: 5300
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		int INF_MIN = -1000;//Integer.MIN_VALUE;
		
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextLine()){

			int H = Integer.parseInt(sc.next());
			int W = Integer.parseInt(sc.next());
			if(H==0 && W==0)break;
			int n = Integer.parseInt(sc.next());
			int[][] dp = new int[H+1][W+1];
			
			
			
			for(int i=0; i<n; i++){
				int stop_h = Integer.parseInt(sc.next())-1;
				int stop_w= Integer.parseInt(sc.next())-1;
				dp[stop_h][stop_w] = INF_MIN;
			}
			
			dp[0][0] = 1;
			
			for(int i=1; i<=H; i++){
				if(dp[i-1][0] == INF_MIN || dp[i][0] == INF_MIN ){
					dp[i][0] = INF_MIN;
				}else{
					dp[i][0] = 1;
				}
			}
			for(int i=1; i<=W; i++){
				if(dp[0][i-1] == INF_MIN || dp[0][i] == INF_MIN ){
					dp[0][i] = INF_MIN;
				}else{
					dp[0][i] = 1;
				}
			}			

			
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					if(dp[i+1][j+1] != INF_MIN){
						if(dp[i][j+1] != INF_MIN)dp[i+1][j+1] += dp[i][j+1];
						if(dp[i+1][j] != INF_MIN)dp[i+1][j+1] += dp[i+1][j];
					}
				}
			}
			/*
			for(int i=0; i<=H; i++){
				for(int j=0; j<=W; j++){
					System.out.print(dp[i][j] + "\t");
				}
				System.out.println();
			}
			*/

			System.out.println(dp[H-1][W-1]);
			
		}
		
		
	}
}




Measured memory_bytes: 26316
#include<cstdio>
#include<map>
using namespace std;
#define N 500200
#define mod1 1000000009
#define mod2 1000000007
#define ch1 131
#define ch2 233
map<long long,int> tp;
int pw1[N],pw2[N],n,su[N],vl[N],ha1[N],ha2[N],as1,as2;
long long as;
char s[N];
int pw(int a,int p,int mod){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d%s",&n,s+1);
	su[0]=n;
	pw1[0]=pw2[0]=1;
	for(int i=1;i<=n*2;i++)pw1[i]=1ll*pw1[i-1]*ch1%mod1,pw2[i]=1ll*pw2[i-1]*ch2%mod2;
	for(int i=1;i<=n;i++)
	{
		su[i]=su[i-1];
		if(s[i]=='<')su[i]--;
		if(s[i]=='>')su[i]++;
		if(s[i]=='+')as1=(as1+pw1[su[i]])%mod1,as2=(as2+pw2[su[i]])%mod2;
		if(s[i]=='-')as1=(as1-pw1[su[i]]+mod1)%mod1,as2=(as2-pw2[su[i]]+mod2)%mod2;
	}
	for(int i=n;i>=1;i--)ha1[i]=(ha1[i+1]+mod1+(s[i]=='+'?1ll:(s[i]=='-'?-1ll:0))*pw1[su[i]])%mod1,ha2[i]=(ha2[i+1]+mod2+(s[i]=='+'?1ll:(s[i]=='-'?-1ll:0))*pw2[su[i]])%mod2;
	tp[0]=1;
	for(int i=n;i>=1;i--)
	{
		int nas1,nas2;
		if(su[i-1]>=su[0])nas1=1ll*as1*pw1[su[i-1]-su[0]]%mod1,nas2=1ll*as2*pw2[su[i-1]-su[0]]%mod2;
		else nas1=1ll*as1*pw(pw(ch1,mod1-2,mod1),su[0]-su[i-1],mod1)%mod1,nas2=1ll*as2*pw(pw(ch2,mod2-2,mod2),su[0]-su[i-1],mod2)%mod2;
		nas1=(ha1[i]-nas1+mod1)%mod1,nas2=(ha2[i]-nas2+mod2)%mod2;
		as+=tp[nas1*10000000000ll+nas2];
		tp[ha1[i]*10000000000ll+ha2[i]]++;
	}
	printf("%lld\n",as);
}//

Measured memory_bytes: 40832
# Aizu Problem 0078: Magic Square
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def magic_square(n):
    sq = [[0 for _ in range(16)] for __ in range(16)]
    nowx, nowy = n // 2, n // 2 + 1
    sq[nowy][nowx] = 1
    for i in range(2, n**2 + 1):
        nowx += 1
        nowy += 1
        while True:
            if nowx >= n:
                nowx = 0
            if nowx < 0:
                nowx = n - 1
            if nowy >= n:
                nowy = 0
            if sq[nowy][nowx] != 0:
                nowx -= 1
                nowy += 1
            if sq[nowy][nowx] == 0 and 0 <= nowx and nowx < n and 0 <= nowy and nowy < n:
                break
        sq[nowy][nowx] = i
    return sq[:n]

while True:
    n = int(input())
    if n == 0:
        break
    sq = magic_square(n)
    for row in sq:
        out = ""
        for k in row[:n]:
            ks = str(k)
            ks = ' ' * (4 - len(ks)) + ks
            out += ks
        print(out)
        
        

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define ll long long
#define f(i) i*i

int main(){
  int i,n;
  ll d[601];

  //DP
  while(scanf("%d",&n) != EOF){
    memset(d,0,sizeof(d));

    for(i=n; i<600; i+=n){
      d[i+n] = d[i] + n*f(i);
    }
    printf("%d\n", d[600]);
  }
    
  

  return 0;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;

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




void Input() {


}



void Solve() {





}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  //Input();
  //Solve();

  int N;
  cin >> N;

  vector< vector<int> > G(N);
  vector< pair<int, int> > vp;

  for(int i = 1; i < N; i++) {

        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(make_pair(a, b));
  }

  queue<int> que;
  vector<int> cs(N, 0);
  vector<int> used(N);
  map< pair<int, int>, int> ans;

  que.emplace(0);
  used[0] = 1;

  int k = 0;
  while(!que.empty()) {

     int v = que.front();
     que.pop();

     if(k < G[v].size()) k = G[v].size();

     int cur = 1;
     for(auto u: G[v]) {

        if(used[u]) continue;
        if(cur == cs[v]) cur++;
        cs[u] = ans[make_pair(u,v)] = ans[make_pair(v, u)] = cur++;
        used[u] = 1;
        que.emplace(u);
     }
  }

  cout << k << endl;
  for(auto p:vp) {

        cout << ans[p] << endl;
  }


  return 0;

}



Measured memory_bytes: 20088
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a,b[1000001],ans;
map<int,int> mp;
vector<int> v;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]++;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    if(mp[1]==1){cout<<1<<endl;return 0;}
    if(mp[1]>1){cout<<0<<endl;return 0;}
    for(int i=0;i<n;i++){
        if(b[v[i]]==0&&mp[v[i]]==1)ans++;
        if(b[v[i]]==0){
            for(int j=v[i];j<=1000000;j+=v[i]){
                b[j]=1;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 16404
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        int[] arr = new int[N];
        
        st = new StringTokenizer(br.readLine());

        for (int i=0; i<N; i++) {
            arr[i] = Integer.parseInt(st.nextToken());
        }

        int[] dp = new int[N];
        dp[0]=0;
        dp[1]=Math.abs(arr[1]-arr[0]);

        for (int i=2; i<N; i++) {
            dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
        }
        System.out.println(dp[N-1]);
    }
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;


int n,m;
priority_queue<P> q;

int main(){
  cin >> n >> m;
  vector<int>a(n), b(m), c(m);

  for(int i=0; i<n; i++){
    cin >> a[i];q.push(P(a[i],1));
  }
  for(int i=0; i<m; i++){
    cin >> b[i] >> c[i];
    q.push(P(c[i], b[i]));
  }
  // while (!q.empty()) {
  //   cout << q.top().first << endl;
  //   q.pop();
  // }
  ll ans = 0;
  for(int i=0;i<n;i++){
    auto tmp = q.top();
    q.pop();
    // cout << tmp.first <<" "<<tmp.second << endl;
    ans += tmp.first;
    if(tmp.second > 1){
      tmp.second -= 1;
      q.push(tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7408
# -*- coding: utf-8 -*-

import sys

def amida(w, side_bar):
    result = []
    side_bar.reverse()
    for x in range(1, w+1):
        status = x
        for bar in side_bar:
            if status == bar[0]:
                status = bar[1]
            elif status == bar[1]:
                status = bar[0]
        result.append(status)
    return result

def main():
    W = int(input())
    N = int(input())
    side_bar = [tuple(map(int, input().split(','))) for line in range(N)]
    result = amida(W, side_bar)
    for r in result:
        print(r)

if __name__ == '__main__':
    main()

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

bool LinearSearch(int num, int A[], int n) {
    A[n] = n;
    int i=0;
    while (A[i] != num) {
        if (i == n) return false;
        i++;
    }
    return true;
}

int main()
{
    static const int MAX = 20000;
    static const int MAX2 = 600;

    int n, s, R[MAX], S[MAX2],tmp;
    int cnt = 0;

    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> R[i];
    }
    std::cin >> s;
    for (int i = 0; i < s; i++)
    {
        std::cin >> S[i];
    }

    for (int m=0; m<s; m++) {
        if (LinearSearch(S[m], R, n)) cnt++;
    }
    std::cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,cnt = 0,a[110];
  cin >> n;
  for(int i = 0; i < n; i++){
        cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
        for(int k = j+1; k < n; k++){
            if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]){
                if(a[i]+a[j] > a[k] && abs(a[i] - a[j]) < a[k])
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3608
s = input()
cube_list = [s[0]]
s = s[1:]
count = 0
for c in s:
    if cube_list:
        if cube_list[-1] == c:
            cube_list.append(c)
        else:
            count += 2
            cube_list.pop(-1)
    else:
        cube_list.append(c)
print(count)


Measured memory_bytes: 4116
#include<iostream>
#include<string>
#include<vector>
//#include<stdlib>
using namespace std;

int main(){
	int a, b;
  	cin >> a >> b;
  	
    int count = 0;
    for(int i = a; i <= b; i++){
        if(i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10){
            count++;
        }
        //cout << a[0] << " " << a[4]
    }

    cout << count << endl;
}

Measured memory_bytes: 256
from collections import deque
N=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
x=0
y=0
z=0
for i in range(N):
    if p[i]<=a:
        x+=1
    if a+1<=p[i]<=b:
        y+=1
    if p[i]>=b+1:
        z+=1
print(min(x,y,z))

Measured memory_bytes: 3316
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            if (s[1] == "X") break;
            if (s[0].Contains("_")) getAns1(s[0], s[1]);
            else if (s[1] == "U" | s[1] == "L") getAns2(s[0], s[1]);
            else getAns3(s[0]);
        }
    }
    public static void getAns3(string s)
    {
        var sL = s.Length;
        if (sL == 1) Console.WriteLine(s.ToLower());
        else
        {
            Console.Write(s[0].ToString().ToLower());
            for (int i = 1; i < sL; i++)
                if (Char.IsUpper(s[i]))
                {
                    Console.Write("_");
                    Console.Write(s[i].ToString().ToLower());
                }
                else Console.Write(s[i]);
            Console.WriteLine();
        }
    }
    public static void getAns2(string s, string c)
    {
        if (c == "U") print(s);
        else
        {
            Console.Write(s.Substring(0, 1).ToLower());
            Console.Write(s.Substring(1));
        }
        Console.WriteLine();
    }
    public static void getAns1(string s, string c)
    {
        if (c == "D") { Console.WriteLine(s); return; }
        string[] s2 = s.Split('_');
        if (c == "U") print(s2[0]);
        else Console.Write(s2[0]);
        for (int i = 1; i < s2.Length; i++)
            print(s2[i]);
        Console.WriteLine();
    }
    public static void print(string a)
    {
        if (a.Length == 1) Console.Write(a.ToUpper());
        else
        {
            Console.Write(a.Substring(0, 1).ToUpper());
            Console.Write(a.Substring(1));
        }
    }
}


Measured memory_bytes: 15848
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;

int main(){
    int N;
    cin >> N;
    int T,A;
    cin >> T >> A;
    
    T*=1000;
    A*=1000;
    
    int neer=INF;
    int neerest=-1;
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        if( abs(A - (T-x*6)) <neer ){
            neer=abs(A - (T-x*6));
            neerest=i;
        }
    }
    cout<<neerest+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b &&a!=c){
    cout<<"Yes"<<endl;
  }
  else if(a==c &&b!=c){
    cout<<"Yes"<<endl;
  }
  else if(c==b &&a!=c){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
const int q=1000000007;
int n,m,f[310][310][310],p;
vi l[310],x[310];
inline void add(int &a,int b)
{
	a=(a+b)%q;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,u,v;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	  {
	   scanf("%d%d%d",&j,&k,&u);
	   l[k].pb(j);
	   x[k].pb(u);
	  }
	f[0][0][0]=1;
	for(i=0;i<=n;i++)
	  for(j=0;j<=n;j++)
	    for(k=0;k<=n;k++)
	      if(f[i][j][k])
	        {
			 u=max(i,max(j,k));
			 for(v=0;v<l[u].size();v++)
			   if((i>=l[u][v])+(j>=l[u][v])+(k>=l[u][v])!=x[u][v])
			     break;
			 if(v<l[u].size())
			   continue;
			 if(u==n)
			   add(p,f[i][j][k]);
			 else
			   {
				add(f[u+1][j][k],f[i][j][k]);
				add(f[i][u+1][k],f[i][j][k]);
				add(f[i][j][u+1],f[i][j][k]);
			   }
			}
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 114944
#include<iostream>
using namespace std;
int main() {
	int r, g, b, x;
	cin >> r >> g >> b;
	x = (r * 100) + (g * 10) + (b * 1);
	if (x % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int count(char(*list)[11], int n, char* word);

int max(int a, int b);

int main() {
	int n, m, i, max_gain;
	char s[100][11], t[100][11];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%s", &s[i]);
	scanf("%d", &m);
	for (i = 0; i < m; i++) scanf("%s", &t[i]);

	max_gain = 0;
	for (i = 0; i < n; i++) {
		max_gain = max(max_gain, count(s, n, s[i]) - count(t, m, s[i]));
	}

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

int count(char(*list)[11], int n, char* word) {
	int i;
	int cnt = 0;
	for (i = 0; i < n; i++) {
		if (strcmp(list[i], word) == 0) cnt++;
	}
	return cnt;
}

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


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1000000000000000000;
typedef pair<int, int> P;
typedef unsigned int ui;
typedef long long ll;
int main(){
	int n, a;
	vector <int> A;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.begin() + n);
	int sum1 = 0;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)sum1 += A[n-1-i];
		else {
			sum2 += A[n-1-i];
		}
	}
	cout << sum1 - sum2 << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
//==================================================================================================
// Name        : SAO.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-08-06
// Time        : 19:30:54
// Directory   : c:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode
// FilePath    : c:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode\SAO.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

bool f( int  n )
{

    int len = 0 ;

    while (n)
    {
        len++ , n /= 10 ;
    }

        if( len % 2 ) return 1 ;
        else  return 0 ;  

}

void solve( void )
{

   int n ;

   cin >> n ;

   int cnt = 0 ;

   //n++ ;  

   while (n > 0)
   {
       if( f(n) )  cnt++ ;

       n-- ;
   }
   
    cout << cnt << endl ;

}

int main( void )

{

    //ios_base::sync_with_stdio( false ) ;  cin.tie( NULL ) ;  cout.tie( NULL ) ;

   

    if( 0 )  {

        int t = 100 ;

        for( int i = 1 ; i <= t ; i++ )  solve() ;

    }

    else  {

        solve() ;

    }

   

    return 0 ;

}


Measured memory_bytes: 256
#include <stdio.h>

#define M 10000
#define N 512
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int d[ M ][ 2 ];
    int c[ N ] = { 0, 1, 0 };
    int r[ N ] = { 0 };
    int res = 0;
    int n, m;

    scanf ( "%d%d", &n, &m );
    if ( !( n | m ) ) break ;

    for ( i = 0; i < m; ++i )
    {
      int a, b;

      scanf ( "%d%d", &a, &b );
      d[ i ][ 0 ] = MIN( a, b );
      d[ i ][ 1 ] = MAX( a, b );
      if ( d[ i ][ 0 ] == 1 ) c[ d[ i ][ 1 ] ] = 1;
    }

    for ( i = 0; i < m; ++i )
    {
      r[ d[ i ][ 1 ] ] |= c[ d[ i ][ 0 ] ];
      r[ d[ i ][ 0 ] ] |= c[ d[ i ][ 1 ] ];
    }
    for ( i = 2; i <= n; ++i )
    {
      res += r[ i ];
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;
int main(){
  int d;
  cin >>d;
  if(d==25) cout <<"Christmas"<<endl;
  else if(d==24) cout <<"Christmas Eve"<<endl;
  else if(d==23) cout <<"Christmas Eve Eve"<<endl;
  else cout <<"Christmas Eve Eve Eve"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <list>
#include <vector>

class Node {
    public:
        int id;
        int depth;
        int parent_id;
        std::list<int> children;
        Node() {}
};

void validate_depth(std::vector<Node>& data, int id, int depth)
{
    data[id].depth = depth;
    for(auto iter = data[id].children.begin(); iter != data[id].children.end(); iter++) {
        validate_depth(data, *iter, depth + 1);
    }
}

void show_nodes(std::vector<Node>& data)
{
    for(int i = 0; i < data.size(); i++) {
        printf("node %d: parent = %d, depth = %d, ", i, data[i].parent_id, data[i].depth);
        if(data[i].parent_id == -1) {
            printf("root, ");
        } else if(data[i].children.empty()) {
            printf("leaf, ");
        } else {
            printf("internal node, ");
        }
        putchar('[');
        for(auto iter = data[i].children.begin(); iter != data[i].children.end(); iter++) {
            if(iter == data[i].children.begin()) {
                printf("%d", *iter);
            } else {
                printf(", %d", *iter);
            }
        }
        puts("]");
    }
}

int search_root(std::vector<Node>& data, int current_id)
{
    if(data[current_id].parent_id == -1) {
        return current_id;
    } else {
        return search_root(data, data[current_id].parent_id);
    }
}

int main()
{
    int input_size;
    std::cin >> input_size;
    std::vector<Node> data(input_size);
    for(int i = 0; i < data.size(); i++) {
        data[i].parent_id = -1;
    }
    for(int i = 0; i < data.size(); i++) {
        int id;
        std::cin >> id;
        int num_of_children;
        std::cin >> num_of_children;
        for(int j = 0; j < num_of_children; j++) {
            int child_id;
            std::cin >> child_id;
            data[id].children.push_back(child_id);
            data[child_id].parent_id = id;
        }
    }

    int root_id = search_root(data, 0);

    validate_depth(data, root_id, 0);
    show_nodes(data);
    return 0;
}

Measured memory_bytes: 9160
N = gets.to_i
class Node
    attr_accessor :index, :children, :parent, :sibling

    def initialize()
        @children = []
        @parent = nil
        @sibling = nil
    end

    def depth
        parent == nil ? 0 : parent.depth + 1
    end

    def degree
        children.length
    end

    def height
        if children.empty?
            0
        else
            children.map {|e| e.height }.max + 1
        end
    end

    def preorder_array
        left_array = children[0] == nil ? [] : children[0].preorder_array
        right_array = children[1] == nil ? [] : children[1].preorder_array
        [[self], [left_array], [right_array]].flatten
    end

    def inorder_array
        left_array = children[0] == nil ? [] : children[0].inorder_array
        right_array = children[1] == nil ? [] : children[1].inorder_array
        [[left_array], [self], [right_array]].flatten
    end

    def postorder_array
        left_array = children[0] == nil ? [] : children[0].postorder_array
        right_array = children[1] == nil ? [] : children[1].postorder_array
        [[left_array], [right_array], [self]].flatten
    end
end
nodes = Array.new(N) { Node.new }
N.times do
    line=gets.chomp.split(" ").map(&:to_i)
    node = nodes[line[0]]
    node.index = line[0]
    
    node.children = line[1..2].map {|e| e==-1 ? nil : nodes[e] }
    node.children.each do |child|
        next if child == nil
        child.parent = node
    end

    if node.children.length == 2
        nodes[line[1]].sibling = nodes[line[2]]
        nodes[line[2]].sibling = nodes[line[1]]
    end
end

root = nodes.select {|e| e.parent == nil }[0]

puts "Preorder"
puts " " + root.preorder_array.map{|e|e.index}.join(" ")
puts "Inorder"
puts " " + root.inorder_array.map{|e|e.index}.join(" ")
puts "Postorder"
puts " " + root.postorder_array.map{|e|e.index}.join(" ")



Measured memory_bytes: 6888
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007LL, INF=mod * 100000;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n+1);
    b[0] = 1LL;
    ll ans = 0LL;
    bool cnt = true;
    for(ll i=0LL;i<=n;i++){
    	cin >> a[i];
    	if(cnt){
    	    if(i == 0LL) b[i] -= a[i];
    	    else b[i] = b[i-1] * 2LL - a[i];
    	    if(b[i] < 0LL){
    		    cout << -1 << endl;
    		    return 0;
    	    }
    	    if(b[i] > INF) cnt = false;
        }else b[i] = INF;
    }
    ll now = a[n];
    ans += now;
    for(ll i=n-1;i>=0;i--){
    	now = min(now, b[i]) + a[i];
    	ans += now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4768
E, Y = map(int, input().split())
 
if E == 0:
    if 1868 <= Y <= 1911:
        ch = "M" + str(Y-1868+1)
    elif 1912 <= Y <= 1925:
        ch = "T" + str(Y-1912+1)
    elif 1926 <= Y <= 1988:
        ch = "S" + str(Y-1926+1)
    else:
        ch = "H" + str(Y-1989+1)
 
elif E == 1:
    ch = 1868 + Y - 1
elif E == 2:
    ch = 1912 + Y - 1
elif E == 3:
    ch = 1926 + Y - 1
else:
    ch = 1989 + Y - 1
 
print(ch)


Measured memory_bytes: 5596
#include<stdio.h>
int main(){
	int i,n,j,k,o,count=0;
	int a[10001];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d",&o);
		for(j=0;j<n;j++){
			if(a[j]==o){
				count++;
				break;
			}
		}
	}
	printf("%d\n",count);
} 


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

int main() {
  long N,K,H;
  long count = 0;
  cin >> N >> K;
  vector<long> lineH(N);
    for(long i = 0; i < N; i++){
      cin >> lineH.at(i);
      count += lineH.at(i);
    }
  sort(lineH.begin(),lineH.end());
  reverse(lineH.begin(),lineH.end());
  if(N-K <=0){
    cout << 0 << endl;
  }else{
  for(long i = 0; i < K; i++){
    count -= lineH.at(i);
  }
  cout << count << endl;
  }
}
  

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		// 입력
		int r = Integer.parseInt(br.readLine());

		if(r < 1200){
			bw.write("ABC");
		}else if(r < 2800){
			bw.write("ARC");		
		}else{
			bw.write("AGC");
		}
		
		bw.flush();
		bw.close();
		br.close();
	}
}

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

namespace ABC054_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var n = aaa[0];
            var m = aaa[1];
            var A = new string[n].Select(x => Console.ReadLine()).ToArray();
            var B = new string[m].Select(x => Console.ReadLine()).ToArray();
            var ans = 0;
            for(int i=0;i+m<=n;i++)
                for(int j=0;j+m<=n;j++)
                {
                    var ok = true;
                    for(int k=0;k<m;k++)
                        for(int l=0;l<m;l++)
                            if (A[i + k][j + l] != B[k][l]) ok = false;
                    if (ok) ans++;
                }
            if (ans > 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
N = int(input())
done = []
#探索スタート地点を「探索候補スタック」に積む
arr = [N]
ans = 0
stop = 0
  
#while スタックが空っぽになるまで
while arr:
  a = arr.pop(0)
  
  if a == -1:
    ans += 1
  
  done.append(a)
  Next = []
  if a-1 >= 0:
    Next.append(a-1)

  if a-46656 >= 0:
    Next.append(a-46656)
  elif a-7776 >= 0:
    Next.append(a-7776)
  elif a-1296 >= 0:
    Next.append(a-1296)
  elif a-216 >= 0:
    Next.append(a-216)
  elif a-36 >= 0:
    Next.append(a-36)
  elif a-6 >= 0:
    Next.append(a-6)

  if a-59049 >= 0:
    Next.append(a-59049)
  elif a-6561 >= 0:
    Next.append(a-6561)
  elif a-729 >= 0:
    Next.append(a-729)
  elif a-81 >= 0:
    Next.append(a-81)
  elif a-9 >= 0:
    Next.append(a-9)
    
  if -1 not in arr:
    arr.append(-1)   

  while Next:
    i = Next.pop(0)
    if i in done:
      continue
    elif i in arr:
      continue
    else:
      arr.append(i)
      if i == 0:
        stop = 1
        break
  if stop == 1:
    break

print(ans+1)

Measured memory_bytes: 3064
from collections import deque

V, E = map(int, input().split())

#グラフを格納
g = [[] for _ in range(V)]

#点に入ってくる矢印の数を記録
in_E = [0 for _ in range(V)]

for _ in range(E):
    s, t = map(int, input().split())
    g[s].append(t)
    in_E[t] += 1

# print(in_E)

d = deque()
#in_Eが0をdequeに格納
for i in range(V):
    if in_E[i] == 0:
        d.append(i)

ans = []

while d:
    # print("d", d)
    v = d.popleft()
    # print("v", v)
    # print("in_E", in_E)
    for u in g[v]:
        # print("u", u)
        in_E[u] -= 1
        if in_E[u] == 0:
            d.append(u)
    ans.append(v)

for i in ans:
    print(i)


Measured memory_bytes: 9000
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
 
st=[0,13,1,2,3,4,5,6,7,8,9,10,11,12]
a,b=MI()
if st[a]>st[b]:
    print("Alice")
elif st[a]==st[b]:
    print("Draw")
else:
    print("Bob")


Measured memory_bytes: 3316
<?php
list($n, $m) = ints();

for ($i = 0; $i < $m; ++$i) {
    list($a, $b) = ints();
    $a--;
    $b--;
    $g[$a][] = $b;
    $g[$b][] = $a;
}
for ($i = 0; $i < $n; ++$i) $ans[] = count($g[$i] ?? []);
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {
	int N,M;
	pair<int,int> PD[10010];
	while(true) {

		cin >> N >> M;

		int d,p;
		if ((N == 0) && (M == 0))
			break;

		for(int i=0;i<N; i++) {
			cin >> d >> p;
			PD[i] = make_pair(p,d);
		}
		sort(PD,PD+N);

		//cout << PD[0].first <<endl;
		//return 0;


		int S = 0;
		int guarded = 0;

		for(int i=0;i<N;i++) {
			S += PD[i].first*PD[i].second;
		}
		for(int i=0;i<N;i++) {
			if(M <= 0) {
				break;
			} else if(M>PD[N-i-1].second) {
				guarded = PD[N-i-1].second;
			} else {
				guarded = M;
			}
			S -= PD[N-i-1].first*guarded;
			M -= guarded;
			
		}

	cout << S << endl;
	}

}

Measured memory_bytes: 3072
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>
#include <climits>

#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m; i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()

#define makevv(i,j,k,l,m) vector<vector<i>> j(k,vector<i>(l,m))

using namespace std;

using ll=long long;

using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

void OUT(bool isTrue, string t="YES", string f="NO"){
    cout<<(isTrue?t:f)<<endl;
}
void out(bool isTrue, string t="yes", string f="yes"){
    cout<<(isTrue?t:f)<<endl;
}

template <typename T>
string printItr(T b, T e, string delim=" ")
{
    stringstream ss;
    ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}

int main(void){
    vi a(3),b={5,5,7};
    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    OUT(a==b);
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
           string[] strNum  = Console.ReadLine().Split(' ');
            int a = int.Parse(strNum[0]);
            int b = int.Parse(strNum[1]);

            if(a >= 10 || b >= 10)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(a * b);
            }
       
        }
    
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin()s,(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define IMX INT_MAX
const int CON = (int)(1e7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int n,m,a,b,pp[505][505],k;
LL ss;
int main()
{
    scanf("%d %d %d %d",&n,&m,&a,&b);
    k=a*b;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i%a==0&&j%b==0)pp[i][j]=-k-CON,ss-=k+CON;
            else if(i%a==1&&j%b==1||(a==1&&j%b==1)||(b==1&&i%a==1))pp[i][j]=k-1+CON,ss+=k-1+CON;
            else pp[i][j]=0;
        }
    }
    if(ss>0)
    {
        printf("Yes\n");
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                printf("%d ",pp[i][j]);
            }
            printf("\n");
        }
    }
    else printf("No");
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define int ll
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 2e5 + 100;
const int mod = 1e9+7;
const int inf = 1e9 + 100;
const int sigma = 30;
int n, m, k, t = 1;
string a, b;

int dp[ms];
int seen[ms];

vi g[ms];

int dfs(int v){
  int best = 0;
  if(seen[v]) return dp[v];
  seen[v] = 1;
  for(auto x: g[v]){
    int cur = dfs(x);
    best = max(best, cur);
  }
  return dp[v] = 1 + best;
}

void solve(){
  cin>>n>>m;
  int a, b;
  for(int i=0; i<m; i++){
    cin>>a>>b;
    g[a-1].pb(b-1);
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    if(seen[i]==0){
      ans = max(ans, dfs(i) -1);
    }
  }
  cout<<ans<<endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 12416
//C - 755
#include <iostream>
#include <string>
#include <vector>
typedef long long int ll;
using namespace std;

vector<string> shichigosan{"3", "5", "7"};
ll cnt;
ll N;

void dfs(ll digits, string s) {
    if(s!="") {
        // stop when s exceeds N
        if(stoll(s) > N) {
            return;
        }
    }
    if (digits != 0 ) {
        if (((s.find("3")+1) && (s.find("5")+1) && (s.find("7")+1))){
            cnt++;
        }
    }
    for (auto c : shichigosan) {
        dfs(digits+1, s+c);
    }
}

int main() {
    cin >> N;

    dfs(0, "");
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll t;
  cin >> n >> t;
  vl a(n);
  rep(i,n)cin>>a[i];
  vl b(n,a[0]);
  rep(i,n-1){
    b[i+1] = min(b[i],a[i]);
  }
  map<ll,int> mp;
  ll mx = 0;
  mp[mx] = 0;
  rep(i,n){
    ll d = a[i]-b[i];
    if(d>0)mp[d]++;
    maxs(mx,d);
  }

  cout<<mp[mx]<<endl;
  return 0;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 100000;
const int maxlen = 1e9;

int n, m, top = 0;
int vist[maxn + 5];
LL mx[maxn + 5], mi[maxn + 5], dist[maxn + 5];
vector<pii> G[maxn + 5];

bool dfs(int x) {
    for(auto it : G[x]) {
        if(!vist[it.fi]) {
            vist[it.fi] = top;
            dist[it.fi] = dist[x] + it.se;
            if(!dfs(it.fi)) return false;
        }
        else {
            if(dist[it.fi] != dist[x] + it.se)
                return false;
        }
    }
    return true;
}

int main() {
    int u, v, dd;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d%d", &u, &v, &dd);
        G[u].PB(MP(v,dd));
        G[v].PB(MP(u,-dd));
    }
    for(int i = 1; i <= n; ++i) {
        if(vist[i]) continue;
        ++top;
        vist[i] = top, dist[i] = 0;
        if(!dfs(i)) { puts("No"); exit(0); }
    }
    mem(mx, 0x80); mem(mi, 0x7f);
    for(int i = 1; i <= n; ++i) {
        mx[vist[i]] = max(mx[vist[i]], dist[i]);
        mi[vist[i]] = max(mi[vist[i]], dist[i]);
    }
    for(int i = 1; i <= top; ++i) {
        if(mx[i] - mi[i] > maxlen) { puts("No"); exit(0); }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 13440
/*B - Homework*/
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int days;
	int assig;

	cin >> days >> assig;

	int need = 0;
	int n;

	for (int i = 0; i < assig; ++i)
	{
		cin >> n;
		need += n;
	}

	int ans = days - need;

	if(ans < 0){
		cout << "-1";
	}
	else{
		cout << ans;
	}

	return 0;
}

Measured memory_bytes: 3656
fun main(args:Array<String>){
  val S = readLine()!!
  val step = arrayOf('L','R')
  var answer = true
  
  for(i in 0 until S.length){
    if(S[i] == step[i%2]){
      answer = false
    }
  }
  println(if(answer)"Yes" else "No")
}

Measured memory_bytes: 33836
import string
xs = input()


def foo(xs):
    a = string.ascii_lowercase
    cnt = [0] * len(a)
    for x in xs:
        cnt[ord(x) - ord('a')] += 1

    for i, c in enumerate(cnt):
         if c == 0:
            print(a[i])
            return
    print("None")
    return


foo(xs)


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n;
ll dp[101][MAX];
ll w[MAX];
ll v[MAX];


ll solve(int i,int we){
       if(i==n){
           return 0;
       }

       ll &res=dp[i][we];
       if(res!=-1){
        return res;
       }


       if(we>=w[i]){
          res=max(solve(i+1,we),solve(i+1,we-w[i])+v[i]);
       }
       else{
          res=solve(i+1,we);
       }

       return res;

}




int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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





    int k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }

    mem(dp,-1);
    cout<<solve(0,k);








     return 0;

}


Measured memory_bytes: 79232
import sys
input = sys.stdin.readline
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i+1):
        tmp += a1[j]
    for k in range(i,n):
        tmp += a2[k]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<vector<int> > plan(N,vector<int>(N-1,0));
    queue<int> que;

    for(int i=0; i<N; i++){
        que.push(i);
        for(int j=0; j<N-1; j++){
            int a;
            cin >> a;
            a--;
            plan[i][j]=a;
        }
    }

    vector<int> cnt(N,0);
    int ans=0;
    
    queue<int> tmpque;
    queue<int> used;
    vector<vector<int> > league(N,vector<int>(N,0));

    while((int) que.size()>0){
        int a=que.front();
        que.pop();

        int b = plan[a][cnt[a]];

        if(league[a][b]==0 && plan[b][cnt[b]] == a){
            //cout << a+1 << ' ' << b+1 << endl;
            used.push(a);
            used.push(b);
            if(cnt[a]<N-2){
                tmpque.push(a);
            }
            if(cnt[b]<N-2){
                tmpque.push(b);
            }
            league[a][b]=1;
            league[b][a]=1;
        }

        if((int) que.size()==0){
            que.swap(tmpque);
            ans++;
            while((int)used.size()>0){
                int c=used.front();
                used.pop();
                cnt[c]++;
            }
            //cout << ans << "day end" << endl;
        }
    }
    for(int i=0; i<N; i++){
        if(cnt[i]<N-1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

bool check(int check_num, vector<int> ans) {
    rep(i, ans.size()) {
        if ( ans[i] == check_num ) {
            return false;
        }
    }
    return true;
}

void dfs(int s, vector<vector<int>> &g, vector<int> ans, int n, int &cnt) {
    if ( !check(s, ans) ) {
        return;
    }
    ans.push_back(s);
    if ( ans.size() == n ) {
        ++cnt;
        return;
    }
    for ( auto v : g[s] ) {
        if ( !check(v, ans) ) continue;
        dfs(v, g, ans, n, cnt);
    }
    return;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int cnt = 0;
    vector<int> ans;
    dfs(0, g, ans, n, cnt);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256