akhauriyash/Code-Regression huggingface dataset:
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [x, k, d] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    x' = abs x :: Int
    (q, r) = x' `divMod` d
    m = q - k :: Int
    n | 0 <= m    = x' - k * d
      | even m    = r
      | otherwise = d - r
  print n

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <cstring>
using namespace std;

const char *t1=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *v1[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
const char *t2="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

int main(){
  string s,t,z;
  int i,j,x;
  map<string,char>m;
  for(i=0;i<32;i++)m[string(v1[i])]=t1[i];
  for(;z=t="",getline(cin,s);cout<<t<<endl){
    for(i=0;i<s.size();i++)
      if((j=strchr(t2,s[i])-t2)+t2)z+=bitset<5>(j).to_string();
    for(x=i=0;;i+=j){
      for(j=1;i+j<=z.size();j++){
        //if(z[i+j-1]=='1')x++;
        if(m[z.substr(i,j)]){x=0;t+=m[z.substr(i,j)];break;}
      }
      if(i+j>z.size())break;
    }
    /*if(x){
      while(!m[z.substr(i)])z+='0';
      t+=m[z.substr(i)];
    }*/
  }
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    map <string, int> mp;
    mp["WA"] = 0;
    mp["AC"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    while (n--) {
        string str;
        cin >> str;
        mp[str]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

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

	cout << "ABC" + N << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

vector<pair<int, long long int>> tree[100001];
bool color[100001];
int check[100001];

void solve(int v, int cost, bool col)
{

    //訪問完了
    check[v] = 1;

    //彩色
    if (cost % 2 == 0)
    {
        color[v] = col;
    }
    else
    {
        color[v] = !col;
    }

    for (auto e : tree[v])
    {
        int next = e.first;
        if (check[next] == 0)
        {
            solve(next, e.second, color[v]);
        }
    }

    return;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;

        tree[u].push_back(make_pair(v, w));
        tree[v].push_back(make_pair(u, w));
    }

    solve(1, 0, true);

    for (int i = 1; i <= n; i++)
    {
        if (color[i])
        {
            cout << "0" << endl;
        }
        else
        {
            cout << "1" << endl;
        }
    }
}

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

int main() {
    ll N;
    cin >> N;
    vector<P> endTime(N);
    for(int i=0;i<N;i++){
        ll A,B;
        cin >> A >>B;
        endTime[i].first = B;
        endTime[i].second = A;
    }
    sort(endTime.begin(),endTime.end());
    ll now =0;
    for(int i=0;i<N;i++){
        // cerr <<"now=" <<now << "i=" <<i  <<"endTime="<< endTime[i].first <<"need=" <<endTime[i].second<<endl;
        if(endTime[i].first < now+ endTime[i].second){
            
            cout <<"No" << endl;
            return 0;
        }
        now += endTime[i].second;
    }

    cout <<"Yes" << endl;
    

    return 0;
}

Measured memory_bytes: 6424
temp=list(map(int, input().split()))
K=temp[0]
X=temp[1]

sita=int(X-K+1)
ue=int(X+K-1)

sita=max([sita, -1000000])
ue=min([ue, 1000000])
ans=[i for i in range(sita, ue+1)]

for i in range(len(ans)):
  print(ans[i], end=' ')

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


int main(){
    ll N;cin>>N;
    double z;
    rep(i,1,3501){
        rep(j,i,3501){
            z=(double)(N*i*j)/(4*i*j-N*i-N*j);
            if(floor(z)==z&&z!=0&&z>0&&z<999999999){
                cout<<i<<" "<<j<<" "<<(ll)z<<endl;
                return 0;
            }
        }
    }
}







Measured memory_bytes: 256
import math

N, M = [int(_) for _ in input().split()]

A = [int(_) for _ in input().split()]

for i in range(N):
    a = A[i]
    if a % 2 > 0:
        print(0)
        exit()
    A[i] = a // 2


def f(v):
    res = 0
    while v % 2 == 0:
        res += 1
        v //= 2
    return res


c = f(A[0])
for i in range(N):
    if c != f(A[i]):
        print(0)
        exit()
    if c > 0:
        A[i] <<= c

if c > 0:
    M <<= c


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


l = 1
for a in A:
    l = lcm(l, a)
if l > M:
    print(0)
    exit()
print((M // l + 1) // 2)


Measured memory_bytes: 85612
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Pair {
    int f;
    int s;

    Pair(int f_, int s_) {
      f = f_;
      s = s_;
    }
  }

  void run() {
    for ( ;; ) {
      int n = ni();

      if ( n == 0 ) {
        break;
      }

      int[] ks = new int[n];
      for(int i = 0; i < n; ++i) {
        ks[i] = ni();
      }
      char[] str = sc.next().toCharArray();
      
      HashMap<Character, Integer> map = new HashMap<Character, Integer>();
      HashMap<Integer, Character> rmap = new HashMap<Integer, Character>();
      for(int i = 0; i < 26; ++i) {
        map.put( (char) ( 'A' + i ), i + 26 );
        rmap.put( i + 26, (char) ( 'A' + i ) );
      }
      for(int i = 0; i < 26; ++i) {
        map.put( (char) ( 'a' + i ), i );
        rmap.put( i, (char) ( 'a' + i ) );
      }
      //debug(map.entrySet());
      
      for(int i = 0; i < str.length; ++i) {
        int idx = (map.get( str[i] ) + 26*2 - ks[i%n])%52;
        str[i] = (char)rmap.get( idx );
      }
      
      System.out.println(new String(str));
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 24772
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=1005;
int b[N*N];
int main(){
 //    freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,j,n,m,K;
    scanf("%d%d%d",&n,&m,&K);
    for (i=0;i<=n;i++)
     for (j=0;j<=m;j++)
      b[i*m+j*n-i*j*2]=1;
    puts(b[K]?"Yes":"No");
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    int n;
    cin>>n;
    vector<long> a(n+1);
    long b;
    long ans=0;
    rep(i,n+1){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b;
        long a1=a.at(i);
        long aa=a.at(i+1);
        if(a1+aa<=b){
            ans=ans+a1+aa;
            a[i]=0;
            a[i+1]=0;
        }else if(a1<=b){
            ans+=b;
            a[i]=0;
            a[i+1]=aa-(b-a1);
        }else{
            ans+=b;
            a[i]=a1-b;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define fi first
#define se second
#define int long long
//template

//main
signed main(){
  int A,B,K;cin>>A>>B>>K;
  int k=0,ans=0;
  for(int i=100;i>0;i--){
    if(A%i==0&&B%i==0){
      k++;
      if(k==K)ans=i;
    }
  }
  Cout(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(a<b){

        if(b<c){
            printf("Yes\n");
        }

        else{
            printf("No\n");
        }
    }

    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[100010];
int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a > 100000) ans++;
		else cnt[a]++;
	}
	for (int i = 1; i <= 100000; i++) {
		if (cnt[i] >= i) ans += cnt[i] - i;
		else ans += cnt[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define all(A)  A.begin(),A.end()  
#define has(m,x)   (m.find(x)!=m.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 1e5+5;
const int MOD = 1e9+7 ;




int main(){

    FIO
    int n; cin>>n;  
    vector<int> arr(n);
    f(i,0,n-1)    cin>>arr[i];
    sort(all(arr)); int ans = 0;
    f(i,0,n-1) f(j,i+1,n-1) f(k,j+1,n-1) {
        if(arr[i]!=arr[j] and arr[j]!=arr[k]
         and arr[i]!=arr[k] and arr[i]+arr[j]>arr[k])    ans++;
    }
    cout<<ans<<endl;
    

    return 0;
}
    


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,col[100005],cnt[5],ok;long long ans;vector<pair<int,int> >e[100005];
void dfs(int x)
{
	cnt[col[x]]++;
	for(int i=0;i<e[x].size();i++)
	{
		if(e[x][i].second==1) cnt[3]++;
		if(col[e[x][i].first]==-1) col[e[x][i].first]=(col[x]+e[x][i].second)%3,dfs(e[x][i].first);
		else if((col[x]+e[x][i].second)%3!=col[e[x][i].first]) ok=1;
	}
}
int main()
{
	scanf("%d%d",&n,&m);memset(col,-1,sizeof(col));
	for(int i=1;i<=m;i++) scanf("%d%d",&x,&y),e[x].push_back(make_pair(y,1)),e[y].push_back(make_pair(x,2));
	for(int i=1;i<=n;i++) if(col[i]==-1)
	{
		memset(cnt,0,sizeof(cnt));ok=col[i]=0;dfs(i);
		if(ok){ans+=1ll*(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]);continue;}
		else if((!cnt[0])||(!cnt[1])||(!cnt[2])){ans+=1ll*cnt[3];continue;}
		else ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
	}
	printf("%lld\n",ans);
}

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

int main() {
  
  	string S;
  	cin >> S;
  
	if( ( S.at(0) == S.at(1) ) || ( S.at(1) == S.at(2) ) || ( S.at(2) == S.at(3) ) )
      cout << "Bad" << endl;
  	else
      cout << "Good" << endl;
}

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

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    priority_queue<ll> a;
    int cnt = 0;
    for(int i=0;i<A;i++) {
        ll p;
        cin >> p;
        if (cnt < X) {
            a.push(-p);
            cnt++;
        }else{
            ll tmp = -a.top();
            if(tmp < p){
                a.pop();
                a.push(-p);
            }
        }
    }
    priority_queue<ll> b;
    cnt = 0;
    for(int i=0;i<B;i++){
        ll q;
        cin >> q;
        if(cnt < Y){
            b.push(-q);
            cnt++;
        }else{
            ll tmp = -b.top();
            if(tmp < q){
                b.pop();
                b.push(-q);
            }
        }
    }
    for(int i=0;i<C;i++){
        ll r;
        cin >> r;
        ll tmp1 = -a.top();
        ll tmp2 = -b.top();
        if(r <= tmp1 && r <= tmp2) continue;
        if(tmp1 <= tmp2){
            a.pop();
            a.push(-r);
        }else{
            b.pop();
            b.push(-r);
        }
    }
    ll ans = 0;
    for(int i=0;i<X;i++) {
        int tmp = -a.top();
        a.pop();
        ans += tmp;
    }
    for(int i=0;i<Y;i++){
        int tmp = -b.top();
        b.pop();
        ans += tmp;
    }
    cout << ans << endl;


}

Measured memory_bytes: 2420
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
  ll a,b,k;
  cin>>a>>b>>k;
  if(k<=a)cout<<a-k<<" "<<b;
  else if(k<=a+b)cout<<0<<" "<<a+b-k;
  else{cout<<0<<" "<<0;}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main(){
	var n int
	fmt.Scan(&n)
	
	goods := make(map[string]int)
	
	good := ""
	for i := 0; i < n; i++ {
		fmt.Scan(&good)
		goods[good]++
	}
	fmt.Println(len(goods))
}

Measured memory_bytes: 22120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long W0 = (W + 1) / 2;
		long W1 = W - W0;
		if(H == 1 || W == 1){
			System.out.println(1);
			return ;
		}
		if(W0 == W1){
			System.out.println(H * W0);
		}else{
			if(H % 2 == 0){
				System.out.println((H / 2) * (W0 + W1));				
			}else{
				long r = (H / 2) * (W0 + W1) + W0;
				System.out.println(r);				
			}
		}
	}
}


Measured memory_bytes: 21844
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K) = read!(usize, usize);
    println!("{}", N - K + 1)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #define fastio() ios_base::sync_with_stdio(false);
    #define rmod(x, y) ((((x)%(y))+(y))%(y))
    using namespace std;
    using namespace __gnu_pbds;
    typedef long long ll;
    typedef long double ld;
    template<typename T, typename R = null_type, typename C = less<T>>
    tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
    	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
    }
     
    const int maxn = 1e5+5;
    int x, y, a, b, c, k;
    deque<int> p, q, r;
     
    int main(){
    	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
    	for(int i = 0; i<a; i++) scanf("%d", &k), p.push_back(k);
    	for(int i = 0; i<b; i++) scanf("%d", &k), q.push_back(k);
    	for(int i = 0; i<c; i++) scanf("%d", &k), r.push_back(k);
    	sort(p.begin(), p.end());
    	sort(q.begin(), q.end());
    	sort(r.begin(), r.end(), greater<int>());
    	while(p.size()>x) p.pop_front();
    	while(q.size()>y) q.pop_front();
    	while(r.size()){
    		int mn = min(p.front(), q.front());
    		if (r.front()<=mn) break;
    		if (p.front()<q.front()) p.push_back(r.front()), p.pop_front(), r.pop_front();
    		else q.push_back(r.front()), r.pop_front(), q.pop_front();
    	}
    	ll ans = 0;
    	for(int v: p) ans+= (ll)v;
    	for(int v: q) ans+= (ll)v;
    	printf("%lld\n", ans);
    	return 0;
    }

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
string str[105];
int pref[105];
map<string, int> pos;
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++){
		string s; int t;
		cin >> s >> t;
		pos[s] = i;
		pref[i] = pref[i - 1] + t; 
	}
	string X;
	cin >> X;
	cout << pref[n] - pref[pos[X]] << "\n";

}

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

int main(){
  int a1, a2, a3, a4, a5, a6, a7, b1, b2, b3, b4, b5, b6, b7;
  cin>>a1>>b1>>a2>>b2>>a3>>b3>>a4>>b4>>a5>>b5>>a6>>b6>>a7>>b7;
  cout<<a1 - b1<<"\n"<<a2 - b2<<"\n"<<a3 - b3<<"\n"<<a4 - b4<<"\n"<<a5 - b5<<"\n"<<a6 - b6<<"\n"<<a7 - b7<<endl;

  return 0;
}



Measured memory_bytes: 3100
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;
int64_t R=1;
void solution(){
    int64_t x;
   for(int i=0,x;i<5;i++){
    cin>>x;
    if(x==0){cout<<i+1<<endl;}
    }
}
int main()
{
    FOR(i,R){solution();}
    return 0;
}


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

using namespace std;

const int maxn = 2e5 + 9;

using lint = long long;

int a[maxn], b[maxn];
priority_queue<pair<int, int>> pq;

int main() {
#if DEBUG
    freopen("in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        pq.push({b[i], i});
    }
    lint ans = 0;
    while (!pq.empty()) {
        pair<int, int> here = pq.top();
        pq.pop();
        if (b[here.second] <= a[here.second]) continue;
        int p = b[(here.second + n - 1) % n];
        int q = b[here.second];
        int r = b[(here.second + 1) % n];
        lint s = (q - a[here.second]) / (p + r);
        if (s <= 0) {
            cout << "-1\n";
            return 0;
        }
        ans += s;
        q -= s * (p + r);
        b[here.second] = q;
        if (a[here.second] != b[here.second])
            pq.push({q, here.second});
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3700
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	std::sort(p,p+a);
	int ret=0;
	for(int i=0;i<a;i++)ret+=p[i];
	ret-=p[a-1]/2;printf("%d\n",ret);
}

Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e14+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

bool solve(void){
	int n,i,rwa=0,wwa=0;cin>>n;
	if(n==0){return false;}
	vector<pair<int,int>>hon(n);
	for(i=0;i<n;i++){cin>>hon[i].fir>>hon[i].sec;rwa+=hon[i].fir;wwa+=hon[i].sec;}
	SO(hon);REV(hon);
	if(hon[0].fir*2<=rwa){cout<<rwa+wwa<<endl;return true;}
	//ロスタイム計測
	int w=hon[0].fir*2-rwa;//これだけの空き時間
	bitset<1001>dp=0;
	dp[0]=1;
	for(i=1;i<n;i++){dp|=(dp<<hon[i].sec);}
	int ros=0;
	for(i=w;i>=0;i--){if(dp[i]){ros=w-i;break;}}
	cout<<rwa+wwa+ros<<endl;
	
	return true;
}
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3144
//! # Bundled libraries

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u64,
    }

    let ans = (1..=n).map(|a| (n - 1) / a).sum::<u64>();
    println!("{}", ans);
}

// The following code was expanded by `cargo-equip`.


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1, 0);
    for (int i = 0; i < N-1; i++) {
        int B;
        cin >> B;
        A[B]++;
    }
    for (int i = 1; i <= N; i++) cout << A[i] << endl;
    return 0;
}


Measured memory_bytes: 4052
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

bool check(string s, char c) {
    bool good = true;
    for (auto x : s) if (x != c) good = false;
    return good;
}

int main() {

    string s;
    cin >> s;

    int ans = INT_MAX;

    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;
        for (int i = 0; i < s.size(); i++) {
            if (check(t, c)) {
                ans = min(i, ans);
                break;
            }
            string _t = "";
            for (int j = 0; j < t.size() - 1; j++) {
                if (t[j] == c || t[j + 1] == c) _t += c;
                else _t += t[j];
            }
            t = _t;
        }
    }

    cout << ans << endl;

}


























































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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int mod = 1e9 + 7;
const int N = 1e4 + 10;
const int K = 110;

