akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

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

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}


/* main */
int main() {
	int r = 0 ,ans = 0;
	char s[20];
	scanf("%s", s);
	REP(i, strlen(s)) {
		if (s[i] == 'A')r++;
		else if (s[i] == 'T')r++;
		else if (s[i] == 'G')r++;
		else if (s[i] == 'C')r++;
		else r = 0;
		ans = max(ans, r);
	}
	printf("%d", ans);
	return 0;
}

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

int main() 
{
    string S;
    cin >> S;
    
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == '1') {
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
while True:
	try:
		n = eval(input())
		if n > 36:
			print(0)
		else:
			count = 0
			for a in range(0, 10):
				for b in range(0, 10):
					for c in range(0, 10):
						for d in range(0, 10):
							if a + b + c + d == n:
								count += 1
			print(count)
	except EOFError:
		break

Measured memory_bytes: 7384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
  	int n, q, a, b, c, d[100005] = {};
  	ll z = 0;
  	cin >> n;
  	for (int i = 1; i <= n; i++) cin >> a, z += a, d[a]++;
  	cin >> q;
  	while (q--) {
      	cin >> b >> c;
      	z += 1ll * d[b] * (c - b);
      	cout << z << '\n';
      	d[c] += d[b];
      	d[b] = 0;
    }
}

Measured memory_bytes: 3588
def main():
    n,k = map(int, input().split())
    MOD = 10**9+7

    # 0人部屋が0~k個の時の場合の数の和
    # Σ(i=[0,k]){comb(n,i)*pow((n-i),i)} を求めれば良い
    # しかし上式ではpowの計算量がデカすぎるので、捉え方を変えて下式まで変形
    # Σ(i=[0,k]){comb(n,i)*comb((n-1),i)} を求めれば良い
    # 注:i=0のとき、つまり0人部屋がない、つまり全部屋に1人ずつ、のケースは1通り
    # comb(n,i+1) = comb(n,i) * (n-i)/(i+1) であることを利用する
    ans = 0
    k1 = 1
    k2 = 1
    for i in range(min(k+1,n)):
        ans += k1*k2
        ans %= MOD
        k1 *= (n-i)*pow(i+1,MOD-2,MOD)
        k1 %= MOD
        k2 *= (n-1-i)*pow(i+1,MOD-2,MOD)
        k2 %= MOD
    print(int(ans))

main()


Measured memory_bytes: 3060
r, c = map(int, input().split())

def num_get(r):
    nums = []
    for i in range(r):
        num = list(map(int, input().split()))
        nums.append(num)
    return nums

def hori_sum(num, r):
    nums = []
    for i in range(r):
        sum_i = sum(num[i])
        num[i].append(sum_i)
        print(" ".join([str(j) for j in num[i]]))
        nums.append(num[i])
    #print(nums)
    return nums

def verti_sum(nums, r, c):
    sums = []
    sum_v = 0
    c = c + 1
    for i in range(c):
        #print(i)
        for j in range(r):
            #print("{} {} {}" .format(i, j, num[j][i]))
            sum_v = sum_v + nums[j][i]
        sums.append(sum_v)
        sum_v = 0
    print(" ".join([str(i) for i in sums]))
    return sums

nums = num_get(r)
hori = hori_sum(nums, r)
#print(hori)
verti_sum(hori, r, c)






