akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MAX=200005;
const ll MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];
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 i,ll j){
    if(i<j) return 0;
    if(i<0||j<0) return 0;
    return fac[i]*(finv[j]*finv[i-j]%MOD)%MOD;
}
ll p[10000];
ll pp=0;
map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(ll i=2;i*i<=n;i++){
        bool w=true;
        while(n%i==0){
            res[i]++;
            n=n/i;
            if(w){
                w=false;
                p[pp]=i;
                pp++;
            }
        }
    }
    if(n!=1){
        res[n]=1;
        p[pp]=n;
        pp++;
    }
    return res;
}
ll n,m;
ll ans=1;
int main(void){
    cin>>n>>m;
    COMinit();
    map<ll,ll> M;
    M=prime_factor(m);
    for(int i=0;i<pp;i++){
        ans=(ans*COM(n-1+M[p[i]],M[p[i]]))%MOD;
    }
    cout<<ans<<endl;

}



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n], b[n], c[n];
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  int dp[401][401];
  fill(dp[0], dp[401], inf);
  dp[0][0] = 0;
  rep(i, n) {
    for(int j = 400; j >= a[i]; j--) {
      for(int k = 400; k >= b[i]; k--) {
	dp[j][k] = min(dp[j][k], dp[j-a[i]][k-b[i]] + c[i]);
      }
    }
  }
  int ans = inf;
  reps(i, 1, 401) reps(j, 1, 401) {
    if(i*mb == j*ma) ans = min(ans, dp[i][j]);
  }
  cout << (ans == inf ? -1 : ans) << endl;

  return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n;ld x,y,sum=0.0;
	cin>>n;
	vector<ll> a;
	REP(i,0,n-1)
	{
		ll m;
		cin>>m;
		a.push_back(m);
	}
	sort(a.begin(),a.end());
	x=(a[0]+a[1])/2.0;
	REP(i,2,n-1)
		x=(x+a[i])/2.0;
	cout<<x;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int x, a, b; cin >> x >> a >> b;
	if (abs(a - x) >= abs(b - x)) {
		cout << 'B' << endl;
	}
	else {
		cout << 'A' << endl;
	}
	cin >> x;
}

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

#include <atcoder/all>
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (ll i = ((ll)(n)-1); i >= 0; --i)
#define rreps(i, n) for (ll i = ((ll)(n)); i > 0; --i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repc2(i, s, n) for (ll i = (s); i <= (ll)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;
const int INF = 0x3f3f3f3f;
int n, m;
char M[51][51];
int dist[51][51][100];
int vert(int y, int x) {
    return y * m + x + 100;
}
int o(int i) {
    return i;
}
pair<int, int> yx(int v) {
    return make_pair((v - 100) / m, (v - 100) % m);
}
void bfs(int sy, int sx, int i) {
    queue<pair<int, pair<int, int>>> Q;
    Q.push(make_pair(0, make_pair(sy, sx)));
    dist[sy][sx][i] = 0;
    while (!Q.empty()) {
        auto u = Q.front();
        int d = u.first;
        int y = u.second.first;
        int x = u.second.second;
        Q.pop();
        if (y + 1 < n && M[y + 1][x] != '#' && dist[y + 1][x][i] > d + 1) {
            Q.push(make_pair(d + 1, make_pair(y + 1, x)));
            dist[y + 1][x][i] = d + 1;
        }
        if (x + 1 < m && M[y][x + 1] != '#' && dist[y][x + 1][i] > d + 1) {
            Q.push(make_pair(d + 1, make_pair(y, x + 1)));
            dist[y][x + 1][i] = d + 1;
        }
    }
}
int s, t;
vector<pair<int, int>> sources;
int main() {
    cin >> n >> m;
    s = n * m + 100, t = n * m + 1 + 100;
    mcf_graph<int, int> graph(n * m + 2 + 100);

    rep(y, n) rep(x, m) {
        cin >> M[y][x];
        if (M[y][x] == '#') {
            ;
        } else {
            if (M[y][x] == 'o') {
                graph.add_edge(s, sources.size(), 1, 0);
                sources.push_back(make_pair(y, x));
            }
            graph.add_edge(vert(y, x), t, 1, 0);
        }
    }
    memset(dist, 0x3f, sizeof(dist));
    rep(i, sources.size()) {
        bfs(sources[i].first, sources[i].second, i);
        rep(y, n) rep(x, m) {
            if (dist[y][x][i] != INF) {
                graph.add_edge(i, vert(y, x), 1, 300 - dist[y][x][i]);
            }
        }
    }
    auto flow = graph.flow(s, t, sources.size());
    int cnt = 0;
    auto edges = graph.edges();
    for (const auto &e : edges) {
        if (e.from != s && e.to != t && e.flow > 0) {
            cnt += e.flow;
            // auto u = yx(e.from);
            auto v = yx(e.to);
            M[v.first][v.second] = '-';
        }
    }
    // rep(y, n) {
    //     rep(x, m) { printf("%c", M[y][x]); }
    //     puts("");
    // }
    // rep(i, sources.size()) rep(y, n) {
    //     rep(x, m) { printf("%d\t", dist[y][x][i]); }
    //     puts("");
    // }
    // cerr << flow.first << " " << flow.second << endl;
    cout << 300 * sources.size() - flow.second << endl;
    return 0;
}