int n;
string s, ss;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n >> s)
    {
        ss = s;

        sort(all(ss));
        // reverse(all(ss));

        // debug(s);
        // debug(ss);

        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'W' && ss[i] == 'R')
            {
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3844
import sys

for num in sys.stdin:
    ini = 100000
    num = int(num)
    for i in range(1, num+1):
        ini = ini + ini*0.05
        mod = ini % 1000
        ini = ini - mod
        if mod != 0:
            ini += 1000
    ini = int(ini)
    print(ini)

Measured memory_bytes: 7664
from math import factorial
def chofuku_cmb(a,b):
    x=factorial(a+b-1)//(factorial(b)*factorial(a-1))
    return x

s=int(input())
if s<3:
    print(0)
    exit()
elif s<6:
    print(1)
    exit()
else:
    ans=0
    m=s//3
    for i in range(1,m+1): #iは項数⇒分けるグループの数
        rem=s-i*3
        ans+=chofuku_cmb(rem+1,i-1)
        ans%=10**9+7
    print(ans)

Measured memory_bytes: 72724
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head) << " ";
  print(tail...);
}

struct Union_Find {
 private:
  vector<int> data;
  ll c;

 public:
  Union_Find(int si) {
    data = vector<int>(si, -1);
    c = si * (ll)(si - 1) / 2;
  }
  bool union_set(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x])
        swap(x, y);
      c -= siz(x) * (ll)siz(y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int siz(int x) { return -data[root(x)]; }
  ll get_c() { return c; }
};

