akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class BTaxRate {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n;cin >> n;
        for(int i =1;i <= n;i++){
            double d = (double)i;
            d *= 1.08;
            int x = (int)d;
            if(x == n){
                cout << i << endl;return;
            }
        }
        cout << ":(" << endl;
    }
};

int main() {
	BTaxRate solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long h,n,a[1005],b[1005],dp[10005];
signed main(){
  	cin>>h>>n;
  	for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
    }
  	for(int i=1;i<=h;i++){
      dp[i]=( (i-1)/a[0]+1 )*b[0];
    }

  
  for(int i=1;i<n;i++){
    for(int j=1;j<=a[i];j++){
      dp[j]=min(dp[j],b[i]);
    }
    for(int j=a[i];j<=h;j++){
      dp[j]=min(dp[j],b[i]+dp[j-a[i]]);
    }
  }
                
  cout<<dp[h]<<endl;
  return(0);
}
  

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
 
#define N 20000
 
typedef struct Data{
  int area,pos;
} Data;
 
Data t[N];
int u[N]; 
int n,i;
char str[N];
int T,U;
int ans,A;
Data B,X;
 
void D_push(Data data){
  t[T++]=data;
}
 
Data D_pop(){
  return t[--T];
}
 
void push(int x){
  u[U++]=x;
}
 
int pop(){
  return u[--U];
}
 
void init(){  
  ans=0;
  T=0;
  U=0;  
}
 
Data makeData(int x,int y){  
  Data res; 
  res.area=x;
  res.pos=y;
  return res;
}
 
int main(){
  init(); 
  scanf("%s",str);
  n = strlen(str);
  for(i = 0;i < n;i++){
    if(str[i] == '/'){
      if(U == 0)continue;
      A = pop();
      X = makeData(i-A,A);
      ans = ans + i - A;
      while(T > 0){
    B = D_pop();
    if(B.pos < A){
      D_push(B);
      break;
    }
    X.area = X.area + B.area;
    if(B.pos < X.pos)X.pos = B.pos;
      }
      D_push(X);
    }else if(str[i] == '\\'){
      push(i);
    }    
  } 
  printf("%d\n%d", ans, T);
  for(i = 0;i < T;i++){
    printf(" %d",t[i].area);
  }
  printf("\n");
  return 0;
}
 

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24308
package main

import "fmt"

/*
展開図の展開の仕方を固定して、回転動作によってどのように展開図の数字が移るかを記録する。
展開図は次の通り。手前の２番を中心に据える展開の仕方。
         ___
    ____|_1_|_______
    |_4_|_2_|_3_|_5_|
        |_6_|

*/
type Dice struct {
	Nums []int
}

func (d *Dice) rotete(direction string) {
	switch direction {
	case "W":
		d.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[2], d.Nums[5], d.Nums[3], d.Nums[0]
	case "E":
		d.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[3], d.Nums[0], d.Nums[2], d.Nums[5]
	case "N":
		d.Nums[0], d.Nums[4], d.Nums[5], d.Nums[1] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]
	case "S":
		d.Nums[5], d.Nums[1], d.Nums[0], d.Nums[4] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]
	}
}

func (d *Dice) printStatus() {
	status :=
		`	　　　 _ _ _ _
     _ _ _|_%3d_|_ _ _ _ _ _
    |_%3d_|_%3d_|_%3d_|_%3d_|
 　       |_%3d_|
`
	fmt.Printf(status, d.Nums[0], d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[5])
	fmt.Println()
}

func main() {
	dice := Dice{
		make([]int, 6),
	}
	for i := 0; i < 6; i++ {
		var n int
		fmt.Scan(&n)
		dice.Nums[i] = n
	}
	var rotationOrder string
	fmt.Scan(&rotationOrder)
	for _, direction := range []rune(rotationOrder) {
		dice.rotete(string(direction))

		/*
		fmt.Printf("rotate direction: %s\n", string(direction))
		dice.printStatus()
		*/
	}
	fmt.Println(dice.Nums[0])
}



Measured memory_bytes: 1188
from collections import Counter
def prime_factorization(n):
    factor = []
    if n == 1:
        factor.append(1)
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            n //= i
            factor.append(i)
    if n != 1:
        factor.append(n)
    return factor

n = int(input())
mod = 10**9+7
ans = 1
c = Counter()