Measured memory_bytes: 9392
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main {

	static int W,N;
	static int[][] dp;
	static int[][] a;
	static Stack<Integer>stack;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int T=0;
		for(;;){
			T++;
			W=cin.nextInt();
			if(W==0)break;
			stack=new Stack<Integer>();
			N=cin.nextInt();
			dp=new int[N+1][W+1];
			a=new int[N+1][2];
			for(int i=1;i<=N;i++){
//				Arrays.fill(dp[i], 1<<30);
				String[] s=cin.next().split(",");
				a[i][0]=Integer.parseInt(s[0]);
				a[i][1]=Integer.parseInt(s[1]);
			}
			
//			dp(0,0);
//			System.out.println(dp(0,0));
			int max=-(1<<30),w=(1<<30);
			for(int i=1;i<=N;i++){
				for(int j=1;j<=W;j++){
					if(j-a[i][1]>=0){
						dp[i][j]=Math.max(dp[i-1][j], dp[i-1][j-a[i][1]]+a[i][0]);
						if(max<dp[i][j]){
							max=dp[i][j];
							w=j;
						}
						else if(max==dp[i][j]){
							w=Math.min(w, j);
						}
					}
					else{
						dp[i][j]=dp[i-1][j];
					}
				}
			}
			System.out.println("Case "+T+":");
			System.out.println(max+"\n"+(w));
			
			if(stack.isEmpty())continue;
			
			for(int i=0;i<N;i++){
				for(int j=0;j<=W;j++){
					if(dp[i][j]==1<<30)continue;
					if(max<dp[i][j]){
						max=dp[i][j];
						w=j;
						System.out.println(j);
					}
					else if(max==dp[i][j]){
						w=Math.min(w, j);
						System.out.println(j);
					}
				}
			}
			
			System.out.println(max+" "+w);
		}
	}
	static int dp(int t,int w){
		int re=0;
		if(t==N){
			return 0;
		}
		if(dp[t][w]!=1<<30)return dp[t][w];
		re=Math.max(re, dp(t+1,w));
		
		for(int i=t;i<N;i++){
			if(a[i][0]!=0){
				int tmp=a[i][0];
				if(w+a[i][1]>W)continue;
				stack.add(i);
				re=Math.max(re,dp(t+1,w+a[i][1])+tmp);
				stack.pop();
				a[i][0]=tmp;
			}
		}
		return dp[t][w]=re;
	}
	
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b,a%b);
}

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

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

  ll A,B,C,D;
  cin>>A>>B>>C>>D;

  ll ac=(A-1)/C;
  ll bc=B/C;
  ll ad=(A-1)/D;
  ll bd=B/D;
  ll acd=(A-1)/lcm(C,D);
  ll bcd=B/lcm(C,D);

  ll ans=(B-A+1);
  cout<<ans-(bc-ac)-(bd-ad)+(bcd-acd)<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main() {
	int i,tmp,j,s[3],total;
	
	for (i = 0; i < 3; i++) {
		scanf("%d", &s[i]);
	}
	if (s[0]< 1 || s[0]>100 || s[1] < 1 || s[1]>100 || s[2] < 1 || s[2]>100) {
		printf("エラー\n");
		return 0;
	}
	for (i = 0; i<3; ++i) {
		for (j = i + 1; j<3; ++j) {
			if (s[i] > s[j]) {
				tmp = s[i];
				s[i] = s[j];
				s[j] = tmp;
			}
		}
	}
	total = (s[1] - s[0]) + (s[2]-s[1]);
	printf("%d\n",total);

	return 0;
}

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	int ret = 0;
	for (int i = 1; i + 1 < n; ++i) 
		if (v[i] < v[i+1] && v[i] > v[i-1] || v[i] > v[i+1] && v[i] < v[i-1]) ret++;
	cout << ret << '\n';
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

typedef struct Node{
	int data;
	struct Node *prev;
	struct Node *next; 
}List, ListNode;

void init(List ** L)
{
	*L = (List*)malloc(sizeof(List));
	(*L)->prev = (*L);
	(*L)->next = (*L);
}

//巧妙 sssssssssss
ListNode* searchNode(List *L, int x)
{
	ListNode *curr = L->next;
	
	while (curr != L && curr->data != x) {
		curr = curr->next;
	}
	
	return curr;
}

//不需要特殊处理无非空结点的情况 
void insertNode(List *L, int x)
{
	ListNode *firstNode = NULL;
	ListNode *newNode = (ListNode*)malloc(sizeof(ListNode));
	newNode->data = x;
	
	newNode->next = L->next;
	newNode->next->prev = newNode;
	L->next = newNode;
	newNode->prev = L;
}

//将搜索与删除解耦合，增强复用性
void deleteNode(List *L, ListNode *p)
{
	if (p == L)
		return;
	p->prev->next = p->next;
	p->next->prev = p->prev;
	free(p);
}

void deleteKey(List *L, int x) 
{
	deleteNode(L, searchNode(L, x));
}

void deleteFirst(List *L)
{
	deleteNode(L, L->next);
}

void deleteLast(List *L)
{
	deleteNode(L, L->prev);
}

