akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail+1)%LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head+1)%LEN;
	return x;
}

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

int main(void){
	int elap =0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	
	for(i = 1; i <= n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1;
	tail = n+1;
	
	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elap += c;
		if(u.t > 0)enqueue(u);
		else printf("%s %d\n", u.name, elap);
	}
	
	return 0;
}



Measured memory_bytes: 11840
from collections import deque

def main():
    N = int(input())
    S = list(input())
    Stmp = S.copy()
    Stmp = deque(Stmp)
    cnt = 0
    for s in S:
        cnt += (s=='(') - (s==')')
        if cnt < 0:
            Stmp.appendleft('(')
            cnt += 1
    for _ in range(cnt):
        Stmp.append(')')
    print(''.join(Stmp))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;
 
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
 
#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
 
#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];
 
int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);
 
    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
 
bool solve(int N, vi& a, vi& b) {
    ll plus = 0, minus2 = 0, minus1 = 0;
    rep(i, N) {
        ll di = a[i] - b[i];
        if (di > 0) {
            plus += di;
        } else if (di < 0) {
            minus2 += -di / 2;
            minus1 += -di % 2;
        }
    }
    if (plus > minus2) return false;
    return true;
}
 
int main() {
    int N = loadint();
    vector<int> a(N), b(N);
    loadvec(a, N);
    loadvec(b, N);
    cout << (solve(N, a, b) ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	ll n, sum = 0; cin>>n;
	vector< ll > v(n);
	unordered_map< ll, ll > m;
	for(ll &i : v){
		cin>>i;
		m[i]++;
		sum += i;
	}
	int q; cin>>q;
	vector< ll > b(q), c(q);
	for(int i = 0; i<q; i++){
		cin>>b[i]>>c[i];
	}
	for(int i = 0; i<q; i++){
		sum = sum - (m[b[i]] * b[i]);
		sum = sum + (m[b[i]] * c[i]);
		m[c[i]] += m[b[i]];
		m[b[i]] = 0;
		cout<<sum<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 9316
<?php

fscanf(STDIN, "%d", $n);
$array = explode(' ', trim(fgets(STDIN)));
$dummy = array();

$count = 0;
$min = null;
for ($i=0; $i < $n; $i++) {
  if ($min == null || $min > $array[$i]) {
    $min = $array[$i];
  }
  if ($array[$i] <= $min) {
    $count++;
  }
}

echo $count;


Measured memory_bytes: 18932
def main():
    N = int(input())
    S = input()
    black = [0] * (N+1)
    white = [0] * (N+1)
    for i in range(N):
        black[i+1] = black[i]
        white[N-i-1] = white[N-i]
        if S[i] == "#":
            black[i+1] += 1
        if S[N-i-1] == ".":
            white[N-i-1] += 1
    ans = float("inf")
    for i in range(N+1):
        ans = min(ans, black[i] + white[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    int n,maxa=-1000000000;
    cin>>n;
    int r[n];
    for(int i=0;i<n;i++) cin>>r[i];
    int mina=r[0];
    for(int i=1;i<n;i++){
        maxa=max(maxa,r[i]-mina);
        mina=min(mina,r[i]);
    }
    cout<<maxa<<endl;
}



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

int main(void) {
	char A[10],B[10],C[10];
	scanf("%s%s%s",A,B,C);
	if (A[strlen(A)-1]==B[0] && B[strlen(B)-1]==C[0]){
		printf("YES");
	}else{
		printf("NO");
	}
	// your code goes here
	return 0;
}


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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		String s = nextToken();
		String t = nextToken();
		for (int both = n; both >= 0; both--) {
			if (s.substring(n - both).equals(t.subSequence(0, both))) {
				out.println(2 * n - both);
				return;
			}
		}
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 8272
/* @ by batr (T) */
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
#define pcc pair<char, char>
 
#define F first
#define S second

using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int a, b, c;

int main () {
	Need_For_Speed();
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << -1 + (a % 2 != 0);
		return 0;
	}
	int ans = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int A1, B1, C1;
		A1 = a;
		B1 = b;
		C1 = c;
		a = (B1 + C1) >> 1;
		b = (A1 + C1) >> 1;
		c = (A1 + B1) >> 1;
		ans++;
	}
	cout << ans;
	return 0;
}	

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}


ll lcm(ll a,ll b){
  ll n;
  n=a*b/gcd(a,b);
  return n;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  ll n;
  	ci(n);
  vll A(5);
  FOR(i,0,n){
    st s;
    	ci(s);
    if(s[0]=='M'){
       A[0]++;
       }
    else if(s[0]=='A'){
      A[1]++;
    }
    else if(s[0]=='R'){
	  A[2]++;
    }
    else if(s[0]=='C'){
	  A[3]++;
    }
    else if(s[0]=='H'){
      A[4]++;
    }
  }
  
  ll ans=0;
  FOR(i,0,4){
    FOR(j,i+1,5){
      FOR(k,j+1,5){
        ans+=A[i]*A[j]*A[k];
      }
    }
  }
  co(ans)
    
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

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


    string S;
    cin >> S;

    int l, r;
    l=r=0;
    int zero;

    if(S[0]=='0')
    {
        zero=1;
    }
    else
    {
        zero=0;
    }
    int ans=0;
    while(r<N)
    {
        if(zero<=K)
        {
            chmax(ans, r-l+1);
            if(S[r]=='1' && S[r+1]=='0')
            {
                zero++;
            }
            r++;
        }
        else
        {
            if(S[l]=='0' && S[l+1]=='1')
            {
                zero--;
            }
            l++;
        }
    }

    cout << ans << '\n';
    
 

 

    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k;
  int count=0;
  cin>>n>>k;
  while(n!=0){
    n/=k;
    count++;
  }
  cout<<count<<'\n';
  return(0);
}


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

int main(){
while(true){
  int iwakurasisetudan;
  int b;
  int c;
  cin>>iwakurasisetudan;
if(iwakurasisetudan==0){break;
}else{  c=1000-iwakurasisetudan;
  b=c/500;
  c=c%500;
  b=b+c/100;
  c=c%100;
  b=b+c/50;
  c=c%50;
  b=b+c/10;
  c=c%10;
  b=b+c/5;
  c=c%5;
  b=b+c;
  cout<<b<<endl;
}}}

  

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

int main(){
  int X;
  cin >> X;
  for(int i=X;i<=100003;i++){
    bool primal=true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0){
        primal=false;
        break;
      }
    }
    if(primal){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
from math import sqrt
from itertools import permutations


def norm(i, j):
    return sqrt((i[0] - j[0]) ** 2 + (i[1] - j[1]) ** 2)


N = int(input())
x = [None] * N
y = [None] * N

for i in range(N):
    x[i], y[i] = map(int, input().split())

rst = 0
cnt = 0
for order in permutations([n for n in range(N)]):
    for n in range(N - 1):
        rst += norm((x[order[n]], y[order[n]]), (x[order[n + 1]], y[order[n + 1]]))
    cnt += 1

print(rst / cnt)


Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> v(N);
  rep(i,N) cin >> v[i];
  sort(all(v));
  double ans = v[0];
  for (int i = 1; i < N; i++){
    ans = (ans + v[i]) / 2.0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3796
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int a[6];

int main()
{
  rep( i, 6 )
    scanf( "%d", a+i );

  std::sort( a, a+4 );
  
  printf( "%d\n", a[1]+a[2]+a[3]+std::max( a[4], a[5] ) );
  
  return 0;
}

Measured memory_bytes: 2768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main implements Runnable {
    
    private int n;
    private int m;
    private int[] x;

    public static void main(String[] args) throws IOException {
        Main m = new Main();
	    m.run();
    }

    private void set() {
	    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
	        String[] parts = br.readLine().split("[\\s]+");
	        n = Integer.parseInt(parts[0]);
	        m = Integer.parseInt(parts[1]);
	        x = Arrays.stream(br.readLine().split("[\\s]+"))
		    .mapToInt(Integer::parseInt).sorted().toArray();
	    } catch (IOException e) {
	        e.printStackTrace();
	    }
    }

    @Override
    public void run() {
	    set();
	    if (n >= m) {
	        System.out.println(0);
	        System.exit(0);
	    }
	    if (n == 1) {
	        System.out.println(x[m-1]-x[0]);
	        System.exit(0);
	    }
	    int[][] y = new int[m-1][2];
	    boolean[] located = new boolean[m];
	    for (int i=0;i<m-1;i++) {
	        y[i][0] = x[i+1] - x[i];
	        y[i][1] = i;
	    }
	    Arrays.sort(y,(a,b) -> Integer.compare(b[0],a[0]));
	    for (int i=0;i<n-1;i++) {
	        located[y[i][1]+1] = true;
	    }
	    if (!located[0]) {
	        located[0] = true;
	    } else {
	        located[y[n-1][1]+1] = true;
	    }
	    int sum = 0;
	    int idx = 0;
	    while (idx < m-1) {
	        if (located[idx]) {
		        int lower = x[idx];
		        while (idx < m-1 && !located[idx+1]) idx++;
		        sum += x[idx] - lower;
	        }
	        idx++;
	    }
	    System.out.println(sum);
    }
}

Measured memory_bytes: 49752
class Main{public static void main(String[]z)throws Exception{char[]a={0,1,0,0};for(byte[]b=new byte[4];System.in.read(b)>-1;a[b[0]]=a[b[2]-=64],a[b[2]]=a[0])a[0]=a[b[0]-=64];System.out.println((char)(new String(a).indexOf(1)+64));}}

Measured memory_bytes: 9368
#include <iostream>
#include <set>

using namespace std;
using ll = long long;

const int MAX_N = 30000;

int n;
string str;

void solve()
{
    string num;
    int cnt = 0;
    int j, k, l;
    for (int i = 0; i < 1000; i++)
    {
        num = to_string(i);
        if (i <= 9)
            num = "00" + num;
        else if (i >= 10 && i <= 99)
            num = "0" + num;
        
        
        bool a = false;
        bool b = false;
        bool c = false;
        for (j = 0; j < n; j++)
        {
            if (str[j] == num[0])
            {
                a = true;
                break;
            }
        }
        for (k = j + 1; k < n; k++)
        {
            if (str[k] == num[1])
            {
                b = true;
                break;
            }
        }
        for (l = k + 1; l < n; l++)
        {
            if (str[l] == num[2])
            {
                c = true;
                break;
            }
        }

        if (a && b && c)
            cnt++;
    }

    cout << cnt << endl;
}

int main()
{

    cin >> n;
    cin >> str;
    solve();

    return EXIT_SUCCESS;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

ll solve(const int N) {
    ll ans = 0;

    int acc = 0;
    int end = 0;
    for (int begin = 0; begin < N; begin++) {
        // [begin, end)
        while (end < N && (acc + as[end]) == (acc ^ as[end])) {
            acc += as[end];
            end++;
        }
        ans += end - begin;
        // printf("begin: %d, end: %d, acc: %d, ans: %lld\n", begin, end, acc, ans);

        acc -= as[begin];
    }

    return ans;
}

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 1152
n = gets.chomp.to_i
plist = gets.chomp.split.collect{ |item| item.to_i}

count = 0
plist.each_with_index do |pi,i|
  if (pi != (i+1))
    count += 1
  end
end

if (count == 0 || count == 2)
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  int dx[]={1,1,1,0,-1,-1,-1,0};
  int dy[]={1,0,-1,-1,-1,0,1,1};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#') continue;
      int c=0;
      for(int k=0;k<8;k++){
	int y=i+dy[k],x=j+dx[k];
	if(y<0||h<=y||x<0||w<=x) continue;
	if(s[y][x]=='#') c++;
      }
      s[i][j]='0'+c;
    }
  }
  for(int i=0;i<h;i++) cout<<s[i]<<endl;
  return 0;
}


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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
int n;
int a[101];

