akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

    int A[N],B[N],C[N-1];

    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    rep(i,N-1){
        cin >> C[i];
    }
    
    int manzoku = 0;
    rep(i,N){
        manzoku += B[A[i]-1];
        if((A[i-1]+1 == A[i]) && (i != 0)){
            manzoku += C[A[i-1]-1];
        }
        //printf("%d %d\n",i,manzoku);
    }


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

    return 0;
}

Measured memory_bytes: 384
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

int main(){
	int n,m;cin >>n >> m;
	vector<pair<int,string>> da(m);
	rip(i,m,0) cin >> da[i].first >> da[i].second;
	vector<int> co(n);
	vector<bool> ju(n);
 	int ac = 0, wa = 0;
	rip(i,m,0){
		if(da[i].second == "AC"){
			ju[da[i].first-1] = true;
		}
		else{
			if(!ju[da[i].first-1])co[da[i].first-1] ++;
		}
	}
	rip(i,n,0){
		if(ju[i]){
			ac ++;
			wa += co[i];
		}
	}
	cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
long long int n,m,j,k,l,t,arr[1009],brr[1009],dp[20009],i,ans;
int main()
{
   for(i=1;i<=20004;i++)
    dp[i]=-1;
    ans=INT_MAX;
    scanf("%lld %lld",&n,&m);
    for(int i=0;i<m;i++)
        scanf("%lld %lld",&arr[i],&brr[i]);
    for(i=0;i<m;i++)
    {
        t=n/arr[i];
        if(n%arr[i])
            t++;
        t*=arr[i];
        for(j=arr[i];j<=t;j++)
        {
           if(dp[j-arr[i]]!=-1)
           {
               if(dp[j]==-1)
                dp[j]=dp[j-arr[i]]+brr[i];
               else
                dp[j]=min(dp[j],dp[j-arr[i]]+brr[i]);
                if(j>=n)
                    ans=min(ans,dp[j]);
           }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int a,b,c;
   cin>>a>>b>>c;
    int z=a+b+c;
    if(z>=22)
    {
       cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int Gcd(int x, int y)
	{
		if (x < y)
			std::swap(x, y);

		if (y == 0) {
			return x;
		}

		return Gcd(y, x % y);
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	//std::istream& stream = std::cin;

	auto values = GetValue<2>(stream);

	int x = values[0];
	int y = values[1];

	std::cout << Gcd(x, y) << std::endl;
}



Measured memory_bytes: 3192
#include<iostream>
#include<bits/stdc++.h>
#define ll                    long long int
#define fo(i,a,b)          for( i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define vi                    vector<ll>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>=y)?x:y
//#define min(x,y)              (x<=y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define start()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll min(ll x,ll y)
{
		return x<=y?x:y;
}

int main()
{
    ll x;
    cin>>x;
    ll ans=100;
    ll years=0;
    while(ans<x)
    {
        ans+=ans/100;
        years++;
    }
    cout<<years;

}

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
#define M 1000001
bool p[M];
int dish[31];
int dp[M];
int n, x;
int main()
{
	rep(i, M) p[i] = true;
	p[0] = p[1] = false;
	for (int i = 2; i * i < M; ++i)
		if (p[i]) for (int j = 2 * i; j < M; j += i)
			if (p[j]) p[j] = false;

	while (true) {
		scanf("%d%d", &n, &x);
		if ((n | x) == 0) break;
		rep(i, n) scanf("%d", dish + i);
		
		rep(j, x+1) dp[j] = -1;
		dp[0] = (1<<20);

		int k = 1;
		rep(i, n) REP(j, 1, x+1) {
			if (dp[j] >= 0)
				dp[j] = (1<<20);
			else if (j < dish[i] || dp[j-dish[i]] <= 0)
				dp[j] = -1;
			else
				dp[j] = dp[j-dish[i]] - 1;
		}
		int res = 0;
		rep(j, x+1) if (p[j] && dp[j] >= 0) res = j;
		if (res > 0)
			printf("%d\n", res);
		else
			puts("NA");
	}
	return 0;
}

Measured memory_bytes: 5644
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999

n = int(input())
A = [-INF] + get_nums_l()

# log(n)
# log(A)

edges = [ [] for _ in range(n+1) ]
for _ in range(n-1):
# for line in map(lambda s: s.strip(), sys.stdin.readlines()):
    line = input()
    # log(line)
    u,v = map(int, line.split())
    edges[u].append(v)
    edges[v].append(u)

def dfs(dp, u, p=None):

    # log(u)
    # log(dp)

    # dpの中でA[u]以上の値が入っている最小のindex
    i = bisect_left(dp, A[u])

    old = dp[i]
    dp[i] = A[u]

    # 有効値(INF以外)が入っている最大のindex
    ans[u] = bisect_left(dp, INF) - 1

    for v in edges[u]:
        if v == p:
            continue
        dfs(dp, v, u)

    # 巻き戻し
    dp[i] = old

# ans[i] = ノード1からノードiへの経路中の最長増加部分列長
ans = [0] * (n+1)

# dp[i] = 最長増加部分列長がiの場合の末尾ノード値の最小
# dp[0]は使用しないので負の無限大を入れておく
dp = [INF] * (n+1)
dp[0] = -INF

dfs(dp, 1, None)

for i in range(1, n+1):
    print(ans[i])


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

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

    while(true){
        C -= B;
        if(C <= 0) {cout << "Yes" << endl; return 0;}
        A -= D;
        if(A <= 0) {cout << "No" << endl; return 0;}
    }
}

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

typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pb push_back
using namespace std;

const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    
    ll x,y,ans=0,s,t;
    cin>>x>>y;
    if((x+y)%3==0&&(2*y-x)>=0&&(2*y-x)%3==0){
        s=(x+y)/3;
        t=(2*y-x)/3;
        ans=COM(s,t);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 119808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) ans +=a.at(i);
    else           ans -=a.at(i);
  }
  
  cout << ans;
}
  

Measured memory_bytes: 3588
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 1300009
#define M 1000000007
#define INF 5e17
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define mp make_pair
#define mt make_tuple
#define pb push_back
bool desc(ll i, ll j) { return i > j; }
ll power(ll x,ll n)
{   if(n==0||x==0) return 1;
    else if(n%2 == 0) return power((x*x)%M,n/2);
    else return (x*power((x*x)%M,(n-1)/2))%M;
}
ll fac[MAX],not_prime[MAX],ar[MAX],dp[MAX];
string s[MAX];
void fact(){
    fac[0]=1;
    for(ll i=1;i<=1000009;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<=MAX;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=MAX;i+=p) not_prime[i]=1;
        }
    }
}
int main(){
    //buf; 
    //sieve(); 
    //fact();
    ll i,j,test,ans,a,b,c,n,z,m,p,k,flag; string sk; 
    test=1;
    while(test--){
        cin>>sk;
        if(sk[0]==sk[2]) cout<<"Yes";
        else cout<<"No";
        
    }
    return 0;
} 

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

