akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, K, A[123][123], d[123];
int c[123];

int main() {

	cin >> N >> K;

	rep(i, K) {
		cin >> d[i];
		rep(j, d[i]) {
			cin >> A[i][j];
			c[A[i][j] - 1]++;
		}
	}

	int ans = 0;
	rep(i, N) {
		if (!c[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3680
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#

def main():
    n, m, q = MII()
    query = [MII() for _ in range(q)]

    def calc_point(lst):
        sumv = 0
        for a, b, c, d in query:
            if lst[b-1] - lst[a-1] == c:
                sumv += d
        return sumv

    def dfs(lst):
        if len(lst) == n:
            return calc_point(lst)
        point = 0
        last_elm = lst[-1] if len(lst) > 0 else 1
        for i in range(last_elm, m+1):
            point = max(point, dfs(lst+[i]))
        return point

    print(dfs([]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
q=int(input())
dp=[0]*(10**5+1)
for i in a:
  dp[i]+=1
 
for j in range(q):
  b,c=map(int,input().split())
  ans+=(c-b)*dp[b]
  dp[c]+=dp[b]
  dp[b]=0
  print(ans)

Measured memory_bytes: 84756
//22
#include<iostream>
#include<queue>

using namespace std;

struct S{
  int t,h,x,y;
};

int main(){
  for(int w,h;cin>>w>>h,w|h;){
    int g[8][8];
    int sy,sx;
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	cin>>g[y][x];
	if(g[y][x]==2){
	  sy=y;
	  sx=x;
	}
      }
    }
    queue<S> que;
    S is={0,6,sx,sy};
    que.push(is);
    int p[8][8]={{}};
    while(!que.empty()){
      S c=que.front();
      if(c.h==0){
	que.pop();
	continue;
      }
      if(g[c.y][c.x]==3)break;
      que.pop();
      if(g[c.y][c.x]==4){
	c.h=6;
      }
      if(p[c.y][c.x]>=c.h)continue;
      p[c.y][c.x]=c.h;
      for(int i=0;i<4;i++){
	int d[]={0,1,0,-1,0};
	int ny=c.y+d[i];
	int nx=c.x+d[i+1];
	if(0<=nx&&nx<w&&0<=ny&&ny<h&&g[c.y][c.x]!=0){
	  S n={c.t+1,c.h-1,nx,ny};
	  que.push(n);
	}
      }
    }
    cout<<(que.empty()?-1:que.front().t)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int l, r, d, ans = 0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3584
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>

#define INF 10000000000;
#define mod 1000000007;
using namespace std;

int main(void){
   int N;
   cin>>N;
   double ans=0;
   double x[N]; char u[N][10]; 
   for(int i=0;i<N;i++){
       cin>>x[i]>>u[i];
   }
   for(int i=0;i<N;i++){
      if(u[i][0]=='B'&&u[i][1]=='T'&&u[i][2]=='C'){ans+=x[i]*380000;}
      else {ans+=x[i];}
   }
   cout<<ans;
   return 0;
}


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

#ifdef ONLINE_JUDGE
    #define DEBUG(...) // Skip Debug
#else
    #define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )
template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c= getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}
using namespace std;

const int N = 100000 + 5;

int n , k , l , r , pos , Ans , A[N];

int main()
{
	read(n) , read(k);
	rep(i , 1 , n)
	{
		read(A[i]);
		if(A[i] == 1) pos = i;
	}
	k -= 1;
	l = r = pos;
	while(l > 1 || r < n)
	{
		Ans++; int T1 = 0 , T2 = 0;
		if(l <= k && l > 1) T1 = k - l + 1;
		if(r + k > n && r < n) T2 = r + k - n;
		if(T1 > T2)
		{
			l = 1 , r += T1;
			continue;
		}
		else if(T2 > 0)
		{
			l -= T2 , r = n;
			continue;
		}
		if(l > 1)l = l - k;
		else r = r + k;
	}
	cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 640
n,m,x = map(int,input().split())
books = []

for i in range(n):
    book = list(map(int,input().split()))
    books.append(book)

min_money = -1

#n冊あるとき、2**n通りの選び方
count = 0
for i in range(2**n):
    select = format(count, "0" + str(n) + "b")
    lst = []
    while "1" in select:
        index = select.index("1")
        lst.append(books[index])
        select = select.replace("1","0",1)
    for j in range(1,m+1):
        skill = sum([lst[k][j] for k in range(len(lst))])
        if skill < x:
            break
    else:
        sum_money = sum([lst[j][0] for j in range(len(lst))])
        if min_money != -1:
            min_money = min(min_money, sum_money)
        else:
            min_money = sum_money

    count += 1

print(min_money)

Measured memory_bytes: 9240
n=int(input())
h=list(map(int, input().split()))
for i in range(n-1):
  if h[i+1] < h[i]-1:
    print('No')
    exit()
  elif h[i+1]== h[i]-1:
    h[i+1] = h[i+1]+1
print('Yes')

Measured memory_bytes: 14396
#include <iostream>

using namespace std;

int main(void) {
    int N = 0;
    cin >> N;

    int V[N];
    int C[N];
    for (int i=0; i<N; i++) {
        cin >> V[i];
    }
    for (int i=0; i<N; i++) {
        cin >> C[i];
    }

    int result = 0;

    for (int i=0; i<N; i++) {
        if (0 < V[i]-C[i]) {
            result += V[i]-C[i];
        }
    }

    cout << result;

    return 0;    
}

Measured memory_bytes: 256
// id: ALDS1_3_C
// CPU: 00:28sec  Memory: 32972KB
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

#define MAX_LEN 11

struct Node;
typedef int ElementType;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;

struct Node {
	ElementType element;
	Position prior;
	Position next;
};

List create_list(void);
void make_empty(List l);
void delete_list(List l);
bool is_empty(List l);
void insert(List l, ElementType x);
void delete(List l, ElementType x);
Position find(List l, ElementType x);
void delete_first(List l);
void delete_last(List l);
void print_list(List l);
static void terminate(const char *message);

int main(void)
{
	int n;
	List dlist = create_list();

	scanf("%d", &n);

	for ( int i = 0; i < n; ++i ) {
		char command[MAX_LEN + 1];
		int key;

		scanf("%s", command);
		
		if ( strcmp(command, "insert") == 0 ) {
			scanf("%d", &key);
			insert(dlist, key);
		}
		else if ( strcmp(command, "delete") == 0 ) {
			scanf("%d", &key);
			delete(dlist, key);
		}
		else if ( strcmp(command, "deleteFirst") == 0 )
			delete_first(dlist);
		else
			delete_last(dlist);
	}

	print_list(dlist);

	delete_list(dlist);

	return 0;
}

List create_list(void)
{
	List l;

	l = malloc(sizeof(struct Node));
	if ( l == NULL )
		terminate("Error in create: list could not be created.");

	l->prior = l;
	l->next = l;

	return l;
}

void make_empty(List l)
{
	while ( !is_empty(l) )
		delete_first(l);
}

void delete_list(List l)
{
	make_empty(l);

	free(l);
}

bool is_empty(List l)
{
	return l->next == l;
}

void insert(List l, ElementType x)
{
	Position tmp = malloc(sizeof(struct Node));

	if ( tmp == NULL ) {
		delete_list(l);
		terminate("Error in insert: fail to allocate space for the new node.");
	}

	tmp->element = x;
	tmp->next = l->next;
	tmp->prior = l;

	l->next = tmp;
	tmp->next->prior = tmp;
}

void delete(List l, ElementType x)
{
	Position p;

	p = find(l, x);

	if ( p != NULL ) {
		p->prior->next = p->next;
		p->next->prior = p->prior;
		
		free(p);
	}
}

Position find(List l, ElementType x)
{
	Position p;

	for ( p = l->next; p != l && p->element != x; p = p->next )
		;

	if ( p == l )
		p = NULL;

	return p;
}

void delete_first(List l)
{
	Position tmp = l->next;

	if ( is_empty(l) ) {
		delete_list(l);
		terminate("Error in delete_first: list is empty.");
	}

	l->next = tmp->next;
	tmp->next->prior = l;

	free(tmp);
}

void delete_last(List l)
{
	Position tmp = l->prior;

	if ( is_empty(l) ) {
		delete_list(l);
		terminate("Error in delete_last: list is empty.");
	}

	tmp->prior->next = l;
	l->prior = tmp->prior;

	free(tmp);
}

void print_list(List l)
{
	Position p = l->next;

	if ( p != l ) {
		printf("%d", p->element);
		p = p->next;
	}

	while ( p != l ) {
		printf(" %d", p->element);
		p = p->next;
	}

	printf("\n");
}

static void terminate(const char *message)
{
	printf("%s\n", message);
	exit(EXIT_FAILURE);
}


Measured memory_bytes: 32940
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
int main(){
  long long i, j, n, a, b;
  cin >> n >> a >> b;
  if(a>b){
    cout << 0;
    return 0;
  }
  if(n==1&&a<b){
    cout << 0;
    return 0;
  }
  cout << (b-a)*(n-2)+1;
  return 0;
}


Measured memory_bytes: 256
// AOJ 1069: Squid Multiplication
// 2017.8.18 bal4u@uu
// 2017.11.19

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

#define MAX 32000
unsigned long long odd[MAX+1], even[MAX+1];
int ol, el;

unsigned long long gcd(unsigned long long a, unsigned long long b)
{
	unsigned long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int cmp(unsigned long long *a, unsigned long long *b) {
	if (*a < *b) return -1;
	if (*a == *b) return 0;
	return 1;
}

char buf[640000], *p;
long long getint()
{
	unsigned long long n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, k, i;
	unsigned long long g, e1, e2, o1;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = (int)getint();
		k = (n*(n + 1)) >> 1;
		fgets(p=buf, 640000, stdin);
		for (ol = el = 0, i = 0; i < k; i++) {
			g = getint(), p++;
			if (g & 1) odd[ol++] = g;
			else       even[el++] = g;
		}
		qsort(odd, ol, sizeof(unsigned long long), cmp);
		qsort(even, el, sizeof(unsigned long long), cmp);
		e1 = even[0], e2 = even[1], o1 = odd[0];
		g = gcd(e1, o1), e1 /= g, o1 /= g;
		g = gcd(e2, o1), e2 /= g, o1 /= g;
		g = (int)sqrt((double)e1 * e2);
		printf("%d\n%d", (int)g, (int)(even[0]/g));
		for (i = 1; i < n; i++) printf(" %d", (int)(even[i]/g));
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2816
import itertools
def isinclude(l, r, x):
    if r-l >= x:
        return True
    elif r % x == 0 or l % x == 0:
        return True
    elif l % x > r % x:
        return True
    return False
    
l, r = map(int, input().split())
if r-1 == 1:
    print((l*r) % 2019)
else:
    if isinclude(l, r, 2019):
        print(0)
    elif isinclude(l, r, 673):
        print(0)
    else:
        checks = list(range(l, r+1))
        min_of_all = 9999
        for num1, num2 in itertools.combinations(checks, 2):
            ans = (num1 * num2) % 2019
            if ans < min_of_all:
                min_of_all = ans
        print(min_of_all)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int x, y; cin >> x >> y;
    
    rep(0,x+1){
        if(2*i + 4*(x-i) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3568
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

#define SIZE 400000
#define SIZE0 200000
#define INF 1000000000
#define mod 1000000009

typedef long long ll;

vector<pair<int,pair<long double, ll> > > G[SIZE];

ll power(ll k, ll n, int M){
  if(n==0) return 1;
  if(n==1) return k % M;

  ll res = power(k, n/2, M);

  res = res * res % M;

  if(n % 2)
    res = k % M * res % M;

  return res;
}

bool visited[SIZE];
long double memo[SIZE];
long long memo2[SIZE];

bool dfs(int now, int back = -1, long double sum = 0, ll modsum = 1) {

  if (visited[now]) return false;
  visited[now] = true;
  memo[now] = sum;
  memo2[now] = modsum;

  for(auto p : G[now]) {
    int to = p.first;
    long double v = p.second.first;
    ll x = p.second.second;

    if (to == back) continue;

    if (visited[to]) {
      //cerr << to << endl;
      //cerr << abs(sum - memo[to] + v) << endl;
      if (abs(sum - memo[to] + v) > 1) {
        //cerr << abs(sum - memo[to] + v) << endl;
        return true;
      } else {
        //cerr << abs(sum - memo[to] + v) << endl;
        if(modsum * x % mod != memo2[to]) return true;
      }
    } else {
      if(dfs(to, now, sum + v, modsum * x % mod)) {
        return true;
      }
    }
  }

  return false;
}

int main(){
  int N, M;

  scanf("%d%d", &N, &M);

  for(int i=0; i<M; i++) {
    int a, b, x;

    scanf("%d%d%d", &a, &b, &x);
    long double v = logl(x);
    a--; b--;

    G[a].push_back({b, {v, x} });
    G[b].push_back({a, {-v, power(x, mod-2, mod)}});
  }


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

    if (ok) {
      puts("No");
      return 0;
    }
  }

  puts("Yes");
  return 0;
}



Measured memory_bytes: 37916
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector< pair<int, int> >
const int inf = 1e9 + 7;
bool cmp(ii a, ii b) {
	if (a.first != b.first)
		return a.first > b.first;
	else
		return a.second < b.second;
}
signed main() {
	int n, sum = 0;
	cin >> n;
	vii a(n + 1);
	vi ans(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	a[0] = make_pair(inf, 0);
	sort(a.begin(), a.end(), cmp);
	ii tmp = a[1];
	sum = tmp.first;
	for (int i = 2; i <= n; i++) {
		if (a[i].first < tmp.first) {
			ans[tmp.second] += sum - a[i].first * (i - 1);
			sum = a[i].first * i;
			if (a[i].second < tmp.second)
				tmp = a[i];
			else
				tmp.first = a[i].first;
		}
		else
			sum += a[i].first;
	}
	ans[tmp.second] += sum;
	for(int i = 1; i <= n; i++) 
		cout << ans[i] << endl;
}

Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string str;
	cin >> str;
	if(str[0]=='9'||str[1]=='9'){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vi A(N), B(N);
	rep(i, N)
		cin >> A[i];
	rep(i, N)
		cin >> B[i];
	vi Al(N + 1, -1);
	vi Ar(N + 1, -1);
	vi Bl(N + 1, -1);
	vi Br(N + 1, -1);
	rep(i, N) {
		Ar[A[i]] = i;
		Br[B[i]] = i;
	}
	rrep(i, N) {
		Al[A[i]] = i;
		Bl[B[i]] = i;
	}
	vi X(N, 0);
	bool can = 1;
	rep(i, N + 1) {
		if (Al[i] == -1 || Bl[i] == -1)
			continue;
		int AL = Al[i];
		int AR = Ar[i];
		int BL = Bl[i];
		int BR = Br[i];
		int L = AL - BR;
		int R = BL - AR;
		if (AR - AL + 1 + BR - BL + 1 > N)
			can = 0;
		if (L > 0) {
			X[L]++;
			X[AR - BL + 1]--;
		}
		else if (R <= 0) {
			X[0]++;
			X[AR - BL + 1]--;
			X[L + N]++;
			X[N]--;
		}
		else {
			X[L + N]++;
			X[N - R + 1]--;
		}
	}
	int n = -1;
	if (can) {
		int k = 0;
		rep(i, N) {
			k += X[i];
			if (k == 0)
				n = i;
		}
	}
	if (n == -1)
		cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		rep(i, N)
			cout << B[(i - n + N) % N] << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 8792
package main

import (
	"fmt"
)
func main() {
	var a,b int
	fmt.Scan(&a,&b)
	if (a * b * 1)%2 == 1{
		fmt.Println("Yes")
	}else if (a * b * 2)%2 == 1{
		fmt.Println("Yes")
	}else if (a * b * 3)%2 == 1{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=(1e5)+10;
int n,a[maxn];
ll iv[maxn],ans,jc=1,sum[maxn];
int main() {
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	iv[0]=sum[0]=iv[1]=sum[1]=1;
	for (int i=2;i<=n;i++)
		iv[i]=mod-iv[mod%i]*(mod/i)%mod;
	for (int i=2;i<=n;i++)
		sum[i]=(sum[i-1]+iv[i])%mod;
	for (int i=1;i<=n;i++)
		ans+=a[i]*(sum[i]+sum[n-i+1]-1+mod)%mod,ans%=mod,jc=jc*i%mod;
	printf("%lld\n",ans*jc%mod);;
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,m;
        cin >> n >> m;
        if(n==m){
            cout << "Yes";
        }
        else{
            cout << "No";
        }

        

}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-06-07 21:36:48
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

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

    if (k >= s.length()) {
        cout << s << endl;
    } else {
        for (int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
int x=1;
int input;
for(int i=1;i<=10000;i++)
{cin >> input;
if(input!=0)
{cout << "Case " << x << ": " << input << endl;}
else
{cout << "" << endl;}
x=x+1;
}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long int ans=1;
  for(int i=1;i<=N;i++){
    ans*=i;
    if(ans>=10000000000){
      ans=ans%1000000007;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//拡張ダイクストラ練習
//(https://atcoder.jp/contests/wupc2012-closed/tasks/wupc2012_5)
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
typedef pair<long long, pair<int, int>> P; //時間、<場所、金>
using Edge = pair<int, pair<long long, long long>>;
using Graph = vector<vector<Edge>>;

int N, M, S;
Graph G;

vector<vector<long long>> dijkstra(int st, vector<vector<long long>> d, int k) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(N, vector<long long>(3000, INF));
    if(k >= 3000) {
        k = 2999;
    }
    d[st][k] = 0LL;
    que.push(P(0LL, make_pair(st, k)));
    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second.first;
        int kane = p.second.second;
        if(d[v][kane] < p.first) {
            continue;
        }
        for(auto e : G[v]) {
            long long cost = e.second.first;
            long long time = e.second.second;
            if(kane - cost < 0) {
                continue;
            }
            if(kane > 2500 && cost < 0) {
                continue;
            }
            long long nexttime = d[v][kane] + time;
            long long nextkane = kane - cost;
            if(nextkane > 2500) {
                nextkane = 2999;
            }
            if(d[e.first][nextkane] > nexttime) {
                d[e.first][nextkane] = nexttime;
                que.push(P(d[e.first][nextkane], make_pair(e.first, nextkane)));
            }
        }
    }
    return d;
}
int main() {
    cin >> N >> M >> S;
    G.assign(N, vector<Edge>());
    rep(i, 0, M) {
        long long u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        G[u].push_back(make_pair(v, make_pair(a, b)));
        G[v].push_back(make_pair(u, make_pair(a, b)));
    }
    rep(i, 0, N) {
        long long c, d;
        cin >> c >> d;
        G[i].push_back(make_pair(i, make_pair(-c, d)));
    }
    vector<vector<long long>> di;
    di = dijkstra(0, di, S);
    // cout << "4" << endl;
    // rep(i, 0, N) {
    //     rep(j, 0, 4) { cout << mod4[i][j] << " "; }
    //     cout << endl;
    // }
    // cout << "7" << endl;
    // rep(i, 0, N) {
    //     rep(j, 0, 7) { cout << mod7[i][j] << " "; }
    //     cout << endl;
    // }
    rep(i, 1, N) {
        long long min = INF;
        rep(j, 0, 3000) {
            if(di[i][j] < min) {
                min = di[i][j];
            }
        }
        cout << min << endl;
    }
}


Measured memory_bytes: 6360
#include<stdio.h>
#include<string.h>
int n,m,p,c[100000]={},f[100000]={},i,a=0,b=0;
char s[3];
int main(){
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%s",&p,s);
        if(f[p]==1)continue;
        if(!strcmp(s,"AC")){
            a++;
            f[p]=1;
            b+=c[p];
            if(a==n)break;
        }
        else c[p]++;
    }
    printf("%d %d",a,b);
    return 0;
}

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

using namespace std;

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

  int ans = 0;
  for (int i = 3; i <= N; i+=2) {
    vector<int> divisor;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) divisor.push_back(j);
    }

    if (divisor.size() == 8) ans++;
  }

  cout << ans;
}

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

void main_()
{
    int N, M;
    vector<int> Ts;
    vector<pair<int, int>> Drinks;
    cin >> N;
    copy_n(istream_iterator<int>(cin), N, back_inserter(Ts));
    cin >> M;
    for (size_t i = 0; i < M; i++) {
        int p, x;
        cin >> p >> x;
        Drinks.emplace_back(p, x);
    }

    int normal_total = accumulate(begin(Ts), end(Ts), 0);

    for (auto&& d : Drinks) {
        int problem_i = d.first - 1;
        int problem_time = d.second;
        int diff = problem_time - Ts[problem_i];
        cout << normal_total + diff << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int LL;
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
LL modexpo(LL a, LL b) {
  LL ans=1;
  while(b>0){
    if((b&1)==1){
      ans=(ans*a)%mod;
    }
    b=b>>1;
    a=(a*a)%mod;
  }
  return ans; 
}
void solve(LL k){
LL dist, tim, speed; 
cin>>dist>>tim>>speed; 
if(tim*speed>=dist) {
  cout<<"Yes"<<endl; 
}
else{
  cout<<"No"<<endl; 
  }
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 3688
from collections import deque

N, M = map(int, input().split())
Ai = list(map(int, input().split()))

Ai.sort(reverse=True)
Ai_deque = deque(Ai)
kari = deque()
for _ in range(M):
    try:
        if Ai_deque[0] > kari[0]:
            value = Ai_deque.popleft() // 2
        else:
            value = kari.popleft() // 2
    
    except:
        if not kari:
            value = Ai_deque.popleft() // 2
        else:
            value = kari.popleft() // 2
    
    kari.append(value)
    
print(sum(Ai_deque) + sum(kari))

Measured memory_bytes: 14508
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        int[] inputs = {a, b, c};
        Arrays.sort(inputs);
 
        int da = inputs[2] - inputs[0];
        int db = inputs[2] - inputs[1];
 
        if (da % 2 == 0 && db % 2 == 0) {  // even & even
            System.out.println((da / 2) + (db / 2));
        }
        else if (da % 2 == 1 && db % 2 == 1) {  // odd & odd
            System.out.println(((da - 1) / 2) + ((db - 1) / 2) + 1);
        }
        else {  // odd & even
            System.out.println((da / 2) + (db / 2) + 2);
        }
    }
}


Measured memory_bytes: 21716
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll a,b;
    cin>>a>>b;
    if(a>=13){cout<<b<<endl;}
    else if(a>5){cout<<b/2<<endl;}
    else{cout<<0<<endl;}
    
    
    return 0;
}


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

int main(){
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  if(n <= k){
    cout << s << endl;
  }
  else{
    cout << s.substr(0,k) << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359
 
int main(){
  ll X, A, B, i, j;
  
  cin >> X;
  
  for (ll A = -130; A <= 130; A++){
    for(ll B = -130; B <= 130; B++){
      if(pow(A, 5) - pow(B, 5) == X){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> d(n);
    rep(i,n) cin >> d[i];
    ll res = 0;
    rep(i,n)rep(j,n){
        if(i >= j)continue;
        res += d[i] * d[j];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int mod = 998244353;
const int maxN = 1e6 + 7;

inline int pls(int x, int y) {return (x + y) % mod;}
inline int mns(int x, int y) {return pls(x, mod - y);}
inline int mul(int x, int y) {return 1LL * x * y % mod;}
inline void Add(int &x, int y) {x = pls(x, y);}
inline void Mul(int &x, int y) {x = mul(x, y);}

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
int iv[maxN];
int fac[maxN], ifac[maxN];

inline int C(int x, int y) {return (y <= x) ? mul(mul(fac[x], ifac[y]), ifac[x - y]) : 0;}
inline int ways(int x, int y) {return C(x + y, y);}

int main() {

	n = ri(), m = ri();
	if (n < m) swap(n, m);
	iv[1] = 1; rep (i, 2, n + m) iv[i] = mul(iv[mod % i], mod - mod / i);
	fac[0] = 1; rep (i, 1, n + m) fac[i] = mul(fac[i - 1], i);
	ifac[0] = 1; rep (i, 1, n + m) ifac[i] = mul(ifac[i - 1], iv[i]);
	
	int res = 0;
	Add(res, mul(ways(n, m), n));
	rep (i, 1, m) Add(res, mul(iv[2], mul(ways(i, i), ways(n-i, m-i))));

	printf("%d\n", mul(res, mul(mul(ifac[n+m], fac[m]), fac[n])));

	return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>

int main(void)
{	
	
	int a,b,c,d,n,sum,count;
	
	while(scanf("%d",&n) != EOF){;
	sum =0;
	count = 0;
	for(a=0;a<=9;a++){
	 for(b=0;b<=9;b++){
	  for(c=0;c<=9;c++){
	   for(d=0;d<=9;d++){
	   	
	   	sum = a+b+c+d;
	   	if(sum == n){
	   		count += 1;
	   	}else{
	   		;
	   	}
	   }
	  }
	 }
	}
	
	printf("%d\n",count);
	}
return 0;
}

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

using namespace std;

int n, t, ans; 

int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d", &t);
		if (i==1) ans=t;
		else ans=__gcd(ans, t);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a;
	cin>>n>>a;
	string s[n];
	for(int i=0;i<n;i++)cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)cout<<s[i];
	cout<<endl;

return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n + 1];
      Arrays.fill(arr, 2);
      arr[1]--;
      for(int i = 2; i * 2 <= n; i++) {
        for(int j = i * 2; j <= n; j += i)
          arr[j]++;
      }
      long sum = 0;

      for(int i = 1; i <= n; i++)
        sum += ((long)arr[i] * i);
      System.out.println(sum);
  }
}

Measured memory_bytes: 74828
W,H,x,y,r = map(int,input().split())
if x-r<0 or x+r>W or y-r<0 or y+r>H :
    print("No")
else:
    pass
if x-r>=0 and x+r<=W and y-r>=0 and y+r<=H:
    print("Yes")
else:
    pass



Measured memory_bytes: 5596
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    if (a*b)%2==1:
        print('Odd')
    else:
        print('Even')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,s;
int main()
{
cin>>a>>b>>c>>n;
for(int i=0;i<=a;i++)
for(int j=0;j<=b;j++)
if(n-i*500-j*100>=0 && n-i*500-j*100<=c*50)s++;
cout<<s;
}

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




int main(){

  ll mod=1e9+7;
  ll n,m,ans=0,a,b,c;

  cin>>n;

  rep(i,n){
      if(i==0)continue;
      a=i;
      if(n%a==0)ans+=n/a-1;
      else ans+=n/a;
  }
cout<<ans;
    

}

Measured memory_bytes: 3632
nums = input().split(" ")
nums = list(map(int, nums))
sign = []

ir = False
if nums[0]==0 and nums[1]==0:
  ir = True
if nums[2]==0 and nums[3]==0:
  ir = True

if nums[0] == 0:
  nums[0] = 1
if nums[1] == 0:
  nums[1] = -1
if nums[2] == 0:
  nums[2] = 1
if nums[3] == 0:
  nums[3] = -1

anss = []
for i in range(2):
  for j in range(2):
    anss.append(nums[i]*nums[j+2])
if ir:
  print(0)
else:
	print(max(anss))

Measured memory_bytes: 9224
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String W = scan.next();
        int count = 0;

        while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 26072
N, K = gets.split.map(&:to_i)

prob = 0.0
1.upto(N) do |i|
  if K <= i
    prob += 1.0 / N
  else
    prob += (1.0 / N) * (0.5 ** Math.log2(K / i.to_f).ceil)
  end
end

puts prob


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

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

vector<int> yakusuu(int x);

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

  vector<int> a(n);
  rep(i,n) cin >> a.at(i);

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

  
  vector<int> double_check(n,0);

  for(int i=0; i<n-1; i++){
    if(a.at(i)==a.at(i+1)) double_check.at(i)=1, double_check.at(i+1)=1;
  }

  int ans=0;

  rep(i,a.size()){
    vector<int> d;
    d =  yakusuu(a.at(i));
    bool ok=true;
    rep(j,d.size()){
      if(d.at(j)!=a.at(i)&&binary_search(a.begin(), a.end(), d.at(j))) {ok=false; break;}
    }
    if(ok&&double_check.at(i)==0) ans++;
  }

  cout << ans;

  
  
}

vector<int> yakusuu(int x){
  vector<int> d;
  for(int i=1; i<sqrt(x)+1; i++){
    if(x%i==0) d.push_back(i), d.push_back(x/i);    
  }

  return d;
}

Measured memory_bytes: 4852
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		string s;
		int w;
		cin >> s >> w;
		for (int i=0 ; i<(int)s.length() ; i+=w)
		cout << s[i];
		cout << endl;
		return 0;  
}  

/*
               
 

*/


Measured memory_bytes: 3624
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e3 + 5;
const double eps = 1e-9;
char a[N][N];
int h, w, k, dp[N][N];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int in(int x, int y) {
  return 1 <= x && x <= h && 1 <= y && y <= w && a[x][y] != '#';
}

int main() {
  scanf("%d %d %d", &h, &w, &k);
  pii s;
  for (int i = 1; i <= h; i++) {
    scanf("%s", a[i]+1);
    for (int j = 1; j <= w; j++) {
      if (a[i][j] == 'S')
        s = {i, j};
      dp[i][j] = inf;
    }
  }
  deque<pii> pq;
  pq.pb(s);
  dp[s.st][s.nd] = 0;
  while (!pq.empty()) {
    auto it = pq.front(); pq.pop_front();
    if (dp[it.st][it.nd] == k)
      continue;
    for (int i = 0; i < 4; i++) {
      int nx = it.st + dx[i], ny = it.nd + dy[i];
      if (!in(nx, ny) || dp[nx][ny] <= dp[it.st][it.nd] + 1)
        continue;
      dp[nx][ny] = dp[it.st][it.nd] + 1;
      pq.pb({nx, ny});
    }
  }
  int ans = inf;
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++) if (dp[i][j] != inf) {
      ans = min(ans, (min({i-1, j-1, h-i, w-j}) + k - 1) / k + 1);
    }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4992
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        keys: [(usize,[usize1]);m]
    }

    //println!("{:?}", keys);

    // dp[x][y] = x(=1101など)の組み合わせの宝箱をy個までの鍵を使って開ける場合の最小価格
    let mut dp = vec![vec![MAX; 1 << n]; m + 1];

    for i in 1..m + 1 {
        let mut key_mask = 0;
        for &k in &keys[i - 1].1 {
            key_mask += 1 << k;
        }

        for j in 1..1 << n {
            if key_mask & j == j {
                dp[i][j] = cmp::min(dp[i - 1][j], keys[i - 1].0);
            } else {
                dp[i][j] = cmp::min(dp[i][j], dp[i - 1][j]);
            }
            if dp[i - 1][j] != MAX {
                dp[i][key_mask | j] = cmp::min(dp[i - 1][j] + keys[i - 1].0, dp[i][key_mask | j]);
            }
        }
    }

    //println!("{:?}", dp);

    let ans = dp[m][(1 << n) - 1];
    if ans == MAX {
        println!("{:?}", -1);
    } else {
        println!("{:?}", dp[m][(1 << n) - 1]);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 34488
import java.util.*;
import java.math.*;


public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long S = Long.parseLong(sc.next());
      long ans = solve(S);
//      return ans;
    }

    public static long solve(long S) {

//        (x1−x3)(y2−y3) = S + (x2−x3)(y1−y3)
//        x1*y2 = S + x2*y1
//        3 = x2*y1 - x1*y2
//        1 3 0 0
//          S = x1*y2 - x2*y1

        long x1, y1, x2, y2, x3, y3 = 0l;
        long sqrt = (long) Math.ceil(Math.sqrt(S));
        long base = sqrt*sqrt-S;
        long sapo = 0l;
        if(base<0l){
          sapo = 0;
        }
        System.out.println(
          new StringBuilder().append(base+sapo).append(" ")
          .append(sqrt).append(" ")
          .append(sqrt+sapo).append(" ")
          .append(1).append(" ")
          .append(0+sapo).append(" ")
          .append(0).toString()
        );
        return 0l;
//        return calc(sqrt*sqrt-S+sapo, sqrt, sqrt+sapo, 1l, 0l+sapo, 0l);
//        System.out.println(calc(sqrt*sqrt-S+sapo, sqrt, sqrt+sapo, 1l, 0l+sapo, 0l));
    }
    public static long calc(long x1,long y1,long x2,long y2,long x3,long y3){
      if(x1 < 0l || y1 < 0l || x2 < 0l || y2 < 0l || x3 < 0l || y3 < 0l
      || x1 > 1000000000l || y1  > 1000000000l || x2  > 1000000000l || y2  > 1000000000l || x3  > 1000000000l || y3  > 1000000000l
      ){
        System.out.println(
          new StringBuilder().append(x1).append(" ").append(y1).append(" ").append(x2).append(" ")
          .append(y2).append(" ").append(x3).append(" ").append(y3).append(" ")
          .append(" ans;").append(Math.abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))).toString()
        );
        throw new Error();
      }
      return Math.abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3));
    }

}


Measured memory_bytes: 21840
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, K, X, Y, ans;
  cin >> N >> K >> X >> Y;
  if (N>=K) {
    ans = X * K + Y * (N - K);
  }
  else {
    ans = X * N;
  }
  cout << ans << endl;
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 200005;
ll a[N] , b[N];


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , m , k;
    cin >> n >> m >> k;
    range(i,1,n){
        cin >> a[i];
        a[i] += a[i-1];
    }

    range(i,1,m){
        cin >> b[i];
        b[i] += b[i-1];
    }


    int ans = 0;
    range(i,1,n){
        if(a[i] > k)break;
        ll have = k - a[i];
        int idx = upper_bound(b , b + m + 1 , have) - b - 1;
        ans = max(ans , i + idx);
    }



    range(i,1,m){
        if(b[i] > k)break;
        ll have = k - b[i];
        int idx = upper_bound(a , a + n + 1 , have) - a - 1;
        ans = max(ans , i + idx);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6744
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;

int main(){
  long long n, m;
  cin >> n >> m;
  priority_queue <long long> list;
  priority_queue <int> log_list;
  long long total = 0;

  for (long long i = 0; i < n; i++)
  {
    long long a;
    cin >> a;
    list.push(a);
    total += a;
    //log_list.push(floor(log2l(a)));
  }

  for (long i = 0; i < m; i++)
  {
    long long t = list.top();
    list.pop();
    total = total - (t - floor(t/2));
    list.push(floor(t/2));
    if(total <= 0)break;
  }

  cout << total << endl;
}

Measured memory_bytes: 1400
/*
氏名：鈴木丈人
学籍番号：190441067
概要：3つの整数を読み込み、それらを値が小さい順に並べて出力するプログラム
*/
#include<stdio.h>
int main(void)
{
	int number[3];   //整数
	int i, j;   //くり返し用
	int temp;   //入れ替え用

	scanf("%d %d %d", &number[0], &number[1], &number[2]);

	/*バブルソート昇順*/
	for (i = 0; i < 2; i++)
	{
		for (j = 2; j>i; j--)
		{
			if (number[j - 1] > number[j])
			{
				temp = number[j - 1];
				number[j - 1] = number[j];
				number[j] = temp;
			}
		}
	}
	printf("%d %d %d\n", number[0], number[1], number[2]);

	return 0;
}


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

int main()
{
    int iRecW = 0;
    int iRecH = 0;
    int iCirX = 0;
    int iCirY = 0;
    int iCirR = 0;
    
    cin >> iRecW >> iRecH >> iCirX >> iCirY >> iCirR;
    if ((iCirX + iCirR <= iRecW) && (iCirX - iCirR >= 0) && (iCirY + iCirR <= iRecH) && (iCirY - iCirR >= 0))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,w=mii()
wei,val=[0],[0]

for i in range(n):
    x,y=mii()
    wei.append(x)
    val.append(y)

dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(1,w+1):
        if j>=wei[i]:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-wei[i]]+val[i])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[-1][-1])



Measured memory_bytes: 125436