akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#define MIN_MAX 1200001
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    vi C(n);
    vvi A(n, vi(m));
    for(int i=0; i<n; i++){
        cin >> C[i];
        for(int &a : A[i]) cin >> a;
    }
    int min = MIN_MAX;
    for(int bit=0; bit<1<<n; bit++){
        int sumC = 0;
        vi sumA(m);
        for(int i=0; i<n; i++)if(bit & 1<<i){
            sumC += C[i];
            for(int j=0; j<m; j++) sumA[j] += A[i][j];
        }
        bool suc = true;
        for(int &a : sumA)if(a<x){suc = false; break;}
        if(suc && sumC < min) min = sumC;
    }
    if(min < MIN_MAX) cout << min << '\n';
    else cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cmath>

#define N 100
#define S 1000

using namespace std;

int main(){

  int n, s;
  long long int soi[10][S + 1] = {};
	
	soi[1][0] = 1;
	
	for(int i=1; i<=N; i++){
		for(int j=8; j>0; j--){
			for(int k=0; k<=S; k++){
				if(soi[j][k] != 0){
					soi[j+1][k + i] += soi[j][k];
				}
			}
		}
		soi[1][i] = 1;
	}
	
	while(1){
		cin >> n >> s;
		if(n == 0 && s == 0) break;
		
		cout << soi[n][s] << endl;
		
	}

  return 0;

}

Measured memory_bytes: 1244
#include<iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){

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

  if((a+b)%2==0)printf("%d\n",(a+b)/2);
  else printf("%d\n",1+(a+b)/2);

  return 0;

}


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

int main(){
    int n;
    cin >> n;
    auto t = vector<int>(n,0);
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    int m;
    cin >> m;
    auto p = vector<int>(m,0);
    auto x = vector<int>(m,0);
    for(int i=0;i<m;i++){
        cin >> p[i] >> x[i];
    }
    for(int i=0;i<m;i++){
        long long ans = 0;
        for(int j=0;j<n;j++){
            if(j==p[i]-1){
                ans += x[i];    
            }else{
                ans += t[j];
            }
        }
        cout << ans << endl;
     }
    
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, H = mapint()
from heapq import heappop, heappush
Q = []
for _ in range(N):
    a, b = mapint()
    heappush(Q, (-a, 'N'))
    heappush(Q, (-b, 'L'))

ans = 0
while H>0:
    v, ty = heappop(Q)
    v *= -1
    if ty=='N':
        print(ans-(-H//v))
        exit()
    H -= v
    ans += 1
print(ans)

        

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;





int main() {
    int n,k;cin >> n >> k;
    int ans = 0;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        vec.push_back(x);
    }
    sort(vec.begin(),vec.end());
    for(int i = 0;i < k;i++) ans+= vec[i];
    cout << ans;
    
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[BITLE(16)][5];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin>>n,n){
    vi hoge;
    for(int i=1;(i*i)<=SHIFT_LEFT(16);i++){
      hoge.pb(i*i);
    }
    for(int i=0;i<BITLE(16);i++)
      for(int j=0;j<5;j++)
	dp[i][j] = 0;
    dp[0][0] = 1;
    for(int i=0;i<hoge.size();i++){
      for(int j=0;j<SHIFT_LEFT(15);j++){
	if(j+hoge[i] > SHIFT_LEFT(15))break;
	for(int k=0;k<4;k++){
	  dp[j+hoge[i]][k+1] += dp[j][k];
	}
      }
    }
    ll ans = 0;
    for(int i=0;i<=4;i++)ans += dp[n][i];
    cout<<ans<<endl;
  }
  return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << " " << 2 * (a + b) << endl;
  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef long long int lli;


int memo[1000010] = {0,0,1};
double PI = 3.14159265359;

lli MOD = 10e9+7;

int main(void){
    
    string str;
    cin >> str;
    
    str[5] = ' ';
    str[13] = ' ';
    
    cout << str << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int dp[100000];
long long int n,k;
int find(vector<int> &v, int i)
{
	if(i+1>=n&&i+2>=n) return 0;
	if(dp[i] != -1) return dp[i];
	int jump=1e9;
	for(int j = 1;j<=k;j++)
		if(i+j<n) 
			jump =	min (jump,abs(v[i] - v[i+j]) + find(v,i+j));

	return dp[i] = jump;
}


int main()
{
	// fio;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin); 
	// freopen("output.txt", "w", stdout); 
	// freopen("error.txt", "w", stderr); 
	// #endif
	long long int x;
	cin>>n>>k;
	vector<int> v;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		cin>>x;
		v.push_back(x);
	}
	cout<<find(v,0)<<"\n";

}

Measured memory_bytes: 10488
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;
    ll sum = 0;
    for (char &c: s) sum += c - '0';
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  string s="Three";
  rep(i,0,n){
    char c;
    cin>>c;
    if(c=='Y') s="Four";
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define S 6000
#define A 4000
#define B 3000
#define C 2000

int main()
{

	int t, n, val[4];

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

		scanf( "%d %d", &t, &n );
		if( t == 1 ) val[i] = S * n;
		else if( t == 2 ) val[i] = A * n;
		else if( t == 3 ) val[i] = B * n;
		else val[i] = C * n;

	}

	for( int i = 0; i < 4; i++ ) printf( "%d\n", val[i] );

	return 0;

}

Measured memory_bytes: 1028
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    s = LI()
    t = LI()
    a = [[1 if i==j else 0 for j in t] for i in s]
    u = [0] * m
    for i in range(n):
        c = a[i]

        for j in range(1,m):
            if c[j] == 1:
                c[j] += u[j-1]

        e = c[:]
        for j in range(1,m):
            e[j] += e[j-1]
            e[j] %= mod

        if i > 0:
            for j in range(m):
                e[j] += u[j]
                e[j] %= mod
        u = e

    r = sum(map(lambda x: sum(x) % mod, a)) + 1

    return r % mod


print(main())





Measured memory_bytes: 102616
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		double a,b,c,d,e,f,y,x;
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			a = sc.nextDouble();
			b = sc.nextDouble();
			c = sc.nextDouble();
			d = sc.nextDouble();
			e = sc.nextDouble();
			f = sc.nextDouble();
			y = (c*d - f*a) / (b*d - e*a);
			x = (c*e - f*b) / (a*e - d*b);
			if(x==-0) x=0;
			if(y==-0) y=0;
			System.out.printf("%1.3f %1.3f\n",x,y);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int t=(a-1)/d,o=(c-1)/b;
	if(t>=o)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int l = 0;
		int m = -1;
		boolean[] f = new boolean[64];
		while ((line = br.readLine()) != null) {
			if (line.length() < 8)
				continue;
			for (int i = 0; i < 8; i++) {
				f[l * 8 + i] = line.charAt(i) == '1';
				if (m < 0 && f[l * 8 + i])
					m = l * 8 + i;
			}
			l++;
			if (l == 8) {
				if (f[m + 1]) {
					if (f[m + 2]) {
						System.out.println("C");
					} else if (f[m + 7]) {
						System.out.println("G");
					} else if (f[m + 8]) {
						System.out.println("A");
					} else {
						System.out.println("E");
					}
				} else if (f[m + 7]) {
					System.out.println("D");
				} else if (f[m + 16]) {
					System.out.println("B");
				} else if (f[m + 17]) {
					System.out.println("F");
				}
				l = 0;
				m = -1;
			}
		}
	}
}

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

