akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int dp[3005][3005];

int main()
{
    string s,t;
    cin >> s >> t;
    ll n=s.length();
    ll m=t.length();
    string ans="";
    rep(i,n) rep(j,m){
        if(s[i]==t[j]){chmax(dp[i+1][j+1],dp[i][j]+1);  continue;}
        chmax(dp[i+1][j+1],dp[i+1][j]);
        chmax(dp[i+1][j+1],dp[i][j+1]);
    }
    ll i=n;
    ll j=m;
    while(i>0 && j>0){
        if(dp[i][j]==dp[i-1][j]){
            i--;
        }
        else if(dp[i][j]==dp[i][j-1]){
            j--;
        }
        else{
            ans=s[i-1]+ans;
            i--; j--;
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 35456
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = 300005;
const int logn = 20;
string s[8], w[8];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
//    cin>>t; 
    while(t--)
    {
        int r, c, b; cin>>r>>c>>b;
        f0(i,r) cin>>s[i];
        ll ans = 0LL;
        f0(i,(1<<r))
        {
            f0(j,(1<<c))
            {
                f0(k,r) w[k] = s[k];
                f0(k,r) if(i&(1<<k)) f0(col,c) w[k][col] = '*';
                f0(k,c) if(j&(1<<k)) f0(row,r) w[row][k] = '*';
                int cnt = 0;
                f0(row,r) f0(col,c) if(w[row][col]=='#') ++cnt;
                if(cnt==b) ans++;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
 
public class Main {
	
	public static final long MOD = 1000000007;
	
	public static long[][] mat_mut(final int N, long[][] mat1, long[][] mat2){
		long[][] ret = new long[N][N];
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					ret[i][j] += mat1[i][k] * mat2[k][j];
					ret[i][j] %= MOD;
				}
			}
		}
		
		return ret;
	}
	
	public static long[][] mat_fact(final int N, long[][] mat, final long K){
		if(K == 1) {
			return mat;
		}else if(K % 2 == 1) {
			return mat_mut(N, mat, mat_fact(N, mat, K - 1));
		}else {
			final long[][] ret = mat_fact(N, mat, K / 2);
			return mat_mut(N, ret, ret);
		}
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final long K = sc.nextLong();
			
			long[][] adj = new long[N][N];
			for(int i = 0; i < N; i++) {
				for(int j = 0; j < N; j++) {
					adj[i][j] = sc.nextInt();
				}
			}
			
			long[][] ret = mat_fact(N, adj, K);
			
			long sum = 0;
			for(int i = 0; i < N; i++) {
				for(int j = 0; j < N; j++) {
					sum += ret[i][j];
					sum %= MOD;
				}
			}
			
			//System.out.println(Arrays.deepToString(ret));
			System.out.println(sum);
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23892
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10 ** 9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    S = I()

    ans = 0
    # 分割につかうしきりの数毎に調べる
    for i in range(S // 3):
        tmp = S - 3 * (i + 1)
        ans += combMod(tmp + i, i, MOD)
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10112
function Main(input) {
    const numbers = input.split(' ').map(n => Number(n));
    const a = numbers[0];
    const b = numbers[1];
    const c = numbers[2];

    if(b - a === c - b) {
      console.log('YES');
    } else {
      console.log('NO');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

N = int(input())
keihin = [input().rstrip() for _ in range(N)]

counter = Counter(keihin)
print(len(counter))


Measured memory_bytes: 39020
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int inf = 1e17;
int fast_pow(int x, int y, int p);
const int sz = 300001;
int bit[sz];
int n;
int get(int index){
	int ans = 0;
	for(;index>0 ; index-=(index&(-index))){
		ans=max(ans,bit[index]);
	}
	return ans;
}
void update(int index,int val){
	for(;index<sz;index+=(index&(-index))){
		bit[index]=max(bit[index],val);
	}
}


void solve() {
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	int ans = 0;
	for(int i=0;i<n;i++){
		int left = get(a[i]-1);
		ans = max(ans,left+b[i]);
		update(a[i],left+b[i]);
	}
	cout<<ans<<endl;

}


int32_t main() {

	IOS;
	int test = 1;
	// cin>>test;
	for (int i = 1; i <= test; i++) {
        // cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
int fast_pow(int x, int y, int p) {
	int res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

Measured memory_bytes: 4992
# n+2m=i
# 2n+m=j
# (4n+2m=2j)
# n=(2j-i)/3
# m=(2i-j)/3
# n+m C n (n+m)!/n!/m!

MOD = 10**9+7
MAX = (10**6)*2+5
fac = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
def COMinit():
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1
    for i in range(2,MAX):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
def COM(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

x,y=list(map(int,input().split()))
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    if n<0 or m<0:
        print(0)
    else:
        COMinit()
        print(COM(n+m,n))

Measured memory_bytes: 87664
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::vector<long long> a){
	sort(ALL(a), greater<long long>());
	int A = 0, B = 0;
	for(int i = 0; i < N; ++i) {
		if (i % 2 == 0) {
			A += a[i];
		} else {
			B += a[i];
		}
	}
	cout << A - B << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()
{
    fastio;
    int n,s;
    cin >> n >> s;
    vector<int>v(n+1);
    for(int i=1;i<=n;i++)
        cin >> v[i];
    vector<vector<int> >vsum(s+1);
    int dp[s+1][n+1];
    for(int sum=1;sum<=s;sum++)
    {
        for(int i=1;i<=n;i++)
        {
            if(v[i]>sum)
            {
                dp[sum][i]=0;
                if(vsum[sum].size()==0)
                    vsum[sum].push_back(0);
                else
                {
                    int t=vsum[sum][vsum[sum].size()-1];
                    vsum[sum].push_back(t);
                }
            }
            else if(v[i]==sum)
            {
                dp[sum][i]=i;
                if(vsum[sum].size()==0)
                    vsum[sum].push_back(i);
                else
                {
                    int t=(vsum[sum][vsum[sum].size()-1]*1LL+i)%mod1;
                    vsum[sum].push_back(t);
                }
            }
            else
            {
                if(i>1)
                    dp[sum][i]=vsum[sum-v[i]][i-2];
                else
                    dp[sum][i]=0;
                int temp=dp[sum][i];
                if(vsum[sum].size()==0)
                    vsum[sum].push_back(temp);
                else
                {
                    int t=(vsum[sum][vsum[sum].size()-1]*1LL+temp)%mod1;
                    vsum[sum].push_back(t);
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=(ans+(dp[s][i]*1LL*(n-i+1))%mod1)%mod1;
    cout << ans << endl;
}

Measured memory_bytes: 82688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;
ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    ll M=0,m=0;
    p = prods(210000);
    for(int i=0; i<n; i++){
        m = (m+a[i]*comb(i,k-1))%MOD;
    }
    reverse(a.begin(),a.end());
    for(int i=0; i<n; i++){
        M = (M+a[i]*comb(i,k-1))%MOD;
    }

    cout<<(-M+m+MOD)%MOD;
    return 0;
}

Measured memory_bytes: 2688
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const INF = (1 << 31) - 1

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	g := make([][]int, N)
	isMinimum := make([][]bool, N)
	for i := 0; i < N; i++ {
		g[i] = nextIntArray(N)
		isMinimum[i] = make([]bool, N)
		for j := 0; j < N; j++ {
			isMinimum[i][j] = true
		}
	}
	ok := true
	for a := 0; a < N; a++ {
		for b := 0; b < N; b++ {
			if g[a][b] != g[b][a] {
				ok = false
			}
		}
	}
	for a := 0; a < N; a++ {
		for b := 0; b < N; b++ {
			for c := 0; c < N; c++ {
				if a == b || b == c || c == a {
					continue
				}
				if g[a][c]+g[c][b] < g[a][b] {
					ok = false
				} else if g[a][c]+g[c][b] == g[a][b] {
					isMinimum[a][b] = false
					isMinimum[b][a] = false
				}
			}
		}
	}
	res := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if isMinimum[i][j] {
				res += g[i][j]
			}
		}
	}
	if ok {
		fmt.Println(res)
	} else {
		fmt.Println(-1)
	}
}

// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(next())
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}

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

func shift(p int) int {
	return 1 << uint(p)
}

func swap(a *int, b *int) {
	tmp := a
	a = b
	b = tmp
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b1,b2;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        b2.push_back(a[i]);
        swap(b1,b2);
    }
    reverse(b1.begin(),b1.end());

    for(auto x:b1){
        cout << x << " ";
    }
    for(auto x:b2){
        cout << x << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3956
import itertools
import fractions

n = int(input())
a = list(map(int, input().split()))
cumgcd = list(itertools.accumulate(a, func=fractions.gcd))
cumgcd_rv = list(itertools.accumulate(a[::-1], func=fractions.gcd))
ans = max(cumgcd[-2],cumgcd_rv[-2])
if n == 2:
  ans = max(a)
else:
  for key,value in enumerate(cumgcd[:n-2]):
    ans = max(ans, fractions.gcd(value,cumgcd_rv[n-3-key]))
print(ans)

Measured memory_bytes: 16160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

ll MIN(ll num1,ll num2){
    return num1<num2?num1:num2;
}

int main(){

    while(1){
        int N;
        vector<int> V;
        cin>>N;
        if(N==0)break;
        for(int i=0;i<N;i++){
            int v;
            cin>>v;
            V.push_back(v);
        }
        sort(V.begin(),V.end());
        int sum=0;
        for(int i=1;i<N-1;i++)sum+=V[i];
        cout<<sum/(N-2)<<endl;
    }

    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
int main()
{
    char a[3];
    scanf("%s",a);
    if(a[0]==a[1]){printf("Bad");}
    else if(a[1]==a[2]){printf("Bad");}
    else if(a[2]==a[3]){printf("Bad");}
    else{printf("Good");}
    return 0;  

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 10000000;
bool can[MX];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m;
	while(cin >> m >> n, m){
		memset(can, 0, sizeof(can));
		for(int i = m; i < MX; i++){
			if(!can[i]){
				if(n-- == 0){
					cout << i << endl;
					break;
				}
				for(int j = i; j < MX; j += i) can[j] = 1;
			}
		}
	}
	return 0;
}

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

using namespace std;


int main() {
  
   long long n, ans = 0;
   
   cin >> n;
   
   vector<int> a(n);
   
   for(int i = 0; i < n; i++) {
      cin >> a[i];
   }
   
   sort(a.begin(), a.end());
   multiset<int> st;
   
   st.insert(-a[n-1]);
   
   for(int i = n-2; i >= 0; i--) {
      ans += -*st.begin();
      st.erase(st.begin());
      
      st.insert(-a[i]);
      st.insert(-a[i]);
    //  cout << i << ' ' << ans << '\n';
   }
   cout << ans;
}

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

#define lop(n) for(int i=0; i<n; i++)
#define loop(j,n) for(int i=j; i<n; i++)

typedef long long ll;

using namespace std;

int main()
{
    int n,i=1;
    for(;cin>>n;i++)
    {
        if(n<1)
        {
            i--;
            continue;
        }
        cout<< "Case " << i << ": " << n << endl;
    }

    return 0;
}






Measured memory_bytes: 3132
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

signed main(){
	int n;scanf("%d",&n);
	char s[111];scanf("%s",s+1);
	int m=strlen(s+1);
	if(m<=n)puts(s+1);
	else{
		for(int i=1;i<=n;i++)printf("%c",s[i]);
		printf("...\n");
	}

	return 0;
}



Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    string s;
    cin >> s;

    int n = (int)s.size();

    int r = 0;
    for (int i = 0; i < n; i++) {
        int t = s[i] == 'p';
        r += i % 2 - t;
    }

    cout << r << endl;

    return 0;
}

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

using namespace std;

int main()
{
   int a, b;
   cin >> a >> b;

   if(a >= 13){
      cout << b << endl;
   }else if(6 <= a && a <= 12){
      cout << b/2 << endl;
   }else{
      cout << 0 << endl;
   }

   return 0;
}



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

using namespace std;

string check(string s, int x) {
	string tmp = std::to_string(x);
	cout << "? " << (s + tmp) << endl;
	cin >> tmp;
	return tmp;
}

void add(string &prefix, int x) {
	string tmp = std::to_string(x);
	prefix = prefix + tmp;
}

string build(string prefix, int last) {
	string tmp = std::to_string(last);
	tmp = prefix + tmp;
	while (tmp.size() < 15) {
		tmp.push_back('9');
	}
	return tmp;
}

int main() {
	string prefix = "";
	while (true) {
		int r = 10;
		int l = 0;
		if (prefix == "") {
			l = 1;
		}
		string v9 = check(prefix, 9);
		bool last = false;
		if (v9 == "Y") {
			string v80 = check(prefix, 80);
			if (v80 == "N") {
				cout << "! " << prefix << "9" << endl;
				return 0;
			}
			string vlast = "";
			if (l == 0)
				vlast = check(prefix + "0", 0);
			else
				vlast = check(prefix, 10);
			if (vlast == "Y") {
				if (check(build(prefix, l), 9) == "Y") {
					cout << "! " << prefix << l << endl;
					return 0;
				} else {
					add(prefix, 9);
					continue;
				}
			}
			last = true;
		}
		if (!last) {
			r--;
			while (r - l > 1) {
				int mid = (r + l) / 2;
				if (check(prefix, mid) == "Y")
					l = mid;
				else
					r = mid;
			}
			add(prefix, l);
			continue;
		}
		l++;
		while (r - l > 1) {
			int mid = (r + l) / 2;
			if (check(prefix, (mid - 1) * 10 + 0) == "N") {
				l = mid;
			} else
				r = mid;
		}
		cout << "! " << prefix << l << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 596
from collections import*
I=9**9
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
m,d=zip(*eval('(input(),[I]*w),'*h))
q=deque([(s-1,t-1,1)])
while q:
 y,x,c=q.popleft()
 if d[y][x]>c:
  for i in range(y-2,y+3):
   for j in range(x-2,x+3):d[y][x]=c;h>i>-1<j<w!=m[i][j]>'#'!=(abs(y-i)+abs(x-j)<2!=q.appendleft((i,j,c)),q.append((i,j,c+1)))
print(d[f-1][g-1]%I-1)

Measured memory_bytes: 252332
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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



int main() {
    ll n, m; cin >> n >> m;
    vector<ll> as(n, 0);
    ll lc = 1;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        lc = lcm(as[i], lc);
    }

    for (int i = 0; i < n; i++) {
        if ((lc / as[i]) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll t = 2 * m / lc;
    if (t == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (t % 2 == 0) {
        t--;
    }
    cout << (t / 2) + 1 << endl;

    return 0;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int64_t count_solve(int64_t n, int64_t k, int64_t b, int64_t d) {
  if (k == 0) {
    return (b / d) * n;
  }
  if (k >= d || b >= d) {
    return ((k / d) * (n - 1) + 2 * (b / d)) * n / 2 + count_solve(n, k % d, b % d, d);
  }
  return count_solve((k * n + b) / d, d, (k * n + b) % d, k);
}
void solve(std::istream &in, std::ostream &out) {
  int t;
  std::cin >> t;
  while (t--) {
    int64_t n,m,a,b;
    std::cin>>n>>m>>a>>b;
    std::cout<<count_solve(n,a,b,m)<<'\n';
  }
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const int N=207;
const int INF=1e9+7;
char s[N];
int d[N][N];
vector<int>E[N];
int n;

int main(){
	scanf("%d",&n);
	rep(i,n)rep(j,n)d[i][j]=(i==j)?0:INF;
	rep(i,n){
		scanf("%s",s+1);
		rep(j,n){
			if(s[j]=='1'){
				d[i][j]=1;
				E[i].push_back(j);
			}
		}
	}
	rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	int mx=-1;
	rep(i,n){
		bool fl=1;
		rep(j,n)rep0(k,E[j].size())if(d[i][j]==d[i][E[j][k]])fl=0;
		if(fl){
			int mn=0;
			rep(j,n)mn=max(mn,d[i][j]);
			mx=max(mx,mn);
		}
	}
	if(mx>=0)printf("%d\n",mx+1);
	else puts("-1");
	return 0;
}


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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    int dp1[n],dp2[n], now = -1;
    for(int i=0;i<n;i++){
    	if(s[i] == 'x') dp1[i] = -1;
    	else if(now == -1)dp1[i] = 1, now = i;
    	else if(i - now > c) dp1[i] = dp1[now] + 1, now = i;
    	else dp1[i] = -1;
    }
    now = n;
    for(int i=n-1;i>=0;i--){
    	if(s[i] == 'x') dp2[i] = -1;
    	else if(now == n) dp2[i] = k, now = i;
    	else if(now - i > c) dp2[i] = dp2[now] - 1, now = i;
    	else dp2[i] = -1;
    }
    vector<int> v;
    for(int i=0;i<n;i++){
    	if(dp1[i] != -1 && dp2[i] != -1 && dp1[i] == dp2[i]){
    		v.pb(i+1);
    	}
    }
    for(int i: v) cout << i << endl;
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

lli n,e;
lli x[e5];

lli solve(lli num){
  if(num == 0) return INF;
  lli ans = 0;
  for(lli i = 1;i <= num;i++){
    ans += x[n-i];
  }
  for(lli i = 1;i <= num;i++){
    lli j,k;
    for(j = n-num-i,k = 1;j >= 0;j-=num,k++){
      ans += (x[j+num]-x[j])*(k+1)*(k+1);
    }
    ans += x[j+num]*(k+1)*(k+1)+e;
  }
  return ans;
}

int main(){
  cin >> n >> e;
  for(lli i = 0;i < n;i++) cin >> x[i];
  // for(lli i = 1;i <= n;i++) cout << solve(i)+e*n << endl;
  lli top = n;
  lli bottom = 0;
  while(top-bottom > 1){
    lli middle = (top+bottom)/2;
    if(solve(middle+1) > solve(middle)) top = middle;
    else bottom = middle;
  }
  cout << solve(top)+e*n << endl;

}


Measured memory_bytes: 1792
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		Integer N = Integer.parseInt(scanner.next());
		Integer K = Integer.parseInt(scanner.next());

		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < K; i++) {
			Integer d = Integer.parseInt(scanner.next());
			for (int j = 0; j < d; j++) {
				set.add(Integer.parseInt(scanner.next()));
			}
		}

		int cnt = 0;
		for (int i = 1; i <= N; i++) {
			if (!set.contains(i)) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}

}


Measured memory_bytes: 40940
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> v(n);
	vector<int> w(m);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> w[i];
	}
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());
	if (v[n - 1] < w[0] && v[n - 1] < y && x < w[0]) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<queue>
using namespace std;

int main(){
	char stage[9][5] = {};
	for (int i = 0; i < 9; i++){
		cin >> stage[i];
		for (int j = 0; j < 5; j++){
			if (stage[i][j] != 0){
				stage[i][j] -= '0';
			}
		}
	}

	//for (int i = 0; i < 9; i++){ for (int j = 0; j < 5; j++) printf("%d ", stage[i][j]); puts(""); }

	int y = 0, x = 0, ny, nx, situ = 1;
	int situ_y[4] = { -1, 0, 1, 0 }, situ_x[4] = { 0, 0, 0, -1 };
	int np_y[4] = { -2, 0, 2, 0 }, np_x[4] = { 0, 1, 0, -1 };
	char situ_char[4] = { 'U', 'R', 'D', 'L' };
	do{
		situ += 3;
		situ %= 4;
		//printf("%d,%d  ", x, y);
		for (int i = 0; i < 4; i++, situ = (situ + 1) % 4){
			ny = y + situ_y[situ];
			nx = x + situ_x[situ];
			//printf(" %d:%d,%d", situ, ny, nx);
			if (ny < 0 || 8 < ny || nx < 0 || 4 < nx) continue;
			if (stage[ny][nx] == 1){
				y += np_y[situ];
				x += np_x[situ];
				//printf("test\n");
				printf("%c", situ_char[situ]);
				break;
			}
		}
	} while (y != 0 || x != 0);
	puts("");
	return 0;
}

Measured memory_bytes: 1100
from bisect import bisect_right

S = input()
T = input()

s_len = len(S)

indexs_by_char = dict([s, []] for s in (S))
for i, s in enumerate(S):
    indexs_by_char[s].append(i)
# print(indexs_by_char)
indexs_len = dict([[k, len(v)] for k, v in indexs_by_char.items()])
# print(indexs_len)

s_count = 0
current_i = -1
for t in T:
    if t not in indexs_by_char:
        print(-1)
        exit()
    j = None
    while True:
        j = bisect_right(indexs_by_char[t], current_i)
        if j < indexs_len[t]:
            break
        s_count += 1
        current_i = -1
    current_i = indexs_by_char[t][j]

print(s_len*s_count + current_i+1)


Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string S;
    cin >> S;
    bool change,judge;
    judge = true;
    change = false;
    for(int i = a;i <= max(c,d);i++){
        if(S[i] == '#' && S[i+1] == '#'){
            judge = false;
        }
        if(c > d && i <= max(c,d)-2 && i <= min(c,d)-1 && b-1 <= i){
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
                change = true;
            }
        }
        if(judge == false)break;
    }
    if(judge == false)cout << "No" << endl;
    else if(c > d && change == false)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll p(n);
  for (ll i = 0; i < n; i++) cin >> p[i];

  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (p[i] == i + 1) {
      if (i < n - 1) {
        cnt++;
        if (p[i + 1] == i + 2) i++;
      }
      else cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    long int n, k;
    cin >> n >> k;
    long int h[n];
    rep(i, n) cin >> h[i];
    sort(h, h + n);
    long int ans = 0;
    for (int i = 0; i < n - k; i++){
        ans += h[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    lint a, b;
    cin >> n >> a >> b;
    vec x(n);
    rep(i, n) cin >> x[i];

    lint res = 0;

    rep(i, n-1) {
        lint diff = x[i+1] - x[i];
        diff *= a;
        if (diff > b) {
            res += b;
        }
        else {
            res += diff;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void) {
	char c;

	cin >> c;

	if(c=='A'){
		cout << 'T';
	}
	else if (c == 'C') {
		cout << 'G';
	}
	else if (c == 'G') {
		cout << 'C';
	}
	else if (c == 'T') {
		cout << 'A';
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "Yes" : "No")
#define mod(a, b) (b + (a % b)) % b
#define MOD  (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pii> vpii;

void solve(){
    int a, b, sum = 0;
    cin >> a >> b;
    for(int i = 0; i < b; i++){
        int x;
        cin >> x;
        sum += x;
    }
    yesno(sum >= a);
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a ,b ,c ;
    cin >> a >> b ;
    c = a + b ;
    if (c < 24)
    cout << c ;
    else if (c > 24 )
    cout <<c-24;
    else if (c==24)
    cout << 0 ;





    return 0;
}


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

int main() {
    int H,W;
    cin>>H>>W;
    vector<char> C(W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>C.at(j);
        }
        for(int k=0;k<W;k++){
            cout<<C.at(k);
        }
            cout<<endl;
        for(int k=0;k<W;k++){
            cout<<C.at(k);
        }
            cout<<endl;
    }
return 0;}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int n;
	long long int y;
	cin >> n;
	cin >> y;
	for (long long int i = 0; i <= n; i++) {
		for (long long int j = 0; j + i <= n; j++) {
			long long int sum = 0;
			sum = 10000 * i;
			sum = sum + 5000 * j;
			if (sum <= y) {
				if ((y - sum) % 1000 == 0) {
					if ((y - sum) / 1000 == n - i - j) {
						cout << i << " " << j << " " << (n- j-i)<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "-1" << " " << "-1" << " " << "-1";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

string s, t;
int main() {
    cin>>s>>t;
    cout<<t<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>
using namespace std;

int main(){
	cout << fixed << setprecision(10);
	const long double EPS=1e-8;
	long double Re,Im;
	int q;
	complex<long double>p1,p2;
	
	cin>>Re>>Im;
	p1.real(Re);
	p1.imag(Im);
	cin>>Re>>Im;
	p2.real(Re);
	p2.imag(Im);
	cin>>q;
	
	for(int i=0;i<q;i++){
		cin>>Re>>Im;
		complex<long double>tmp(Re,Im),p1_copy=p1,p2_copy=p2;
		
		
		tmp-=p1_copy;
		p2_copy-=p1_copy;
		complex<long double>p1_re=p1_copy;
		p1_copy-=p1_copy;
		tmp=tmp/p2_copy;
		complex<long double>p2_re=p2_copy;
		p2_copy=p2_copy/p2_copy;
      
        

		if(tmp.imag()>EPS){
			cout<<"COUNTER_CLOCKWISE"<<endl;
		}else if(tmp.imag()<-EPS){
			cout<<"CLOCKWISE"<<endl;
		}else if(tmp.real()<p1_copy.real()){
			cout<<"ONLINE_BACK"<<endl;
			
		}else if(tmp.real()<=p2_copy.real()){
			cout<<"ON_SEGMENT"<<endl;
		}else{
			cout<<"ONLINE_FRONT"<<endl;
		}
	}
	
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; ++i) cin >> a[i] >> b[i];

	int m=h+*max_element(a.begin(),a.end());
	vector<int> dp(m, 1e9);
	dp[0]=0;
	for(int i=1; i<m; ++i){
		for(int j=0; j<n; ++j){
			if(a[j]>i) continue;
			dp[i]=min(dp[i],b[j]+dp[i-a[j]]);
		}
	}

	cout << *min_element(dp.begin()+h,dp.end()) << endl;
}

Measured memory_bytes: 384
<?php
      
    	$n = explode(" ",fgets(STDIN));
		$j = (int)$n[2] - (int)$n[1];
		$judge = $j+1;
		$array = array_fill(0, $n[0], 0);

		if($j >= 0){
          for($i =0; $i<$n[2]; $i++){
			$tmp = fgets(STDIN);
            $array[$tmp-1] += 1;
          }
		  for($i =0; $i<$n[0]; $i++){
             if($array[$i] >= $judge){
              	 echo "Yes"."\n" ;
             }else{
                echo "No"."\n" ; 
             }
          } 
        }else{
			for($i =0; $i<$n[0]; $i++){
                echo "Yes"."\n" ;
          } 
        }

?>

Measured memory_bytes: 16372
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Factor_L(T N, T fac[], int fs[]){
  T i;
  int sz=0;
  if(N%2==0){
    fac[sz] = 2;
    fs[sz] = 1;
    N /= 2;
    while(N%2==0){
      N /= 2;
      fs[sz]++;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      fac[sz] = i;
      fs[sz] = 1;
      N /= i;
      while(N%i==0){
        N /= i;
        fs[sz]++;
      }
      sz++;
    }
  }
  if(N > 1){
    fac[sz] = N;
    fs[sz] = 1;
    sz++;
  }
  return sz;
}
template<class T> int Divisor_L(T N, T res[], void *mem = wmem){
  T *fc;
  int *fs, fsz, i, j, k, s, sz=0;
  fc = (T*)wmem;
  fs = (int*)(fc+100);
  fsz =Factor_L(N, fc, fs);
  res[sz++] = 1;
  for(i=0;i<fsz;i++){
    s = sz;
    k = s * fs[i];
    for(j=0;j<k;j++){
      res[sz++] = res[j] * fc[i];
    }
  }
  sort(res, res+sz);
  return sz;
}
char memarr[96000000];
int N;
int M;
int d[10000];
int ds;
int main(){
  int i, res;
  wmem = memarr;
  rd(N);
  rd(M);
  ds =Divisor_L(M, d);
  for(i=0;i<ds;i++){
    if( (long long)d[i]*N > M ){
      break;
    }
    res = d[i];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, M;
// 
// int d[10000], ds;
// {
//   int i, res;
// 
//   rd(N,M);
//   ds = Divisor(M, d);
// 
//   rep(i,ds){
//     if( (ll)d[i]*N > M ) break;
//     res = d[i];
//   }
// 
//   wt(res);
// }


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

def main(N,A,B,C):
    ans = 0
    olda = float("INF")
    for a in A:
        if a - olda == 1:
            ans += C[olda]
        olda = a
    print(ans+sum(B))
        

if __name__ == '__main__':
    N = int(input())
    A = [int(a)-1 for a in input().split()]
    B = [int(a) for a in input().split()]
    C = [int(a) for a in input().split()]
    main(N,A,B,C)

Measured memory_bytes: 3064
import fractions

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

A,B,C,D = map(int,input().split())

#0からわりきれる
x0 = B//C
y0 = B//D
z0 = B//lcm(C,D)

all0 = x0+y0-z0
all0 = B-all0

#それ以下から
x1 = (A-1)//C
y1 = (A-1)//D
z1 = (A-1)//lcm(C,D)
all1 = x1+y1-z1
all1 = A-1-all1


print(all0-all1)


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

typedef vector<int> VI;
typedef vector<VI> VVI;

#define PB push_back

VI PS, QS, AS, NS, cnts;
int P, Q, A, N;
int T;

VVI have_n_ts;

int p_, q_;

// p / q

constexpr int MEMO_LIMIT = 3000;
int memo[MEMO_LIMIT][MEMO_LIMIT] = {};

// require: m > n
inline int gcd(int m, int n) {
    if (m < n) return gcd(n, m);
    if (m < MEMO_LIMIT && memo[m][n]) return memo[m][n];

    int r = m % n;

    if (!r) {
        if (m < MEMO_LIMIT) memo[m][n] = n;
        return n;
    } else {
        int ans = __gcd(n, r);
        if (m < MEMO_LIMIT) memo[m][n] = ans;
        return ans;
    }
}

inline void yakubun(int &p, int &q) {
    int c = gcd(p, q);
    if (c == 1) return;
    p /= c;
    q /= c;
}

inline void add(int p1, int q1, int p2, int q2, int &np, int &nq) {
    np = p1 * q2 + p2 * q1;
    nq = q1 * q2;
    if (np > 0) {
        yakubun(np, nq);
    }
}

inline void sub(int p1, int q1, int p2, int q2, int &np, int &nq) {
    add(p1, q1, -1 * p2, q2, np, nq);
}

int np, nq;
inline void dfs(int p, int q, int a, int n, int before) {
    if (a > 12000) return;

    for (int t : have_n_ts[n]) {
        cnts[t] += a <= AS[t] && p == PS[t] && q == QS[t];
    }
    
    if (n >= 7) return;

    for (int i = before; i * a <= 12000; i++) {
        add(p, q, 1, i, np, nq);
        dfs(np, nq, a * i, n + 1, i);
    }
}

int main(void) {
    have_n_ts.resize(8);
    T = 0;
    while (cin >> P >> Q >> A >> N, P) {
        yakubun(P, Q);
        PS.PB(P);
        QS.PB(Q);
        AS.PB(A);
        NS.PB(N);
        for (int i = 1; i <= N; i++) {
            have_n_ts[i].PB(T);
        }
        ++T;
    }

    cnts.resize(T);

    dfs(0, 1, 1, 0, 1);

    for (auto cnt : cnts) cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 35136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;
typedef string::const_iterator State;

int expression1(State &begin);
int expression2(State &begin);
int term(State &begin);
int number(State &begin);

int expression1(State &begin){
    int ret=number(begin);
    
    for(;;){
        if(*begin=='+') ret+=number(++begin);
        else if(*begin=='*') ret*=number(++begin);
        else break;
    }
    
    return ret;
}

int expression2(State &begin){
    int ret=term(begin);
    
    for(;;){
        if(*begin=='+') ret+=term(++begin);
        else break;
    }
    
    return ret;
}

int term(State &begin){
    int ret=number(begin);
    
    for(;;){
        if(*begin=='*') ret*=number(++begin);
        else break;
    }
    
    return ret;
}

int number(State &begin){
    int ret=0;
    
    while(isdigit(*begin)){
        ret*=10;
        ret+=*begin-'0';
        
        begin++;
    }
    
    return ret;
}
 
int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    
    State a=S.begin(),b=a;
    int A=expression1(a),B=expression2(b);
    
    int T;cin>>T;
    
    if(A==T&&B==T) cout<<"U"<<endl;
    else if(A==T) cout<<"L"<<endl;
    else if(B==T) cout<<"M"<<endl;
    else cout<<"I"<<endl;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  int max = *max_element(l.begin(),l.end());
  int sum = accumulate(l.begin(),l.end(),0);
  if(max<sum-max){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
  return 0;
}

Measured memory_bytes: 256