int main() {
  GI2(N, M);
  vector<P> br(M);
  FOR(i, M) {
    GI2(A, B);
    br[i] = P(A - 1, B - 1);
  }
  Union_Find uf(N);
  vector<ll> ans(M, 0LL);
  ans[M - 1] = uf.get_c();
  for (int i = M - 1; i > 0; --i) {
    P b = br[i];
    uf.union_set(b.first, b.second);
    if (uf.get_c() == 0LL)
      break;
    ans[i - 1] = uf.get_c();
  }
  FOR(i, M) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    double x;
    // scanf("%d", &x);
    cin >> x;
    // printf("%d\n", x * x * x);
    cout << 2 * x * 3.14159 << endl;
}

Measured memory_bytes: 3788
//c.c C-Energy Drink Collector
#include<stdio.h>
#include<stdlib.h>
typedef long long lld;

typedef struct{
    lld a;
    lld b;
}energy;


int cmp(const void *a,const void *b){
    lld x = ((energy*)a)->a;
    lld y = ((energy*)b)->a;
    if(x>y){
        return 1;
    }
    if(x<y){
        return -1;
    }
    return 0;
}


int main(void){
    lld n,m;
    scanf("%lld %lld",&n,&m);
    energy buf[n];
    for(int i=0;i<n;++i){
        scanf("%lld %lld",&buf[i].a,&buf[i].b);
    }
    qsort(buf,n,sizeof(energy),cmp);

    lld ans = 0;
    for(int i=0;i<n;++i){
        if(buf[i].b>=m){
            ans += buf[i].a * m;
            printf("%lld\n",ans);
            break;
        }else{
            ans += buf[i].a * buf[i].b;
            m -= buf[i].b;
        }
    }
    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int digit(ll n){
	if(n==0) return 1;
	int res = 0;
	while(n){
		n /= 10;
		res++;
	}
	return res;
}

int main(void) {
	int k; cin >> k;
	vll lun;
	
	queue<ll> q;
	rep2(i,1,10) q.push(ll(i));
	while(true){
		ll x = q.front(); q.pop();
		if(x) lun.push_back(x);
		if(lun.size()==100000) break;
		int r = x%10;
		for(int i=max(0,r-1); i<=min(9,r+1); i++){
			ll nxt = x*10+ll(i);
			q.push(nxt);
		}
	}
	SORT(lun);
//	rep(i,k) cout << lun[i] << endl;
	cout << lun[k-1] << endl;
}




Measured memory_bytes: 2548
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n,dig;
    int h=0;
    cin >> n;
    dig=n;
    while(dig/10){
        h+=dig%10;
        dig/=10;
    }
    h+=dig;
    if(n%h) puts("No");
    else puts("Yes");
}


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

