akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int a = 0;
    int l=0 ;
    for(char c:s){
        if(c=='R'){
            l++;
            a = max(a,l);
        }
        else{
            l = 0;
        }
    }
    cout<<a;
}



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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    string a,b;
    cin >> a >> b;
    b.pop_back();
    if(a == b)cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	
	for(int i = 0;i < n;i++)cin >> a[i];

	if(a[0] != 0){
		cout << -1 << endl;
		return 0;
	}

	for(int i = 0;i < n-1;i++){
		if(a[i+1] > a[i] + 1){
			cout << -1 << endl;
			return 0;
		}
	}

	ll ans = 0;
	for(int i = 0;i < n;i++){
		int now = a[i];
		int j = i;
		while(j + 1 < n && a[j+1] > a[j]){
			j++;
		}
		ans += a[j];
		i = j;
	}

	cout << ans << endl;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll siz;
ll ofst;
vll seg;

void change(ll i, char c) {
  i += ofst;
  seg[i] = 1LL << (c - 'a');
  while (true) {
    i /= 2;
    if (i == 0) break;
    seg[i]= seg[2 * i] | seg[2 * i + 1];
  }
}

ll get(ll l, ll r) {
  ll s = 0;
  l += ofst, r += ofst + 1;
  while (l < r) {
    if (l % 2 == 1) {
      s |= seg[l];
      l++;
    }
    l /= 2;
    if (r % 2 == 1) {
      s |= seg[r - 1];
      r--;
    }
    r /= 2;
  }
  return __builtin_popcount(s);
}