for i in range(2,n+1):
    c.update(Counter(prime_factorization(i)))

for key in c:
    ans *= c[key] + 1
    ans %= mod

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    vector<string> Z(4);
    Z[0] = "dream";
    Z[1] = "dreamer";
    Z[2] = "erase";
    Z[3] = "eraser";
    rep(i, 4) reverse(Z[i].begin(), Z[i].end());

    int p = 0; //今参照してる場所
    while (1)
    {
        int no = 1;
        rep(i, 4)
        {
            if (s.substr(p, Z[i].length()) == Z[i])
            {
                p += Z[i].length();
                no = 0;
                break;
            }
        }
        if (no)
        {
            cout << "NO" << endl;
            return 0;
        }
        if (p == s.length())
        {
            cout << "YES" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
from time import time
start=time()
from copy import deepcopy
from random import randint

d=int(input())
c=list(map(int,input().split())) #scoreを減らす
s=[] #scoreを増やす
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)
last=[0]*26 #それぞれのコンテストが最後に行われたのは何日目か
ans_lst=[]

for i in range(1,d): #364日、1日目ならi=1
    temp_best=-100000000
    for j in range(26): #それぞれの日において、26個のコンテストを順番にピックアップ
        temp=s[i-1][j]
        for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
            if j!=k:
                temp-=(c[k]*(i-last[k]))
        temp_last=deepcopy(last)
        temp_last[j]=i
        for k in range(26):
            temp+=s[i][k]
            for l in range(26):
                if k!=l:
                    temp-=(c[l]*(i+1-temp_last[l]))
        if temp>temp_best:
            temp_best=temp
            rem=j
    ans_lst.append(rem)
    last[rem]=i
    
temp_best=-100000000 #365日目は、次の日のことは考えなくてよい
for j in range(26): #26個のコンテストを順番にピックアップ
    temp=s[i-1][j]
    for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
        if j!=k:
            temp-=(c[k]*(i-last[k]))
    if temp>temp_best:
        temp_best=temp
        rem=j
ans_lst.append(rem) #AtCoder運営お疲れ様です

score=0
las=[0]*26
for i in range(d):
    for j in range(26):
        las[j]+=1
    score+=s[i][ans_lst[i]]
    las[ans_lst[i]]=0
    for j in range(26):
        score-=c[j]*las[j]

for q in range(1,26):
    for p in range(d-q):
        las=[0]*26
        temp_score=0
        temp_ans_lst=deepcopy(ans_lst)
        temp_ans_lst[p],temp_ans_lst[p+q]=temp_ans_lst[p+q],temp_ans_lst[p]
        for i in range(d):
            for j in range(26):
                las[j]+=1
            temp_score+=s[i][temp_ans_lst[i]]
            las[temp_ans_lst[i]]=0
            for j in range(26):
                temp_score-=c[j]*las[j]
        if temp_score>score:
            score=temp_score
            ans_lst=temp_ans_lst

while time()-start<1.9:
    las=[0]*26
    temp_score=0
    temp_ans_lst=deepcopy(ans_lst)
    a=randint(0,d-2)
    b=randint(0,d-2)
    temp_ans_lst[a],temp_ans_lst[a+1]=temp_ans_lst[a+1],temp_ans_lst[a]
    temp_ans_lst[b],temp_ans_lst[b+1]=temp_ans_lst[b+1],temp_ans_lst[b]
    for i in range(d):
        for j in range(26):
            las[j]+=1
        temp_score+=s[i][temp_ans_lst[i]]
        las[temp_ans_lst[i]]=0
        for j in range(26):
            temp_score-=c[j]*las[j]
    if temp_score>score:
        score=temp_score
        ans_lst=temp_ans_lst

for i in ans_lst:
    print(i+1)

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;
    vpii len(n) ;
    REP(i,n){
        int x, l ;
        cin >> x >> l ;
        len[i] = MP(x-l,x+l) ;
    }
    sort(ALL(len)) ;
    int ans = 0 ;
    int right = -2*INF ;
    REP(i,n){
        if(right<=len[i].FI){
            ans++ ;
            right = len[i].SE ;
        }
        if(len[i].SE <= right){
            right = len[i].SE ;
        }
    }
    cout << ans <<endl;





    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

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

/*-------------------------------------------*/

int n;
int a[30];

int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    int ans=0;
    FOR(i,1,n-1){
        if(a[i-1]<a[i]^a[i]>a[i+1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = list(input())

ok = False
for i in range(3):
    if N[i] == '7':
        ok = True

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9112
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<set>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){


    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }

    ll sum = 0;
    ll ans1 = 0;

    /*正負の順*/
    for(int i = 0,s = 1; i < n; i++,s*= -1){
        sum += a[i];
        if(sum * s <= 0){
            ans1+= abs(sum-s);
            sum = s;
        }
    }
    sum = 0;
    /*負正の順*/
    ll ans2 = 0;
    for(int i = 0,s = -1; i < n; i++,s*= -1){
        sum += a[i];
        if(sum * s <= 0){
            ans2+= abs(sum-s);
            sum = s;
        }
    }
    cout << min(ans1,ans2) << endl;




   
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,m,k;
    cin>>n>>m;
    k=1<<m;
    cout<<k*(m*1900+(n-m)*100)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long int n,a,b,c=0,m =1e18;
    cin >> n >> a;
    while(n > 0)
    {
        n -= a;
        c++;
    }
    cout << c << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int N,M,X,Y; cin>>N>>M>>X>>Y;
    vector<int> x(N);
    vector<int> y(M);
    rep(i,N) cin >> x[i];
    rep(i,M) cin >> y[i];
    
    int max_x = *std::max_element(x.begin(), x.end());
    int min_y = *std::min_element(y.begin(), y.end());

    bool flag = 0;
    for(int i=X+1; i<=Y; ++i){
        if(max_x<i && i<=min_y) flag = 1;
    }
    if(flag) cout << "No War" << endl;
    else cout << "War" << endl;
    
}



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

int main(){
  int N;
  cin >> N;
  int f = 0;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i*j == N)
        f = 1;
    }
  }
  if(f == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int a, b, c, k;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> a >> b >> c >> k;
	while(b <= a) b *= 2, k--;
	while(c <= b) c *= 2, k--;
	cout << (k >= 0 ? "Yes" : "No");
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7




int main(){


    int n;
    cin >> n;
    vector<pair<ll,ll> > arr(n);
    REP(i,n){
        cin >> arr[i].first >> arr[i].second;
    }

    ll tmp = 0;
    for(int i = n-1;i >= 0;i--){

        arr[i].first += tmp;/*今までに加えた回数分足しておく*/

        if(arr[i].first % arr[i].second == 0){
            continue;
        }


        if(arr[i].second != 1){
            tmp += (arr[i].second - (arr[i].first % arr[i].second));   
        }
    }
    cout << tmp << endl;


    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int T = N*A;
		long[][] dp = new long[N+1][];
		for(int i=0;i<=N;i++)dp[i] = new long[T+1];
		dp[0][0] = 1;
		foreach(var x in X){
			for(int i=N-1;i>=0;i--){
				for(int j=T;j>=0;j--){
					if(dp[i][j] == 0)continue;
					if(j+x <= T){
						dp[i+1][j+x] += dp[i][j];
					}
				}
			}
		}
		
		long sum = 0;
		for(int i=1;i<=N;i++){
			sum += dp[i][i*A];
		}
		Console.WriteLine(sum);
		
	}
	int N,A;
	int[] X;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1];
		X = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 3800
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int main(){
	int n, t;
	while(cin >> t, t){
		cin >> n;
		rep(i, n){
			int s, f;
			cin >> s >> f;
			t -= f - s;
		}
		if(t <= 0) cout << "OK" << endl;
		else cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   int n;
   scanf("%d",&n);
   map<int,int>mp;
   int x,flag=1;
   for(int i=0;i<n;i++){
    scanf("%d",&x);
    mp[x]++;
    if(mp[x]>1)flag=0;
   }
   if(flag){
    printf("YES\n");
   }
   else{
    printf("NO\n");
   }
}


Measured memory_bytes: 9600
#![allow(non_snake_case)]
use proconio::marker::*;
use proconio::*;
use rand::prelude::*;
use std::i64;
use std::thread::sleep;
use std::time::*;

#[derive(Debug)]
struct State {
    D: usize,
    c: Vec<i64>,
    s: Vec<Vec<i64>>,
    t: Vec<usize>,
    lasts: Vec<usize>,
    d: usize,
    score: i64,
}

impl State {
    fn new(D: usize, c: Vec<i64>, s: Vec<Vec<i64>>) -> State {
        State {
            D,
            c,
            s,
            t: vec![0; D],
            lasts: vec![0; 26],
            d: 0,
            score: 0,
        }
    }

    fn set_rand(&mut self) {
        let mut rng = thread_rng();
        for i in 0..self.D {
            self.t[i] = rng.gen_range(0, 26);
        }
    }

    fn set_greed(&mut self) {
        for i in 0..self.D {
            let mut max_score = i64::min_value();
            let mut q = 0;
            let last = self.lasts[self.t[i]];
            for j in 0..26 {
                self.t[i] = j;
                let score = self.calc(i);
                self.lasts[j] = last;
                if score > max_score {
                    max_score = score;
                    q = j;
                }
            }

            self.lasts[q] = i + 1;
            self.t[i] = q;
        }
    }

    fn calc(&mut self, d: usize) -> i64 {
        let mut score = self.s[d][self.t[d]];

        self.lasts[self.t[d]] = d + 1;
        for i in 0..26 {
            score -= (d + 1 - self.lasts[i]) as i64 * self.c[i];
        }

        score
    }

    fn result(&self) -> i64 {
        let mut score = 0;
        let mut lasts = vec![0; 26];
        for d in 0..self.D {
            score += self.s[d][self.t[d]];
            let l = lasts[self.t[d]];
            lasts[self.t[d]] = d + 1;
            score -= self.c[self.t[d]] * ((d - l) * (d - l + 1) / 2) as i64;
        }

        for i in 0..26 {
            let l = lasts[i];
            score -= self.c[i] * ((self.D - l) * (self.D - l + 1) / 2) as i64;
        }

        score
    }
}

fn main() {
    input! {
        D: usize,
        c: [i64; 26],
        s: [[i64; 26]; D],
    };
    let mut obj = State::new(D, c, s);
    let mut rng = thread_rng();
    let time = SystemTime::now();
    let mut pre_score = -1000000;
    obj.set_greed();

    loop {
        let d = rng.gen_range(0, D);
        let q = rng.gen_range(0, 26);
        let tq = obj.t[d];
        obj.t[d] = q;
        let score = obj.result();
        if score > pre_score {
            pre_score = score;
        } else {
            obj.t[d] = tq;
        }

        if time.elapsed().unwrap().as_millis() > 1900 {
            break;
        }
    }

    for &t in &obj.t {
        println!("{}", t + 1);
    }
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int n;
  string s,t;
  string st;
  cin>>n>>s>>t;
  REP(i,n){
    st+=s[i];
    st+=t[i];
  }
  cout<<st<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct numAndAmount {
    long long num;
    long long amount;
    numAndAmount(long long num){
        this->num = num;
        amount = 1;
    }
};

bool operator<(const numAndAmount& l, const numAndAmount& r){
    return l.amount < r.amount;
}
bool operator>(const numAndAmount& l, const numAndAmount& r){
    return l.amount > r.amount;
}

vector<numAndAmount> makeVector(vector<long long> v){
    vector<numAndAmount> vec;
    vec.push_back(numAndAmount(v[0]));
    for(long long i = 1; i< v.size(); i++){
        if(v[i] == v[i-1]){
            vec[vec.size()-1].amount++;
        } else {
            vec.push_back(v[i]);
        }
    }
    sort(vec.begin(), vec.end(), greater<numAndAmount>());
    return vec;
}

void printVector(vector<numAndAmount> v) {
    cout << "print vector" << endl;
    for(long long i = 0; i < 2;i++){
    // for(long long i = 0; i< v.size();i++){
        cout << v[i].num << " " << v[i].amount << endl;
    }
}

int main(){
    long long n,tmp; cin >> n;
    vector<long long> v1;
    vector<long long> v2;

    for(long long i=0;i<n;i++){
        cin >> tmp;
        if(i%2==0)
            v1.push_back(tmp);
        else
            v2.push_back(tmp);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    vector<numAndAmount> vec1 = makeVector(v1);
    vector<numAndAmount> vec2 = makeVector(v2);

    if(vec1[0].num != vec2[0].num){
        cout << v1.size()*2 - vec1[0].amount - vec2[0].amount << endl;
    } else {
        if (vec1.size() > 1 && vec2.size() > 1){
            long long case1 = v1.size()*2 - vec1[1].amount - vec2[0].amount;
            long long case2 = v1.size()*2 - vec1[0].amount - vec2[1].amount;
            if(case1 > case2)
                cout << case2 <<endl;
            else
                cout << case1 <<endl;
            return 0;
        }
        if (vec1.size() > 1 && vec2.size() == 1) {
            cout << v1.size() - vec1[1].amount << endl;
            return 0;
        }
        if (vec1.size() == 1 && vec2.size() > 1) {
            cout << v1.size() - vec2[1].amount << endl;
            return 0;
        }
        if(vec1.size() == 1 && vec2.size() == 1) {
            cout << v1.size()<< endl;
            return 0;
        }
    }

}



Measured memory_bytes: 3692
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int H, W, K;
    cin >> H >> W >> K;

    vector<string> field(H);
    for (int i = 0; i < H; i++) {
        cin >> field[i];
    }

    int ans = 0;
    for (int h = (1 << H) - 1; h >= 0; h--) {
        for (int w = (1 << W) - 1; w >= 0; w--) {
            vector<string> c(H);

            for (int i = 0; i < H; i++) {
                string ss;
                int hh = h >> i, ww = w;
                for (int j = 0; j < W; j++) {
                    if ((hh & 1) || (ww & 1)) {
                        ss += '.';
                    } else {
                        ss += field[i][j];
                    }

                    ww = ww >> 1;
                }

                c[i] = ss;
            }

            // for (int i = 0; i < H; i++) {
            //     dump(c[i]);
            // }
            // cout << endl;

            int tem = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (c[i][j] == '#') {
                        tem++;
                    }
                }
            }

            if (tem == K) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int d;
int c[26];
int s[365][26];

int t[365];

int score(){
	int last[26] = {0};
	int evl = 0;

	for( int i = 1; i <= d; i++ ){
		last[t[i-1]-1] = i;
		evl += s[i-1][t[i-1]-1];
		for( int j = 0; j < 26; j++ ){
			evl -= c[j]*(i - last[j]);
		}
		//cout << i << " score:" << evl << endl;
	}
//	cout << "score:" << evl << endl;

	return evl;
}

int main(){
	cin >> d;
	for( int i = 0; i < 26; i++ ){
		cin >> c[i];
	}
	for( int i = 0; i < d; i++ ){
		for( int j = 0; j < 26; j++ ){
			cin >> s[i][j];
		}
	}

	int gre;

	for( int i = 0; i < d; i++ ){
		gre = 0;
		for( int j = 0; j < 26; j++ ){
			gre = max( gre, s[i][j] );
			if( gre == s[i][j] ){
				t[i] = j + 1;
			}
		}
	}

	int bscore = score();
	int nsc;
	int bt[2];

	for( int i = 0; i < 365; i++ ){
		bt[0] = rand() % 26;
		bt[1] = t[bt[0]];
		t[bt[0]] = rand() % 26;
		nsc = score();
		bscore = max( bscore, nsc );
		if( bscore == nsc ){
			t[bt[0]] = bt[1];
		}
//		cout << i << "score:" << bscore << endl;
	}

	for( int i = 0; i < d; i++ ){
		cout << t[i] << endl;
	}

//	cout << "score:" << bscore << endl;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n + 1, 0);
    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            v[a]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (v[i] == 0)
        {
            ans++;
        }
    }

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

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 41136
//Tsundoku
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
#include <stack>
using namespace std;
const int INF = 1 << 29;

template<class T>
bool isOK(vector<T> a, int index, T key) 
{
    if (a[index] > key) {
        return true;
    }
    else {
        return false;
    }
}

template<class T>
T binarysearch(vector<T> a, T key) 
{
    int left = -1;
    int right = (int) a.size();
    while (abs(right - left) > 1) {
        int mid = left + (right - left) / 2;
        /*
        cout << "left " << left << endl;
        cout << "right " << right << endl;
        cout << "mid " << mid << endl;
        */
        if (isOK(a, mid,key)) {
            right = mid;
        }
        else {
            left = mid;
        }
    }
    //cout << "return " << right << endl;
    return right;
}


int main ()
{
    unsigned long long N,M,K;
    cin >> N >> M >> K;
    vector<long long> A(N);
    vector<long long> accA(N+1,0);
    //stack<int>A;
    
    // 累積和をつくる
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        accA[i+1] = accA[i] + A[i];
    }
    vector<long long> B(M);
    vector<long long> accB(M+1,0);
    //stack<int> B;
    for (int j = 0; j < M; j++) {
        cin >> B[j];
        accB[j+1] = accB[j] + B[j];
    }
    long long ans = 0;
    for (int i = 0; i <= N; i++) {
        //cout << "i=" << i << endl;
        long long tmp = K - accA[i];
        if (tmp < 0) {
            break;
        }
        //cout << "tmp=" << tmp << endl;
        long long result = 0;
        long long l,r;
        l = 0;
        r = accB.size();

        /*
        auto it = upper_bound(accB.begin(), accB.end(), tmp);
        long long n = it - accB.begin();
        ans = max(ans, i + n-1);
        */
        

       //long long res = binarysearch(accB, tmp) + i -1;
        //cout << res << endl;
        
        while (r-l>1) {
            long long mid = l + (r - l) / 2;
            //cout << "mid=" << mid << endl;
            if (accB[mid] > tmp) {
                r= mid;
                //cout << "l=" << l << endl;
                //cout << "r=" << r << endl;
            }
            else {
                l = mid ;
                //cout << "l=" << l << endl;
                //cout << "r=" << r << endl;
            }        
        }
        result = i + l;
        
        //cout << "result=" << result << endl;
        ans = max(ans,result);
    }


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


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    LL n,ans=0;
    cin >> n;
    ans+=(n/500)*1000;
    n%=500;
    ans+=n/5*5;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
S=input()

N=len(S)
dp=[0]*(N+1)
dp[0]=1
L=["dream", "dreamer", "erase", "eraser"]
for i in range(1,N+1):
    for l in L:
        n=len(l)
        if 0<=i-n<N:
            if S[i-n:i]==l and dp[i-n]:
                dp[i]=1

if dp[-1]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 74576
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), n = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			System.out.println(k - IntStream.range(0, n).map(i -> (i == 0) ? a[0] + k - a[n - 1] : a[i] - a[i - 1])
					.max().getAsInt());
		}
	}
}