using namespace std;

int main() {
    int N,H[100],i,j;
    cin>>N;
    for(i=0;i<N;i++){
        cin>>H[i];
    }
    bool did=true;
    int ans = 0;
    while(did) {
        did = false;
        int water=0,minHeight=101,start=0;
        for(i=0;i<N;i++){
            if(H[i]!=0)did=true;
            if(H[i]==0){
                if(minHeight!=101){
                    for(j=start;j<=i-1;j++){
                        H[j]-=minHeight;
                    }
                    ans+=minHeight;
                }
                start=i+1;
                minHeight=101;
            }
            if(H[i]!=0){
                minHeight=min(minHeight,H[i]);
            }
        }
        if(minHeight!=101){
            for(j=start;j<=i;j++){
                H[j]-=minHeight;
            }
            ans+=minHeight;
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
A = input().split()

def Revpol(A):
    S = [] #スタック
    for i in range(len(A)):
        if A[i] != '+' and A[i] != '-' and A[i] != '*':
            S.append(int(A[i]))
        elif len(S)>=2:
            if A[i] == '+':
                tmp = S[len(S)-2] + S[len(S)-1]
                S.pop()
                S.pop()
                S.append(tmp)
            elif A[i] == '-':
                tmp = S[len(S)-2] - S[len(S)-1]
                S.pop()
                S.pop()
                S.append(tmp)
            elif A[i] == '*':
                tmp = S[len(S)-2] * S[len(S)-1]
                S.pop()
                S.pop()
                S.append(tmp)
        else:
            print("error1")
            break
    if len(S) == 1:
        print(S[0])
    else:
        print("error2")

Revpol(A)



Measured memory_bytes: 5612
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;


vector<int> h(100010);
vector<int> dp(100010, inf);

// メモ化再帰
int rec(int n)
{
	if (dp.at(n) < inf)
	{
		return dp.at(n);
	}

	if (n == 0)
	{
		return 0;
	}

	int res = inf;
	res = min(res, rec(n - 1) + abs(h.at(n) - h.at(n - 1)));
	if (n > 1)
	{
		res = min(res, rec(n - 2) + abs(h.at(n) - h.at(n - 2)));
	}

	return dp.at(n) = res;
}

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

	
	for (int i = 0; i < n; i++)
	{
		cin >> h.at(i);
	}

	vector<int> dp(n, inf);
	dp.at(0) = 0;

	// 貰うDP
	/*
	for (int i = 1; i < n; i++)
	{
		dp.at(i) = min(dp.at(i), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
		if (i - 2 >= 0)
		{
			dp.at(i) = min(dp.at(i), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
		}
	}
	*/

	// 配るDP
	/*
	for (int i = 0; i < n - 1; i++)
	{
		dp.at(i + 1) = min(dp.at(i + 1), dp.at(i) + abs(h.at(i + 1) - h.at(i)));
		if (i + 2 < n)
		{
			dp.at(i + 2) = min(dp.at(i + 2), dp.at(i) + abs(h.at(i + 2) - h.at(i)));
		}
	}
	*/
	

	//cout << dp.at(n - 1) << endl;
	cout << rec(n - 1) << endl;
}


Measured memory_bytes: 6144
a = list(input())
if a[0] == 'A' and a[1].islower() and a[len(a)-1].islower():
    a = a[2:len(a)-1]
    c_cnt = 0
    ng_f = 0
    for i in range(len(a)):
        if a[i] == 'C':
            c_cnt = c_cnt + 1
        else:
            if not a[i].islower():
                ng_f = 1
                break
    if ng_f == 0 and c_cnt == 1:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

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

int main(void){
    int i=0,p=0,r=0;
    char a[100];
    gets(a);

    while(i<strlen(a)){
        if(i==0){
            if(a[0]!=65){
                r=-1;
                break;
            }
        }
        if(i>=1){
        if(i>=2&&a[i]==67){
            if(p==0) p=1;
            else if(p==1){
                r=-1;
                break; 
            }
        }
        else if(a[i]>=65&&a[i]<=90){
            r=-1;
            break;
        }  
        }
        i++;
    }
    if(a[i-1]=='C') r=-1;
    if(r==-1||p==0) printf("WA\n");
    else if(r==0) printf("AC\n");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
m = pow(10, 18)
s = 0
for i in range(n):
    s += ab[i][0]
    if ab[i][0] > ab[i][1]:
        m = min(m, ab[i][1])
ans = max(0, s - m)
print(ans)

Measured memory_bytes: 12636
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

ll n, h[200020], a[200020], dp[200020];
void update(int i, ll x) {
  for(; i <= n; i += i & -i) dp[i] = max(dp[i], x);
}
ll query(int i) {
  ll res = 0;
  for(; i > 0; i -= i & -i) res = max(res, dp[i]);
  return res;
}

int main()
{
  cin >> n;
  REP(i, n) cin >> h[i];
  REP(i, n) cin >> a[i];

  REP(i, n) update(h[i], query(h[i] - 1) + a[i]);

  cout << query(n);
  return 0;
}

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

int main()
{
	string str, ord;
	int n = 0;

	cin >> str;
	cin >> n;

	for (int i = 0; i < n; i++) {

		string temp;
		int a = 0, b = 0;

		cin >> ord;

		if (ord == "print") {
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (ord == "reverse") {
			cin >> a >> b;
			for (int j = 0; j <= b - a; j++)
				temp += str[b - j];
			str.replace(a, b - a + 1, temp);
		}
		else if (ord == "replace") {
			cin >> a >> b >> temp;
			str.replace(a, b - a + 1, temp);
		}
	}
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    vector<int> A(N);

    rep(i, N)
    {
        cin >> A.at(i);
    }

    int lighting = 1;
    int cnt = 0;

    rep(i, N)
    {
        lighting = A.at(lighting - 1);
        cnt++;
        if (lighting == 2)
        {
            cout << cnt << endl;
            break;
        }
    }
    if (cnt == N)
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define MAX 1000000000000
#define N 100005
int n,m;
vector<int> g[N];
int dp[N];
int solve(int u)
{
    if(dp[u]!=-1) return dp[u];
    int ans=0;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        ans=max(ans,solve(v));
    }
    return dp[u]=1+ans;
}
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        g[x].pb(y);
    }
    memset(dp,-1,sizeof dp);
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        mx=max(mx,solve(i));
    }
    printf("%d",mx-1);
}


Measured memory_bytes: 8192
#include<cstdio> 
using namespace std;
int cnt,isprime123[1000005],prime123[1000005];
int main(){
	for (int i=2; i<=10000; i++){
		if (!isprime123[i]) prime123[++cnt]=i;
		for (int j=1; j<=cnt && prime123[j]*i<=10000; j++){
			isprime123[i*prime123[j]]=1;
			if (i%prime123[j]==0) break;
		}
	}
	int n;
	scanf("%d",&n);
	for (int i=1; i<=cnt; i++)
		if (prime123[i]%5==1){
			n--;
			printf("%d ",prime123[i]);
			if (!n) return 0;
		}
	return 0;
}

Measured memory_bytes: 2176
from collections import defaultdict
import heapq
def solve():
    N,M = map(int,input().split())
    day_fee = defaultdict(list)
    for i in range(N):
        a, b = map(int,input().split())
        day_fee[a].append(b)

    fee_heap = []
    heapq.heapify(fee_heap)

    ans = 0
    for day in range(1,M+1):
        for fee in day_fee[day]:
            heapq.heappush(fee_heap, -fee)
        
        if len(fee_heap) != 0:
            ans += -heapq.heappop(fee_heap)
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 77912
def roll(l, command):
    '''
    return rolled list

    l : string list
    command: string
    '''
    res = []
    i = -1
    if command =='N':
        res = [l[i+2], l[i+6], l[i+3], l[i+4], l[i+1], l[i+5]]
    if command =='S':
        res = [l[i+5], l[i+1], l[i+3], l[i+4], l[i+6], l[i+2]]
    if command =='E':
        res = [l[i+4], l[i+2], l[i+1], l[i+6], l[i+5], l[i+3]]
    if command =='W':
        res = [l[i+3], l[i+2], l[i+6], l[i+1], l[i+5], l[i+4]]

    return res

def spin(l):
    '''
    return right sppined list

    l : string list
    '''

    i = -1
    res = [l[i+1], l[i+3], l[i+5], l[i+2], l[i+4], l[i+6]]

    return res
def has_same_faces(a, b):
    '''
    check if all elements of a are equel to those of b.
    a : string list
    b : string list
    '''
    return set(a) == set(b)

def is_identical_lists(a, b):
    for x, y in zip(a, b):
        if x != y:
            return False

    return True

def check_two_dice(a, b):
    if not has_same_faces(a, b):
        return False
    
    orig_a = a[:]

    #roll and spin to check
    for i in range(6):
        if 1 <= i <= 3:
            a = roll(a, "N")
        elif i == 4:
            pass
            a = orig_a[:]
            a = roll(a, "W")
        elif i == 5:
            a = orig_a[:]
            a = roll(a, "E")

        # spin 4 times
        for _ in range(4): #spin 3 times
            a = spin(a)
            if is_identical_lists(a, b):
                return True
        
    return False


if __name__ == "__main__":
    a_list = input().split()
    b_list = input().split()
    res = check_two_dice(a_list, b_list)  
    print("Yes") if res else print("No")






Measured memory_bytes: 5596
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){return null;}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function Main(){
  var k = 1*input[0].split(" ")[0]
  var s = 1*input[0].split(" ")[1]
 // console.log(y)
  var c = 0;
  for(var i = 0 ; i<=k; ++i){
     for(var j = 0 ; j<=(s-i) && j<=k; ++j){
       
       if((s-i-j)>=0 && (s-i-j)<=k){
       //  console.log(i + ":" + j)
         ++c
       }

       
       
     }
  }
console.log(c)


  
}
Main();