int main() {
  ll n, q;
  string s;
  cin >> n >> s >> q;

  siz = 1;
  while (siz < 2 * n) siz <<= 1;
  ofst = siz >> 1;
  seg.resize(siz, 0);
  rep(i, n) change(i, s[i]);

  rep(i, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      ll i;
      char c;
      cin >> i >> c;
      i--;
      change(i, c);
    } else {
      ll l, r;
      cin >> l >> r;
      l--;
      r--;
      cout << get(l, r) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 9092
#include <stdio.h>

int main(void) {
	
	int a, b, c, d, e, k;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	scanf("%d", &k);
	
	if ((e - a) <= k) printf("Yay!");
	else printf(":(");
	
	return 0;
	
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

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

struct State { int tx, ty, kx, ky, cost; };
int X, Y;
int d[52][52];
bool used[52][52][52][52];

int main() {
    while (cin >> X >> Y, X) {
        int tx, ty, kx, ky;
        cin >> tx >> ty >> kx >> ky;
        for (int i=0; i<=Y+1; ++i) {
            for (int j=0; j<=X+1; ++j) {
                if (i==0 || i==Y+1 || j==0 || j==X+1) d[i][j] = 1;
                else cin >> d[i][j];
            }
        }
        memset(used, false, sizeof used);
        queue<State> q;
        q.push((State){tx, ty, kx, ky, 0});
        int res = -1;
        while ( ! q.empty()) {
            State s = q.front(); q.pop();
            if (used[s.tx][s.ty][s.kx][s.ky]) continue;
            used[s.tx][s.ty][s.kx][s.ky] = true;
            if (s.tx == s.kx && s.ty == s.ky) {
                res = s.cost;
                break;
            }
            for (int i=0; i<4; ++i) {
                if (d[s.ty+dy[i]][s.tx+dx[i]] && d[s.ky-dy[i]][s.kx-dx[i]]) continue;
                int tx2 = s.tx, ty2 = s.ty;
                if ( ! d[s.ty+dy[i]][s.tx+dx[i]]) {
                    tx2 += dx[i];
                    ty2 += dy[i];
                }
                int kx2 = s.kx, ky2 = s.ky;
                if ( ! d[s.ky-dy[i]][s.kx-dx[i]]) {
                    kx2 -= dx[i];
                    ky2 -= dy[i];
                }
                q.push((State){tx2, ty2, kx2, ky2, s.cost+1});
            }
        }
        if (res < 0) {
            cout << "NA" << endl;
        } else {
            cout << res << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9288
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
	static boolean debug = true;
	static Scanner sc = new Scanner(System.in);
 
	static long max = Long.MIN_VALUE;
 
	public static void main(String[] args) throws Exception {
		long sum=0;
		int N=sc.nextInt();
		int T=sc.nextInt();
		int before=sc.nextInt();
		for(int i=0;i<N-1;i++){
			int k=sc.nextInt();
			int time=k-before;
			if(time>T)
				sum+=T;
			else sum+=time;
			before=k;
		}
		sum+=T;
		System.out.println(sum);
		 

	}
 
	private static void print(String string) {
		// TODO Auto-generated method stub
		if (debug)
			System.out.println(string);
	}
 
	private static void print(int[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(String[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(char[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(double[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(int[][] data) {
 
		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data[0].length; j++) {
					System.out.print(data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	private static void print(char[][] data) {
 
		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data[0].length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	private static void print(String[][] data) {
 
		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data[0].length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	private static void print(double[][] data) {
 
		if (debug) {
			for (int i = 0; i < data[0].length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	public static void inPutData(char[][] c) {
		for (int i = 0; i < c.length; i++) {
			c[i] = sc.nextLine().toCharArray();
		}
	}
 
}

Measured memory_bytes: 62684
import bisect
N = int(input())
An = list(map(int,input().split(' '))) 

bit_list = [1]
for i in range(100000):
    bit_list.append(bit_list[i]*2)
    if bit_list[i+1] > 2**60:
        break
start_point = bisect.bisect_right(bit_list,max(An))
keta_list = [0] *  start_point

for A in An:
    abin = format(A, 'b')
    for i in range(len(abin)):
        if abin[i] == '1':
            keta_list[len(abin)-1-i] += 1
count = 0
for idx,keta_count in enumerate(keta_list):
    count += (N-keta_count) * bit_list[idx] * keta_count
    count = count % (1000000000+7)
print(count)

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

using namespace std;

int main(void){
    string S;
    cin >> S;
    for(int i = 0; i < S.length() - 1; i++){
        if(S[i] == S[i + 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

using ll = long long;

const ll INF = 2e18;

const int MAXN = 2.1e5;
int N;
ll K;

const int MAXV = 2.1e5;
const int V = int(2e5) + 100;
int A[MAXN];

int nxtOcc[MAXV];
ll jumpDist[MAXN][61];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = N-1; i >= 0; i--) {
		nxtOcc[A[i]] = i+N;
	}
	for (int i = N-1; i >= 0; i--) {
		jumpDist[i][0] = (nxtOcc[A[i]] - i) + 1;
		assert(jumpDist[i][0] <= N+1);

		nxtOcc[A[i]] = i;
	}

	for (int l = 0; l < 60; l++) {
		for (int i = 0; i < N; i++) {
			jumpDist[i][l+1] = min(INF, jumpDist[i][l] + jumpDist[(i + jumpDist[i][l]) % N][l]);
		}
	}


	for (int i = 0; i < N; i++) {
		//cerr << i << ' '; for (int l = 0; l <= 60; l++) { cerr << jumpDist[i][l] << ' '; } cerr << '\n';
	}

	ll curLoc = 0;
	for (int l = 60; l >= 0; l--) {
		if (curLoc + jumpDist[curLoc % N][l] <= N * K) {
			curLoc += jumpDist[curLoc % N][l];
		}
	}

	vector<int> ans;
	while (curLoc < N * K) {
		ll nxtLoc = (curLoc + jumpDist[curLoc % N][0]);
		if (nxtLoc <= N * K) {
			curLoc = nxtLoc;
		} else {
			ans.push_back(A[curLoc % N]);
			curLoc++;
		}
	}

	if (ans.empty()) {
		cout << '\n';
	} else {
		for (int i = 0; i < int(ans.size()); i++) {
			cout << ans[i] << " \n"[i+1==int(ans.size())];
		}
	}

	return 0;
}


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

int main(){
  string S;
  cin>>S;
  int flaga,flagb,flagc;
  flaga=0;
  flagb=0;
  flagc=0;
  for(int i=0;i<3;i++){
    if(S.at(i)=='a'){
      flaga=1;
    }
        if(S.at(i)=='b'){
      flagb=1;
    }
        if(S.at(i)=='c'){
      flagc=1;
    }
  }
  if(((flaga==1)&&(flagb==1))&&(flagc==1)){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


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

int main(){
  int k,A,B;
  cin>>k>>A>>B;
  
  string ans;
  
  for(int i=A; i<=B; i++){
    if(i%k==0){ ans="OK"; break;}
  }
  
  if(ans!="OK"){ ans ="NG";}
  
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int ans = sc.ni()%1000;
        int p = (1000-ans)%1000;
        pw.println(p);
        
        pw.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 32812
import math
N = int(input())

divisors = []
for i in range(1, int(math.sqrt(N))+2):
    if N%i == 0:
        if i < N//i:
            divisors.append(i)
            divisors.append(N//i)
        elif i == N//i:
            divisors.append(i)
ans = 0
for elem in divisors:
    m = elem-1
    p = N//(m+1)
    if 0 <= p and p < m:
        ans += m
print(ans)



Measured memory_bytes: 3288
import sys
input = sys.stdin.readline

K,N = map(int, input().split())
A = list(map(int, input().split()))
d = [0]*N
for i in range(N):
    t = i+1
    if i+1 == N:
        t = 0
    d[i] = min(abs(A[i]-A[t]), abs(K-A[i])+A[t])
print(sum(d)-max(d))

Measured memory_bytes: 72140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 200;

int n,m;
char s[N][N];
int f[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>s[i]+1;
	memset(f,INF,sizeof(f));
    f[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i>1) f[i][j]=min(f[i][j],f[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
			if(j>1) f[i][j]=min(f[i][j],f[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'));
		}
	}
	cout<<f[n][m]<<'\n';
	return 0;
}

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

int main() 
{
    string s; cin >> s;
    int n=s.size();
    long long int ans=0,cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A')
        {
            cnt++;
        }
        else if(s[i]=='B' && s[i+1]=='C')
        {
            ans=ans+cnt;
            i++;
        }
        else
        {
            cnt=0;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3732
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    let red = s.iter().filter(|&&c| c == '0').count();
    let blue = s.len() - red;
    println!("{}", std::cmp::min(red, blue) * 2);
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
	    List<int> input = IO.GetIntList();
	    int h = input[0];
	    int n = input[1];
	    int[,] dp = new int[n+1,h+1];
	    for(int i=0;i<h+1;i++){
	        dp[0,i] = int.MaxValue;
	    }
        for(int i=1;i<n+1;i++){
            List<int> s = IO.GetIntList();
            for(int j=1;j<h+1;j++){
                int uDp = dp[i-1,j];
                int lDp = dp[i,Math.Max(0,j-s[0])];
                int v = Math.Min(uDp,lDp + s[1]);
                dp[i,j] = v;
	        }
	    }
	    /*
	    for(int i=1;i<=n;i++){
	        List<int> s = IO.GetIntList();
	        int aC = 0; //attackCount
	        while(true){
	            aC++;
	            int j = Math.Min(aC*s[0],h);
	            int lDp = dp[i,(aC-1)*s[0]];
	            int uDp = (dp[i-1,j]==0)?int.MaxValue:dp[i-1,j];
	            int v = Math.Min(uDp,lDp + s[1]);
	            for(int k=(aC-1)*s[0]+1;k<=j;k++){
	                dp[i,k] = v;
	            }
	            
	            //Console.WriteLine("i="+i+" j="+j+" "+dp[i,j]);
	            if(j==h)break;
	        }
	    }
	    */
	    Console.WriteLine(dp[n,h]);
	    /*
	    for(int i=n-10;i<n+1;i++){
	        for(int j=h-10;j<h+1;j++){
	            Console.Write((dp[i,j]==int.MaxValue)?"-":dp[i,j]+" ");
	        }
	        Console.WriteLine("");
	    }
	    */
	    
	}

}

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}

Measured memory_bytes: 50144
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 26 21:17:50 2020

@author: H_Hoshigi
"""

H = int(input())

total_attack = 0

now_H = H
now_N = 1
while now_H > 1:
    total_attack += now_N
    now_H = now_H // 2
    now_N = now_N * 2
total_attack += now_N

print(total_attack)




Measured memory_bytes: 3060
import sys
S = input()
K = int(input())
if len(S) == 1:
    print(K//2)
    sys.exit()
cnt0 = 1
cntL = 1
cnt = 1
ans = 0
i = 0
while i < len(S)-1:
    for j in range(i+1,len(S)):
        if S[i] == S[j]:
            cnt +=1
        else:
            if i == 0:
                cnt0 = cnt
            i = j
            break
    if cnt > 1:
        ans += cnt//2
        cnt = 1
        i = j

for i in range(len(S)-1,0,-1):
    if S[i] == S[i-1]:
        cntL +=1
    else:
        break
ans = K*ans
if S[0] == S[-1] and cnt0%2 != 0 and cntL %2 != 0:
    ans += K-1
if cntL == len(S):
    if (K*cntL)%2==0:
        print((K*cntL)//2)
    else:
        print((K*cntL-1)//2)
    sys.exit()
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define K 10
#define ll long long
int dp[K+1][K+1][K+1];

ll a, b, c;
int k;

ll solve(int pa, int pb, int pc)
{
	if(dp[pa][pb][pc]==-1)
	{
		if((pa + pb + pc) == k)
		{
			dp[pa][pb][pc] = ((1LL<<pa)*a)+((1LL<<pb)*b)+((1LL<<pc)*c);
		}
		else
		{
			dp[pa][pb][pc] = max({solve(pa+1,pb,pc), solve(pa,pb+1,pc),
						solve(pa,pb,pc+1)});
		}
	}
	return dp[pa][pb][pc];
}

int main() {
	cin >> a >> b >> c >> k;
	memset(&dp,-1,sizeof(dp));
	cout << solve(0,0,0) << endl;
	return 0;
}

Measured memory_bytes: 256
I=float('inf')
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 F=[[I]*-~n for _ in[0]*-~n]
 for i in range(1,n+1):F[i][i]=0
 for _ in[0]*k:
  f=input();g=map(int,f[2:].split())
  if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
  else:
   c,d,e=g
   if e<F[c][d]:
    for i in range(2,n+1):
     for j in range(1,i):
      F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])


Measured memory_bytes: 5776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

struct Cake {
  ll x, y, z;

  bool operator < (const Cake& c) const {
    return x + y + z > c.x + c.y + c.z;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<Cake> c(n);
  rep(i, n) cin >> c[i].x >> c[i].y >> c[i].z;

  ll ans = 0;
  rep(i, 2) {
    rep(j, 2) {
      rep(k, 2) {
        vector<Cake> resc(n);
        rep(l, n) {
          resc[l] = c[l];
          if (i) resc[l].x *= -1;
          if (j) resc[l].y *= -1;
          if (k) resc[l].z *= -1;
        }

        sort(resc.begin(), resc.end());
        ll res = 0;
        rep(l, m) {
          res += resc[l].x + resc[l].y + resc[l].z;
        }
        ans = max(ans, res);
      }
    }
  }

  cout << ans << endl;


  
  return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for (int i = 0; i < n; i ++) {
    int t; cin >> t;
    sum += t;
  }
  string ans = sum >= h ? "Yes" : "No";

  cout << ans << endl;
}

Measured memory_bytes: 256
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if d1 == 31:
    print("1")
elif d1 == 30 and d2 == 1:
    print("1")
elif d1 == 28 and m1 == 2:
    print("1")
else:
    print("0")

Measured memory_bytes: 38256
ask=->n{$>.<<("? %d\n"%n).flush;gets.chomp=='Y'}
put=->n{$>.<<("! %d\n"%n).flush;exit}
ask[i=10**9]?(i=1;loop{ask[i*2]&&put[i];i*=10}):loop{ask[i]&&put[(i+1..i*10-1).bsearch{|e|ask[e*10+9]}];i/=10}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define endl '\n'

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int INF = 1e9+10;
const int maxn = 60;
	
int h,w,white=0;

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

char g[maxn][maxn];
int dist[maxn][maxn];

bool ok(int x,int y){
	return x>=1 && x<=h && y>=1 && y<=w && g[x][y]=='.';
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	cin>>h>>w;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cin>>g[i][j];
			if(g[i][j]=='.')
				white++;
		}
	}
	for(int i=0;i<maxn;++i){
		for(int j=0;j<maxn;++j){
			dist[i][j]=INF;
		}
	}
	queue<ii> q;
	q.push(ii(1,1));
	dist[1][1]=1;
	while(!q.empty()){
		int x=q.front().ff,y=q.front().ss;
		q.pop();
		for(int i=0;i<4;++i){
			if(ok(x+dx[i],y+dy[i]) && dist[x][y]+1 < dist[x+dx[i]][y+dy[i]]){
				dist[x+dx[i]][y+dy[i]]=dist[x][y]+1;
				q.push(ii(x+dx[i],y+dy[i]));
			}
		}
	}
	if(dist[h][w]==INF)
		cout<<-1<<endl;
	else
		cout<<white-dist[h][w]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] A = new int[3];
        for(int i=0;i<3;i++) A[i]=sc.nextInt();
        Arrays.sort(A);
        int ans = A[2]*10+A[1]+A[0];
        System.out.println(ans);
    }
}


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

int main() {
  int N;
  cin >> N;
  bool x = true;
  for(int i=0;i<50000;i++){
    if(floor(i*1.08) == N){
      cout << i << endl;
      x = false;
      break;
    }
  }
    if(x)
      cout << ":(" << endl;
      
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int n;cin >> n;
      int arr[n + 5];
      int sum = 0;
      for(int i = 0;i < n;i++){
            cin >> arr[i];
            sum += arr[i];
      }
      int m;cin >> m;
      for(int i = 0;i < m;i++){
            int p,x;cin >> p >> x;
            cout << sum - (arr[p - 1] - x) << "\n";
      }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,M;
  cin>>N>>M;
  vector<ll>A(N);
  vector<ll>B(M);
  vector<ll>C(M);
  vector<pair<ll,ll>>D(M);
  ll sum=0;
  rep(i,N){
cin>>A[i];
    sum+=A[i];
  }
  
  rep(i,M){
cin>>B[i]>>C[i];
    D[i].first=C[i];
    D[i].second=B[i];
  }
  
  sort(all(D));
  reverse(all(D));
  sort(all(A));
  
ll now=0;
  
  rep(i,N){
if(A[i]<D[now].first&&D[now].second!=0){
  sum+=D[now].first-A[i];
  D[now].second--;
}
else if(A[i]<D[now].first&&D[now].second==0){
now++;
  if(A[i]<D[now].first){
 sum+=D[now].first-A[i];
  D[now].second--;
  }
}
  }

  cout<<sum<<endl;
}

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

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("bbreeds.in","r",stdin );
#define outF freopen("bbreeds.out" , "w" , stdout ) ;

#define ll long long

const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const int N = 1e3 + 3 , oo = 1e9 , M = N * 4, mod = 1e9 + 7 , K = 12;
int H , W ;
ll dp[N][N];
char grid[N][N];
const int di[] = {1 , 0};
const int dj[] = {0 , 1};


bool valid(int i , int j){
    return i > -1 && j > -1 && i < H && j < W && grid[i][j] != '#';
}

ll calc(int i , int j){
    if(i == H - 1 && j == W - 1)
        return 1 ;

    ll &ret = dp[i][j] ;

    if(~ret)
        return ret ;

    ret = 0 ;

    for(int k = 0 ; k < 2; k ++){
        int newi = i + di[k];
        int newj = j + dj[k];
        if(valid(newi , newj)){
            ret += calc(newi , newj) % mod ;
            ret %= mod ;
        }
    }
    return ret ;

}
int32_t main(){
    fastio ;

    // Dont Forget memset

    //calculate constraints please!!!
    cin >> H >> W ;

    for(int i = 0 ; i < H ; i++)
        for(int j = 0 ; j < W ; j++)
            cin >> grid[i][j];

    memset(dp , -1 , sizeof dp);

    cout << calc(0 , 0);
     return 0 ;
}




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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    string s;
    cin >> s;
    map<string, string> mp;

    mp["Sunny"] = "Cloudy";
    mp["Cloudy"] = "Rainy";
    mp["Rainy"] = "Sunny";

    cout << mp[s] << '\n';
    return 0;
}


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

public class Main {
  private static long solve(int n) {
    long[] cache = new long[n];
    cache[n - 1] = n;
    long sumA = 0;
    long sumB = n - 1;
    for (int i = n - 2; i >= 0; i--) {
      if (i <= n - 4) {
        sumA = sumA + cache[i + 3];
        sumB = sumB - 1;
      }
      cache[i] = (cache[i + 1] + (long)(n - 1) * (long)(n - 1) + sumA + sumB) % 1_000_000_007L;
    }
    return cache[0];
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    out.println(solve(n));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 31572
a=input()
b=input()
ans=[]
if len(a)==len(b):
    for i in range(len(a)):
        ans.append(a[i])
        ans.append(b[i])
else:
    for i in range(len(b)):
        ans.append(a[i])
        ans.append(b[i])
    ans.append(a[len(a)-1])
print(''.join(ans))

Measured memory_bytes: 3060
a=int(input())
b=len(str(a))

ans=0

if b%2==0:
    for i in range(int(b/2)):
        c=1+i*2
        ans+=(10**c-(10**(c-1)))

else:
    ans+=(a-(10**(b-1))+1)
    for i in range(int((b-1)/2)):
        e=1+i*2
        ans+=(10**e-(10**(e-1)))

print(int(ans))


Measured memory_bytes: 3060
def fill(y,x):
    global l,c,w,h
    if 0<=x+1<w and 0<=y<h and l[y][x+1]==".":
        c+=1
        l[y][x+1]=1
        fill(y,x+1)
    if 0<=x-1<w and 0<=y<h and l[y][x-1]==".":
        c+=1
        l[y][x-1]=1
        fill(y,x-1)
    if 0<=x<w and 0<=y+1<h and l[y+1][x]==".":
        c+=1
        l[y+1][x]=1
        fill(y+1,x)
    if 0<=x<w and 0<=y-1<h and l[y-1][x]==".":
        c+=1
        l[y-1][x]=1
        fill(y-1,x)
    return c

while 1:
    w,h=map(int,input().split())
    if not w and not h:break
    l=[list(input()) for _ in range(h)]
    y,x=[[n,i.index("@")] for (n,i) in enumerate(l) if "@" in i][0]
    l[y][x]=1
    c=1
    print(fill(y,x))



Measured memory_bytes: 5776
#include<iostream>
#include<vector>
#include<functional>
#include<queue>
#include<algorithm>

using namespace std;

int main(void){

    int x, y;
    int ans = 0;

    cin >> x >> y;

    if(x == 3) ans += 100000;
    else if(x == 2) ans += 200000;
    else if(x == 1) ans += 300000;

    if(y == 3) ans += 100000;
    else if(y == 2) ans += 200000;
    else if(y == 1) ans += 300000;

    if(x == 1 && y == 1) ans += 400000;

    cout << ans << endl;
    return 0;
}

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

int main(){
  int stu[28],cou=1,ans[2]={0},cou_ans=0;
  for(int i=0;i<28;i++){
    cin >> stu[i];
  }
  sort(stu,stu+28);
  for(int i=0;i<28;i++){
    if(stu[i] == cou){
      cou++;
    }
    else{
      cout << cou << endl;
      cou++;
      i -= 1;
    }
    if(i==27 && stu[i] == 29){
      cout << "30" << endl;
    }
  }
}
      

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

const uint64_t MAGIC = 998244353;

uint64_t PowerMod(uint64_t n, uint64_t k, uint64_t mod) {
    uint64_t ret = 1;
    while (k) {
        if (k & 1) {
            ret = ret * n % mod;
        }
        n = n * n % mod;
        k >>= 1;
    }
    return ret;
}

class ChooseMod {
    public:
    ChooseMod(size_t max_n , uint64_t mod):mod_(mod) {
        fac_.resize(max_n + 1);
        inv_.resize(max_n + 1);
        fac_[0] = inv_[0] = 1;
        for (size_t i = 1; i <= max_n; ++i) {
            fac_[i] = fac_[i-1] * i % mod_;
            inv_[i] = PowerMod(fac_[i], mod_ - 2, mod_);
        }
    }
    uint64_t Choose(uint64_t n, uint64_t k) {
        return fac_[n] * inv_[n-k] % mod_ * inv_[k] % mod_;
    }
    uint64_t Fac(size_t x) {
        return fac_[x];
    }
    private:
    uint64_t mod_;
    vector<uint64_t> fac_;
    vector<uint64_t> inv_;
};

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

    int N, M, K;
    cin >> N >> M >> K;

    uint64_t ans = 0;
    uint64_t p = PowerMod(M-1, N-1-K, MAGIC);
    ChooseMod c(N-1, MAGIC);

    for (int i = K; i >= 0; --i) {
        ans = (ans + c.Choose(N-1, i) * p % MAGIC) % MAGIC;
        p = p * (M-1) % MAGIC;
    }
    ans = (ans * M) % MAGIC;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define LOCAL
#define all(a) begin(a), end(a)
#define MOD 1000000007
#define PII pair<int, int>
#define REP(x, l, u) for(ll x = l;x<u;x++)
#define RED(x, l, u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(begin(a),end(a)),end(a))
#define mst(x, a) memset(x,a,sizeof(x))
typedef vector<int> VI;
typedef long long ll;

ll quick_pow(ll a, ll b) {
    long long res = 1;
    while (b) {
        if (b & 1) { res = a * res; }
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) {
    a = abs(a), b = abs(b);
    while (b != 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

bool is_prime(int n) {
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    int j = sqrt(n);
    for (int i = 2; i <= j; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

ll reverse_num(ll n) {
    ll x = 0, t = n;
    while (t != 0) {
        x = x * 10 + t % 10;
        t /= 10;
    }
    return x;
}

// TO-DO
// contest required
#ifdef LOCAL


void solve() {
    int n;
    cin >> n;
    int a[n + 1];
    mst(a, 0);
    for (int x = 1; x <= 100; ++x) {
        for (int y = 1; y <= 100; ++y) {
            for (int z = 1; z <= 100; ++z) {
                int cur = x * x + y * y + z * z + x * y + y * z + z * x;
                if (cur <= n) a[cur]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) cout << a[i] << endl;
}

int main() {
    // 加速输入和输出
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}

#endif

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int fst = 1;
		int snd = 1;
		
		for(int i = 1; i < n; i++){
			final int thd = fst + snd;
			fst = snd;
			snd = thd;
		}
		System.out.println(snd);
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public void close() throws IOException {
			br.close();
		}
	}

}

Measured memory_bytes: 17064
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let mut prev = 0;
    let mut ret = 0;
    for i in 0..n {
        let p: usize = parse!(it);
        if i == 0 {
            if p != 0 {
                println!("{}", -1);
                return;
            }
            continue;
        }
        if p == prev + 1 {
            ret += 1;
        } else if p > prev + 1 {
            println!("{:?}", -1); // DEBUG
            return;
        } else {
            ret += p;
        }
        prev = p
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int main() {
	int  n,m;
  	cin >> n >> m;
  	vector<int> box(n,1);
  	vector<bool>red(n);
  	red[0] = true;
  	int x,y;
  	for(int i = 0; i < m; i++) {
    	cin >> x >> y;
      	x--;y--;
      	if(red[x] == true)
          	red[y] = true;
      	if(box[x] == 1 && red[x] == true)
        	red[x] = false;
      	
        box[x]--;
      	box[y]++;
    }
  	int count=0;
  	for(int i = 0; i < n; i++)
  		if(red[i] == true)
          	count++;
  
  	printf("%d\n",count);
}

Measured memory_bytes: 640
#include <stdio.h>
 
int prime[999999];
 
int main() {
  int i, k, n, N = 0;
  for(i = 2; i <= 999999; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= 999999; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= 999999; k += i) {
        prime[k] = 0;
      }
    }
  }
  for(i = 2; i <= 999999; i++) {
    if(prime[i] == 1){
      N++;
      prime[i] = N;
    }else if(prime[i] == 0){
      prime[i] = N;
    }
  }
  while(scanf("%d", &n) != EOF){
    printf("%d\n", prime[n]);
  }
  return 0;
}

Measured memory_bytes: 4500
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt( sc.nextLine());

		Integer a[] = Stream.of(sc.nextLine().split(" ", n))
				.map(s -> Integer.parseInt(s))
				.toArray(Integer[]::new);

		Arrays.sort(a , Comparator.reverseOrder());

		int gap = 0;

		for (int i = 0; i < a.length; i++) {
			if (i % 2 ==0) {
				gap += a[i];
			} else {
				gap -= a[i];

			}

		}
		System.out.println(gap);


	}

}

Measured memory_bytes: 26832
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for i in range(n):
    d[a[i]] += 1

k = list(d.keys())
v = list(d.values())

if len(k) == 1 and k[0] == 0:
    ans = "Yes"
elif n % 3 != 0:
    ans = "No"
elif len(k) == 2 and 0 in d and d[0] == n // 3:
    ans = "Yes"
elif len(k) == 3 and v[0] == v[1] == v[2] and k[0] ^ k[1] ^ k[2] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

#define MAX_V 100005

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    vector<set<int>> tunagi(n);

    int ans = 0;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        tunagi[a].insert(h[b]);
        tunagi[b].insert(h[a]);
    }

    REP(i, n) {
        bool ok = true;
        for(auto k: tunagi[i]) {
            //cout << i << " " << k << " " << h[i] << endl;
            if(k >= h[i]) {
                ok = false;
            }
        }
        if(ok) {
            //cout << i << endl;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17712
N = int(input())
A = str(input())
B = str(input())
C = str(input())

count = 0
for i in range(N):
    if A[i] == B[i]:
        if B[i] != C[i]:
            count += 1
    else:
        if A[i] == C[i]:
            count += 1
        elif B[i] == C[i]:
            count += 1
        else:
            count += 2

print(count)

Measured memory_bytes: 3064
//Handstand 2

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vector<vector<int>>c(10,vector<int>(10,0));
    rep(i,1,n+1){
        string s = to_string(i);
        int a,b;
        a=s[0]-'0';b=s[s.size()-1]-'0';
        c[a][b]++;
    }
    int ans = 0;
    rep(i,1,10){
        rep(j,1,10){
            ans+=c[i][j]*c[j][i];
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000007
typedef long long ll;
int N, K;
ll rem = 0;
ll sum1, sum2 = 0;

ll Sum(ll num)
{
    ll sum1,sum2;
    if (num == N + 2)
        return 0;
    sum1 = num * (num - 1) / 2;
    sum2 = num * (2 * (N - num + 1) + (num - 1)) / 2;
    rem += sum2 - sum1 + 1;
    rem %= BUFSIZE;
    Sum(num + 1);
    return 0;
}

int main(void)
{
    scanf("%d", &N);
    scanf("%d", &K);
    Sum(K);
    printf("%lld", rem % BUFSIZE);
    return 0;
}


Measured memory_bytes: 4852
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            int[,] town = new int[N,N];
            
            for(int i = 0 ; i < M ; i++)
            {
                input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0])-1;
                int b = int.Parse(input[1])-1;
                
                town[a,b] += 1;
                town[b,a] += 1;
            }
            int ans;
            for(int i = 0 ; i < N ; i++)
            {
                ans = 0;
                for(int j = 0 ; j < N ; j++)
                {
                    ans += town[i,j];
                }
                Console.WriteLine(ans);
            }

        }
    }
}

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

int main() {
	int n, k, x, y;
	scanf("%d %d %d %d", &n, &k, &x, &y);
	int ans;
	ans = min(n, k) * x;
	ans += max(0, n - k) * y;
	printf("%d\n", ans);
	
	return 0;
}

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

string func(int N, int M, int K) {
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            int cnt = i * M + j * N - 2 * i * j;
            if (cnt == K) return "Yes";
        }
    }
    return "No";
} 

int main() {
    int N, M, K; cin >> N >> M >> K;
    cout << func(N, M, K) << endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

_, M = map(int, raw_input().split())
lst = []

for i in range(M):
    a, b = map(int, raw_input().split())
    lst.append((a, b))

lst.sort()
pos = 0
ans = 0

for p in lst:
    if p[0] > pos:
        ans += 1
        pos = p[1] - 1
    elif p[1] <= pos:
        pos = p[1] - 1

print ans

Measured memory_bytes: 18680
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//The House of Huge Family
public class Main{

	class E{
		int s, t, c, id;
		public E(int s, int t, int c, int id) {
			this.s = s;
			this.t = t;
			this.c = c;
			this.id = id;
		}
	}
	
	int n, m;
	List<E>[] adj;
	
	boolean isCon(int f1, int f2){
		boolean[] u = new boolean[n];
		List<Integer> l = new ArrayList<Integer>();
		l.add(0); u[0] = true;
		int N = 0;
		while(!l.isEmpty()){
			List<Integer> next = new ArrayList<Integer>();
			for(int i:l){
				N++;
				for(E e:adj[i])if(!u[e.t]&&e.id!=f1&&e.id!=f2){
					u[e.t] = true; next.add(e.t);
				}
			}
			l = next;
		}
		return N==n;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt(); m = sc.nextInt();
			if((n|m)==0)break;
			adj = new List[n];
			for(int i=0;i<n;i++)adj[i]=new ArrayList<E>();
			int N = 0, M = 0;
			List<Integer> cost = new ArrayList<Integer>();
			while(m--!=0){
				int s = sc.nextInt(), t = sc.nextInt(), c = sc.nextInt();
				if(c<=0)M+=c;
				else{
					cost.add(c); adj[s].add(new E(s, t, c, N)); adj[t].add(new E(t, s, c, N)); N++;
				}
			}
			int min = Integer.MAX_VALUE;
			if(!isCon(-1, -1))min = 0;
			for(int i=0;i<N;i++)if(!isCon(i, -1))min = Math.min(min, cost.get(i));
			for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)if(!isCon(i, j))min = Math.min(min, cost.get(i)+cost.get(j));
			System.out.println(M+min);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<pair<int, int>> ab(n);
    vector<int> c(n);
    for (int i=0; i<n; ++i) cin >> ab.at(i).first >> ab.at(i).second >> c.at(i);

    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(401, vector<int>(401, INF)));
    dp.at(0).at(0).at(0) = 0;
    for (int i=1; i<n+1; ++i) {
        int a = ab.at(i-1).first, b = ab.at(i-1).second;
        for (int j=0; j<401; ++j) {
            for (int k=0; k<401; ++k) {
                chmin(dp.at(i).at(j).at(k), dp.at(i-1).at(j).at(k));
                if (j >= a && k >= b) chmin(dp.at(i).at(j).at(k), dp.at(i-1).at(j-a).at(k-b) + c.at(i-1));
            }
        }
    }
    int res = INF;
    for (int i=1; i<401; ++i) {
        for (int j=1; j<401; ++j) {
            if (ma * j == mb * i) chmin(res, dp.at(n).at(i).at(j));
        }
    }
    cout << (res == INF ? -1 : res) << '\n';
}

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

    solve();

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
    return 0;
}

Measured memory_bytes: 256