Measured memory_bytes: 5704
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] kk =new int[m][n];
		for(int i=0;  i<m; i++){
			int k=sc.nextInt();
			for(int j=0;j<k; j++){
				int s = sc.nextInt()-1;
				kk[i][s]=1;
			}
		}
		int[] p=new int[m];
		for(int i=0; i<m; i++){
			p[i]= sc.nextInt();
		}
		boolean oi=true;
		long ans=0;
		for(int i=0; i<Math.pow(2,n); i++){
			for(int j=0; j<m; j++){
				int count=0;
				oi=true;
				for(int k=0; k<n; k++){
					if(kk[j][k]==1 && ((i>>k)&1)==1){
						count++;
					}
				}
				if(count%2!=p[j]){
					oi=false;
					break;
				}
			}
			if(oi){
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << 60 * (h2 - h1) + m2 - m1 - k;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int v,e;
    cin>>v>>e;
    vector<int> deg(v,0);
    
    rep(i,e){
        int a,b;
        cin>>a>>b;
        a--,b--;
        deg[a]++;
        deg[b]++;
    }
    
    rep(i,v)cout<<deg[i]<<endl;
}

Measured memory_bytes: 256
import sys
n = int(input())
k =[]
x = list(map(int, input().split()))
x = x[::-1]
for i in range(n):
    for j,p in enumerate(x):
        if p == n-j:
            k.append(p)
            x.pop(j)
            n-=1

            break
    else:
        print(-1)
        sys.exit()
for i in k[::-1]:
    print(i)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

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 DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	ll a, b;
	cin >> a >> b;
	for(ll i = 1; i <= 50000; i++) {
		if(i * 2 / 25 == a && i / 10 == b) {
			cout << i << '\n'; return 0;
		}
	}
	cout << "-1\n";
}



Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
ans = {True:0, False:0}
for s in [True, False]:
    sign = s
    total = 0
    for i in range(len(A)):
        if total + A[i] == 0 or sign == (total + A[i] > 0):
            ans[s] += abs(total + A[i]) + 1
            total = -1 if sign else 1
        else:
            total += A[i]
        sign = total > 0
print(min(ans.values()))


Measured memory_bytes: 14332
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)

if c[0] == N:
    print("Yes")
    exit()

if N % 3 == 0 and c[0] == N // 3 and len(c.values()) == 2:
    print("Yes")
    exit()

n =  N // 3
k = list(c.keys())
v = list(c.values())

if N % 3 == 0 and v == [n, n, n] and k[0]^k[1]^k[2] == 0:
    print("Yes")
    exit()

print("No")

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

int n, m, x;
map <int, int> c1, c2;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    while(n-- && cin >> x)
        c1[x]++;
    cin >> m;
    while(m-- && cin >> x)
        c2[x]++;
    for(auto i : c2)
        if(c1[i.first] < i.second) return cout << "NO" << endl, 0;
    cout << "YES" << endl;
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    int n=str.length();
    if(str.length()==0)
        return 0;
    if(str[str.length()-1]=='s')
    {
        str.replace(n,n-1,"es");
    }
    else
    {
        str.push_back('s');
    }
    cout<<str<<endl;

    return 0;
}

Measured memory_bytes: 3648
n,k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])

nums = [0]*(n-1)
for i in range(n-1): nums[i] = h[i+1]-h[i]

ans = sum(nums[:k-1])
t = sum(nums[:k-1])
for i in range(k-1,n-1):
  t += nums[i] - nums[i-k+1]
  if t < ans: ans = t
print(ans)

Measured memory_bytes: 17096
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int N, M, C;
	vector<int> B, ans;
	vector< vector<int> > A;

	cin >> N >> M >> C;
	for(int i = 0; i < M; ++i){
		int Bi; cin >> Bi;
		B.push_back(Bi);
	}

	for(int i = 0; i < N; ++i){
		vector<int> Ai;
		for(int j = 0; j < M; ++j){
			int Aij; cin >> Aij;
			Ai.push_back(Aij);
		}
		A.push_back(Ai);
	}

	int tmp;
	for(int i = 0; i < N; ++i){
		tmp = 0; 
		for(int j = 0; j < M; ++j){
			tmp += B[j] * A[i][j];
		}
		tmp += C;
		if(tmp > 0) ans.push_back(tmp);
	}

	cout << ans.size() << endl;

	return 0;
}


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