using namespace std;

int main()
{
    float sum = 0 , z ;
    int n , m , cnt=0  , i;
    cin>>n>>m;
    float  a[n];
    for( i = 0 ; i < n ; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    z=sum/(4*m);
    for( i= 0 ; i < n ; i++)
    {
        if(a[i]>=z)cnt++;
    }
    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n;
	double res = 0.0, x;
	string u;
	cin >> n;
	REP(i, n) {
		cin >> x >> u;
		if (u == "JPY") res += x;
		else res += x * 380000;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=2e5+5;
int he[N],ver[N*2],nex[N*2],tot;
void addedge(int,int);

int a[N],de[N],top;

int st[N*4];
#define lc i<<1
#define rc i<<1|1
void update(int,int,int,int,int);
int query(int,int,int,int,int);

void dfs(int,int);
int ans[N];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],de[++top]=a[i];
    sort(de+1,de+top+1);
    top=unique(de+1,de+top+1)-de-1;
    for(int i=1;i<=n;i++) a[i]=lower_bound(de+1,de+top+1,a[i])-de;
    int u,v;tot=1;
    for(int i=1;i<n;i++){
        cin>>u>>v;
        addedge(u,v);
        addedge(v,u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';
}
void dfs(int u,int fa){
    int mx=a[u]==1?0:query(1,a[u]-1,1,top,1);
    mx++;
    int pre=query(a[u],a[u],1,top,1);
    if(pre<mx) update(a[u],1,top,1,mx);
    ans[u]=st[1];
    for(int i=he[u];i;i=nex[i]){
        int v=ver[i];
        if(v==fa) continue;
        dfs(v,u);
    }
    if(pre<mx) update(a[u],1,top,1,pre);
}
int query(int l,int r,int s,int e,int i){
    if(l<=s&&e<=r) return st[i];
    int mid=(s+e)/2,re=0;
    if(l<=mid) re=max(re,query(l,r,s,mid,lc));
    if(mid<r) re=max(re,query(l,r,mid+1,e,rc));
    return re;
}
void update(int index,int s,int e,int i,int x){
    if(s==e){
        st[i]=x;
        return;
    }
    int mid=(s+e)/2;
    if(index<=mid) update(index,s,mid,lc,x);
    else update(index,mid+1,e,rc,x);
    st[i]=max(st[lc],st[rc]);
}
void addedge(int u,int v){
    ver[tot]=v;nex[tot]=he[u];he[u]=tot++;
}


Measured memory_bytes: 24324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+5,inf=0x3f3f3f3f;
#define mst(a) memset(a,0,sizeof a)
ll a[N][N],ans[N],n;
void init(){
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++) a[i][j]=a[j][i]=j-i;
}
int main(){
	ll x,y;
	while(cin>>n>>x>>y){
		mst(a),mst(ans);
		init();
		 for(int i=1;i<n;i++)
		 	for(int j=i+1;j<=n;j++)
		 	{
		 		if(i<=x&&j>=y)
		 		{
		 			a[i][j]=min(a[i][j],x-i+j-y+1);
				}
				if(i>=x&&j>=y)
				{
						a[i][j]=min(a[i][j],i-x+1+j-y);
				}
				if(i>=x&&j<=y){
					a[i][j]=min(a[i][j],i-x+1+y-j);
				}
				if(i<=x&&j<=y)
				{
					a[i][j]=min(a[i][j],y-j+1+x-i);
				}
				ans[a[i][j]]++;
				//printf("a[%d][%d]=%d\n",i,j,a[i][j]);
			}
			for(int i=1;i<n;i++)
				printf(i==n-1?"%lld\n":"%lld ",ans[i]);
	}
	return 0;
} 

Measured memory_bytes: 31616
<?php
$n = (int)trim(fgets(STDIN));
$enemy = [];
$capacity = [];

$input = explode(' ', trim(fgets(STDIN)));
foreach ($input as $v) {
	$enemy[] = (int)$v;
}

$input = explode(' ', trim(fgets(STDIN)));
foreach ($input as $v) {
	$capacity[] = (int)$v;
}

$sum = 0;
for ($i=0; $i < $n; $i++) { 
	if ($enemy[$i] <= $capacity[$i]) {
		$sum += $enemy[$i];
		$original_next = $enemy[$i+1];
		$enemy[$i+1] = max(0, $enemy[$i+1] - ($capacity[$i] - $enemy[$i]));
		$sum += $original_next - $enemy[$i+1];
	}else{
		$sum += $capacity[$i];
	}
}
echo $sum;

Measured memory_bytes: 27116
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
// ctrl + cで実行


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

    string s;
    cin>>s;
    int n = s.size();
    int cnt[26]={};
    string t = "";
    for(int i=0;i<n;i++){
        cnt[s[i]-'a']++;
        if(s[i] != 'x') t += s[i];
    }
    for(int i=0;i<t.size();i++){
        if(t[i] != t[t.size()-1-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    int l = 0, r = n-1;
    int ans = 0;
    while(r>l){
        if(s[l]!=s[r]){
            ans++;
            if(s[l]=='x') l++;
            else r--;
        }
        else{
            r--;
            l++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 592
#include <iostream>

int main()
{
	bool flag[101];

	for (int i = 0; i < 101; ++i)
	{
		flag[i] = false;
	}

	int a, b, c;
	std::cin >> a >> b >> c;

	for (int i = 0; i < 101; ++i)
	{
		if (i == a || i == b || i == c)
		{
			flag[i] = true;
		}
	}

	int cnt = 0;
	for (int i = 0; i < 101; ++i)
	{
		if (flag[i]) cnt++;
	}

	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

char input[128];

int main(void) {
	int i, j, k;
	int ans = 0;
	char temp[8];

	while(scanf("%s", input) != EOF) {
		i = 0;
		while(input[i]) {
			for(; (input[i] < '0' || '9' < input[i]) && input[i]; i++);

			if('0' <= input[i] && input[i] <= '9') {
				for(j = 0; '0' <= input[i] && input[i] <= '9'; j++, i++) {
					temp[j] = input[i];
				}

				temp[j] = '\0';
				ans += atoi(temp);
			}
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
P a[214514];
signed main() {
	ll n, ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i].second >> a[i].first;
	sort(a, a + n);
	rep(i, n) {
		ans += a[i].second;
		if (ans > a[i].first) {
			puts("No");
			ggr
		}
	}
	puts("Yes");
	ggr
}



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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<n; i++)


int main() {
    int K;
    cin >> K;
    int hai [] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << hai[K-1] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ios_base::sync_with_stdio(false);
#define MAXN 500005          // cin.tie(NULL);
#define di pair<int, int>
#define tri pair<int, di>
#define bi pair<bool, int>
using namespace std;
void swap(int ar[],int  i,int j)
    {int aux = ar[j]; ar[j] = ar[i]; ar[i] = ar[j];}

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

    if(A >= 6 && A<= 12)
        cout << B/2;
    else if(A <= 5)
        cout << 0;
    else
        cout << B;
    
    
    
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	y := intScanner()
	if y == 1 {
		fmt.Println("Hello World")
	} else {
		fmt.Println(intScanner() + intScanner())
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int a,b,x;
	cin >> a >> b >> x;
	if (a == x)
	{
		cout << "YES\n"; return 0;
	}
	else if (a < x &&  a + b >= x)
	{
		cout << "YES\n"; return 0;
	}
	cout << "NO\n";
	return (0);
}


Measured memory_bytes: 256
import sys
import collections
import bisect


def main():
    n = int(input())
    a = [str(i + 1)[0] + str(i + 1)[-1] for i in range(n)]
    b = [str(i + 1)[-1] + str(i + 1)[0] for i in range(n)]
    ac, bc = collections.Counter(a), collections.Counter(b)
    print(sum(ac[i] * bc[i] for i in ac.keys()))


if __name__ == '__main__':
    main()


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            double money = 100000;

            for (int i = n; i > 0; i--)
            {
                money *= 1.05d;

                money = Math.Ceiling(money / 1000) * 1000;
            }
            Console.WriteLine(money);
        }
    }
}

Measured memory_bytes: 9104
#include <iostream>

int main()
{
	char a, b, c, d, e, f;
	std::cin >> a >> b >> c >> d >> e >> f;
	if (a == f&&b == e&&c == d) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int Q = Integer.parseInt(sc.next());

        int countAnswer = Q - K;
        Map<Integer, Integer> scoreMap = new HashMap<>();
        for (int i = 0; i < Q; i++) {
            int ans = Integer.parseInt(sc.next());
            int score = scoreMap.getOrDefault(ans, 0);
            scoreMap.put(ans, score + 1);
        }

        for (int i = 1; i <= N; i++) {
            if (scoreMap.getOrDefault(i, -countAnswer) <= countAnswer) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 54792
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	int N;
    cin >> N;
    int H[N+1];
    for(int i=1;i<=N;i++)cin >> H[i];
    int dp[N+1];
    dp[N]=0;
    int Ans=dp[N];
    for(int i=1;i<N;i++){
        if(H[N-i+1]<=H[N-i])dp[N-i]=dp[N-i+1]+1;
        else dp[N-i]=0;
        Ans=max(Ans,dp[N-i]);
    }
    cout << Ans << endl;
}

Measured memory_bytes: 4316
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<int> x(n), y(n);
	vector<P> v(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
		v[i].first = x[i];
		v[i].second = y[i];
	}

	sort(v.begin(), v.end());

	int ans = INF;
	rep(i, n) {
		REP(j, i+1, n) {
			int x = v[i].first, y = v[i].second;
			int x2 = v[j].first, y2 = v[j].second;
			int d = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y);
			if((x2 - x) * (x2 - x) > ans) break;
			ans = min(ans, d);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8856
#include <stdio.h>
int main()
{
  int n,i;
  unsigned long int debt_price;
  scanf("%d",&n);
  debt_price = 100000;
  for(i=0; i<n; i++){
       debt_price *= 1.05;
       if(debt_price % 1000 )
       debt_price =(debt_price/1000+1)*1000;
       }
  printf("%lu\n",debt_price);
  return 0;
}    

Measured memory_bytes: 596
A, B = map(str, input().split())

D = {'A':1, 'B':2, 'C':3, 'D':4, 'E':5, 'F':6}
if D[A] < D[B]:
    print('<')
elif D[A] > D[B]:
    print('>')
else:
    print('=')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

//////検証する数,超えられない数////

long long cine(long long a, long long b) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
};
//vector型の初期化

void vec_initialize(vector<ll>& a, const ll N) {
	ll c;

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

		cin >> c;
		a.push_back(c);

	}

};
void vec_pair_initialize(vector<pair<ll, ll>>& a, const ll N) {
	ll c, d;
	for (int i = 0; i < N; i++) {
		cin >> c >> d;
		a.push_back(make_pair(c, d));
	}
};
int main() {
	ll X;
	cin >> X;
	ll money = 100;
	ll year = 0;
	while (1) {
		year++;
		money += money * 0.01;
		if (money >= X) {

			break;
		}

	}
	cout << year;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 302, M = 998244353;

int n, k;
char a[N];

vector<int> v;

int dp[N][N][N];

void solv()
{
    scanf(" %s", a);
    n = strlen(a);
    scanf("%d", &k);
    /*n = 300;
    for (int i = 0; i < n; ++i)
    {
        a[i] = rnd() % 2 + '0';
        if (i < n / 2)
            a[i] = '0';
        else
            a[i] = '1';
    }
    k = 300;*/
    int maxk = 0;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == '1')
            ++maxk;
    }
    k = min(k, maxk);
    int q = 0;
    for (int i = n - 1; i >= 0; --i)
    {
        if (a[i] == '0')
        {
            v.push_back(q);
            q = 0;
        }
        else
            ++q;
    }
    v.push_back(q);
    dp[0][k][0] = 1;
    for (int i = 0; i < v.size(); ++i)
    {
        for (int kk = 0; kk <= k; ++kk)
        {
            for (int q = 0; q <= k - kk; ++q)
            {
                if (dp[i][kk][q] == 0)
                    continue;
                for (int u = 0; u <= v[i]; ++u)
                {
                    if (kk - u < 0)
                        break;
                    dp[i + 1][kk - u][q + u] = (dp[i + 1][kk - u][q + u] +
                                                dp[i][kk][q]) % M;
                }
                for (int u = 1; u <= q; ++u)
                {
                    dp[i + 1][kk][q - u] = (dp[i + 1][kk][q - u] +
                                            dp[i][kk][q]) % M;
                }
            }
        }
    }
    int ans = 0;
    for (int kk = 0; kk <= k; ++kk)
        ans = (ans + dp[v.size()][kk][0]) % M;
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


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

using namespace std;

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) return 0;
        for (int i = 0; i < h; ++i) {
            if (i == 0 || i == h - 1) {
                for (int j = 0; j < w; ++j) {
                    cout << '#';
                }
            } else {
                cout << '#';
                for (int j = 0; j < w - 2; ++j) {
                    cout << '.';
                }
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include<stdio.h>
int main(){
  char s[102];
  int i,j;
  while(scanf("%s",s)!=EOF){
    for(i=0;s[i];i++){
      if(s[i]=='@'){
	for(j=0;j<s[i+1]-'0';j++)printf("%c",s[i+2]);
	i+=2;
      }
      else printf("%c",s[i]); 
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,ans=0;
struct node{
	ll a,b;
	ll cha(){return b-a;}
};
node s[200010];
struct qnode{
	ll x;
	ll pre(){return (x+1)%n;}
	ll nxt(){return (x+n-1)%n;}
};
bool operator<(qnode aa,qnode bb){
	return s[aa.x].b<s[bb.x].b;
}
priority_queue<qnode> q;
int main(){
	//ios_base::sync_with_stdio(false);
	cin>>n;
	
	for(ll i=0;i<n;i++)cin>>s[i].a;
	for(ll i=0;i<n;i++)cin>>s[i].b;
	for(ll i=0;i<n;i++)
	if(s[i].cha()<0){
		cout<<-1<<endl;
		return 0;
	}
	else if(s[i].cha()>0)
		q.push((qnode){i});
	while(1){
		if(q.empty()){
			cout<<ans<<endl;
			break;
		}
		qnode x=q.top();
		q.pop();
		
		ll xx=s[x.pre()].b+s[x.nxt()].b;
		ll y=max(s[x.pre()].b,s[x.nxt()].b);
		ll cnt=s[x.x].cha()/xx;
		cnt=min(cnt,(s[x.x].b-y)/xx+1);
		
		if(cnt<=0){
			cout<<-1<<endl;
			return 0;
		}
		ans+=cnt;
		s[x.x].b-=cnt*(s[x.pre()].b+s[x.nxt()].b);
		if(s[x.x].cha()!=0)
			q.push(x);
	}
	return 0;
}


Measured memory_bytes: 6516
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;

int main(){

int x,a,b;
	
	cin>>x>>a>>b;
	
	if(b<=a)cout<<"delicious"<<endl;
	else if(b-a<=x)cout<<"safe"<<endl;
	else cout<<"dangerous"<<endl;
	
	return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
		int A=in.nextInt();
		int B=in.nextInt();
		int C=in.nextInt();
		int K=in.nextInt();
		int sum=0;
		if (K<=A && K<=(A+B)) {
			sum=K;
			System.out.println(sum);
		}else {
			int s =K-(A+B);
			sum =A-s;
			System.out.println(sum);
			
		}
	}
}

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

using namespace std;

#define ll long long

/* aとbの最大公約数を求める. */
ll gcd(ll a, ll b) {
	if (b > a) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

/* ax+by=gcd(a,b)を満たす(x,y)を格納し、gcd(a,b)を返す. */
ll extgcd(ll a, ll b, ll& x, ll& y) {
	if (b > a) return extgcd(b, a, y, x);
	if (b == 0) {
		x = 1; y = 0;
		return a;
	}
	ll g = extgcd(b, a % b, y, x);
	y -= (a / b) * x;
	return g;
}

/* mod mでのaの逆元を求める.(gcd(a,m) = 1) */
ll modinv(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

/* 連立線形方程式を解く.
		A[i] * x ≡ B[i] (mod M[i])
	なる方程式の解が
		x ≡ b (mod m)
	とかけるとき、(b, m)を返す.(存在しなければ(0, -1)) */
pair<ll, ll> liner_congruence(
	vector<ll> A, vector<ll> B, vector<ll> M
) {
	ll x = 0, m = 1;

	for (int i = 0; i < A.size(); ++i) {
		ll a = A[i] * m,
			b = B[i] - A[i] * x,
			d = gcd(M[i], a);

		if (b % d != 0) // 解なし
			return make_pair(0, -1);

		ll t = b / d * modinv(a / d, M[i] / d) % (M[i] / d);
		x = x + m * t;
		m *= M[i] / d;
	}

	return make_pair(x % m, m);
}

signed main() {
	int n; cin >> n;
	vector<int> p(n), q(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	for (int i = 0; i < n; ++i)
		cin >> q[i];

	// dp[i][j] := 数字iがj日後に何に書き換わるか
	int dp[201][201];
	for (int i = 1; i <= n; ++i) // 初期化
		dp[i][0] = i;
	for (int j = 1; j <= 200; ++j)
		for (int i = 1; i <= n; ++i)
			dp[i][j] = q[dp[i][j - 1] - 1];

	// i番目の数字について、
	// ・B[i-1]日後に初めてiになり、
	// ・M[i-1]日周期で数字が繰り返す
	// を求める.(i=1,2,...,n)
	vector<ll> B(n);
	for (int i = 1; i <= n; ++i) {
		B[i - 1] = -1;
		int pi = p[i - 1]; // 0日目の数字
		for (int j = 0; j <= 200; ++j) {
			if (dp[pi][j] == i) {
				B[i - 1] = j;
				break;
			}
		}
		if (B[i - 1] == -1) { // iになることがなければ-1
			cout << -1 << endl;
			return 0;
		}
	}

	vector<ll> M(n);
	for (int i = 1; i <= n; ++i) {
		M[i - 1] = -1;
		int pi = p[i - 1]; // 0日目の数字
		for (int j = 1; j <= 200; ++j) {
			if (dp[pi][j] == pi) {
				M[i - 1] = j;
				break;
			}
		}
	}

	vector<ll> A(n, 1);
	auto ans = (liner_congruence(A, B, M));
	if (ans.second == -1) {
		cout << -1 << endl;
	}
	else if (ans.first >= 0) {
		cout << ans.first << endl;
	}
	else {
		cout << (ans.first + ans.second) << endl;
	}

	return 0;
}


Measured memory_bytes: 3336
#include <algorithm>
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	int P[8], Q[8];
	for (int i = 0; i < N; i++) {
		scanf("%d", &P[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &Q[i]);
	}
	int p, q;
	vector<int> series;
	for (int i = 0; i < N; i++) {
		series.push_back(i + 1);
	}
	int order = 1;
	do {
		bool pflag = true, qflag = true;
		for (int i = 0; i < N; i++) {
			if (series[i] != P[i]) pflag = false;
			if (series[i] != Q[i]) qflag = false;
		}
		if (pflag) p = order;
		if (qflag) q = order;
		order++;
	} while (next_permutation(series.begin(), series.end()));
	printf("%d\n", abs(p - q));

	return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <set>
const int inf = 0x3f3f3f3f;
typedef long long ll;
const ll INF_LL  = 1e18;
using namespace std;
int mou[25],maxn[25];
int main(){
	ios::sync_with_stdio(false);
int n,cnt=1;
cin>>n;
for(int i=0;i<n;i++){
	cin>>mou[i];
		maxn[i]=max(mou[i],maxn[i-1]);
	}
for(int i=1;i<n;i++){
	if(mou[i]>=maxn[i])cnt++;
}
cout<<cnt;
return 0;
}


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

int main() {
	int a, b;
	char op;
	for (int i = 0; ; i++) {
		cin >> a >> op >> b;
		if (op == '?') break;
		if (op == '+') cout << a + b << endl;
		if (op == '-') cout << a - b << endl;
		if (op == '*') cout << a * b << endl;
		if (op == '/') cout << a / b << endl;
	}
}


Measured memory_bytes: 3104
N = int(input())
LIST =[input() for _ in range(N)]
AC = LIST.count("AC")
WA = LIST.count("WA")
TLE = LIST.count("TLE")
RE = LIST.count("RE")
print(f"AC x {AC}\nWA x {WA}\nTLE x {TLE}\nRE x {RE}")

Measured memory_bytes: 16280
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = np.array([list(map(int, input().split())) for _ in range(N)])
cnt = 0
for a in A:
    if sum(a*B) + C > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 26808
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int i,j;
int N;
cin >> N;
vector<string> S;
string SS;
int P[N];
int ans[N];
for(i=0;i<N;i++){
  cin >> SS >> P[i];
  S.push_back(SS);}
int count=1;
for(i=0;i<N;i++){
    count = 1;
for(j=0;j<N;j++){
if(i==j)continue;
else{
  if(S[i]>S[j])count++;
  else if(S[i]==S[j]){
      if(P[i]<P[j])count++;
  }}}
 ans[count-1]=i+1;
}
for(i=0;i<N;i++)cout << ans[i]<<endl;
}

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

int main(){
  while(1){
  int m[300000]={};
  int count=0;
  int n;
  cin>>n;
  if(n==0) break;
  m[1]=1;
  for(int j=2;j<=sqrt(2*n);j++){
    if(m[j]==0){
      for(int i=2;i<=(2*n)/j;i++){
    m[i*j]=1;
    }
    }
  }
  for(int i=n+1;i<=2*n;i++)    if(m[i]==0)count++;
  cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 2340
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens()) {
				String cad = br.readLine();
				if (cad == null)
					return null;
				tk=new StringTokenizer(cad);
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public long nextLong() throws NumberFormatException, IOException{
			return Long.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}
	
	public static void main(String args[]) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int run = 0;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			int c = sc.nextInt() - 1;
			if (c == i)
				run++;
			else {
				ans += (run + 1) / 2;
				run = 0;
			}
		}
		ans += (run + 1) / 2;
		System.out.println(ans);
	}

}


Measured memory_bytes: 35868
fn main(){
	fn f(n: Vec<i32>) -> &'static str{
		if n[0] < n[1]      { "<" }
		else if n[0] > n[1] { ">" }
		else                { "==" }
	}
    
    println!("a {} b", f(read_vec::<i32>()));
}
  
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5032
A, B, C = list(map(int, input().split()))
H = [A, B, C]
S = [A%2, B%2, C%2]

def kouhan(l):
  ans = (3 * max(l) - sum(l)) //2
  return ans

if S == [0,0,0] or S == [1,1,1]:
  count = kouhan(H)
  
elif S.count(1) == 2:
  for i in range(3):
    if H[i]%2 == 1:
      H[i] += 1
  count = 1
  count += kouhan(H)
  
elif S.count(1) == 1:
  for i in range(3):
    if H[i]%2 == 0:
      H[i] += 1
  count = 1
  count += kouhan(H)


print(count)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int[][] a = new int[h][w];
		for (int i = 0; i < h; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < w; j++) {
				a[i][j] = Integer.parseInt(sa[j]);
			}
		}
		int[][] b = new int[h][w];
		for (int i = 0; i < h; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < w; j++) {
				b[i][j] = Integer.parseInt(sa[j]);
			}
		}
		br.close();

		int[][] c = new int[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				c[i][j] = Math.abs(a[i][j] - b[i][j]);
			}
		}

		boolean[][][] d = new boolean[h][w][6401];
		d[0][0][c[0][0]] = true;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i > 0) {
					for (int k = 0; k <= 6400 - c[i][j]; k++) {
						if (d[i - 1][j][k]) {
							d[i][j][Math.abs(k - c[i][j])] = true;
							d[i][j][k + c[i][j]] = true;
						}
					}
				}
				if (j > 0) {
					for (int k = 0; k <= 6400 - c[i][j]; k++) {
						if (d[i][j - 1][k]) {
							d[i][j][Math.abs(k - c[i][j])] = true;
							d[i][j][k + c[i][j]] = true;
						}
					}
				}
			}
		}

		for (int i = 0; i <= 6400; i++) {
			if (d[h - 1][w - 1][i]) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 82120
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int lds(vector<int> &v) {
	for (int &a : v)a = -a;
	vector<int> dp(v.size() , 1<<30);
	for (int &a : v) {
		*upper_bound(dp.begin(), dp.end(), a) = a;
	}
	return lower_bound(dp.begin(), dp.end(), 1 << 30) - dp.begin();
}


int a[100000];


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

	int n, t;
	cin >> n >> t;
	int mi = 1 << 30;
	int ma = 0;
	rep(i,n) {
		cin >> a[i];
		ma = max(ma, a[i] - mi);
		mi = min(mi, a[i]);
	}
	map<int, vector<int>> vv;
	rep(i, n) {
		vv[a[i] % ma].push_back(a[i]);
	}
	int ans = 0;
	for (auto p: vv) {
		ans += p.second.size() - lds(p.second);
	}
	cout << ans << endl;

	


	return 0;
}

Measured memory_bytes: 11648
n=int(input())
l=sorted(list(map(int, input().split())))

ans=0
for i in range(len(l)):
    for j in range(i+1, len(l)):
        for k in range(j+1, len(l)):
            if l[i]==l[j] or l[j]==l[k] or l[k]==l[i]:
                continue
            if l[i]+l[j]>l[k]:
                ans+=1
print(ans)

Measured memory_bytes: 9092
#include<bits/stdc++.h>
#include<map>
#include<iosfwd>
#include<ios>
#include<istream>
#include<sstream>
#include<complex>
#include<ccomplex>
using namespace std;
typedef pair<int,int> P;
map<P,int> mp;
int main()
{
	int n;
	cin>>n;
	vector<P> vp;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		vp.push_back(make_pair(x,y));
	}
	int sum = 0;
//	cout<<n<<endl;
	for(int i=0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			int dx = vp[j].first - vp[i].first;
			int dy = vp[j].second - vp[i].second;
			mp[P(dx,dy)]++;
			mp[P(-dx,-dy)]++;
//			cout<<i<<endl;
		}
	}
	for(map<P,int>::iterator it = mp.begin();it!=mp.end();it++)
	{
		if(it->second>sum)
			sum = it->second;
	}
	cout<<n-sum<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int k,a,b;
	int i,j;
	scanf("%d %d %d",&k,&a,&b);
	i=1;
	while(1){
		i=k*j;
		j++;
		if(i>=a&&i<=b){
			printf("OK\n");
			break;
		}
		else if(i>=b){	
			printf("NG\n");
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <string>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;


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

    int ans_rate = 0;

    if(N>=10) {
        ans_rate = R;
    } else
    {
        ans_rate = R + 100*(10-N);
    }
    
    cout << ans_rate << endl;

    return 0;
  
}


Measured memory_bytes: 256
N = int(input())
nums = list(map(int, input().split()))

# 解説の通りに実装
num_max = 10 ** 6 + 5  # 制限の上限で配列を用意しておく（わざわざmax()の計算しない）
exist_counts = [0] * num_max
for num in nums:
  # すでにcountされてる場合、重複であることだけ残して抜ける
  if exist_counts[num]:
    exist_counts[num] = 2
    continue
  # はじめてのcountであれば、自分自身とその倍数にチェックをつける
  idx = num
  while idx < num_max:
    exist_counts[idx] += 1
    idx += num

# 各numについて、count=1ならば条件を満たしたということ
count = 0
for num in nums:
  if exist_counts[num] == 1:
    count += 1
print(count)

Measured memory_bytes: 32396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int mod=998244353;
long long dp[5003][5003];
long long lgput (long long val)
{
    long long exp=mod-2;
    long long rez=1;
    while(exp)
    {
        if(exp&1)
        {
            rez=(rez*1LL*val)%mod;
            exp^=1;
        }
        else
        {
            val=(val*1LL*val)%mod;
            exp>>=1;
        }
    }
    return rez;
}
long long cmmdc (long long a, long long b)
{
    long long r;
    while(b)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int v[200005];
int main()
{
    long long n,m,k,i,j,s=0,rz=0,a,b;
    cin>>n;
    if(n&1LL)
    {
        cout<<0;
        return 0;
    }
    s=5;
    n/=2LL;
    while(n)
    {
        rz+=n/s;
        n/=s;
    }
    cout<<rz;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[N];
		sc.fill(a);

		long count = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] > x) {
				count += a[i] - x;
				a[i] = x;
			}
		}
		for (int i = 1; i < N; i++) {
			if (a[i] + a[i - 1] > x) {
				int eat = (a[i] + a[i - 1]) - x;
				a[i - 1] -= Math.max(eat - a[i], 0);
				a[i] -= Math.min(a[i], eat);
				count += eat;
			}
		}

		System.out.println(count);
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

const int N = 1005, M = 5005;

int n, f[N], head[N], nxt[N], val[N];
void link(int x, int y) {nxt[y] = head[x], head[x] = y;}

int dfs(int x) {
	std::vector<int> q; int sum = 0, base = 0;
	for (int i = head[x]; i; i = nxt[i]) {
		int ret = dfs(i), d = std::abs(ret - val[i]);
		base += std::min(ret, val[i]), sum += ret + val[i];
		q.emplace_back(d);
	}
	static std::bitset<5000> b; b.reset(), b.set(0);
	if (base > val[x]) {std::cout << "IMPOSSIBLE\n", std::exit(0);}
	for (int d : q) b |= b << d; int lst = -1;
	for (int i = b._Find_first(); i <= val[x] - base; i = b._Find_next(i)) lst = i;
	return sum - base - lst;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 2, x; i <= n; ++i) std::cin >> x, link(x, i);
	for (int i = 1; i <= n; ++i) std::cin >> val[i];
	dfs(1), std::cout << "POSSIBLE\n";
	return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    x = inputInt()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38768