Measured memory_bytes: 79704
#include<iostream>
#include <atcoder/dsu>

//QCFium法
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//浮動小数点処理高速化
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace atcoder;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;
constexpr f80 PI = 3.14159265358979323846;

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(int)(start);i<(int)(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(int)(start);i>(int)(end);--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >

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

template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

//sort(rng(P),[](const vi &a, const vi &b){return a[1]<b[1];});

void Main()
{
  int N, Q;
  cin >> N >> Q;
  dsu d(N);

  int t, u, v;
  rep(i, Q) {
    cin >> t >> u >> v;
    if(t==0) {
      d.merge(u, v);
    } else {
      if(d.same(u, v)) {
        cout << "1\n";
      } else {
        cout << "0\n";
      }
    }
  }
}

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

Measured memory_bytes: 3932
#include <iostream>
#include <algorithm>

int n, c, k, t[100005], tf, ans, cnt;

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

	std::cin >> n >> c >> k;
	for (int i = 0; i < n; ++i) std::cin >> t[i];

	std::sort(t, t + n);

	for (int i = 0; i < n; ++i) {
		//std::cout << "pre :" << ans << " " << cnt << std::endl;
		if (tf == 0) {
			tf = t[i];
			cnt++;
		}
		else {
			if (t[i] <= tf + k && cnt < c) {
				cnt++;
				if (i == n - 1) {
					ans++;
				}
			}
			else if (t[i] > tf + k || cnt >= c) {
				ans++;
				tf = t[i];
				cnt = 1;
				if (i == n - 1) ans++;
			}
		}
		//std::cout << ans << " " << cnt << std::endl;
	}



	std::cout << ans << std::endl;

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
using namespace std;
 
int main(){
    
    int N,tmp,ans=0;
    cin >> N;

    if(N<105){
        cout << 0 << endl;
        return 0; 
    }

    for(int i=105;i<=N;i+=2){
        tmp=0;
        for(int j=1;j<=i;j++){
            if((i%j)==0){
                tmp+=1;
            }
        }
        if(tmp==8){
            ans+=1;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1LL<<60;

int main(){
  int n; cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ull ans = 1;
  if(a[0] == 0){
    cout << 0 << endl;
    return 0;
  }else{
    ull fl = 1000000000000000000;
    for(int i = 0; i < n; i++){
      ull temp = ans;
      ans *= a[i];
      if(ans / a[i] != temp){
        cout << -1 << endl;
        return 0;
      }
      if(fl < ans){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4044
#include<time.h>
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdarg.h>
#include<tgmath.h>
#include<assert.h>
#include<iso646.h>
#include<stdbool.h>
inline int max(int a, int b){return a>b?a:b;}
inline int min(int a, int b){return b>a?a:b;}

#define MAX_V 222
typedef int32_t Cap;
const Cap Cap_MAX = INT32_MAX;
typedef struct mf_edge{
	int to;
	Cap cap;
	struct mf_edge *next, *rev;
} mf_edge;
typedef mf_edge* edge;
edge nil, G[MAX_V], iter[MAX_V];
int level[MAX_V];
void add_edge(int _from, int _to, Cap cap){
	edge go = (edge)malloc(sizeof(mf_edge));
	edge back = (edge)malloc(sizeof(mf_edge));
	*go = (mf_edge){_to, cap, G[_from], back};
	*back = (mf_edge){_from, 0, G[_to], go};
	G[_from] = go;
	G[_to] = back;
	return;
}
void maxflow_bfs(int s){
	for(int i=0; i<MAX_V; i++)level[i] = -1;
	int que[MAX_V], l = 0, r = 0;
	level[s] = 0;
	que[r++] = s;
	while(l != r){
		int v = que[l++]; l %= MAX_V;
		for(edge e = G[v]; e != nil; e = (*e).next){
			if((*e).cap > 0 && level[(*e).to] < 0){
				level[(*e).to] = level[v] + 1;
				que[r++] = (*e).to; r %= MAX_V;
			}
		}
	}
}
Cap maxflow_dfs(int v, int t, Cap f){
	if(v == t) return f;
	for(; iter[v] != nil; iter[v] = (*iter[v]).next){
		edge e = iter[v];
		if((*e).cap > 0 && level[v] < level[(*e).to]){
			Cap d = maxflow_dfs((*e).to, t, f>(*e).cap?(*e).cap:f);
			if(d > 0){
				(*e).cap -= d;
				(*(*e).rev).cap += d;
				return d;
			}
		}
	}
	return 0;
}
Cap maxflow(int s, int t){
	Cap flow = 0;
	for(;;){
		maxflow_bfs(s);
		if(level[t] < 0) return flow;
		for(int i=0; i<MAX_V; i++)iter[i] = G[i];
		Cap f;
		while((f = maxflow_dfs(s, t, Cap_MAX)) > 0){
			flow += f;
		}
	}
}

int main(){
	int N;
	scanf("%d", &N);
	int a[111], b[111], c[111], d[111];
	for(int i=0; i<N; i++)scanf("%d%d", a+i, b+i);
	for(int i=0; i<N; i++)scanf("%d%d", c+i, d+i);
	for(int i=0; i<N; i++){
		add_edge(200, i, 1);
		add_edge(i+100, 201, 1);
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(a[i] < c[j] && b[i] < d[j]){
				add_edge(i, j+100, 1);
			}
		}
	}
	printf("%d\n", maxflow(200, 201));
	return 0;
}

Measured memory_bytes: 1880
#include<iostream>
using namespace std;
int main(){
  int a,b,n,s;
  while(cin>>a>>b>>n){
    s = 0;
    for(int i=0;i<n;i++){
      a = (a % b) * 10;
      s += a / b;
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

bool a[2000000];

int main(){
	
	int N = 1500000;
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	for(int i = 2; i < N; i++){
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}
	
	int n, ans;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		ans = 0;
		for(int i = 0; i < n; i++){
			if(i > n - i){
				break;
			}
			if(a[i] && a[n - i]){
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 2608
#include <stdio.h>

int main()
{
  int H,i;

  scanf("%d",&H);

  int A[H+1];

  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(i>1) printf("parent key = %d, ",A[i/2]);
    if(i*2<=H) printf("left key = %d, ",A[i*2]);
    if(i*2+1<=H) printf("right key = %d, ",A[i*2+1]);
    
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2052
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <random>
#include <set>
#include <sstream>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    printf("%d", n * (n - 1) / 2 + m * (m - 1) / 2);
    return 0;
}

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

int main(void) {
	// in
	int n, k;
	cin >> n >> k;
	vector<long long> v(n);
	for(int i = 0; i < n; ++i) cin >> v[i];

	// dfs ?
	//long long val_max = rec(0, n, k, v);
	
	long long value_max = 0;
	for(int i = 0; i <= k; ++i) {	// toru kaisuu
		long long value = 0;
		if(i > v.size()) break;
		for(int j = 0; j <= i; ++j) {	// hidari kara toru kaisuu
			vector<long long> jewels;
			for(int jj = 0; jj < j; ++jj) {	// hidari kara toru
				jewels.push_back(v[jj]);
			}
			for(int jj = 0; jj < i - j; ++jj) {	// migi kara toru
				jewels.push_back(v[n - jj - 1]);
			}
			// sort
			sort(jewels.begin(), jewels.end(), [](long long &lhs, long long &rhs) { return lhs > rhs; });
			// debug
			//for(int a = 0; a < jewels.size(); ++a) cout << jewels[a] << " ";
			//cout << endl;
			// suteru
			for(int ii = 0; ii <= k - i; ++ii) {	// suteru kaisuu
				if(ii > jewels.size()) break;
				long long buf_value = std::accumulate(jewels.begin(), jewels.end() - ii, 0LL);
				//cout << buf_value << endl;
				value = (value < buf_value ? buf_value : value);
			}
		}
		value_max = (value_max < value ? value : value_max);
	}

	cout << value_max << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <array>
#include <iostream>
#include <string>


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

  std::array<std::string, 3> as;
  for (auto&& e : as) {
    std::cin >> e;
  }

  for (decltype(as)::size_type i = 1; i < as.size(); i++) {
    if (as[i].front() != as[i - 1].back()) {
      std::cout << "NO" << std::endl;
      return EXIT_SUCCESS;
    }
  }
  std::cout << "YES" << std::endl;

  return EXIT_SUCCESS;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int x[n+1], backup[n+1];
  for(int i=1; i<=n; i++){
    cin >> x[i];
    backup[i] = x[i];
  }
  int l = (n+1) / 2;
  sort(x+1, x+1+n, greater<int>());
  for(int i=1; i<=n; i++){
    if(x[l] > backup[i]) cout << x[l] << endl;
    else cout << x[l+1] << endl;
  }
  return 0;
}


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

int main() {
  int x,a,b,c,d;
  cin >> x;
  a=x/1000;
  b=(x-a*1000)/100;
  c=(x-a*1000-b*100)/10;
  d=(x-a*1000-b*100-c*10);
  
  if (b == c && (a == b || c == d )) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using std::max;
using std::min;
using std::cerr;
using std::endl;
using std::sort;

inline void read(int &x)
{
    int s = 0, w = 1;
    char c = getchar();
    while(!isdigit(c)){if(c == '-')w = -1; c = getchar();}
    while(isdigit(c)){s = (s << 3) + (s << 1) + c - '0', c = getchar();}
    x = s * w;
}

typedef long long ll;
#define rg register int

const int N = 10010;

int f[N][N], w[N], n;

struct edge
{
    int to, nxxt;
}e[N << 1];
int head[N], cnt;

inline void add(int x, int y)
{
    e[++cnt].to = y;
    e[cnt].nxxt = head[x];
    head[x] = cnt;
}

int sz[N], val[N], ans;

inline void dfs(int u, int fa,int pre)
{
    sz[u] = 1;
    for (rg i = head[u]; i; i = e[i].nxxt)
    {
        int to = e[i].to;
        if(to == fa)continue ;
        dfs(to, u, pre + sz[u]);
        val[to] = w[pre + sz[u] + 1];
        sz[u] += sz[to];
        ans += val[to];
    }
}

inline bool cmp(int a, int b){return a > b;}

int main()
{
    read(n);
    for (rg i = 1, a, b; i < n; i++)
        read(a), read(b), add(a, b), add(b, a);
    for (rg i = 1; i <= n; i++)
        read(w[i]);
    sort(w + 1, w + n + 1, cmp);
    dfs(1, 0, 0);
    val[1] = w[1];
    printf("%d\n", ans);
    for (rg i = 1; i <= n; i++)
        printf("%d ", val[i]);
    
}

Measured memory_bytes: 896