int main(){
  int n,m; cin>>n>>m;
  vector<ll> a(n),b(n),c(n);

  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  vector<ll> sum(n,0);
  ll ans=0,pre=0;
  //x+y+z
  for(int i=0;i<n;i++){
    sum[i]=a[i]+b[i]+c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //x+y-z
  for(int i=0;i<n;i++){
    sum[i]=a[i]+b[i]-c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //x-y+z
  for(int i=0;i<n;i++){
    sum[i]=a[i]-b[i]+c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //-x+y+z
  for(int i=0;i<n;i++){
    sum[i]=-a[i]+b[i]+c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //-x-y-z
  for(int i=0;i<n;i++){
    sum[i]=-a[i]-b[i]-c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //x-y-z
  for(int i=0;i<n;i++){
    sum[i]=a[i]-b[i]-c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //-x-y+z
  for(int i=0;i<n;i++){
    sum[i]=-a[i]-b[i]+c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  //-x+y-z
  for(int i=0;i<n;i++){
    sum[i]=-a[i]+b[i]-c[i];
  }sort(sum.rbegin(),sum.rend());
  for(int i=0;i<m;i++){
    pre+=sum[i];
  }
  ans=max(ans,pre);
  pre=0;
  for(int i=0;i<n;i++){
    sum[i]=0;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2==2:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N,X;

int main() {
	cin >> N >> X;
	cout << max((ll)0, N - X) << endl;
	return 0;
}

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

int main() {
    long a, b, c;
    cin >> a >> b >> c;
    cout << (a + b < c && (c - a - b) * (c - a - b) > 4 * a * b ? "Yes" : "No")
         << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

n, m , q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

num = []

for i in range(1, m + 1):
    num.append(i)


ans = 0


for A in list(itertools.combinations_with_replacement(num, n)):
    p = 0
    for abcdi in abcd:
        if A[abcdi[1] - 1] - A[abcdi[0] - 1] == abcdi[2]:
            p += abcdi[3]
    
    if p > ans:
        ans = p

print(ans)

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



int main(){
    ll s; cin >> s;
    ll y1, y2;

    y1 = (s / 1000000000) + 1;
    y2 = 1000000000 - (s % 1000000000);

    if (s == 1000000000000000000){
        cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 1000000000 << " " << 1000000000 << endl;
        return 0;
    }

    cout << 0 << " " << 0 << " " << 1 << " " << y1 << " " << 1000000000 << " " << y2 << endl;
}

Measured memory_bytes: 3604
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n = getint()
s = [input() for _ in range(n)]
c = collections.Counter()

for h in s:
    c[h[0]] += 1

res = 0
for perm in itertools.combinations("MARCH", 3):
    res += c[perm[0]] * c[perm[1]] * c[perm[2]]

print(res)


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

using namespace std;

const int N = int(2e5 + 10);
vector< int > adj[N];
int dis[N];
int father[N];
queue< int > q;

void bfs(){
	dis[1] = 0;

	q.push(1);

	while(!q.empty()){
		int u = q.front();
		q.pop();

		for(int v: adj[u]){
			if(dis[v] == -1){
				father[v] = u;
				dis[v] = dis[u] + 1;

				q.push(v);
			}
		}
	}
}

int main(){
	memset(dis, -1, sizeof dis);

	int n, m;

	scanf("%d %d", &n, &m);

	for(int i = 0 ; i < m ; i++){
		int ai, bi;

		scanf("%d %d", &ai, &bi);

		adj[ai].push_back(bi);
		adj[bi].push_back(ai);
	}

	bfs();

	for(int i = 2 ; i <= n ; i++){
		if(dis[i] == -1){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	for(int i = 2 ; i <= n ; i++){
		printf("%d\n", father[i]);
	}

	return 0;
}

Measured memory_bytes: 13800
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN+1];

int head,tail,n;
int isEmpty(){
  return head==tail;
}

int isFull(){
  return head==(tail+1)%LEN;
}

void enqueue(P x){
  if(isFull()){
    printf("Overflow\n");
    exit(2);
  }
  Q[tail]=x;
  if(tail+1==LEN) tail=0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty()){
    printf("Empty\n");
    exit(3);
  }
  x=Q[head];
  if(head+1==LEN) head=0;
  else head++;
  return x;
}
  

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  head=1;
  tail=0;
  scanf("%d %d",&n,&q);
  tail=n+1;
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  //printf("\n");
  while(head!=tail){
    u=dequeue();
    if(u.t-q<=0){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }
    else {
      elaps+=q;
      u.t-=q;
      enqueue(u);
    }
  }
  return 0;
}



Measured memory_bytes: 11940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 998244353
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll 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;
  }
}

// 二項係数計算
ll COM(ll n,ll 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(){
  ll N,M,ans=0;
  cin>>N>>M;
  COMinit();
  
  for(int i=M%2; i<=min(N,M); i+=2){
    ll L=(M-i)/2;
    ans+=COM(N,i)*COM(M+L+N-1,N-1);
    ans%=MOD;
    ans-=N*(COM(N-1,i-1)*COM(L+N-1,N-1)%MOD+COM(N-1,i)*COM(L+N-2,N-1)%MOD);
    ans%=MOD;
    if(ans<0) ans+=MOD;
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 123168
#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, a, b;
  cin >> n >> a >> b;

  int result = min(a * n, b);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;
#define size 200010

ll POW(ll n,ll m){
  long long pow = 1;
  while (m>0) {
    if ((m&1) == 1) pow = (pow*n)%MOD;
    m >>= 1;
    n = (n*n)%MOD;
  }
    return pow;
}

int main(){
  int N,K; cin >> N >> K;
  int n;
  ll ans = 0;
  map<int,ll> A;
  for(int i=1;i<=K;i++){
    int t = K-i+1;
    n = K / t;
    A[t] += POW(n,N);
    for(int j=2;;j++){
      if(j * t > K) break;
      else{
        A[t] -= A[j * t];
        A[t] = (A[t] + MOD) % MOD;
      }
    }
  }
  for(int i=1;i<=K;i++){
    ans = (ans + i * A[i] % MOD + MOD) % MOD;
  }
  AA(ans);
  return 0;
}

Measured memory_bytes: 9844
#include<bits/stdc++.h>
using namespace std;
double res[3000],ans,p;
int main(){
	res[0]=1;
	int n,i,j;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>p;
		for(j=i;j>=0;j--){
		res[j+1]+=res[j]*p;
		res[j]*=(1-p);
		}
	}
	for(i=n/2+1;i<=n;i++)ans+=res[i];
	cout<<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 384
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [LIST() for i in range(N)]

import itertools
l = [i for i in range(N)] #生成する数字
bit = list(permutations(l))
# print(bit)
cnt = 0
ans = 0
s = 0
for t in bit:
    # s = 0
    # print(t)
    for i in range(len(t)-1):
        # print(i)
        a, b = L[t[i]][0], L[t[i]][1]
        c, d = L[t[i+1]][0], L[t[i+1]][1]
        s += sqrt((a - c) ** 2 + (b - d) ** 2)
    # print(s)
    # ans += s
    # s = 0

ans = s / len(bit)
print(ans)

Measured memory_bytes: 8680
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;

/*
  let's try computer shogi!
 */

int main(){
  int N,A,B;
  cin >> N >>A >>B;
  if(((A-B)%2)==0){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Borys"<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  string str;
  cin >> str;
  int k;
  cin >> k;

  stringstream ss(str);
  int cnt = 0;
  char c;
  while (ss >> c) {
    if (c != '1')
      break;
    ++cnt;
  }

  if (k <= cnt)
    cout << 1 << endl;
  else
    cout << c << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

 ll h,sum=0;
 cin>>h;
 ll i=0;
 while(h>0)
 {
     sum+=pow(2,i);
     h=h/2;
     i++;
 }
 cout<<sum<<endl;

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(3 * 10 ** 5)
input = sys.stdin.buffer.readline


def main() -> None:
    def dfs(v, par, cnt):
        ans[v] += cnt
        for c in edges[v]:
            if c == par:
                continue
            dfs(c, v, ans[v])

    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        edges[a].append(b)
        edges[b].append(a)
    ans = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p - 1] += x
    dfs(0, -1, 0)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 282708
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cout << "ACL";
  }
  return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
pii poyo[252521];
int v[252521];
int l[252521], r[252521];

int dp[252521];

#define ADD(a,b) (a)+=(b),(a)=((a)>=MOD?(a)-MOD:(a))

int main(){
  scanf("%d",&n);
  REP(i,n){
    int xx,vv;
    scanf("%d%d",&xx,&vv);
    poyo[i] = pii(xx,vv);
  }
  // zaatu
  sort(poyo,poyo+n);
  REP(i,n)poyo[i] = pii(poyo[i].second,i);
  sort(poyo,poyo+n);
  REP(i,n)v[poyo[i].second] = i+1;
  // left
  l[0] = v[0];
  FOR(i,1,n)l[i] = max(l[i-1],v[i]);
  // right
  r[n-1] = v[n-1];
  FORR(i,0,n-1)r[i] = min(r[i+1],v[i]);
  // dp[r[i]] += sum(dp[l[i]-1]~dp[r[i]])
  dp[0] = 1;
  int sum = 1;
  int lw = 0, hi = 0;
  REP(i,n){
    while(hi < l[i])hi++,ADD(sum,dp[hi]);
    while(lw < r[i]-1)ADD(sum,MOD-dp[lw]),lw++;
    ADD(dp[l[i]],sum);
    ADD(sum,sum);
  }
  printf("%d\n",dp[n]);
  return 0;
}


Measured memory_bytes: 5376
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

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

n = int(input())
lines = sys.stdin.readlines()

works = [None]*n
_ = 0
for l in lines:
    works[_] = tuple(map(int, l.split(" ")))
    _ += 1

works.sort(key=lambda w:w[1], reverse=True)


time = 9999999999999999999999999
for i,w in enumerate(works):
    time = min(time,w[1]) - w[0]

print("Yes" if time >= 0 else "No")

Measured memory_bytes: 96604
#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
long long ans;
int main()
{
	scanf("%d", &n);
	a[0] = a[n + 1] = 0;
	ans = 0;
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 0; i <= n; i++) ans += abs(a[i + 1] - a[i]);
	for (int i = 1; i <= n; i++) printf("%lld\n", ans - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]));
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 6e4+9, M = 1e7, OO = 0x3f3f3f3f;
int n,k,dp[N];
pair<int,int> knap[N];

int main()
{
  
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;++i) 
    scanf("%d%d",&knap[i].first,&knap[i].second);
  
  memset(dp, 0, sizeof(dp));
  sort(knap,knap+n);
   

  for(int i=0;i<n;++i)
  {
    for(int j=k+knap[i].first-1;j>=knap[i].first;--j) 
      dp[j]=max(dp[j],dp[j-knap[i].first]+knap[i].second);
  }
  printf("%d\n",*max_element(dp,dp+N));
  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    string S,T;
    cin >> S >> T;
    int count = 0;
    REP(i,S.size()){
        if(S[i] != T[i])count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int P[50];
int main(){
  int i, k;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(P[Lj4PdHRW]);P[Lj4PdHRW] += (-1);
    }
  }
  k = 0;
  for(i=0;i<N;i++){
    if(P[i]!=i){
      k++;
    }
  }
  if(k <= 2){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, P[50];
// {
//   int i, k;
//   rd(N,(P--)(N));
// 
//   k = 0;
//   rep(i,N) if(P[i]!=i) k++;
//   wt( if[k <= 2, "YES", "NO"] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double w,h,x,y,c=0;
    
    cin>>w>>h>>x>>y;
    if(2*x==w and 2*y==h) {
        c = 1;
    }

    cout<<(w*h)/2<<" "<<c<<"\n";
    return 0;
}

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

void chmin(int &a, int b) {
    if (a > b) a = b;
}

signed main() {
    int h, n;
    cin >> h >> n;

    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];

    const int inf = 1e+12;
    vector<vector<int>> dp(n + 1, vector<int>(h + 1, inf));
    dp[0][0] = 0;

    rep(i, 0, n) rep(j, 0, h + 1) {
        chmin(dp[i + 1][j], dp[i][j]);
        chmin(dp[i][min(h, j + a[i])], dp[i][j] + b[i]);
    }

    cout << dp[n][h] << endl;

    return 0;
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
const int mo=1e9+7,N=2e5+5;
typedef long long LL;
void Inverse(int p,int a[],int n){//ÏßÐÔÇó<=nµÄÊý%pÒâÒåÏÂµÄÄæÔª 
	a[1]=1;
	for(int i=2;i<=n;i++){
		a[i]=1ll*(p-p/i)*a[p%i]%p;
	}
}
LL Pow(LL a,int b){
	LL ans=1;
	while(b){
		if(b&1)(ans*=a)%=mo;
		(a*=a)%=mo,b>>=1;
	}
	return ans;
}
int inv[N];
LL C(int n,int a){
	LL ans=1;
	for(int i=1;i<=a;i++)ans=ans*(n-i+1)%mo*inv[i]%mo;
	return ans;
}
int main(){
	int n,a,b;scanf("%d%d%d",&n,&a,&b);
	Inverse(mo,inv,b);
	printf("%d",((Pow(2,n)-C(n,a)-C(n,b)-1)%mo+mo)%mo);
	return 0;
}

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

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<std::vector<int>> s(m);

    for (int i = 0; i < m; i++) {
        int num;
        std::cin >> num;
        for (int j = 0; j < num; j++) {
            int temp;
            std::cin >> temp;
            temp--;
            s[i].push_back(temp);
        }
    }

    std::vector<int> reminders(m);
    for (int i = 0; i < m; i++) {
        std::cin >> reminders[i];
    }

    long long ans = 0;
    for (unsigned switch_conditions = 0; switch_conditions < 1 << n; switch_conditions++) {
        auto check = [&](int lamp_id) {
            int count = 0;
            for (auto c : s[lamp_id]) {
                //printf("%d %d %d\n", switch_conditions, (1 << c), switch_conditions & (1 << c));
                if ((switch_conditions & (1 << c)) == 1 << c) {
                    count++;
                }
            }

            //printf("%d\n", count);
            if (count % 2 == reminders[lamp_id]) {
                return true;
            }
            return false;
        };

        int count = 0;
        for (int i = 0; i < m; i++) {
            if (check(i)) {
                count++;
            }
        }

        if (count >= m) {
            ans++;
        }
    }

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


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(input() for _ in range(N))
B = list(input() for _ in range(M))
b = len(B[0])

ans = "No"
for i in range(N-(M-1)):
  n = -1
  c = 0
  for j in range(M):
    if B[j] in A[i+j]:
      if n < 0:
        n = A[i + j].index(B[j])
        c += 1
      else:
        if B[j] in A[i + j][n: n + b + 1]:
          c += 1
  if c == M:
    ans = "Yes"
print(ans)

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


int main() {
	int x ,y;
	while(1){
		cin >> x >> y;
		if(!x && !y) break;
		if(x < y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void){
	int C1,C2,C3,a[10],i,ok;
	while(scanf("%d %d %d",&C1,&C2,&C3)!=EOF){
		for(i=0;i<10;i++)a[i]=1;
		a[C1-1]=0;a[C2-1]=0;a[C3-1]=0;ok=0;
		for(i=1;i+C1+C2<21;i++)if(a[i-1])ok++;
		if(ok>3)printf("YES\n"); else printf("NO\n");
	}
	return 0;
}

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

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

bool compareElem(const P &e1, const P &e2)
{
    return e1.first * e2.second > e2.first * e1.second;
}

int main()
{
    int N, W;
    cin >> N >> W;
    vector<P> elems(N);
    for(int i=0;i<N;++i)
    {
        cin >> elems[i].first >> elems[i].second;
    }

    sort(elems.begin(), elems.end(), compareElem);

    double ans = 0;
    for(int i=0; i<N; ++i)
    {
        if(W >= elems[i].second)
        {
            W -= elems[i].second;
            ans += elems[i].first;
        }
        else{
            ans += double(elems[i].first * W) / elems[i].second;
            break;
        }
    }
    printf("%.10lf\n", ans);
}



Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define REPD(a,b,c) for(int a=b; a>(int)c; a--)
#define rep(a,b) REP(a,0,b)
#define repd(a,b) REPD(a,b,0)
typedef long long int ll;
using namespace std;

void show(vector<vector<int> > board){
  rep(i,board.size()){
    rep(j,5){
      cout << board[i][j];
    }
    cout << endl;
  }
}


int main(){
  while(true){
    int H;
    cin >> H;
    if(H == 0) break;
    vector<vector<int> > board(H, vector<int>(5, 0));
    rep(i,H)rep(j,5) cin >> board[i][j];
    int ans = 0;
    while(true){
      bool isFin = true;
      //      show(board);
      //cout << endl;
      rep(i,H){
        int num = board[i][0], cnt = 1;
        int j;
        for(j=1;j<5; j++){
          if(num == board[i][j]){
            cnt++;
          }else{
            if(cnt >= 3) break;
            num = board[i][j];
            cnt = 1;
          }
        }
        if(cnt >= 3 && num != 0){
          ans += cnt * num;
          int first_idx = j-cnt;
          for(int k=0; k < cnt; k++){
            board[i][first_idx+k] = 0;
          }
          isFin = false;
        }
      }
      for(int i=H-1; i>=0; i--){
        rep(j,5){
          if(board[i][j] == 0){
            for(int k=i-1; k>=0; k--){
              if(board[k][j] != 0){
                board[i][j] = board[k][j];
                board[k][j] = 0;
                break;
              }
            }
          }
        }
      }
      if(isFin) break;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
N, K = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
    P[i] -= 1
C = list(map(int, input().split()))

ans = -(10 ** 18)

for si in range(N):
    x = si
    loop = []
    total = 0
    while 1:
        x = P[x]
        loop.append(C[x])
        total += C[x]
        if x == si:
            break
    T = len(loop)  # 周期の大きさ
    tmp = 0
    for i in range(T):
        tmp += loop[i]
        if K < i + 1:
            break
        now = tmp
        if total > 0:  # loopの和が正ならloopを回した方がお得
            loop_times = (K - (i + 1)) // T  # 何周できるか
            now += total * loop_times
        ans = max(ans, now)

print(ans)



Measured memory_bytes: 81076
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
item = []
for key,Value in c.items():
    item.append([key,Value])
koho = []
if len(item) == 1:
    print(item[0][1])
    sys.exit()
if item[1][0] - item[0][0] == 1:
    cnt = item[1][1] + item[0][1]
else:
    cnt = item[0][1]
koho.append(cnt)
cnt = 0
for i in range(1,len(item)-1):
    cnt = 0
    if item[i][0] - item[i-1][0] == 1:
        cnt += item[i-1][1] + item[i][1]
    if item[i+1][0] - item[i][0] == 1:
        cnt += item[i+1][1]
    koho.append(cnt)
cnt = 0
if item[-1][0] - item[-2][0] == 1:
    cnt += item[-1][1] + item[-2][1]
else:
    cnt += item[-1][1]
koho.append(cnt)
print(max(koho))



Measured memory_bytes: 17336
#include<iostream>

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s[0]=='R'){
     if(s[1]=='R'){
     	if(s[2]=='R'){
          cout << 3 << "\n";
        }else cout << 2 << "\n";
     }else cout << 1 << "\n";
  }else if(s[1]=='R'){
    	if(s[2]=='R') cout << 2 << "\n";
    	else cout << 1 << "\n";
  }else if(s[2]=='R') cout << 1 << "\n";
   else cout << 0 << "\n";
}

Measured memory_bytes: 3628
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>

using namespace std;

int main() {
  int64_t N, M, K;
  cin >> N >> M >> K;

  vector<int64_t> a(N+1);
  for (int64_t n = 1; n <= N; ++n) {
    cin >> a[n];
    if (n != 0) {
      a[n] += a[n - 1];
    }
  }
  vector<int64_t> b(M);
  for (int64_t m = 0; m < M; ++m) {
    cin >> b[m];
    if (m != 0) {
      b[m] += b[m - 1];
    }
  }
  int64_t idx_b = 0;
  int64_t res = 0;
  for (int64_t idx_a = N; idx_a >= 0; --idx_a) {
    if (a[idx_a] > K) {
      continue;
    }
    int64_t base = a[idx_a];
    int64_t tmp = idx_a;
    for (; idx_b < M; ++idx_b) {
      if (base + b[idx_b] > K) {
        break;
      }
    }
    tmp += idx_b;
    res = max(res, tmp);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 6424
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    int x;
    cin >> x;
    if(x==3 || x==5 || x==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
const int INF=1<<29;
const int N_MAX=100000;
int N;
vector<int> h;
int dp[N_MAX];
//dp[i-1]:頂点iが持つ最小コスト
signed main(){
    cin>>N;
    h.resize(N);
    REP(i,N) cin>>h[i];
    dp[N-1]=0;
    dp[N-2]=abs(h[N-1]-h[N-2]);
    for(int i=N-3;i>=0;--i){
        dp[i]=min(dp[i+1]+abs(h[i]-h[i+1]),
                  dp[i+2]+abs(h[i]-h[i+2]));
    }
    cout<<dp[0]<<endl;
}

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

int main() {
	int r,c;cin>>r>>c;
	vector<string>v(r);vector<bool>row(r,true);vector<bool>col(c,true);
	for(int i=0;i<r;i++)cin>>v[i];
	for(int i=0;i<r;i++){
		bool flag=true;
		for(int j=0;j<c;j++){
			//cout<<v[i][j]<<" "; 
			if(v[i][j]=='#')flag=false;
		}
		if(flag){
			row[i]=false;	
		}
	}
	for(int i=0;i<r;i++){
	//	cout<<row[i]<<" ";
	}
	for(int i=0;i<c;i++){
		bool flag=true;
		for(int j=0;j<r;j++){
			if(v[j][i]=='#')flag=false;
		}
		if(flag){
			col[i]=false;	
		}
	}
	vector<string>v1;
	for(int i=0;i<r;i++){
		string s;
		for(int j=0;j<c;j++){
			if(row[i]==true&&col[j]==true)s.push_back(v[i][j]);
			
		}
		if(!s.empty())
		v1.push_back(s);
		 
	}
	for(int i=0;i<v1.size();i++){
		cout<<v1[i]<<endl;
	}
	// your code goes here
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	vector<ll> dp(31,0);
	dp[0]=1;
	for(int i=0;i<30;i++){
		dp[i+1] += dp[i];
		if(i+2<=30) dp[i+2] += dp[i];
		if(i+3<=30) dp[i+3] += dp[i];
	}

	while(true){
		ll N=in();
		if(!N) break;

		ll M=dp[N]/3650LL;
		if(dp[N]%3650LL) M++;
		out(M);
	}
	
	return 0;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    if(2*c > a + b) {
        ans = a*x + b*y;
    } else {
        ans = 2*c*min(x, y);
        if(x > y) {
            ans += (x-y)*a;
        }else{
            ans += (y-x)*b;
        }
        ans = min(ans, (ll)2*c*max(x, y));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//hello.cpp
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
  long a[5],n,d;
  long time=0;
  for(int i=0;i<6;i++){
    if(i==0){
		cin >> n;
    }
    else{
      cin >> a[i-1];
      if(i==1) d = a[0];
      if(d>a[i-1]) d = a[i-1];
    }
  } 
  time = 5;
  time += (n + d -1)/d -1;
  cout << time << endl;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char ans = 'a';
        boolean found = false;
        for (char c = 'a'; c <= 'z'; c++) {
            for (int i = 0; i < a.length; i++) {
                if (a[i] == c) {
                    found = true;
                    break;
                }
                if (i == a.length - 1 && !found) {
                    ans = c;
                    System.out.println(ans);
                    return;
                }
            }
            found = false;
        }
        System.out.println("None");
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define MAXN 10010
#define pii  pair<ll, ll>
#define ss second
#define ff first

using ll = long long;
using namespace std;
const int mod = 1e9 + 7;

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

    vector<int> v(n), s(n);

    for (int i =0; i<n; i++){
        cin >> v[i];
        s[i] = v[i];
    }
    sort(s.begin(), s.end());

    for (int i=0; i<n; i++){
        if (v[i] == s[n-1]){
            cout << s[n-2] << endl;
        }
        else {
            cout << s[n-1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;



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

  int n, k;
  cin >> n >> k;

  cout << (n - k + 1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

int main() {

	int N;
	cin >> N;

	if (1 <= N && N <= 999) {
		cout << "ABC" << endl;
	}
	else{
		cout << "ABD" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,a,b,c,i,j,k,t=0;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  for(i=0;i<=a;i++)for(j=0;j<=b;j++)for(k=0;k<=c;k++)if(500*i+100*j+50*k==x)t++;
  printf("%d",t);
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    string S;
    input(S);

    string a = S.substr(0, S.size() / 2);
    string b = S.substr(S.size() / 2);

    ll res = 0;

    rep(i, 0, a.size())
    {
        res += (a[i] != b[b.size() - 1 - i]);
    }

    cout << res << endl;

    return 0;
}

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

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int array[128];

int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}

int main(){

    array['A']=1,array['C']=2,array['G']=3,array['T']=4;

    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];

    char* check_table = new char[TABLE_SIZE];

    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}



Measured memory_bytes: 4468