Measured memory_bytes: 7372
def make_divisors(n):
    if n==1:
        divisors=[1]
        return divisors
    else:
        divisors=[]
        for i in range(1,n):
            if i*i>n:
                break
            if n%i==0:
                divisors.append(i)
                if i!=n//i:
                    divisors.append(n//i)

        divisors.sort(reverse=True)
        return divisors

from sys import stdin
from math import gcd
def main():
    #入力
    readline=stdin.readline
    a,b,k=map(int,readline().split())

    c=gcd(a,b)
    li=make_divisors(c)

    print(li[k-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 9044
using System;
using System.IO;

namespace AtCoder {
	class Program {
		public static void Main(string[] args) {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

			int x = int.Parse(Console.ReadLine());
			int a = x / 500;
			x %= 500;
			int b = x / 5;
			Console.WriteLine(a * 1000 + b * 5);

			Console.Out.Flush();
		}
	}
}

Measured memory_bytes: 11092
#include <cstdio>

const int N=101;
short f[N][N][N][N];
short pl[N][N],pu[N][N];
char s[N][N];
short n,m,sx,sy,ans;

inline short min(short A,short B) {return A<B?A:B;}
inline short max(short A,short B) {return A>B?A:B;}
inline void cmax(short&A,short B) {A=A>B?A:B;}

void init();void work();
int main(){init();work();return 0;}

void work(){
	for(short l=sy;l;--l)
	for(short u=sx;u;--u)
	for(short r=sy;r<=m;++r)
	for(short d=sx;d<=n;++d){
		if(1 < u and d+1 < sx+u)	cmax(f[u-1][l][d][r] , f[u][l][d][r] + pl[u-1][min(r,m-(sy-l))]-pl[u-1][max(l,r-sy+1)-1]);
		if(1 < l and r+1 < sy+l)	cmax(f[u][l-1][d][r] , f[u][l][d][r] + pu[l-1][min(d,n-(sx-u))]-pu[l-1][max(u,d-sx+1)-1]);
		if(d < n and sx+d < n+u)	cmax(f[u][l][d+1][r] , f[u][l][d][r] + pl[d+1][min(r,m-(sy-l))]-pl[d+1][max(l,r-sy+1)-1]);
		if(r < m and sy+r < m+l)	cmax(f[u][l][d][r+1] , f[u][l][d][r] + pu[r+1][min(d,n-(sx-u))]-pu[r+1][max(u,d-sx+1)-1]);
		cmax(ans,f[u][l][d][r]);
	}
	printf("%d\n",(int)ans);
}

void init(){
	int inn,inm;
	scanf("%d%d",&inn,&inm);
	n=inn,m=inm;
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;++j){
			pl[i][j]=pl[i][j-1]+(s[i][j]=='o');
			if(s[i][j]=='E')s[i][j]='.',sx=i,sy=j;
		}
	}
	for(int j=1;j<=m;++j)
	for(int i=1;i<=n;++i)
		pu[j][i]=pu[j][i-1]+(s[i][j]=='o');
}

Measured memory_bytes: 200960