int main()
{
 long long x,y;
    int cnt=1;
  cin>>x>>y;
   while(x<=y)
   {
       x=x*2;
       if(x<=y)
       cnt++;
   }
    cout<<cnt;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#define ri register int 
#define ll long long 
using namespace std;
const int inf=0xfffffff;
const int maxn=100;
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
	while(!isdigit(c=getchar()))ne=c=='-';
	x=c-48;
	while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
	x=ne?-x:x;
	return ;
}
int a,b;
int main(){
	read(a),read(b);
	if(a>8||b>8)puts(":(");
	else puts("Yay!");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
signed main() {
	cout << "square1001\n";
}


Measured memory_bytes: 3084
program main
  implicit none
  integer :: N
  integer(8), allocatable  :: A(:)
  integer :: i,j
  integer(8) :: out, A_sum, idiv
  read(*,*) N
  allocate(A(N))
  read(*,*) A(:)

  out = 0
  !
!!  do i = 1,N-1
!!     do j= i+1,N
!!        out = out + mod(A(i)*A(j),10**9+7)
!!        out = mod(out,10**9+7)
!!     end do
!!  end do
  A_sum = sum(A)
  idiv = int(10**9+7,8)
  do i = 1,N-1
     A_sum = A_sum - A(i)
     out = mod( out + A(i)*mod(A_sum,idiv), idiv ) 
  end do
  write(*,'(i0)') mod(out,idiv)
  deallocate(A)
end program main


Measured memory_bytes: 4664
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        long[] input = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        if (input[1] <= input[0] * 2)
        {
            Console.WriteLine(input[1] / 2);
        } else
        {
            Console.WriteLine(input[0] + (input[1] - input[0] * 2) / 4);
        }
    }
}