/*funcs*/


/*main*/
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int c[8]={0};
    int count=0;
    for(int i=0;i<n;i++){
        if(a[i]<3200){
            c[(a[i]/400)]=1;
        }else{
            count++;
        }
    }
    int sum=0;
    for(int i=0;i<8;i++){
        if(c[i]==1){
            sum++;
        }
    }
    int max,min;
    if(sum==0){
        min=1;
        max=count;
    }else{
        min=sum;
        max=sum+count;
    }
    cout<<min<<" "<<max;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  mod 1e18
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;
int a[10000005];
int32_t main()
{
	fast
	int n,i,j,ans=0;
	for(i=1;i<=1e7;i++)
		for(j=i;j<=1e7;j+=i)
			a[j]++;
	cin>>n;
	for(i=1;i<=n;i++)
		ans+=i*a[i];
	cout<<ans<<endl;

	
}


Measured memory_bytes: 81772
def 買う(株, 金, 株価):
    買う株 = 金 // 株価
    金 = 金 - 買う株*株価
    株 += 買う株
    return 株, 金

def 売る(株, 金, 株価):
    金 = 金 + 株*株価
    株 = 0
    return 株, 金

n = int(input())
株価 = [int(i) for i in input().split()]
株価.append(-1)

株 = 0
金 = 1000