void print(List *L)
{
	ListNode *curr = L->next;
	
	while (curr != L) {
		printf("%d", curr->data);
		if (curr->next != L) {
			printf(" ");
		} 
		curr = curr->next;
	}
	printf("\n");
}

int main()
{
	int n;
	char op[20];
	int x;
	List *L;
	
	init(&L);
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", op);
		if (strcmp(op, "insert") == 0) {
			scanf("%d", &x);
			insertNode(L, x);
		}
		if (strcmp(op, "delete") == 0) {
			scanf("%d", &x);
			deleteKey(L, x);
		}
		if (strcmp(op, "deleteFirst") == 0) {
			deleteFirst(L);
		}
		if (strcmp(op, "deleteLast") == 0) {
			deleteLast(L);
		}
	}
	print(L);
	
	return 0;
}


Measured memory_bytes: 33812
//反向搜索（类比于反向建图） 
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
map<string,int> dp;
int next[4]={-1,1,-4,4};
//左，右，上，下移动 

void bfs()
{
	queue<string> q;
	q.push("01234567");
	dp["01234567"]=0;
	//dp兼有标记作用 
	while(q.size())
	{
		string s=q.front();
		q.pop();
		string::size_type x=s.find('0');
		//find函数查找指定元素的下标 
		for(int i=0;i<4;i++)
		{
			int tx=x+next[i];
			//右上角不能右移，左下角不能左移 
			if(0<=tx&&tx<8&&!(x==3&&i==1)&&!(x==4&&i==0))
			{
				string ts=s;
				swap(ts[x],ts[tx]);
				//若dp中无该字符串，则未访问过
				//可访问之 
				if(dp.find(ts)==dp.end())
				{
					dp[ts]=dp[s]+1;
					q.push(ts);
				}	
			}
		}
	}
}

int main()
{
	bfs();
	string s;
	while(getline(cin,s))
	{
		s.erase(remove(s.begin(),s.end(),' '),s.end());
		//删除字符串中的空格(依赖于头文件algorithm) 
		cout<<dp[s]<<endl;
	}
	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, s1 = 0, s2 = 0, s3 = 0, s4 = 0;
    string s;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> s;
        if(s == "AC") {
           s1++;
        }
        if(s == "WA") {
            s2++;
        }
        if(s == "TLE") {
            s3++;
        }
        if(s == "RE") {
            s4++;
        }
    }
    cout << "AC x " << s1 << "\n";
    cout << "WA x " << s2 << "\n";
    cout << "TLE x " << s3 << "\n";
    cout << "RE x " << s4 << "\n";
    return 0;
}


Measured memory_bytes: 3612
#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() {
  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