Measured memory_bytes: 13268
N,K=map(int,input().split())
A=list(map(int,input().split()))

T=[10**9]*(N+1)
label=[-1]*(N+1)
T[0]=1
label[1]=0
for i in range(1,N+1):
    T[i]=A[T[i-1]-1]
    if label[T[i]]>=0:
        poss=label[T[i]]
        pose=i
        break
    else:
        label[T[i]]=i

pos=K-poss-1
if pos>=0:
    pos=pos%(pose-poss)
    print(T[poss+pos+1])
else:
    print(T[K])

Measured memory_bytes: 32344
// Aizu 1174: Identically Colored Panels Connection
// 2017.9.17 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int r, c; } Q;
Q q[70]; int top, end;
char mk[8][8];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char map[8][8]; int h, w, color;
int ans, max;

int count(char p[8][8])
{
	int i, r, c, r2, c2, f;
	q[0].r = q[0].c = 0, top = 0, end = 1, memset(mk, 0, sizeof(mk)), mk[0][0] = 1, f = 1;
	while (top < end) {
		r = q[top].r, c = q[top++].c;
		for (i = 0; i < 4; i++) {
			r2 = r + mv[i][0], c2 = c + mv[i][1];
			if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || p[r2][c2] != p[r][c] || mk[r2][c2]) continue;
			mk[r2][c2] = 1, f++, q[end].r = r2, q[end++].c = c2;
		}
	}
	return f;
}

int combi(int c0, int k, char p[8][8])
{
	int i, j, r, c, r2, c2, m;
	char t[8][8];

	if (k == 5) return 0;
	for (j = 1; j <= 6; j++) {
		if (j == c0) continue;
		memcpy(t, p, sizeof(t)); t[0][0] = j;
		q[0].r = q[0].c = 0, top = 0, end = 1, memset(mk, 0, sizeof(mk)), mk[0][0] = 1;
		while (top < end) {
			r = q[top].r, c = q[top++].c;
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || t[r2][c2] != c0 || mk[r2][c2]) continue;
				mk[r2][c2] = 1, t[r2][c2] = j, q[end].r = r2, q[end++].c = c2;
			}
		}
		if (j == color) if ((m = count(t)) > ans) ans = m;
		if (combi(j, k+1, t)) return 1;
	}
	return 0;
}

int main()
{
	int a, r, c;

	while(scanf("%d%d%d", &h, &w, &color) && h) {
		for (max = 0, r = 0; r < h; r++) for (c = 0; c < w; c++)	{
			scanf("%d", &a), map[r][c] = a; if (a == color) max++;
		}
		ans = 0; if (map[0][0] == color) ans = count(map);
		combi(map[0][0], 0, map);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,A,B;
  cin>>n>>A>>B;
  string s;
  cin>>s;
  int as=0,bs=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='a'&&as+bs<A+B){
      cout<<"Yes"<<endl;
      as++;
    }
    else if(s.at(i)=='b'&&as+bs<A+B&&bs<B){
      cout<<"Yes"<<endl;
      bs++;
    }
    else{
      cout<<"No"<<endl;
    }
  }

}

Measured memory_bytes: 3776
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		System.out.println(getCD(a,b,k));
	}
	private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
}

