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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int q; cin >> q;
    multiset<int> S;
    rep(i,q){
        int query; cin >> query;
        if(query == 0){
            int x; cin >> x;
            S.insert(x);
            cout << S.size() << endl;
        }else if(query == 1){
            int x; cin >> x;
            cout << S.count(x) << endl;
        }else if(query == 2){
            int x; cin >> x;
            S.erase(x);
        }else if(query == 3){
            int L,R; cin >> L >> R;
            auto it = S.lower_bound(L);
			while (it != S.end() && *it <= R) {
				printf("%d\n", *it); ++it;
			}
        }
        
    }
}


Measured memory_bytes: 12384
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
// namespace mp = boost::multiprecision;
// using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll mm=0;
ll kk=0;

bool binary_j(ll mid){
  ll ans=(ll)1<<53;
  ll z=mm+kk*mid;
  if(ans<=z)return true;
  return false;
}

ll binary_search(ll left,ll right){
  ll mid;
  while(left<right){
    mid = (left+right)/2;
    if(binary_j(mid)){
      right = mid;
    }
    else{
      left = mid+1;
    }
  }
  return left;
}



int main(){
  ll n;
  string s;
  while(cin>>n,n!=0){
    cin>>s;
    ll e=0;
    ll m=1;
    for(ll i=0;i<52;i++){
      m<<=1;
      if(s[i]=='1')m++;
    }
    ll k=m;
    for(;k>0&&n>0;){
      ll x=0;
      mm=m;
      kk=k;
      x=binary_search(1,min(n,((ll)1<<54)/k));
      m=m+k*x;
      n-=x;
      if(m>=(ll)1<<53){
        k>>=1;
        m>>=1;
        e++;
      }
      m=m&(((ll)1<<53)-1);
    }
    m=m&(((ll)1<<52)-1);
    e=e&(((ll)1<<12)-1);
    cout<<bitset<12>(e)<<bitset<52>(m)<<endl;
  }
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define int long long 
using namespace std;

int32_t main(){

   string a,b;  cin >> a >> b;
   int f1[26] = {0} , f2[26] = {0};

//    sort(all(a)) , sort(all(b));
//    cout << a << endl << b << endl;

   for(auto ch : a) f1[ch - 'a']++;
   for(auto ch : b) f2[ch - 'a']++;

    sort(f1 , f1 + 26) , sort(f2 , f2 + 26);

    for(int x=0;x<26;x++){
        if(f1[x] != f2[x]) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long r = lread();
    writeln(3 * r * r);
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(string s) {
    for (int i = 0; i < s.length; i += 2) {
        switch (s[i]) {
        case 'R':
        case 'U':
        case 'D':
            break;
        default:
            return false;
        }
    }

    for (int i = 1; i < s.length; i += 2) {
        switch (s[i]) {
        case 'L':
        case 'U':
        case 'D':
            break;
        default:
            return false;
        }
    }
    return true;
}

void main() {
    string s = read!string;
    writeln(calc(s) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
  int n,cnt=0;
  int a[101];
  cin >> n;

  for(int i=1;i<=n;i++){
    cin >> a[i];
    if(i%2 == 1 && a[i] %2 == 1) cnt++;
  }
  cout << cnt;
  return 0;
}


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

int main() {

  int A, B, C;
  cin >> A >> B >> C;

  int K;
  cin >> K;

  for(int i = 0; i < K; i++){
    if(B <= A){
      B *= 2;
    }else if(C <= B){
      C *= 2;
    }
  }

  if(B > A && C > B){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
// --------------
// Tejas Pandey  |
// 07 - 07 - 19  |
// ABC #133      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ll n;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++)
	cin >> a[i];
	int k = 1;
	ll val = 0;
	for(int i = 0;i < n-1;i++)
	{
		val += (a[i]*k);
		k = k*-1;
	}
	int ans[n];
	ans[0] = a[n-1] + val;
	for(int k = 1;k < n;k++)
	{
		ans[k] = 2*(a[k-1] - (ans[k-1])/2);
	}
	for(int j = 0;j < n;j++)
	cout << ans[j] << " "; 
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++++i)
		s[i] = '0' + '1' - s[i];
	cout << min(count(s.begin(), s.end(), '0'), count(s.begin(), s.end(), '1')) << endl;
}

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

using namespace std;
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
using namespace std;
using ll = long long int;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

ll prod=1;
int N;
cin>>N;
vector<ll> v(N);
forn(i,N) {
    cin>>v[i];
    if(v[i]==0) prod=0;
}
if(prod==0) {
    cout<<0<<endl;
    return 0;
}
long double l=0;
forn(i,N) {
    l+=(log10(v[i]));
}
if(l>18.1) {
    cout<<-1<<endl;
    return 0;
}
forn(i,N) {
    prod*=v[i];
}
if(prod>1000000000000000000)
    cout<<-1<<endl;
else
    cout<<prod<<endl;
return 0;
}


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

int main(){
    char str[20];
    char c;
    int i = 0;
    
    memset(str, '\n', 20);

    while((c = getchar()) != '\n'){
        str[i++] = c;
    }
    while(i--){
        printf("%c", str[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;


int main() {
	
	int numofSrcs, numofFeatures, C;
	vector<int> features;
	
	int ans = 0;

	scanf("%d %d %d", &numofSrcs, &numofFeatures, &C);

	for (int i = 0; i < numofFeatures; ++i) {
		int f;
		scanf("%d", &f);
		features.push_back(f);
	}
	for (int f = 0; f < numofSrcs; ++f) {
		int total = 0;
		for (int s = 0; s < numofFeatures; ++s) {
			int in;
			scanf("%d", &in);
			total += features[s] * in;
		}
		total += C;

		if (total > 0)
			ans++;
	}

	cout << ans;

}

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

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 1e6 + 7;
const int INF = 1e9 + 7;

int dp[N][3];
int a[N], b[N], c[N];
int n;

main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    for (int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
    }
    printf("%d", max(dp[n][0], max(dp[n][1], dp[n][2])));
}


Measured memory_bytes: 12928
n=int(input())

lst=[int(input()) for _ in range(n)]
work_mx=10**10

mx=-10**16
for i in range(n-1):
    if lst[i]>=work_mx : continue
    work_mx=lst[i]
    sm=max(lst[i+1:])-lst[i]
    mx=max(sm,mx)

print(mx)


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

int main(void){
    // Your code here!
    char s[4];
    scanf("%s",s);
    if(strlen(s) == 2)
    {
        printf("%s\n",s);
    }
    else
    {
        printf("%c%c%c\n",s[2],s[1],s[0]);
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <set>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    set<int> s;
    while(m--){
        int a, b;
        cin >> a >> b;
        if(s.count(a)){
            s.erase(a);
        }else{
            s.insert(a);
        }
        if(s.count(b)){
            s.erase(b);
        }else{
            s.insert(b);
        }
    }
    if(s.size()){
        cout << "NO\n";
    }else{
        cout << "YES\n";
    }
}

Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
int temp,tot,n,m,q;
int a[11000];
int map[150][150];
bool f[150][150];
int dx[5]={0,0,1,0,-1};
int dy[5]={0,1,0,-1,0};
void dfs(int x,int y)
{
    map[x][y]=a[temp];
    f[x][y]=1;
    temp++;
    for(int i=1;i<=4;i++)
    {
        int nx,ny;
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&!f[nx][ny])
        dfs(nx,ny);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%d",&q);
    for(int i=1;i<=q;i++)
    {
        int x;
        scanf("%d",&x);
        for(int j=1;j<=x;j++)
        {
            tot++;
            a[tot]=i;
        }
    }
    temp=1;
    dfs(1,1);
    for(int i=1;i<=n-1;i++)
    {
        for(int j=1;j<=m-1;j++)
            printf("%d ",map[i][j]);
        printf("%d\n",map[i][m]);
    }
    for(int i=1;i<=m-1;i++)
        printf("%d ",map[n][i]);
    printf("%d",map[n][m]);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int d, t, s; cin >> d >> t >> s;
    if (d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int a[30]={0};
int main()
{
  string s;
  cin>>s;
  int ans=0;
  if(s.length()==4)
  {  int flag=0;
  	 for(int i=0;i<s.length();i++)
  	 {
  	 	if(!isupper(s[i]))
  	 	{
  	 	flag=1;
		   }
		   if(!a[s[i]-'A'])
		   {ans++;
		   a[s[i]-'A']=1;
		   }
	   }
	   if(!flag&&ans==2)
	   {
	   	printf("Yes\n");
	   	return 0;
	   }
   } 
   printf("No\n");
}




Measured memory_bytes: 256
from collections import deque
n,m=[int(_) for _ in input().split()]
H=[int(_) for _ in input().split()]
Hlist=deque(deque() for a in range(n))
count=0
for a in range(m):
    a,b=[int(_) for _ in input().split()]
    Hlist[a-1].append(b-1)
    Hlist[b-1].append(a-1)
for i,j in enumerate(Hlist):
    flag=1
    for a in j:
        if H[a]>=H[i]:
            flag=0
    if flag==1:
        count+=1
    flag=1
print(count)

Measured memory_bytes: 151340
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
print((pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod) + mod) % mod)


Measured memory_bytes: 68952
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
  int n, t;
  cin >> n >> t;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  int ans = 1, lowest = INF, dif = 0;
  for(int i=0; i<n; ++i){
    if(an[i] < lowest) lowest = an[i];
    else if(an[i] - lowest > dif){
      ans = 1;
      dif = an[i] - lowest;
    }
    else if(an[i] - lowest == dif) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 998244353;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}
void YES(bool condition){
	if(condition){
		p("YES");
	}else{
		p("NO");
	}
	return;
}
void Yes(bool condition){
	if(condition){
		p("Yes");
	}else{
		p("No");
	}
	return;
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l,num,sum,ans,ok,ng,mid;
ll x[500005],y[500005],z[500005];
ll dp[500005][10];
char s[500005],t[500005],u[500005];
bool dame,flag;
//string s;
int main(){
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	//dp[i][j] := 
	for(i=1;i<=n;i++){
		//dp[i][0] ~ dp[i][4]を求める
		if(x[i] != 0){
			dp[i][0] = dp[i-1][0] + x[i];
			dp[i][1] = min(dp[i-1][0],dp[i-1][1]) + x[i] % 2;
			dp[i][2] = min(min(dp[i-1][0],dp[i-1][1]),dp[i-1][2]) + (x[i] + 1) % 2;
			dp[i][3] = min(min(min(dp[i-1][2],dp[i-1][0]),dp[i-1][1]),dp[i-1][3]) + x[i] % 2;
			dp[i][4] = min(min(min(min(dp[i-1][0],dp[i-1][1]),dp[i-1][2]),dp[i-1][3]),dp[i-1][4]) + x[i];
		}else{
			dp[i][0] = dp[i-1][0];
			dp[i][1] = min(dp[i-1][0],dp[i-1][1]) + 2;
			dp[i][2] = min(min(dp[i-1][0],dp[i-1][1]),dp[i-1][2]) + 1;
			dp[i][3] = min(min(min(dp[i-1][2],dp[i-1][0]),dp[i-1][1]),dp[i-1][3]) + 2;
			dp[i][4] = min(min(min(min(dp[i-1][0],dp[i-1][1]),dp[i-1][2]),dp[i-1][3]),dp[i-1][4]);
		}
		for(j=0;j<5;j++){
			//pe(dp[i][j]);
		}
		//el;
	}
	ans = INF;
	for(i=0;i<5;i++){
		ans = min(ans,dp[n][i]);
	}	
	p(ans);
	return 0;
}

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

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

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

        long limit = (long) 1e18;
        long res = 1;
        for (int i = 0; i < N; i++) {
            if (res > limit / a[i]) {
                res = -1;
                break;
            }
            res *= a[i];

        }

        for (int i = 0; i < N; i++) {
            if (a[i] == 0) res = 0;
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;  // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }
  // 素数である
  return true;
}

int main() {
  int x;
  cin >> x;
  while (true) {
    if (IsPrime(x)) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		
		int rireki = 0;
		
		for(int i = N; i > 0; i--) {
			if(i == N) {
				rireki = K;
			}else {
				rireki = rireki * (K-1);
			}
		}

		System.out.print(rireki);
		keyboard.close();	
	}
}


Measured memory_bytes: 21844
MOD = 10**9+7
d1 = {0: 1}
d2 = {0: 1, 1: 2}
def f(k):
    if k in d1:return d1[k]
    d1[k] = f(k/2) + (k%2<1 and f(k/2-1))
    return d1[k]
def s(k):
    if k in d2:return d2[k]
    d2[k] = (f(k) + s(k-1) if k%2 else s(k/2) + 2*s(k/2-1)) % MOD
    return d2[k]
print s(input())

Measured memory_bytes: 2692
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>

    #define ll long long
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
    #define sz(x) (int)x.size()
    #define all(x) x.begin(), x.end()

    using namespace std;
    using namespace __gnu_pbds;

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
    template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
    template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

    int n;
    vector<ll> a;
    pair<ll, ll> dp[3004][3004];

    pair<ll, ll> score(int l, int r)
    {
        if(l > r)
            return make_pair(0,0);
        if(dp[l][r].first != -1)
        {
            //cout << l << " " << r << ": " << dp[l][r] << endl;
            return dp[l][r];
        }
        if(l == r)
        {
            dp[l][r] = make_pair(a[l], 0);
        }

        ll levi = score(l+1, r).second + a[l];
        ll desni = score(l, r-1).second + a[r];

        if(levi > desni)
        {
            dp[l][r].first = levi;
            dp[l][r].second = score(l+1, r).first;
        }
        else
        {
            dp[l][r].first = desni;
            dp[l][r].second = score(l, r-1).first;
        }
        //cout << l << " " << r << ": " << dp[l][r]<< endl;
        return dp[l][r];
    }

    int main()
    {
        cin >> n;
        for(int i = 0; i < n; i++)
        {
            ll pom;
            cin >> pom;
            a.push_back(pom);
        }

        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                dp[i][j] = make_pair(-1, 0);
            }
        }

        pair<ll,ll> pom = score(0, n-1);
        cout << pom.first - pom.second << endl;

        return 0;
    }


Measured memory_bytes: 141312
import java.io.*;
import java.util.*;

class Main {

    void solve(){

	Scanner sc = new Scanner( System.in );
	int w = sc.nextInt();

	StringBuilder res = new StringBuilder();

	while ( w > 0 ) {
	    
	    switch ( w%3 ) {
	    case 0:
		res.insert(0, '0');
		w /= 3;
		break;
	    case 1:
		res.insert(0, '+');
		w /= 3;
		break;
	    case 2:
		res.insert(0, '-');
		w = w/3 + 1;
		break;
	    }
	}
	
	System.out.println( res.toString() );
    }

    public static void main( String[] a ) { new Main().solve(); }
}



Measured memory_bytes: 26276
#include <iostream>
#include <cmath>
using namespace std;
bool can(int arr[] , int N , int K , int val);
int main(){
    int N , K;
    cin >> N >> K;
    int arr[N];
    for (int i = 0 ; i < N ; i++)
        cin >> arr[i];
    int l = 1 , r = 1e9;
    while(l < r){
        int mid = (l + r) / 2;
        if (can(arr , N , K , mid))
            r = mid;
        else
            l = mid + 1;
    }
    cout << l << endl;
}
bool can(int arr[] , int N , int K , int val){
    long long total = 0;
    for (int i = 0 ; i < N ; i++)
        total += ceil(double(arr[i]) / val) - 1;
    return total <= K;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int a, b;
    cin >> a >> b;
    int a_min = (a*100+7)/8;
    int a_max = ((a+1)*100+7)/8-1;
    int b_min = (b*100+9)/10;
    int b_max = ((b+1)*100+9)/10-1;
    a = max(a_min, b_min);
    if(a > min(a_max, b_max)) cout << "-1" << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    string S;
    cin >> S;
    
    sort(S.begin(),S.end());
    
    if(S == "abc"){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
        return 0;
    }
    


Measured memory_bytes: 256
# include <stdio.h>  
int a[200000+3], n;  
bool small(int i, int j, int k) {return a[i]<=k && a[j]<=k;}  
bool big(int i, int j, int k) {return a[i]>k && a[j]>k;}  
bool judge(int k)  
{  
    for(int i=0; i<n-1; ++i)  
    {  
        if(big(n+i, n+i+1, k) || big(n-i, n-i-1, k)) return false;  
        if(small(n+i, n+i+1, k) || small(n-i, n-i-1, k)) return true;  
    }  
    return small(1,1,k);  
}  
int main()  
{  
    scanf("%d",&n);  
    for(int i=1; i<n<<1; ++i)  
        scanf("%d",&a[i]);  
    int l=1, r=(n<<1)-1, mid;  
    while(l < r)  
    {  
        mid = l+r>>1;  
        if(judge(mid))  
            r = mid;  
        else  
            l = mid + 1;  
    }  
    printf("%d\n",r);  
    return 0;  
}  

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

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String s = scanner.next();
        String t = scanner.next();
        if (s.equals(t)) {
        	System.out.println("Yes");
        }else {
        	boolean tmp = false;
        	for(int i = 0;i<s.length();i++) {
        		if(t.equals(s.substring(s.length()-1, s.length())+s.substring(0,s.length()-1))) {
        			System.out.println("Yes");
        			tmp = true;
        			break;
        		}
        		s = s.substring(s.length()-1, s.length())+s.substring(0,s.length()-1);
        	}
        	if (tmp == false) {
        		System.out.println("No");
        	}
        }



    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21204
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		System.out.println(str.replace("a", "").length() == 2
			&& str.replace("b", "").length() == 2
			&& str.replace("c", "").length() == 2
			? "Yes" : "No");
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int countw=0,counte=0;
    for(int i=0;i<n;i++){
       if(s.at(i)=='W')countw++;
    }
    int res=INT_MAX;
    for(int i=n-1;i>=0;i--){
        if(s.at(i)=='W')countw--;
        chmin(res,countw+counte);
        if(s.at(i)=='E')counte++;
    }
   cout<<res<<endl;
}

Measured memory_bytes: 900
import java.util.Scanner;

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

        int a1 = sc.nextInt();
        int an = a1;
        int n = 1;
        int anArray[] = new int[1000000];
        anArray[0] = an;

        for (int i = 0; ; i++) {
            //System.out.println(an);
            n += 1;
            if (an % 2 == 0) {
                an = an / 2;
            } else {
                an = 3 * an + 1;
            }

            for (int j = 0; j < i; j++) {
                if (an == anArray[j]) {
                    System.out.println(n);
                    System.exit(0);
                }
            }

            anArray[n - 1] = an;
        }
    }
}

Measured memory_bytes: 27348
X, Y = map(int, input().split())
MOD = 10 ** 9 + 7


S = -X + 2 * Y
T = 2 * X - Y

if S < 0 or T < 0:
    print(0)
    exit()
if S % 3 != 0 or T % 3 != 0:
    print(0)
    exit()

S //= 3
T //= 3


def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p


# print(S, T)
ans = cmb(S + T, S, MOD) % MOD
print(ans % MOD)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "


int main()
{
    int a,b,c;
    int k;
    cin >> a >> b >> c >> k;
    int f=0;
    for(int i=0;i<=k and f==0;i++)
    {
        for(int j=0;j<=i and f==0;j++)
        {
            for(int l=0;l<=i-j and f==0;l++)
            {
                int r=i-(j+l);
                int a1=a*pow(2,j);
                int b2=b*pow(2,l);
                int c2=c*pow(2,r);
                if(c2>b2 and b2>a1)
                    f=1;
            }
        }
    }
    if(f==1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

set<ll> can[300];
ll ans[100100];

signed main() {
  string s, t;
  cin >> s >> t;
  ll ns = s.size(), nt = t.size();
  rep(i, ns) {
    can[s[i]].insert(i);
  }
  rep(i, 300) {
    if (can[i].size() == 0)
      continue;
    auto mi = *can[i].begin();
    can[i].insert(mi + ns);
    //printf("%c :", i);
    //for (auto c : can[i]) {
    //  printf("%d ", c);
    //}
    //printf("\n");
  }

  // printf("ans: ");
  ll pos = -1;
  rep(i, nt) {
    if (can[t[i]].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    ll now = pos % ns;
    ll nxt = *can[t[i]].lower_bound((pos+1) % ns);
    if (nxt > now) {
      pos = pos + (nxt-now);
    } else {
      pos = pos + (ns+nxt-now);
    }
    ans[i] = pos;
    //printf("%d ", ans[i]);
  }
  //printf("\n");
  cout << ans[nt-1] + 1 << endl;
  return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int num[10];
bool check(int pos, int l, int r){
    if(pos >= 10) return true;
    if(l < num[pos]) if(check(pos+1,num[pos],r)) return true;
    if(r < num[pos]) if(check(pos+1,l,num[pos])) return true;
    return false;
}
int main(){
    int n;
    cin >> n;
    rep(i,n){
        rep(j,10) cin >> num[j];
        if(check(0,-1,-1)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
int h,w,m;
int a,b;
map<pair<int,int> ,bool> mp;
int x[300010],y[300010];
vector<int> v;
vector<int> t;
int mx=0,mx2=0;
int main(){
	cin>>h>>w>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		x[a]++;
		y[b]++;
		mp[make_pair(a,b)]=1;
		mx=max(mx,x[a]);
		mx2=max(mx2,y[b]);
	}
	for(int i=1;i<=h;i++){
		if(x[i]==mx){
			v.push_back(i);
		}
	}
	for(int i=1;i<=w;i++){
		if(y[i]==mx2){
			t.push_back(i);
		}
	}
	for(int i=0;i<v.size();i++){
		for(int j=0;j<t.size();j++){
			if(!mp[make_pair(v[i],t[j])]){
				cout<<mx+mx2<<endl;
				return 0;
			}
		}
	}
	cout<<mx+mx2-1<<endl;
	return 0;
}

Measured memory_bytes: 28452
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 998244353
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,t=0,q=0,x,y=100000000000,m;
    cin>>n>>k;
    ll a[n];
    l=0;
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(i=0;i<k;i++)
    l=l+a[i];
    cout<<l<<endl;
}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 3668
from collections import Counter
s=input()
t=input()
s1=Counter(s)
t1=Counter(t)
ans='Yes'
if len(s1)!=len(t1):ans='No'
else:
    for i,j in zip(s1.most_common(),t1.most_common()):
        if i[1]!=j[1]:ans='No'
print(ans)

Measured memory_bytes: 3888
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  bool flag = true;
  while(A > 0|| C > 0){
    A -= D;
    C -= B;
    // cout << A << " " << C << endl;
    if (C <= 0){
      break;
    }
    if(A <= 0){
      flag = false;
      break;
    }
    
  }

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

}


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

using namespace std;

#define ll long long

int a, b;

void solve() {
  cin >> a >> b;
  if (((a>=1)&&(a<=9))&&((b>=1)&&(b<=9))) {
    cout << a*b << '\n';
  } else {
    cout << "-1\n";
  }
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct pt
{
	int l,r;
}a[100005];
bool cmp(const pt x,const pt y)
{
	return x.r==y.r?x.l<y.l:x.r<y.r;
}
bool cmp2(const pt x,const pt y)
{
	return x.l<y.l;
}
int n,pre[100005],suf[100005];
int main()
{
	int len=0,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].l,&a[i].r),len=max(len,a[i].r-a[i].l+1);
	sort(a+1,a+n+1,cmp);
	sort(a+2,a+n+1,cmp2);
	//for(int i=1;i<=n;i++)
	//	printf("i=%d,l=%d,r=%d\n",i,a[i].l,a[i].r);
	int l=-1e9,r=1e9;
	for(int i=1;i<=n;i++)
	{
		l=max(l,a[i].l);
		r=min(r,a[i].r);
		pre[i]=(l<=r?r-l+1:0);
	}
	ans=max(ans,len+pre[n]);
	l=-1e9,r=1e9;
	for(int i=n;i;i--)
	{
		l=max(l,a[i].l);
		r=min(r,a[i].r);
		suf[i]=(l<=r?r-l+1:0);
	}
	for(int i=1;i<n;i++)
		ans=max(ans,pre[i]+suf[i+1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define ll long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=2e5+5;
const int M=1e9+7;

void solve()
{
	int n;
	cin>>n;
	int a[n+1]={0};
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int pp=i*i+j*j+k*k+i*j+j*k+k*i;
				if(pp<=n)
				a[pp]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<endl;
}

signed main()
{
	int t=1;
	// cin>>t;
	for(int tc=1;tc<=t;tc++)
	{
		solve();
	}
}

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

int main(){
  int n;
  cin>>n;
  int a[n+1], b[n];
  long long ans=0;
  for(int i=0;i<n+1;i++){
      cin>>a[i];
  }
  for(int i=0;i<n;i++){
      cin>>b[i];
  }
  for(int i=0;i<n;i++){
      int v=min(a[i],b[i]);
      a[i]-=v;
      b[i]-=v;
      ans+=v;
      v=min(a[i+1],b[i]);
      a[i+1]-=v;
      b[i]-=v;
      ans+=v;
  }
  cout<<ans<<endl;
}
      
  


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S, T;
    cin >> S >> T;
    int lenS = S.length(), lenT = T.length();
    int mini = MX, total = 0;
    for (int i = 0; i <= lenS - lenT; ++i) {
		for (int j = 0; j < lenT; ++j) {
			if (S[i+j] != T[j]) {
				++total;
			}
		}
		mini = min(mini, total);
		total = 0;
	}
	cout << mini << '\n';
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3588
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			long[] masks = new long[sc.nextInt()];
			for(int i = 0; i < masks.length; i++) {
				int maskLength = sc.nextInt();
				for(int j = 0; j < maskLength; j++) {
					masks[i] += 1L<<sc.nextInt();
				}
			}
			int q = sc.nextInt();
			long flags = 0;

			for(int k = 0; k < q; k++) {
				switch(sc.nextInt()) {
				case 0:
					System.out.println((flags>>sc.nextInt())&1L);
					break;
				case 1:
					flags = flags | masks[sc.nextInt()];
					break;
				case 2:
					flags = flags & ~masks[sc.nextInt()];
					break;
				case 3:
					flags = flags ^ masks[sc.nextInt()];
					break;
				case 4:
					System.out.println((flags|masks[sc.nextInt()])==flags?1:0);
					break;
				case 5:
					System.out.println((flags&~masks[sc.nextInt()])!=flags?1:0);
					break;
				case 6:
					System.out.println((flags&~masks[sc.nextInt()])==flags?1:0);
					break;
				case 7:{
					int cnt = 0;
					int i = sc.nextInt();
					for(int j = 0; j < 64; j++) {
						if(((masks[i]>>j)&1L)>0&&((flags>>j)&1L)>0)
							cnt++;
					}
					System.out.println(cnt);
					break;
				}
				case 8:
					System.out.println(Long.toUnsignedString(flags&masks[sc.nextInt()]));
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 118680
#include <stdio.h>
#define MAX 500000

int N;
int H[MAX];
int getLeft(int i) { return 2*i + 1; }
int getRight(int i) { return 2*i + 2; }
int getParent(int i) { return (i-1)/2; }
void swap(int i, int j)
{
    int temp = H[i];
    H[i] = H[j];
    H[j] = temp;
}

void heapify(int i){
    while (i < N) {
        int max_idx = i;
        int l = getLeft(i);
        if (l < N && H[l] > H[max_idx]) max_idx = l;
        int r = getRight(i);
        if (r < N && H[r] > H[max_idx]) max_idx = r;
        if (max_idx != i) {
            swap(i, max_idx);
            i = max_idx;
        } else {
            break;
        }
    }
}

void buildHeap(void)
{
    for(int i = N - 1; i >= 0; --i) heapify(i);
}

int main(void)
{
    //freopen("in.txt", "r", stdin);
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &H[i]);
    buildHeap();
    for (int i = 0; i < N; ++i) printf(" %d", H[i]);
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 4624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	int flg = 0;
	for(int i = 1; i <= 9; i++){
		if(n % i == 0 && n / i <= 9 && n / i >= 0){
			flg = 1;
		}
	}
	if(flg == 1){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> pii; // (cst, to)

int main() {
	int x, y, s;

	while (scanf("%d %d %d", &x, &y, &s)) {
		if (x == 0) {
			return 0;
		}

		int Max = 0;

		for (int i = 1; s >= i; i++) {
			for (int j = i; s >= j; j++) {
				if (s == (int) ((100+x) * i / 100) + (int) ((100 + x) * j / 100)) {
					Max = max(Max, (int) ((100 + y) * i / 100) + (int) ((100 + y) * j / 100));
				}
			}
		}
		printf("%d\n", Max);
	}


	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 998244353;
// #define LOCAL LDD
// #define int LL

const int N = 3002;
LL dp[N][N];

LL solve(int ps,int sm,int n,vector<int>& v){
  if(sm<0) return 0LL;
  if(ps==n) return (sm==0);
  if(dp[ps][sm]!=-1) return dp[ps][sm];
  LL ans = 0;
  ans += solve(ps+1,sm-v[ps],n,v);
  ans += 2*solve(ps+1,sm,n,v);
  ans %= MOD;
  // cout << ps << ", " << sm << " :" << ans << endl;
  return dp[ps][sm] = ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  memset(dp,-1,sizeof(dp));
  int n,s;cin >> n >> s;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin >> v[i];
  cout << solve(0,s,n,v) << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 74444
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    rep(i, m)cin >> a.at(i);
    ll dp[n+1];
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2; i <= n; i++){
        dp[i] = inf;
    }
    rep(i, m){
        dp[a[i]] = 0;
    }
    for(int i = 2; i <= n; i++){
        if(dp[i] == inf)dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= mod;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1792