string S, x[2][2][2] = { {{"black","blue"}, {"lime","aqua"}}, { {"red","fuchsia"}, {"yellow","white"} } };
char T[9] = "89abcdef";
int a, b, c;
int main() {
	while (true) {
		a = 0; b = 0; c = 0;
		cin >> S;
		if (S == "0") { break; }
		for (int i = 0; i < 8; i++){
			if (T[i] == S[1]) {
				a = 1;
			}
		}
		for (int i = 0; i < 8; i++) {
			if (T[i] == S[3]) {
				b = 1;
			}
		}
		for (int i = 0; i < 8; i++) {
			if (T[i] == S[5]) {
				c = 1;
			}
		}
		cout << x[a][b][c] << endl;
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

struct rect{
	rect(){}
	double leftX;
	double leftY;
	double rightX;
	double rightY;
};

int main(){
	rect a, b;
	while(cin >> a.leftX >> a.leftY >> a.rightX >> a.rightY >> b.leftX >> b.leftY >> b.rightX >> b.rightY){
		if(cin.eof()) break;
		if(a.leftX>b.rightX||a.rightX<b.leftX||a.rightY<b.leftY||a.leftY>b.rightY) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict
    n, m = map(int, readline().split())
    edge = []

    for _ in range(m):
        a, b, c = map(int, readline().split())
        edge.append((a - 1, b - 1, -c))

    dist = [INF] * n
    dist[0] = 0

    for i in range(n - 1):
        for a, b, c in edge:
            dist[b] = min(dist[b], dist[a] + c)

    loop = [False] * n
    for i in range(n):
        for a, b, c in edge:
            if dist[b] > dist[a] + c:
                dist[b] = dist[a] + c
                loop[b] = True

    if loop[n - 1]:
        print("inf")
    else:
        print(-dist[n - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 74496
import bisect
N = int(input())
a = list(map(int, input().split()))
a.sort()
s = [0]*(10**5+1)

ans = 0
for i in range(10**5+1-2):
    ans = max(ans, bisect.bisect_right(a, i+2) - bisect.bisect_left(a, i))
print(ans)


Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(all(p));
  ll ans = 4e18;
  rep(m, n - k + 1) {
    rep2(i, k, n - m + 1) {
      vector<P> q;
      rep(j, i) q.push_back(P(p[j + m].second, p[j + m].first));
      sort(all(q));
      rep(j, i - k + 1) {
        ll dy = q[j + k - 1].first - q[j].first;
        ll a = 4e18, c = -4e18;
        rep2(x, j, j + k) {
          a = min(a, q[x].second);
          c = max(c, q[x].second);
        }
        ans = min(ans, dy * (c - a));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc107.cpp
// Author      : a
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

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

	cout << (N-i+1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define Max_N 10

using namespace std;

int decide(int *a){
    int i = 1;
    int flag;
    int b[10]= {0};
    int c[10]= {0};
    b[0] = a[0];
    int i_b =1;
    int i_c =1;
    while(i < 10){
        if(b[i_b-1] > a[i] && c[i_c-1] > a[i]){
            flag = 1;
            break;
        }

        else if(b[i_b-1] > a[i] && c[i_c-1] < a[i]){
            c[i_c] = a[i];
            i_c++;
            flag = 0;
        }

        else if(b[i_b-1] < a[i] && c[i_c-1] > a[i]){
            b[i_b] = a[i];
            i_b++;
            flag = 0;
        }

        else{
            int minus_b = a[i]-b[i_b-1];
            int minus_c = a[i]-c[i_c-1];
            if(minus_b > minus_c){
                c[i_c] = a[i];
                i_c++;
            }
            else{
                b[i_b] = a[i];
                i_b++;
            }
            flag = 0;
        }
        i++;
    }
    return flag;
}

int main(){
    //input
    int a[Max_N];
    int n,m,k;
    scanf("%d", &n);
    int ans[n];
    for(m =0 ; m < n;m++){
        scanf("%d %d %d %d %d %d %d %d %d %d\n", &a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
        ans[m] = decide(a);
    }
    for(m = 0; m < n; m++){
        if(ans[m] == 0){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn = 1e5+5;
char str[maxn];
int ans[maxn];
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    int tot=0;
    for(int i=0;i<len;i++)
    {
        if(str[i]=='0') ans[tot++]=0;
        else if(str[i]=='1') ans[tot++]=1;
        else tot=max(0,tot-1);
    }
    for(int i=0;i<tot;i++) printf("%d",ans[i]);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		String s = sc.next();
		int k = sc.nextInt();

		char c = s.charAt(k - 1);

		String ans = s.replaceAll("[^" + c + "]", "*");
		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int numa, numb, numc, numd;
    cin >> numa >> numb >> numc >> numd;
    if(numa!=numc){
        cout << "1\n"; 
    }else{
        cout << "0\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    long sum = k;

    for (int i = 0; i < n-1; i++) {
      sum *= (k-1);
    }

    System.out.println(sum);
  }

}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    int n;
    cin>> n;

    int a, c= -1;
    for(int i= 0; i<n; i++)
    {
        cin>> a;
        if(a% 2== 0 && a%5!= 0 && a%3!= 0)
            c= 0;
    }

    cout << (c== -1? "APPROVED\n" : "DENIED\n");

             return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
const int MOD = 998244353;

struct Combi
{
	vector<int> fact;
	vector<int> ifact;
	vector<int> inv;
	vector<int> pow2;
	int add(int a, int b)
	{
		a+=b;
		while(a>=MOD) a-=MOD;
		return a;
	}
	int mult(int a, int b)
	{
		return (a*1LL*b)%MOD;
	}
	int modpow(int a, int b)
	{
		int r=1;
		while(b)
		{
			if(b&1) r=mult(r,a);
			a=mult(a,a);
			b>>=1;
		}
		return r;
	}
	int choose(int a, int b)
	{
		if(a<b) return 0;
		if(b==0) return 1;
		if(a==b) return 1;
		return mult(fact[a],mult(ifact[b],ifact[a-b]));
	}
	int inverse(int a)
	{
		return modpow(a,MOD-2);
	}
	void init(int _n)
	{
		fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
		fact.resize(_n+1);
		ifact.resize(_n+1);
		inv.resize(_n+1);
		pow2.resize(_n+1);
		pow2[0]=1;
		ifact[0]=1;
		fact[0]=1;
		for(int i=1;i<=_n;i++)
		{
			pow2[i]=add(pow2[i-1],pow2[i-1]);
			fact[i]=mult(fact[i-1],i);
			//ifact[i]=mult(ifact[i-1],inv[i]);
		}
		ifact[_n] = inverse(fact[_n]);
		for(int i=_n-1;i>=1;i--)
		{
		    ifact[i] = mult(ifact[i + 1], i + 1);
		}
		for(int i=1;i<=_n;i++)
		{
		    inv[i] = mult(fact[i-1],ifact[i]);
		}
	}
};

Combi combi;

int solve(int a, int b, int c, int d)
{
	if(a<b||c<d) return 0;
	return combi.add(combi.choose(c+d-a-b,c-a),MOD-combi.choose(c+d-a-b,c-b+1));
}

int countpaths(int n, int r, int b)
{
	return solve(n, 0, r + n, b);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	combi.init(1111111);
	int n,k; cin>>k>>n;
	int ans=0;
	for(int diff=0;diff<=n;diff++)
	{
		if(diff%2!=n%2) continue;
		int r = (diff + n)/2; int b = (n - diff)/2;
		if(diff==0)
		{
			ans = combi.add(ans, countpaths(r - k, r, b - 1));
		}
		else
		{
			ans = combi.add(ans, countpaths(r - k, r, b));
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n + 1], bit[25][n + 1];
  for (int i = 1; i <= n; i++)
    cin >> arr[i];
  for (int p = 0; p < 25; p++)
    bit[p][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int p = 0; p < 25; p++) bit[p][i] = bit[p][i - 1];
    int num = arr[i], p = 0;
    while (num) {
      if (num & 1)
        bit[p][i]++;
      num >>= 1;
      p++;
    }
  }
  int e = 1;
  long long ans = 0;
  for (int s = 1; s <= n; s++) {
    // shift e to right s.t. all bits either never appear or only once appear between s to e
    while (true) {
      bool stop = false;
      for (int p = 0; p < 25; p++) {
        if (bit[p][e] - bit[p][s - 1] > 1)
          stop = true;
      }
      if (stop) {
        e--;
        break;
      }
      else if (e == n)
        break;
      else
        e++;
    }
    ans += e - s + 1;
  }
  cout << ans;
  return 0;
}

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

char rot(char c, int i)
{
	if (c + i <= 'Z')
		return(c+i);
	return(c+i - ('Z'-'A')-1);
}
int main (void)
{
	int n;
	char s[10000];
	scanf("%d",&n);
	scanf("%s",s);
	int i = 0;
	while(s[i] != '\0')
	{
		printf("%c",rot(s[i],n));
		i++;
	}
	
	return(0);
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int N = sc.nextInt();
			if (N == 0) {
				return;
			}
			Info info[] = new Info[N];
			for (int i = 0; i < N; i++) {
				String name = sc.next();
				int price = sc.nextInt();
				int time[] = new int[5];
				for (int j = 0; j < 5; j++) {
					time[j] = sc.nextInt();
				}
				int F = sc.nextInt();
				int S = sc.nextInt();
				int M = sc.nextInt();
				info[i] = new Info(name, price, time, F, S, M, 0);
			}
			for (int i = 0; i < N; i++) {
				double time = 0;
				double money = 0;
				time = info[i].time[0] + info[i].time[1] + info[i].time[2];
				time += (info[i].time[3] + info[i].time[4]) * info[i].M;
				money = info[i].F * info[i].S * info[i].M - info[i].price;
				info[i].efficient = money / time;
			}
			Arrays.sort(info, new ComparatorInfo());
			for (int i = 0; i < N; i++) {
				System.out.println(info[i].name);
			}
			System.out.println("#");
		}
	}

	class Info {
		String name;
		int price;
		int time[];
		int F;
		int S;
		int M;
		double efficient;

		public Info(String name, int price, int[] time, int F, int S, int M,
				double efficient) {
			this.name = name;
			this.price = price;
			this.time = time;
			this.F = F;
			this.S = S;
			this.M = M;
			this.efficient = efficient;
		}
	}

	class ComparatorInfo implements Comparator<Info> {

		@Override
		public int compare(Info arg0, Info arg1) {
			int cmp = 0;
			if (arg0.efficient < arg1.efficient) {
				cmp = 1;
			} else if (arg0.efficient > arg1.efficient) {
				cmp = -1;
			} else {
				cmp = arg0.name.compareTo(arg1.name);
			}
			return cmp;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 37908
H, W = map(int, input().split())
 
x = ["."*(W+2)]
for k in range(H):
    x.append("."+input()+".")
x.append("."*(W+2))

ans =[]
for l in range(1,H+1):
    b =[]
    for k in range(1,W+1):
        if x[l][k]==".":
            sum=0
            aa=x[l+1][k-1:k+2].count("#")+x[l][k-1:k+2].count("#")+x[l-1][k-1:k+2].count("#")
            b.append(aa)
        else:
            b.append('#')
    
    ans.append(b)
for i in ans:
  print(''.join(map(str, i)))
  		

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		while (true) {
			int N = s.nextInt();

			if (N == 0)
				break;

			int[][] graph = new int[21][21];

			for (int i = 0; i < N; i++) {
				int x = s.nextInt();
				int y = s.nextInt();
				graph[y][x] = 1;
			}

			// for (int p = 0; p < 21; p++) {
			// for (int q = 0; q < 21; q++) {
			// System.out.print(graph[p][q]);
			// }
			// System.out.println();
			// }

			int M = s.nextInt();
			int robox = 10, roboy = 10;

			for (int j = 0; j < M; j++) {
				char d = s.next().charAt(0);
				int l = s.nextInt();

				graph[roboy][robox] = 2;

				switch (d) {
				case 'N':
					for (int t = 0; t <= l; t++) {
						graph[roboy + t][robox] = 2;
					}
					roboy = roboy + l;
					break;

				case 'E':
					for (int t = 0; t <= l; t++) {
						graph[roboy][robox + t] = 2;
					}
					robox = robox + l;
					break;

				case 'W':
					for (int t = 0; t <= l; t++) {
						graph[roboy][robox - t] = 2;
					}
					robox = robox - l;
					break;

				case 'S':
					for (int t = 0; t <= l; t++) {
						graph[roboy - t][robox] = 2;
					}
					roboy = roboy - l;
					break;

				default:
					break;

				}

				// for (int p = 0; p < 21; p++) {
				// for (int q = 0; q < 21; q++) {
				// System.out.print(graph[p][q]);
				// }
				// System.out.println();
				// }

			}

			int count = 0;

			for (int p = 0; p < 21; p++) {
				for (int q = 0; q < 21; q++) {
					if (graph[p][q] == 1)
						count++;
				}
			}

			if (count == 0)
				System.out.println("Yes");
			else
				System.out.println("No");

		}
		s.close();
	}
}

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

int main(){
    int n, k;
    cin >>  n >> k;
    int a[200009];
    int b[200009];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        b[i] = 0;
    }
    for(int i = 0; i < n; ++i){
        b[a[i]]++;
    }

    sort(b, b+n, greater<int>());
    int in_k = 0;
    for(int j = 0; j < k; ++j){
        in_k += b[j];
    }

    cout << n - in_k << endl;

}

Measured memory_bytes: 1920
// SeeAlso: 

#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;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < 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))

char b;
int main() {
    cin >> b;

    char ans;
    switch (b) {
        case 'A':
            ans = 'T';
            break;
        case 'T':
            ans = 'A';
            break;
        case 'C':
            ans = 'G';
            break;            
        case 'G':
            ans = 'C';
            break;            
    }
        
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		int[] a = new int[N];
		ArrayDeque<Integer> dq = new ArrayDeque<>();
		for (int i = 0; i < N; ++i) {
			a[i] = sc.nextInt();
			for (int j = 0; j < a[i]; ++j) {
				dq.add(i + 1);
			}
		}
		int[][] col = new int[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				col[i][(i % 2 == 0 ? j : W - 1 - j)] = dq.pollFirst();
			}
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				System.out.print(col[i][j] + (j == W - 1 ? "\n" : " "));
			}
		}
	}
}

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


def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    ans = 0

    if n % 2 == 0:
        ans = min(8 * q, 4 * h, 2 * s, d) * (n // 2)
    else:
        ans = min(8 * q, 4 * h, 2 * s, d) * (n // 2)
        ans += min(4 * q, 2 * h, s)

    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);

    int i = n / 111; //111の何倍か
    if(n % 111 != 0) i++; //割り切れなかったら次の倍数にする

    printf("%d", i * 111); 
    return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> p;
void solve(ll x){
    for(ll i=2;i*i<=x;i++){
        if(x%i==0){
            p[i]++;
            while(x%i==0) x/=i;
        }
    }
    if(x>1) p[x]++;
}
int main(){
    ll a,b,num=0;
    cin>>a>>b;
    solve(a);
    solve(b);
    for(auto x:p){
        if(x.second==2) num++;
    }
    cout<<num+1<<endl;
}  

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    
    if m == -1 and f == -1 and r == -1:
        break

    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')




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

using namespace std;
typedef long long ll;

const ll INF = 1000000000;

int main() {
 
  ll N, W;
  cin >> N >> W;

  vector<ll> w(N + 1);
  vector<ll> v(N + 1);
  ll V = 0;
  rep (i, N) {
    cin >> w[i] >> v[i];
    V = max(V, v[i]);
  }

  vector<vector<ll>> dp(N + 1, vector<ll>(N * V + 1));

  rep (i, N) {
    fill(dp[i].begin(), dp[i].end(), INF);
  }

  dp[0][0] = 0;

  rep (i, N) {
    for (ll j = 0; j <= N * V; j++) {
      if (j < v[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }
    }
  }

  ll answer = 0;

  for (ll i = 0; i <= N * V; i++) {
    if (dp[N][i] <= W) {
      answer = max(answer,(ll) i);
    }
  }

  cout << answer << endl;

}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, a[100], b[100];

int p[200];
bool e[200][200], v[200];

bool match(int s){
	if(s < 0) return 1;
	rep(i, 2 * n) if(!v[i] && e[s][i]){
		v[i] = 1;
		if(match(p[i])) return p[i] = s, p[s] = i, 1;
	}
	return 0;
}

int main(){
	
	cin >> n;
	rep(i, n){
		cin >> a[i] >> b[i];
		if(a[i] > b[i]) swap(a[i], b[i]);
	}
	
	rep(i, n) rep(j, n){
		
		if(a[i] <= a[j] || b[i] <= b[j]) continue;
		e[i][j + n] = e[j + n][i] = 1;
		
		//cerr<<"i: "<<i<<" j: "<<j<<endl;
	}
	
	memset(p, -1, sizeof(p));
	
	int ans = n;
	
	rep(i, 2 * n) if(p[i] < 0){
		memset(v, 0, sizeof(v));
		if(match(i)) ans--;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1200
#if 0
date +%Y.%m.%d

称形如 111...111 的数为 MAGIC ，特别的， 0 也是 MAGIC 。
上升数一定可以表示成恰好 9 个 MAGIC 的和。
那么 N 表示成 K 个上升数的和就等价于 9K 个 MAGIC 的和。
即 N = sum(9K) { (10^x - 1) / 9 } 。
化简得 9N + 9K = sum(9K) { 10^x } 。
那么从小到大枚举 K ，每次 K 的增加会使左边加 9 。
考虑右边的数的数位和，假设没有进位显然是 9K ，算上进位，右边的取值是形如 9K - 9X 的数。
那么找到第一个 K 满足左边的数位和不大于 9K 即可。
#endif
#include <cstdio>
#include <cstring>
#define debug(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 1000005;
char s[maxn];
int a[maxn];

int main() {
	scanf("%s", s);
	int n = strlen(s), k = 0, sum = 0;
	for(int i = 0; i < n; i ++) {
		a[i] = (s[n - i - 1] - '0') * 9;
		sum += a[i];
	}
	for(int i = 0; i < n or a[i]; i ++) {
		sum -= a[i] / 10 * 9;
		a[i + 1] += a[i] / 10;
		a[i] %= 10;
		// debug("%d", a[i]);
	}
	// debug(" -> %d\n", sum);
	while(sum > 9 * k) {
		a[0] += 9;
		sum += 9;
		for(int i = 0; a[i] > 9; i ++) {
			sum -= 9;
			a[i + 1] ++;
			a[i] -= 10;
		}
		k ++;
	}
	printf("%d\n", k);
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int r;
	cin >> r;
	cout << 3 * r*r << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
   char g[20]; string h,i;
    cin >> a;
   if(a==1) cout <<"Hello World";
  else { cin >>b >>c;
        cout <<b+c;
    
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        long a = sc.nextLong(), b = sc.nextLong(), x = sc.nextLong();
                        System.out.println(b / x - a / x + (a % x == 0 ? 1 : 0));
                }
        }
}

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

typedef long long LL;

typedef struct ParserState {
    int pos, len;
    std::string str;
    std::deque<int> stack;

    bool isEOF() {return pos >= len;}
    bool isNotEOF() {return pos < len;}

    char getCh() {
        return pos < len ? str[pos++] : -1;
    }
    char seek() {
        return pos < len ? str[pos] : -1;
    }
    char seek(int offset) {
        return (pos+offset) < len ? str[pos+offset] : -1;
    }
    std::string lookAhead(int l) {
        return str.substr(pos, l);
    }

    void setBackrack(){stack.push_front(pos);}
    bool backtrack(){
        if(stack.empty()) return false;
        pos = stack.front();
        stack.pop_front();
        return true;
    }

    bool isDigit(){return isDigit(0);}
    bool isDigit(int offset) {
        char c = seek(offset);
        return c != -1 && c >= '0' && c <= '9';
    }
    bool isUpperAlpha(){return isUpperAlpha(0);}
    bool isUpperAlpha(int offset) {
        char c = seek(offset);
        return c != -1 && c >= 'A' && c <= 'Z';
    }
    bool isLowerAlpha(){return isLowerAlpha(0);}
    bool isLowerAlpha(int offset) {
        char c = seek(offset);
        return c != -1 && c >= 'a' && c <= 'z';
    }
}State;

std::map<char,int> pri;
int bot = 0;

LL parseNumber(State*);
LL parse(State*);

LL calc(char op, LL left, LL right) {
    if(op == '+') return left + right;
    if(op == '-') return left - right;
    if(op == '*') return left * right;
    return assert(pri.count(op) > 0), -1;
}

LL parseNumber(State* state) {
    LL res = 0LL;
    while(state->isNotEOF() && state->isDigit()) {
        res *= 10;
        res += (int)(state->getCh() - '0');
    }
    return res;
}

LL parse(int level, State* state) {
    if(bot < level) {
        if(state->isDigit()) return parseNumber(state);

        state->getCh(); // eat (
        LL r = parse(0, state);
        state->getCh(); // eat )
        return r;
    }

    LL result = parse(level + 1, state);
    while(state->isNotEOF() && state->seek() != ')') {
        char ch = state->seek();
        if(pri[ch] < level) break;
        state->getCh(); //eat op

        LL res = parse(level + 1, state);
        result = calc(ch, result, res);

        if(state->isEOF()) break;
    }
    return result;
}

int main() {
    std::string S;
    std::cin >> S;
    int len = S.length();

    LL ans = std::numeric_limits<LL>::min();
    for(int i=0; i<27; ++i) {
        pri['+'] = i     % 3;
        pri['-'] = (i/3) % 3;
        pri['*'] = (i/9) % 3;
        bot = std::max(i%3, std::max((i/3)%3, (i/9)%3));

        State state = State{0, len, S};
        LL res = parse(0, &state);

        ans = std::max(ans, res);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3236
while s = gets
    s = s.chomp
    ans = String.new()
    i = 0
    while i < s.length do
        if s[i] == "@"
            ans += s[i+2]*(s[i+1].to_i)
            i += 3
        else
            ans += s[i]
            i += 1
        end
    end
    printf("%s\n", ans)
end

Measured memory_bytes: 6100
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	string s1, s2; cin >> s1 >> s2;
	rep(i, n){
		cout << s1[i] << s2[i];
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  long long S = 0;
  vector<long long> A(N+1);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
    S += A.at(i);
  }
  long long ans = S;
  long long sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += A.at(i);
    ans = min(ans, abs(sum - (S - sum)));
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    while(a >= b){
        b *= 2;
        k--;
    }
    
    while(b >= c){
        c *= 2;
        k--;
    }
    
    if(k >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  sort(H.begin(), H.end());   
  long long count = 0;
  for (int i = 0; i < N-K; i++) {
    count += H.at(i);
  }
  cout << count << endl;
   
  return 0;
}

Measured memory_bytes: 1792
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    is.pop();
    println!(
        "{}",
        if is.chars().all(|c| c.is_ascii_uppercase()) {
            'A'
        } else {
            'a'
        }
    );
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int x=0,ans=0;
  for (int i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
    }
    if(s[i]=='D'){
      x--;
    }
    ans=max(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
char a[110];
char b[110];
char c[110];

int ai, bi, ci;

int main(void)
{
  scanf("%s", a);
  scanf("%s", b);
  scanf("%s", c);

  char p = a[ai++];

  while(1)
    {
      if(p == 'a' && a[ai] == '\0')
	{
	  printf("A\n");
	  break;
	}
      if(p == 'b' && b[bi] == '\0')
	{
	  printf("B\n");
	  break;
	}
      if(p == 'c' && c[ci] == '\0')
	{
	  printf("C\n");
	  break;
	}


      if(p == 'a')
	p = a[ai++];
      else if(p == 'b')
	p = b[bi++];
      else
	p = c[ci++];
    }

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
   int a,b,c,k,i,max,x;

   scanf("%d%d%d%d",&a,&b,&c,&k);

   max=a;
   x=b+c;
   if(max<b){
      max=b;
      x=a+c;
   }
   if(b<c){
      max=c;
      x=a+b;
   }

   for(i=0;i<k;i++){
      max*=2;
   }
   printf("%d\n",max+x);
   return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,x,i,j,k,prt[200005];
bool v[200005];
int main()
{
	scanf("%d%d",&n,&x);
	if(n==2)
	{
		if(x==2)
			printf("Yes\n1\n2\n3");
		else
			printf("No");
		return 0;
	}
	if(x>1&&x<2*n-1)
	{
		prt[n]=x;
		prt[n-1]=1,prt[n+1]=2*n-1;
		v[x]=v[1]=v[2*n-1]=true;
		if(x>2)
			prt[n+2]=2,v[2]=true;
		else
			prt[n-2]=2*n-2,v[2*n-2]=true;
		for(i=1,j=1;i<=2*n-1;++i)
			if(!prt[i])
			{
				while(v[j])
					++j;
				prt[i]=j++;
			}
		puts("Yes");
		for(i=1;i<=2*n-1;++i)
			printf("%d\n",prt[i]);
		return 0;
	}
	printf("No");
	return 0;
}


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

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

int main()
{
  int h, w;
  cin >> h >> w;
  
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  
  vector<vector<bool>> a(h, vector<bool>(w, false));
  
  ll res = 0;
  rep(i,h) rep(j,w)
  {
    if(a[i][j]) continue;
    
    ll bb = (s[i][j] == '#'), ww = 1 - bb;
    queue<P> q;
    q.push(P(i, j));
    a[i][j] = true;
    
    while(!q.empty())
    {
      auto p = q.front();
      q.pop();
      rep(k,4)
      {
        int ny = p.first + dy[k], nx = p.second + dx[k];
        if(ny < 0 || ny >= h || nx < 0 || nx >= w || a[ny][nx] || 
          s[p.first][p.second] == s[ny][nx]) continue;
        q.push(P(ny, nx));
        a[ny][nx] = true;
        if(s[ny][nx] == '#') bb++;
        else ww++;
      }
    }
    res += bb * ww;
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, int, int> T;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;cin>>a>>b>>c;


  cout << (a*b)/2 << endl;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define double long double
#define mp make_pair
#define pb push_back
#define er erase
#define cl clear
#define sw swap
#define br break
#define ct continue
#define rt return
#define xx exit(0)
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#define x first
#define y second
#define fo(i,a,b) for(int i=a;i<b;i++)
using namespace std;
struct st{
    
};
bool cmp(){
    return 1;
}
int go(int a,int b){
    return (a%b==0?a/b:a/b+1);
}
void recur(){
    
}
void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    cout<<go(n,x)*t;
    
    
    
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    fo(i,0,t) solve();
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int data1[200005];
double x[200005];
int main()
{
    int n,k;
    double sumn=0,summ;
    double ans =0;
    cin>>n>>k;
    for(int i = 0; i < n; i++)
    {
        cin>>data1[i];
         x[i] = (double)(data1[i]+1)/2;
        sumn+=x[i];
        if(i==k-1) summ=sumn;
        if(i>=k)
        {
            sumn = sumn - x[i-k];
            if(sumn > summ)
            {
                summ = sumn;
            }
        }
    }

    printf("%.12lf",summ);
}

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

int a,b,c,d,e,f,cnt;

int main()
{
    int i;
    cin >> a >> b;
    for(i=a; i<=b; i++) {
        c = i/10000;
        d = i/1000%10;
        e = i/10%10;
        f = i%10;
        if(c==f && d==e) cnt++;
    }
    cout << cnt;
    return 0;
}


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

#pragma warning(disable:4996)


int main(void) {
	int N;
	char S[10 + 1];
	int K;
	scanf("%d", &N);
	scanf("%s", &S[0]);
	scanf("%d", &K);

	char c = S[K - 1];
	for (int i = 0; i < N; ++i) {
		if (S[i] != c) {
			S[i] = '*';
		}
	}
	printf("%s", S);
	return 0;
}

Measured memory_bytes: 128