Measured memory_bytes: 35740
#include<iostream>
using namespace std;
int main(){
    int N,K;
    long long ans=0;
    cin >> N >> K;
    for(int b = K+1;b <= N;b++){
        ans += (b-K) * (N/b);
        if(N%b >= K) ans += N%b-K+1;
    }
    if(K == 0) ans -= N;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, M, K; std::cin >> N >> M >> K;
    std::vector<long long> A(N+1), B(M+1);
    for(int i(0); i < N; ++i){
        std::cin >> A[i+1];
        A[i+1] += A[i];
    }
    for(int i(0); i < M; ++i){
        std::cin >> B[i+1];
        B[i+1] += B[i];
    }
    int ans(0);
    for(int i(0); i <= N; ++i){
        if(A[i] > K) break;
        if(A[i] + B[M] <= K){
            chmax(ans, i + M);
            continue;
        }
        int a(std::distance(std::begin(B), std::upper_bound(std::begin(B), std::end(B), K-A[i])));
        chmax(ans, i + a - 1);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <cstdlib>
#include <sstream>

using namespace std;

int main(void) {
  int n,j = 0;
  string s, item;
  int min,max;
  long long sum;
  cin >> n;
  cin.ignore();
  int a[n];
  getline(cin, s);
  stringstream ss(s);
  while(getline(ss, item, ' '))
    a[j++] = atoi(item.c_str());
  min = a[0];
  max = a[0];
  sum = 0;
  for(int i = 0; i < n; i++) {
    if(min > a[i])
      min = a[i];
    if(max < a[i])
      max = a[i];
    sum += a[i];
  }
  cout << min << ' ' << max << ' ' << sum << endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
  ::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
  for (::std::int64_t i = 2; i*i <= x; ++i) {
    if (x % i == 0) {
      res.emplace_back(i, 1);
      x /= i;
      while (x % i == 0) x /= i, res.back().second++;
    }
  }
  if (x != 1) res.emplace_back(x, 1);
  return res;
}

::std::vector<::std::int64_t> divisors(::std::int64_t x) {
  ::std::vector<::std::int64_t> res;
  for (::std::int64_t i = 1; i*i <= x; ++i) {
    if (x % i == 0) {
      res.push_back(i);
      if (i * i != x) res.push_back(x / i);
    }
  }
  ::std::sort(res.begin(), res.end());
  return res;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	auto d1 = divisors(N), d2 = divisors(N-1);
	set<int64> st;
	REP(i, d1.size()) {
	  st.insert(d1[i]);
	}
	int64 res = 0;
  REP(i, d2.size()) {
    if (st.find(d2[i]) == st.end()) {
      res++;
    }
  }
  REP(i, d1.size()) {
    if (d1[i] == 1) continue;
    int64 x = N;
    while (x > 1) {
      if (x % d1[i] == 0) {
        x /= d1[i];
      } else {
        x %= d1[i];
        break;
      }
    }
    if (x == 1) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 640
n = int(input())
t, a = map(int,input().split())
height = list(map(int,input().split()))

L = [0]*n

for i in range(0,n):
    L[i] = abs(t - height[i] * 0.006 - a)

num = 0
a = 1000

for i in range(0,n):
    a = min(a, L[i])
    if a == L[i]:
        num = i+1

print (num)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main() {
	int n, m;double p;
	while (cin >> n >> m >> p&&n&&m) {
		//p /= 100;
		vector<int> x;
		int cnt = 0,y;
		for (int i = 0; i < n; i++) {
			cin >> y;
			x.push_back(y);
		}
		double money = 100*accumulate(x.begin(), x.end(), 0);
		money = money*(100 - p);
		if (x[m-1]==0)cout << 0 << endl;
		else cout << (int)(money / (double)x[m-1]/100.0) << endl;
	}
	return 0;
}

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

struct Circle{
  double x, y, r;
};

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++) {
    Circle a, b;
    cin >> a.x >> a.y >> a.r >> b.x >> b.y >> b.r;
    double d = pow(a.x-b.x, 2.0) + pow(a.y-b.y, 2.0);
    if(d < pow(a.r-b.r, 2.0)) {
      if(a.r > b.r)      cout << 2 << endl;
      else if(a.r < b.r) cout << -2 << endl;
    } else if(d > pow(a.r + b.r, 2.0)) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}

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

int main() {
  int n, a;

  cin >> n >> a;

  if (n % 500 == 0) {
    cout << "Yes";
  } else if (a == 0) {
    cout << "No";
  } else if (n % 500 / a == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    
    REP(i, N) {
        ll mini = -D * i + C * (N - i - 1);
        ll maxi = -C * i + D * (N - i - 1);
        
        if (mini <= B - A and B - A <= maxi) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N, M = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    pre = 0
    B = [0]
    for a in A:
        pre += a
        B.append(pre)
    
    B = [b % M for b in B]
    c = Counter(B)
    res = 0
    for cnt in c.values():
        res += cnt * (cnt-1) // 2

    print(res)    


if __name__ == '__main__':
    main()

Measured memory_bytes: 16928
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU

// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University
 
#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;

template<typename T> T fast_power(T x,T y,T m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes(or gcd(a,b)==1) in ax+by = t*gcd(a,b);
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}

typedef long long ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

/******************* MAIN PROGRAM ***************/

int main(){
	FAST
	ll a,b,k;
	cin >> a >> b >> k;
	ll ans1, ans2;
	ll mn1 = min( a, k);
	ans1 = a - mn1;
	ll mn2 = min( k - mn1, b);
	ans2 = b - mn2;
	cout << ans1 << " " << ans2 << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
using ll = long long;
using vll = vector<ll>;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int N; cin >> N;
  vll inp(N);
  for(int i = 0; i < N; i++) cin >> inp[i];
  sort(inp.begin(), inp.end());
  ll s1 = -1, s2 = -1;
  for(int i = N-1; i - 1 >= 0; i--){
    if(inp[i] == inp[i-1]){
      if(s1 == -1) s1 = inp[i--];
      else{ cout << s1*inp[i]; return 0;} 
    }
  }
  cout << 0;
  return 0;
}

Measured memory_bytes: 3976
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  set<int> Z;
  for(int i = 0; n > i; i++){
    int a;cin>>a;
    if(Z.find(a) != Z.end()){
      cout << "NO" << endl;
      return 0;
    }
    Z.insert(a);
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 9600
// https://atcoder.jp/contests/abc144/tasks/abc144_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// 約数列挙
vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ALL(ret));
    return ret;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, minv = 1e13;
    cin >> n;
    auto t = divisor(n);
    for (auto &x : t) {
        minv = min(minv, x + n / x);
    }
    cout << minv - 2 << endl;

    return 0;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[2005];
vector<vector<int>> len(2005, vector<int>(2005, -1));
vector<vector<int>> sorted(2005, vector<int>());

void dfs(int s, int p, int l) {
  len[s][p] = l;
  sorted[s].push_back(p);
  for(auto e: graph[p]) {
    if (len[s][e] == -1) {
      dfs(s, e, l+1);
    }
  }
}

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

  int n; cin >> n;
  string s; cin >> s;
  vector<bool> vec(n+1);
  rep(i, n) {
    if (s[i] == '1') {
      vec[i+1] = true;
      debug(i+1);
    }
  }

  rep(i, n-1) {
    int a, b; cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  for(int i=1; i<=n; i++) {
    dfs(i, i, 0);
  }

  int mi = INT_MAX;
  for(int i=1; i<=n; i++) {
    int sum = 0;
    for(int j=1; j<=n; j++) {
      if (vec[j]) {
        sum += len[i][j];
      }
    }
    if (sum%2 == 0) {
      reverse(sorted[i].begin(), sorted[i].end());
      vector<P> dp(2005); // P(dp, lensum);
      vector<int> cnt(2005);
      vector<bool> used(2005);
      for(auto p: sorted[i]) {
        used[p] = true;
        P top = P(0, 0);
        P total = P(0, 0);
        if (vec[p]) cnt[p]++;
        for(auto e: graph[p]) {
          if (used[e]) {
            P pa = dp[e];
            total.first += pa.first;
            total.second += pa.second;
            cnt[p] += cnt[e];
            if (pa.second > top.second) {
              top = pa;
            }
          }
        }
        P rest = {total.first-top.first, total.second-top.second};
        dp[p].second = total.second;
        if (top.second-top.first*2 <= rest.second) {
          dp[p].first = dp[p].second/2;
        } else {
          dp[p].first = top.first + rest.second;
        }
        dp[p].second += cnt[p];
        debug(i, p, cnt[p], dp[p].first, dp[p].second);
      }
      if (dp[i].first == sum/2) {
        chmin(mi, sum/2);
      }
    }
  }

  if (mi == INT_MAX) {
    cout << -1 << endl;
  } else {
    cout << mi << endl;
  }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int a,b;
  cin >> a >> b;
  if(!(a%3) || !(b%3) || !((a+b)%3))cout << "Possible" << endl;
  else cout << "Impossible" << endl;




  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner scanner = new Scanner(System.in);
    boolean isFalse = false;
    int n = scanner.nextInt();

    for (int i = 0; i < n; i++) {
      int t = scanner.nextInt();
      int x = scanner.nextInt();
      int y = scanner.nextInt();

      if (t < (x + y)) {
        isFalse = true;
        break;
      }

      if ((t % 2) == 0) {
        if ((x + y) % 2 != 0) {
          isFalse = true;
          break;
        }
      }

      if ((t % 2) != 0) {
        if ((x + y) % 2 == 0) {
          isFalse = true;
          break;
        }
      }
    }

    if (!isFalse) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 86304
n=int(input())
a=[]
while(n%2==0):
    a.append(2)
    n=n/2
for i in range(3,int((n**0.5))+1,2):
    while(n%i==0):
        a.append(i)
        n=n/i
if(n>2):
    a.append(int(n))
l=list(set(a))
c=1
t=0
for i in range(len(l)):
    while(0.5*(c*(c+1))<=a.count(l[i])):
        t=t+1
        c=c+1
    c=1
print(t)

Measured memory_bytes: 9380
import java.io.BufferedReader
import java.io.InputStreamReader

const val MOD = 1000000007L

fun main(omkar: Array<String>) {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val line = jin.readLine().split(" ")
    val n = line[0].toInt()
    val m = line[1].toInt()
    val earliest = Array(4) { IntArray(n + 1) { Int.MAX_VALUE } }
    val latest = Array(4) { IntArray(n + 1) }
    for (j in 1..m) {
        val line = jin.readLine().split(" ")
        val l = line[0].toInt()
        val r = line[1].toInt()
        val x = line[2].toInt()
        earliest[x][r] = Math.min(earliest[x][r], l)
        latest[x][r] = Math.max(latest[x][r], l)
    }
    var dp = Array(n + 1) { LongArray(n + 1) }
    var dpAlt = Array(n + 1) { LongArray(n + 1) }
    dp[0][0] = 1L
    for (j1 in 0 until n) {
        dpAlt.forEach { it.fill(0L) }
        for (j2 in 0 until n) {
            for (j3 in 0 until n) {
                if (earliest[1][j1] > j2 && latest[2][j1] <= j2 && earliest[2][j1] > j3 && latest[3][j1] <= j3) {
                    // same as j1
                    dpAlt[j2][j3] += dp[j2][j3]
                    dpAlt[j2][j3] %= MOD
                    // same as j2
                    dpAlt[j1][j3] += dp[j2][j3]
                    dpAlt[j1][j3] %= MOD
                    // same as j3
                    dpAlt[j1][j2] += dp[j2][j3]
                    dpAlt[j1][j2] %= MOD
                }
            }
        }
        val temp = dp
        dp = dpAlt
        dpAlt = temp
    }
    var answer = 0L
    for (j2 in 0 until n) {
        for (j3 in 0 until n) {
            if (earliest[1][n] > j2 && latest[2][n] <= j2 && earliest[2][n] > j3 && latest[3][n] <= j3) {
                answer += dp[j2][j3]
                answer %= MOD
            }
        }
    }
    println(answer)
}

Measured memory_bytes: 42692
#include <iostream>

 

using namespace std;

 

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r>=0 && y-r >=0 && x+r<=w && y+r<=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
#include<fstream>
using namespace std;

int main(){
   int n;
   cin>>n;
   int d[1000000];
   for(int i=0;i<1000000;i++){
      d[i]=0;
   }
   for(int i=1;i<=n-1;i++){
      int k=1;
      while(i*k<=n){
         d[i*k]+=1;
         k++;
      }
   }
   int cnt=0;
   for(int i=1;i<=n-1;i++){
      cnt+=d[i];
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 7508
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
ans = float("inf")

def func(i, sum, count, remain): 
    global ans
    #iはi*100点の問題を解くかどうか判断した後を示す
    #sumはi*100点の問題までで合計何点か
    #countはi+100点の問題までで何問といたか
    #remainは何番目の問題が残っているかを示す

    #ベースラインとして，d番目まで判断したら終わり
    if i == d:
        #もしgに届かなければ，残った問題のうち一番大きいものを解く
        if sum < g:
            use = max(remain)
            n = min(pc[use -1][0], -(-(g-sum) // (use * 100)))
            count += n
            sum += n * use * 100
        if sum >= g:
            ans = min(ans, count)
    else:
        func(i+1, sum, count, remain)
        func(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], remain-{i+1})

func(0, 0, 0, set(range(1, d+1)))
print(ans)
        

Measured memory_bytes: 40688
N = 8
FREE = 1
NOT_FREE = -1

def initialize():
    row = [FREE] * N
    col = [FREE] * N
    dpos = [FREE] * (2 * N - 1)
    dneg = [FREE] * (2 * N - 1)
    return row, col, dpos, dneg


def printBoard(x, row):
    for i in range(N):
        for j in range(N):
            if x[i][j]:
                if row[i] != j:
                    return
    for i in range(N):
        line = ''
        for j in range(N):
            if row[i] == j:
                line += 'Q'
            else:
                line += '.'
        print(line)


def recursive(i, x, row, col, dpos, dneg):
    if i == N:
        printBoard(x, row)
        return

    for j in range(N):
        if (NOT_FREE == col[j] or
            NOT_FREE == dpos[i + j] or
            NOT_FREE == dneg[i - j + N - 1]):
            continue
        row[i] = j
        col[j] = NOT_FREE
        dpos[i + j] = NOT_FREE
        dneg[i - j + N - 1] = NOT_FREE
        recursive(i+1, x, row, col, dpos, dneg)
        row[i] = FREE
        col[j] = FREE
        dpos[i + j] = FREE
        dneg[i - j + N - 1] = FREE


if __name__ == '__main__':
    row, col, dpos, dneg = initialize()
    x = [[False] * N for i in range(N)]
    k = int(input())
    for i in range(k):
        r, c = [int(v) for v in input().split()]
        x[r][c] = True

    recursive(0, x, row, col, dpos, dneg)


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

typedef long long LL ;
typedef pair < int , int > pii ;

#define clr( a , x ) memset ( a , x , sizeof a )

const int MAXN = 100005 ;

int a[MAXN] , n ;

void solve () {
	int now = 1 ;
	LL ans = 0 ;
	for ( int i = 1 ; i <= n ; ++ i ) {
		//printf ( "---%d %lld\n" , now , ans ) ;
		scanf ( "%d" , &a[i] ) ;
		if ( a[i] < now ) continue ;
		if ( a[i] == now ) {
			++ now ;
			continue ;
		}
		ans += a[i] / now ;
		if ( a[i] % now == 0 ) -- ans ;
		if ( now == 1 ) ++ now ;
	}
	printf ( "%lld\n" , ans ) ;
}

int main () {
	while ( ~scanf ( "%d" , &n ) ) solve () ;
	return 0 ;
}

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

int main(){
    int n,a;
    cin>>n>>a;
    vector<ll> x(n+1);
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    vector<vector<vector<ll>>> dat(n+1,vector<vector<ll>>(n+1,vector<ll>(50*n+5)));
    dat[0][0][0]++;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=50*n+3;k++){
                dat[i][j][k]+=dat[i-1][j][k];
                if(j-1>=0&&k-x[i]>=0) dat[i][j][k]+=dat[i-1][j-1][k-x[i]];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dat[n][i][i*a];
    }
    cout<<ans;
}

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

int main() {long N, A, B;
cin >> N >> A >> B;
vector<long> x(N + 1);
erep(i, N) cin >> x.at(i);
long ans = 0;

erep(i, N - 1){
    ans += min(A * (x.at(i + 1) - x.at(i)), B);
}




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



Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int x;
  scanf("%d",&x);
  switch(x % 7) {
    case 0:
    printf("thu\n");
    break;
    case 1:
    printf("fri\n");
    break;
    case 2:
    printf("sat\n");
    break;
    case 3:
    printf("sun\n");
    break;
    case 4:
    printf("mon\n");
    break;
    case 5:
    printf("tue\n");
    break;
    case 6:
    printf("wed\n");
    break;
  }
  return 0;
}


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

int main(void){
  int i,j,n,m,max=0,ans;
  scanf("%d",&n);
  char s[n][10];
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
  }
  scanf("%d",&m);
  char t[m][10];
  for(i=0;i<m;i++){
    scanf("%s",t[i]);
  }
  for(i=0;i<n;i++){
    ans=0;
    for(j=0;j<n;j++){
      if(strcmp(s[i],s[j])==0) ans++;
    }
    for(j=0;j<m;j++){
      if(strcmp(s[i],t[j])==0) ans--;
    }
    if(max<ans) max = ans;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val a = mutableListOf<Int>()
    (1..M).forEach {
        val num = readLine()!!.toInt()
        a.add(num)
    }

    val dp = Array(N + 1, { 0L })
    dp[0] = 1
    val MOD = 1000000007

    var index = 0
    (1..N).forEach { n ->
        val isNthBroken = if (index >= M) false else a[index] == n
        if (isNthBroken) {
            index++
        }

        if (isNthBroken) {
            dp[n] = 0
        } else {
            if (n -2 >= 0) {
                dp[n] = (dp[n-1] + dp[n-2]) % MOD
            } else {
                dp[n] = dp[n-1]
            }
        }
    }
    println(dp[N])
}

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

const int DIM = 1e5 + 5;
const int MOD = 1e9 + 7;

int fct[DIM];

int main(void) {
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    
    fct[0] = 1;
    for (int i = 1; i <= max(n, m); ++i)
        fct[i] = (1LL * fct[i - 1] * i) % MOD;
    
    if (abs(n - m) > 1)
        cout << 0;
    else
    if (abs(n - m) == 1)
        cout << (1LL * fct[n] * fct[m]) % MOD;
    else
        cout << (2LL * fct[n] * fct[m]) % MOD;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int A[100001];

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


Measured memory_bytes: 640
from math import atan, pi

a,b,x = map(int, input().split())

if x <= a*a*b / 2:
    h = x/b/a*2
    print(atan(b/h)*180/pi)
else:
    h=(a*a*b-x)/(a*a)*2
    print(atan(h/a)*180/pi)

Measured memory_bytes: 9264
#include <stdio.h>
int main(){
  long int a;
  long double b;
  long double ans;
  long int ans_2;
  scanf("%ld %Lf",&a,&b);
  ans =a*b;
  ans_2 = ans;

  printf("%ld\n",ans_2);
  return 0;
}



Measured memory_bytes: 1716
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
vector<llint> G[100005];

llint dfs(int v, int p)
{
	llint sum = 0, sum2 = 0;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		llint res = dfs(G[v][i], v);
		sum2 |= sum & res;
		sum |= res;
	}
	
	llint pos = -1;
	for(int i = 20; i >= 0; i--){
		if(sum2 & (1<<i)){
			pos = i;
			break;
		}
	}
	pos++;
	
	for(int i = pos; i <= 20; i++){
		if((sum & (1<<i)) == 0){
			pos = i;
			break;
		}
	}
	sum >>= pos, sum <<= pos;
	sum |= 1<<pos;
	
	return sum;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	llint res = dfs(1, -1);
	
	llint ans = 0;
	for(;res;res>>=1) ans++;
	cout << ans-1 << endl;
	
	return 0;
}

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

int main() {
  string a;
  cin>>a;
  int n=a.size();
  int ans=0;
  if(n%2==0){
    for (int i = 0; i < n/2; i++) {
      if(a.at(i)!=a.at(n-i-1)){
        ans++;
      }
    }
  }
  else{
    for (int i = 0; i < (n-1)/2; i++) {
      if(a.at(i)!=a.at(n-i-1)){
        ans++;
      }
    }
  }


  cout << ans << endl;
}




Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    bool ok=false;
    int n;
    cin>>n;
    vec<pint> d(n);
    rep(i,n){
        cin>>d[i].fi>>d[i].se;
        if(d[i].fi==d[i].se && i>=2){
            if(d[i-1].fi==d[i-1].se && d[i-2].fi==d[i-2].se) ok=true;
        }
    }

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3656