for i in range(n):
    if 株価[i] < 株価[i+1]:
        株, 金 = 買う(株, 金, 株価[i])
    else:
        株, 金 = 売る(株, 金, 株価[i])

print(金)

Measured memory_bytes: 9220
#include <stdio.h>
int main()
{int H,N,j,i,a,flag=0;
    scanf("%d",&H);
    scanf("%d",&N);
    int ;
    for (i=0;i<N;i++)
    {scanf("%d",&a);
    H=H-a;
        if(H<=0)
        {flag=1;
    }
    }
    if (flag==1)
    {printf("Yes");
    }
    else
    {printf("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int X,A;
  cin>>X>>A;
  if(X<A) cout<<0<<endl;
  else cout<<10<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	ll p, q, r;
	cin >> p >> q >> r;
	dump(min(p + q, min(q + r, p + r)));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
main()
{
	int n,c,k,t[1<<17];
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)cin>>t[i];
	sort(t,t+n);
	int cnt=0;
	int last=-1e9;
	int lcnt=0;
	for(int i=0;i<n;i++)
	{
		if(last<t[i]||lcnt>=c)
		{
			cnt++;
			lcnt=1;
			last=t[i]+k;
		}
		else
		{
			lcnt++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main() {
    int C[4][3][10];
    for (int i=0;i<4;i++) {
        for (int j=0;j<3;j++) {
            for (int k=0;k<10;k++) {
                C[i][j][k] = 0;
            }
        }
    }
    int n;
    cin >> n;
    int f, b, r,v;
    for (int i=0;i<n;i++) {
        cin >> b >> f >> r >> v;
        C[b-1][f-1][r-1] += v;
    }
    for (int i=0;i<4;i++) {
        if (i>0) {
            cout << "####################" << endl;
        }
        for (int j=0;j<3;j++) {
            for (int k=0;k<10;k++) {
                cout << " " << C[i][j][k];
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    vector<int> p(n);
    int nmax = 0;
    int sum = 0;
    rep(i, n) {
        cin >> p[i];
        sum += p[i];
        nmax = max(nmax, p[i]);
    }

    cout << sum - nmax/2 << endl;
    return 0;
}

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

int main(){
    string S; cin >> S;
    ll cnt = 0;
    for(int i = 0; i < S.size(); i++) if(S[i] == 'R') cnt++;
    if(cnt == 1) cout << 1 << endl;
    else if(cnt == 2){
        if(S[1] == 'R') cout << 2 << endl;
        else cout << 1 << endl;
    }
    else if(cnt == 3) cout << 3 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

llong gcd(llong x, llong y) {
   if (x < y)
      swap(x, y);
   if (y == 0)
      return x;
   return gcd(y, x % y);
}
llong lcm(llong x, llong y) {
   return x / gcd(x, y) * y;
}

llong f(llong x, int s, int t) {
   llong res = x;
   res -= x / s;
   res -= x / t;
   res += x / lcm(s, t);
   return res;
}
int main() {
   llong a, b;
   int c, d;
   cin >> a >> b >> c >> d;
   llong ans = f(b, c, d) - f(a - 1, c, d);
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m;

	scanf("%d",&n);

	m=n%10;
	if(m==3){
		printf("bon\n");
		return 0;
	}
	else if(m==0||m==1||m==6||m==8){
		printf("pon\n");
		return 0;
	}
	else{
		printf("hon\n");
		return 0;
	}
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;
#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;
int main(){
    double tc,T,avg,a,temp, currDiff;
    double ans,diff;

    cin >> tc;
    cin >> T >> avg;
    currDiff =INT_MAX;
    //cout << fixed;
    for(int i=1;i<=tc;i++){
        cin >> a;
        temp = ( T - a * .006);
        diff = abs(avg- temp);
        if(diff <= currDiff){
            currDiff = diff;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int q;
  cin >> q;
  set<int> st;
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      int x;
      cin >> x;
      st.insert(x);
      cout << st.size() << endl;
    }
    else if (type == 1)
    {
      int x;
      cin >> x;
      cout << st.count(x) << endl;
    }
    else if (type == 2)
    {
      int x;
      cin >> x;
      st.erase(x);
    }
    else
    {
      int l, r;
      cin >> l >> r;
      auto itr = st.lower_bound(l);
      while (itr != st.end() && *itr <= r)
      {
        cout << *itr << endl;
        itr++;
      }
    }
  }
  return 0;
}



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

int FindMax(int a[],int N) {
	int max = a[0];
	int index = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] > max) {
			max = a[i];
			index = i;
		}
	}
	a[index] = 0;
	return max;
}

int main() {
	int N;
	int a[100];
	int AlicePoint = 0, BobPoint = 0;

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

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			AlicePoint += FindMax(a, N);
		}
		else {
			BobPoint += FindMax(a, N);
		}
	}

	cout << AlicePoint - BobPoint << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
list = [list(map(int, input().split())) for x in range(m)]
list.sort(key=lambda x: x[1], reverse=True) # １番の要素で降順ソート

app_count = 0
for i in list:
    a += [i[1]]*i[0]
    app_count += i[0]
    if app_count>n:
        break

a.sort(reverse=True)

print(sum(a[:n]))


Measured memory_bytes: 34676
#include<cstdio>
long long mod = -1;
long long f[3005], invf[3005];
long long d[3005][3005];
long long count[3005];
long long superPow[3005]; //sp[i] = 2^(2^(i))
long long pow2[9000005];

long long power(long long a,long long b){
    long long res  = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return power(u,mod-2); }

long long getComb(int n,int m){
    if(m>n || m<0) return 0;
    else return f[n]*invf[m]%mod*invf[n-m]%mod;
}

void preWork(int n){
    f[0] = invf[0] = 1;
    superPow[0] = 2;
    for(long long i = 1; i <= n; i++){
        f[i] = i*f[i-1]%mod;
        invf[i] = inv(f[i]);
        superPow[i] = superPow[i-1]*superPow[i-1]%mod;
    }
    pow2[0] = 1;
    for(int i = 1; i <= n*n; i++) pow2[i] = pow2[i-1]*2%mod;
}

void dp(int n){
    d[0][0] = 1;
    for(long long i = 1; i <= n; i++){
        for(long long j = 0; j <= n; j++){
            d[i][j] = d[i-1][j];
            d[i][j] += j*d[i-1][j]%mod; if(d[i][j]>=mod) d[i][j] -= mod;
            if(j!=0) d[i][j] += d[i-1][j-1]; 
            if(d[i][j]>=mod) d[i][j] -= mod;
        }
    }
    for(int i = 0; i <= n; i++){
        count[i] = 0;
        for(int j = 0; j <= i; j++){
            long long add = d[i][j]*pow2[(n-i)*j]%mod;
            count[i] += add; if(count[i]>=mod) count[i] -= mod;
        }
        count[i] = count[i]*superPow[n-i]%mod;
    }
}


int main(){
    int n;
    scanf("%d%lld",&n,&mod);
    preWork(n), dp(n);
    long long ans = 0, sign = mod-1;
    for(int i = 0; i <= n; i++){
        long long cur = getComb(n,i)*count[i]%mod;
        if(i%2) cur = cur*sign%mod;
        ans = (ans+cur)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

using int64 = long long;

vector<vector<int64>> AllPairsShortestPath(
    const vector<vector<int64>>& cost_matrix) {
  vector<vector<int64>> result = cost_matrix;
  int n = result.size();
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (result[i][k] == INT64_MAX) continue;
        if (result[k][j] == INT64_MAX) continue;
        result[i][j] = min(
            result[i][j],
            result[i][k] + result[k][j]);
      }
    }
  }
  return result;
}

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

  int n, m;
  cin >> n >> m;
  vector<vector<int64>> cost_matrix(n, vector<int64>(n, INT64_MAX));
  for (int i = 0; i < n; i++) {
    cost_matrix[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int s, t;
    int64 d;
    cin >> s >> t >> d;
    cost_matrix[s][t] = d;
  }
  auto result = AllPairsShortestPath(cost_matrix);
  for (int i = 0; i < n; i++) {
    if(result[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j > 0) cout << " ";
      if (result[i][j] == INT64_MAX) cout << "INF";
      else cout << result[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  int a,b;
  cin >> a >> b;
  vector<int> c = {a-b,a+b,a*b};
  sort(c);
  reverse(c);
  cout << c[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
int n, a, b;
int jc[N];
int cot[N];
inline int fp(int a, int n, int mod) {
	int res = 1;
	while (n) {
		if (n & 1) res = (res * a) % mod;
		a = (a * a) % mod;
		n >>= 1;
	}
	return res % mod;
}

inline int inv(int a) {
	return fp(a, mod - 2, mod);
}
signed main() {
	cin >> n >> a >> b;
	jc[0] = 1;
	for (int i = 1; i <= max(a, b); i++) {
		jc[i] = (jc[i - 1] * i) % mod;
	}
	// cout << "ok " << endl;
	cot[1] = n;
	for (int i = 2; i <= max(a, b); i++) {
		cot[i] = (cot[i - 1] * (n - i + 1)) % mod; 
	}
	cout << (fp(2, n, mod) + mod - ((cot[a] * inv(jc[a]) % mod)) - ((cot[b] * inv(jc[b])) % mod) % mod - 1 + mod) % mod  << endl;

	return 0;
}

Measured memory_bytes: 3328
N,M=map(int,input().split())
graph = []
for i in range(M):
  l,r = map(int,input().split())
  graph.append((l,r))
count = 0
for j in range(M):
  queue = [graph[j][0]]
  check = [graph[j][0]]
  while len(queue) > 0:
    for k in range(M): 
      if graph[k][0] == queue[0] and graph[k][1] not in check and k != j:
        queue.append(graph[k][1])
        check.append(graph[k][1])
      elif graph[k][1] == queue[0] and graph[k][0] not in check and k != j:
        queue.append(graph[k][0])
        check.append(graph[k][0])
    queue.pop(0)
  if len(check) == N:
    count += 1
print(M - count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,x[10],p=0,i;
	char s[10];
	scanf("%s", s);
	n=strlen(s);
	for(i=0; i<n; i++)
	{
		if(s[i]=='B'&&p>0)
		p--;
		if(s[i]=='0')
		{
			x[p]=0;
			p++;
		}
		if(s[i]=='1')
		{
			x[p]=1;
			p++;
		}
	}
	for(i=0; i<p; i++)
	printf("%d", x[i]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
n,m,x = map(int,input().split())

c = [0] * n
a = [[] for _ in range(n)]

for i in range(n):
    A = list(map(int,input().split()))
    c[i] = A[0]
    a[i] = A[1:]

t = [0] * m
for i in range(n):
    for j in range(m):
        t[j] += a[i][j]
if(min(t) < x):
    print(-1)
    exit()
mi = sum(c) + 1
for i in range(2**n):
    cost = 0
    sk = [0] * m
    for j in range(n):
        y = 2**j
        if(i & y != 0):
            cost += c[j]
            for k in range(m):
                sk[k] += a[j][k]
    if(min(sk) >= x):
        mi = min(mi,cost)
print(mi)

Measured memory_bytes: 9260
def main():
    s = input()[::-1]
    sum_digits = 0
    cnts = [0] * 2019
    cnts[0] = 1
    d = 1
    for c in s:
        sum_digits += int(c) * d
        sum_digits %= 2019
        # print(sum_digits)
        d *= 10
        d %= 2019
        cnts[sum_digits] += 1
    ans = 0
    for i, cnt in enumerate(cnts):
        # if cnt > 0: print(i, cnt)
        ans += cnt * (cnt - 1) // 2
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws IOException{
               BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));	
			String[] lo = reader.readLine().split(" ");
			int k = Integer.parseInt(lo[1]);
			int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			Arrays.sort(list);
			int sum = 0;
			for(int i = 0;i<k;i++) sum+=list[i];
			System.out.println(sum);
	}
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    vector<vector<int>> G(H, vector<int>(W, -1));
    // ddump(G);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i < B) {
                if (j < A) {
                    G[i][j] = 0;
                } else {
                    G[i][j] = 1;
                }
            } else {
                if (j < A) {
                    G[i][j] = 1;
                } else {
                    G[i][j] = 0;
                }
            }
        }
    }

    rep(i, H) {
        rep(j, W) { cout << G[i][j]; }
        cout << endl;
    }
    // ddump(G);
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int, int> P;


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

	int K, A, B;
	cin >> K >> A >> B;
	if(B-A<=2){
		cout << K+1 << endl;
	}
	else{
		if(K <= A){
			cout << K + 1 << endl;
		}
		else{
			K -= (A-1);
			int dx = B-A;
			int ans = A + dx * (K/2);
			if(K % 2 == 1) ans++;
			cout << ans << endl;
		}
	}
}

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

int main(){
	string s;
	cin >> s;
	int l = s.size();
	string a[11451];
    string b[11551];
	string c[11451];
	
	for (int i = 0; i < l / 2; i++){
		a[i] = s.substr(i * 2, 1);
		b[i] = s.substr(i * 2 + 1, 1);
		if (a[i] == "1"){ c[2 * i] = "";}
		if (a[i] == "2"){ c[2 * i] = "k";}
		if (a[i] == "3"){ c[2 * i] = "s";}
		if (a[i] == "4"){ c[2 * i] = "t";}
		if (a[i] == "5"){ c[2 * i] = "n";}
		if (a[i] == "6"){ c[2 * i] = "h";}
		if (a[i] == "7"){ c[2 * i] = "m";}
		if (a[i] == "8"){ c[2 * i] = "y";}
		if (a[i] == "9"){ c[2 * i] = "r";}
		if (a[i] == "0"){ c[2 * i] = "w";}
		if (b[i] == "T"){ c[2 * i + 1] = "a"; }
		if (b[i] == "L"){ c[2 * i + 1] = "i"; }
		if (b[i] == "U"&&a[i] != "0"){ c[2 * i + 1] = "u"; }
		if (b[i] == "R"){ c[2 * i + 1] = "e"; }
		if (b[i] == "D"){ c[2 * i + 1] = "o"; }
		if (b[i]=="U"&&a[i]=="0") {
			c[2 * i] = "n";
			c[2 * i + 1] = "n";
		};
		cout << c[2 * i] << c[2 * i + 1];
	}
	cout << endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 099 A / Link: http://abc099.contest.atcoder.jp/tasks/abc099_a  ----- */


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

	LL N; 
	cin >> N;
	string ans = (N <= 999 ? "ABC" : "ABD");
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x( N ), y( M );
    for( auto &a : x )
    {
        cin >> a;
    }
    for( auto &b : y )
    {
        cin >> b;
    }
    x.emplace_back( X );
    y.emplace_back( Y );
    int xmax = *max_element( ALL( x ) ), ymin = *min_element( ALL( y ) );
    REP( i, 100 )
    {
        if( i > xmax && i <= ymin )
        {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define MAX_V 100000

vector<int> G[MAX_V];

int main(){
  ll n;
  cin >> n;
  int a[n-1], b[n-1];
  REP(i,n-1){
    cin >> a[i] >> b[i];
    G[a[i]-1].push_back(b[i]-1);
    G[b[i]-1].push_back(a[i]-1);
  }
  int d1[n], dn[n];

  bool used[n];
  REP(i,n)used[i] = false;

  queue<pi> q;
  q.push(pi(0,0));
  while(!q.empty()){
    pi p = q.front(); q.pop();
    int v = p.first;
    int d = p.second;
    used[v] = true;
    d1[v] = d;
    REP(i,G[v].size()){
      if(!used[G[v][i]])q.push(pi(G[v][i], d+1));
    }
  }

  REP(i,n)used[i] = false;
  q.push(pi(n-1,0));
  while(!q.empty()){
    pi p = q.front(); q.pop();
    int v = p.first;
    int d = p.second;
    used[v] = true;
    dn[v] = d;
    REP(i,G[v].size()){
      if(!used[G[v][i]])q.push(pi(G[v][i], d+1));
    }
  }


  int num1=0, numn=0;
  REP(i,n){
    if(d1[i] > dn[i]){
      numn++;
    }else{
      num1++;
    }
  }

  if(num1 <= numn){
    cout << "Snuke" << endl;
  }else{
    cout << "Fennec" <<  endl;
  }




  return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, a, b;
	cin >> n;
	if(n==1)
	{
		cout<<"Hello World"<<endl;
		return 0;
	}
	cin >> a >> b;
	cout<<a+b<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    lint k=input;
    lint n=50;

    lint q=k/n,r=k%n;
    std::vector<lint>a(n,n-1+q);
    for(lint i=0;i<r;i++)a.at(i)+=n+1;
    for(lint&x:a)x-=r;

    std::cout<<n<<'\n';
    for(lint i=0;i<n;i++){
        std::cout<<(i?" ":"")<<a.at(i);
    }
    std::cout<<'\n';
}


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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3708
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> P;

int h, w;
char a[1000][1000];

int d[1000][1000];
queue<P> que;

void bfs(){
  while(!que.empty()){
    P p = que.front(); que.pop();
    REP(i, 4){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(nx>=0&&nx<h&&ny>=0&&ny<w&&d[nx][ny]==1e9){
        d[nx][ny] = d[p.first][p.second] + 1;
        que.push(P(nx, ny));
      }
    }
  }
}

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

  cin >> h >> w;

  REP(i, 1000) REP(j, 1000) d[i][j] = 1e9;
  REP(i, h) REP(j, w){
    cin >> a[i][j];
    if(a[i][j] == '#'){
      que.push(P(i, j));
      d[i][j] = 0;
    }
  }

  bfs();

  int ans = -1;
  REP(i, h) REP(j, w) ans = max(ans, d[i][j]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 25396
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int h,w,i,j;
    char a[110][110];
    cin>>h>>w;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0;i<=w+1;i++)
    {
        cout<<"#";
    }
    cout<<endl;
    for(i=0;i<h;i++)
    {
        for(j=-1;j<=w;j++)
        {
            if(j==-1 || j==w)
            cout<<"#";
            else
            cout<<a[i][j];
        }
        cout<<endl;
    }
    for(i=0;i<=w+1;i++)
    {
        cout<<"#";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long n,k,w[100009], mn=10000, mx=0, sm=0;

bool check(int p){
  if(k*p<sm || p<mx)return false;
  long long rest=0, cnt=1;
  for(int i=0;i<n;i++){
    if(rest + w[i] > p){
      cnt++;
      rest = w[i];
    }
    else rest += w[i];
  }
  if(cnt>k)return false;
  return true;
}

int main(){
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> w[i];
    mn = min(w[i], mn);
    mx = max(w[i], mx);
    sm += w[i];
  };
  long long left=mn, right=1e9;
  while(left<right){
    long long md = (left + right)/2;
    if(check(md))right=md;
    else left=md+1;
  }
  cout << left << endl;
}


Measured memory_bytes: 3864