akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
				using namespace std;
				#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
				#define ll long long int
				#define pb push_back
				#define fe first
				#define se second
				#define endl "\n"
				#define pii pair<int, int>

				#define PI 3.14159265358979323846
				const int N = 1e5 + 10;
				int a,b,k,c1,c2,maxi;	   
             
				void solve() {
					
					string s;
					cin>>s;
					int len=s.size();
					queue<char> q;
					
					
					for(int i=0;i<len;i++) {
						if(s[i]=='0') {
							  if(q.size()>0 && q.front()=='1') {
								  
								    c2+=2;
								    q.pop();
								  }
								else 
								  q.push(s[i]); 
							
							  }
							  
							  else {
								      if(q.size()>0 && q.front()=='0') {
								  
								    c2+=2;
								    q.pop();
								  }
								else 
								  q.push(s[i]); 
							
								  }
							  
						
					
							    
					}  					
		
					cout<<c2;
					
					 					
				}
					  
					
				
					   

				int main() {
				  cool;
				  int t = 1;
				  while (t--)
					solve();

				  return 0;
				}


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

typedef long long ll;

int main(void){
    ll N;
    cin>>N;
    
    ll A[N];
    vector<ll> B(N+1);
    B[0]=0;
    map<ll,ll> p;
    p[0]++;
    

    for(int i=0;i<N;i++){
        cin>>A[i];
        B[i+1]=A[i]+B[i];
        p[B[i+1]]++;
    }
    
    sort(B.begin(),B.end());
    unique(B.begin(),B.end());
    
    ll count=0;    
    for(int i=0;i<p.size();i++){
        if(p[B[i]]>=2)count+=(p[B[i]])*(p[B[i]]-1)/2;
    }
    
    cout<<count<<endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=0; i<(int)(n-1); ++i)
#define lp3(j, n)  for(int j=1; j<=(int)(n); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

    int n,arrA[N],arrB[N],arrC[N],sum=0;
    cin>>n;
    lp1(i,n)
    cin>>arrA[i];
    lp1(i,n)
    cin>>arrB[i];
    lp2(i,n)
    cin>>arrC[i];
    lp1(i,n)
    {
        lp3(j,n)
        {
            if(arrA[i]==j)
                sum+=arrB[i];
            if(arrA[i]==j && arrA[i+1]==j+1)
                sum+=arrC[j-1];
        }
    }

    cout<<sum;
go;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
int_fast64_t ans = 1;
int D[(int)1e5];
constexpr int mod = 1e9+7, MAX = 1e5+30;
int_fast64_t fac[MAX], finv[MAX], inv[MAX];
void cmb_init() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int_fast64_t cmb(int n, int k){
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
void Main(){
    int N = read(), M = read();//N 1e5 M 1e9
    int j = -1;
    int m = M;
    for (int i = 2; i*i <= M; i++) {
        if (m%i == 0) j++;
        while (m%i == 0) {
            m /= i;
            D[j]++;
        }
    }
    if (m != 1) D[++j]++;
    cmb_init();
    for (auto d:D) {
        if (d == 0) break;
        ans *= cmb(d+N-1, d);
        ans %= mod;
    }
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


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

int main(){
	int n,m,p;
	int x[100];
	while(cin>>n>>m>>p,n|m|p){
		int s=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			s+=x[i];
		}
		s*=(100-p);
		if(x[m-1])cout<<s/x[m-1]<<endl;
		else cout<<0<<endl;
	}
	return 0;
}

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

using namespace std;

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

	set<int> mochi;
	for (int i = 0; i < n; i++) {
		cin >> d;
		mochi.insert(d);
	}

	cout << mochi.size() << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

type Player struct {
	cards string
}

func newPlayer(cards string) *Player {
	return &Player{
		cards: cards,
	}
}

func (p *Player) getNextCard() string {
	if len(p.cards) == 0 {
		return ""
	}
	ret := string(p.cards[0])
	p.cards = p.cards[1:]
	return ret
}

func main() {
	var cardsA, cardsB, cardsC string
	fmt.Scanf("%s", &cardsA)
	fmt.Scanf("%s", &cardsB)
	fmt.Scanf("%s", &cardsC)

	playerA := newPlayer(cardsA)
	playerB := newPlayer(cardsB)
	playerC := newPlayer(cardsC)

	current := "A"
	next := playerA.getNextCard()
	for {
		if next == "" {
			break
		}
		switch next {
		case "a":
			current = "A"
			next = playerA.getNextCard()
		case "b":
			current = "B"
			next = playerB.getNextCard()
		case "c":
			current = "C"
			next = playerC.getNextCard()
		}
	}

	fmt.Println(current)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> vs;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        vs.push_back(v);
    }
    sort(vs.begin(), vs.end(), greater<int>());

    int m = 1;
    for (int i = 1; i < n; i++) {
        if (vs[i-1] > vs[i]) {
            m++;
        }
    }
    cout << m << endl;
}  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int digit10(int num){
    int sum=0;
    while(num>0){
        sum+=num%10;
        num/=10;
    }
    return sum;
}

int main() {
    int N;
    cin>>N;
    if(N%digit10(N)==0)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
const int N=25,A=1<<21|1;
int f[N][A],l[A],nxt[A][2];
int main(){
	ri n,k,i,u,s,t,pre,x,ans;
	scanf("%d%d",&n,&k);
	for(i=0;i<=n;++i)
		for(s=0;s<1<<i;++s)
			scanf("%1d",&f[i][1<<i|s]); // 在每个串前面加上1
	u=(1<<n+1)-1;
	for(s=2;s<=u;++s){
		l[s]=l[s>>1]+1;
		if(s&(1<<l[s]-1))
			nxt[s][1]=s^1<<l[s],
			nxt[s][0]=nxt[nxt[s][1]][0];
		else
			nxt[s][0]=s^3<<l[s]-1,
			nxt[s][1]=nxt[nxt[s][0]][1];
	}
	for(i=n;i>0;--i)
		for(s=1<<i;s<=u;++s)
			if(f[i][s]){
				pre=s>>i;
				t=s&(1<<i)-1|1<<i;
				if(x=nxt[t][0]) f[l[x]][(pre<<1|1)<<l[x]^x]+=f[i][s]; // |1 和 x开头的 1 相消 
				if(x=nxt[t][1]) f[l[x]][(pre<<1  )<<l[x]^x]+=f[i][s];
				f[0][pre]+=f[i][s];
			}
	ans=1;
	for(s=2;s<=u;++s)
		if(f[0][s]>=k&&l[s]>l[ans])
			ans=s;
	i=n;
	while(~ans>>i&1) --i;
	while(i--) printf("%d",ans>>i&1);
	puts("");
	return 0;
}

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

int main()
{
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(10);
    cout<<1.0*w*h/2.0<<" ";
    if(x*2==w&&y*2==h) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int H, W, N, MX;
    int result = 0;
    int i = 0;
    cin >> H >> W >> N;
    bool boo = true;
    MX = max(H, W);
    for (; N > result; i++) {
        result += MX;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	string s;
	long long int y=n;
	char c;
	while(1)
	{		
		int x=y%26;
		y=y/26;
		if(x==0)
		{
			y=y-1;
			c='z';
		}
		else
		c=char(int(x)+96);
		
		s.push_back(c);
		if(y==0)
		{
			break;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
	
}

Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val x = readLine()!!.map { s -> s - '0'}
    val K = readLine()!!.toLong() - 1
    var pos = 0
    for (i in 0 until x.size) {
        if (x[i] > 1) {
            pos = i
            break
        }
    }
    println(if (K < pos) 1 else x[pos])
}

Measured memory_bytes: 33788
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
signed main() {
	int n, m;
	cin >> n >> m;
	if (n>=10) {
		cout << m << endl;
	}
	else {
		cout << m + 100 * (10 - n) << endl;
	}
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n: i8 = read();
  
  if n == 1 {
    println!("Hello World");
    return;
  }
  
  let (a, b): (i32, i32) = (read(), read());
  println!("{}", a + b);
}

Measured memory_bytes: 4352
from itertools import chain
m,k=map(int,input().split())
if k==0:
    print(" ".join([str(i) for i in chain(range(0,2**m),range(2**m-1,-1,-1))]))
elif 0<k<2**m:
    s=0
    for i in range(0,2**m):
        if i!=k:
            s^=i
    if s==k:
        print(" ".join([str(i) for i in chain(range(0,k),range(k+1,2**m),[k],range(2**m-1,k,-1),range(k-1,-1,-1),[k])]))
    else:
        print(-1)
else:
    print(-1)

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

typedef long long ll;
typedef long double ld;

/*
int %d
long long %lld
double %lf %0.6lf
long double %0.6Lf
char %c
string %s
*/

int main()
{
#if _MSC_VER
	freopen("input.txt", "r", stdin);
#endif
	ll k;
	int n, m;
	scanf("%d%d%lld", &n, &m, &k);
	std::vector<int> a(n);
	std::vector<ll> b(m);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < m; ++i)
	{
		scanf("%lld", &b[i]);
		if (i)
		{
			b[i] += b[i - 1ll];
		}
	}
	int ans = std::upper_bound(b.begin(), b.end(), k) - b.begin();
	ll acum = 0;
	for (int i = 0; i < n; ++i)
	{
		acum += a[i];
		if (acum > k)
		{
			break;
		}
		int temp = std::upper_bound(b.begin(), b.end(), k - acum) - b.begin();
		ans = std::max(ans, i + 1 + temp);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5640
abc = sorted(list(map(int, input().split())), reverse=True)
ans = 0

if abc[1]%2 != 0 and abc[2]%2 == 0:
    ans += 1
    abc[0] += 1
    abc[1] += 1

elif abc[1]%2 == 0 and abc[2]%2 != 0:
    ans += 1
    abc[0] += 1
    abc[2] += 1

ans += abc[0] - abc[1]
ans += (abc[1] - abc[2])//2

print(ans)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, m;
  cin >> n >> m;
  vector<P> key;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j,b) {
      int c;
      cin >> c;
      c--;
      s |= 1<<c;
    }
    key.emplace_back(s,a);
  }
  vi dp(1<<n, inf);
  dp[0] = 0;
  rep(i,1<<n) {
    rep(j,m) {
      int next = i | key[j].first;
      int tmp = dp[i] + key[j].second;
      dp[next] = min(dp[next], tmp);
    }
  }
  int ans = dp.back();
  if(ans == inf) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
#include<valarray>
typedef unsigned long long ull;
typedef  long long ll;

int main() {
	ll N, D;

	std::cin >> N >> D;

	ll ans =  (N  + 2 * D) / (2 * D + 1);

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

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a.sort()
totl=0
x=0
for j,k in a:
  if x+k<m:
    totl+=j*k
    x+=k
  else:
    totl+=j*(m-x)
    break
print(totl)
    
    
  
  


Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN maxn

using namespace std;

string s;

signed main()
{
	IO;
	getline(cin, s);
	cout << s << (s[s.length() - 1] == 's' ? "es" : "s") << endl;
	return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	char x;
	while(~scanf("%d %c %d",&a,&x,&b)){
//		scanf("%c",&x);
//		scanf("%d",&b);
		getchar();
		if(x=='+')
			printf("%d\n",a+b);
			else
			printf("%d\n",a-b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  int INF = 1000000;

  string str;
  while(cin>>str){
    for(int i=str.size()-1; i>=0; --i){
      cout << str[i];
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
#include <iostream>
#include <cmath>
#define REP(val,times) for(int val = 0;val < times;val++)
using namespace std;

int main(){
    char str[4];
    int count = 0;
    REP(i,4){
        scanf("%c",&str[i]);
        if(str[i] == '+')
            count++;
        else
            count--;
    }

    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 
    fast;

    ll n,k;
    cin>>n>>k;

    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];

    sort(a.begin(),a.end());
    ll ans=0;

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

        for(ll i=k;i<n;i++)
        {
            ans+=a[i];
        }
        cout<<ans<<endl;
  
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
    cout << "Left";
  } else if (A+B < C+D) {
    cout << "Right";
  } else {
    cout << "Balanced";
  }
}



Measured memory_bytes: 256
INF = 10 ** 20

def main():
  while True:
    n, m = map(int, input().split())
    if not n:
      break
  
    chairs = list("#" * n)
  
    def sit(s):
      if s == "A":
        chairs[chairs.index("#")] = "A"
      
      elif s == "B":
        for i in range(n - 1, -1, -1):
          if chairs[i] == "#" and (i == 0 or chairs[i - 1] != "A") and (i == n - 1 or chairs[i + 1] != "A"):
            chairs[i] = "B"
            break
        else:
          chairs[chairs.index("#")] = "B"
  
      elif s == "C":
        for i in range(n):
          if chairs[i] != "#":
            if i + 1 <= n - 1 and chairs[i + 1] == "#":
              chairs[i + 1] = "C"
              break
   
            elif i - 1  >= 0 and chairs[i - 1] == "#":
              chairs[i - 1] = "C"
              break
  
      else:
        score = [INF for _ in range(n)]
        dist = INF
        for i in range(n):
          if chairs[i] == "#":
            dist += 1
          else:
            dist = 0
          score[i] = dist
  
        dist = INF
        for i in range(n - 1, -1, -1):
          if chairs[i] == "#":
            dist += 1
          else:
            dist = 0
          score[i] = min(score[i], dist)
        high_score = max(score)
  
        chairs[score.index(high_score)] = "D"
    
    first = input()
    if first in ["A", "D"]:
      chairs[0] = first
    elif first == "B":
      chairs[-1] = "B"
    else:
      chairs[n // 2] = "C"
    
    for _ in range(m - 1):
      sit(input())
    print("".join(chairs))

main() 


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			if(!(a[i]%3==0||a[i]%5==0))
			{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MOD = 1000000007;

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

    string S;
    cin >> S;
    ll n = S.size();

    vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
    ll weight = 1;
    dp[0][0] = 1;

    Rep (i, n) {
        Rep (j, 13) {
            if (S[n-1-i] == '?') {
                Rep (k, 10) {
                    dp[i+1][(j+k*weight)%13] += dp[i][j];
                    dp[i+1][(j+k*weight)%13] %= MOD;
                }
            } else {
                dp[i+1][(j+(S[n-1-i]-'0')*weight)%13] += dp[i][j];
                dp[i+1][(j+(S[n-1-i]-'0')*weight)%13] %= MOD;
            }
        }
        weight *= 10;
        weight %= 13;
    }

    // Rep (i, n+1) {
    //     Rep (j, 13) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][5] << "\n";
}

Measured memory_bytes: 13648
#include <bits/stdc++.h>
#define maxs 222020
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
struct node
{
    int a;
    int b;
}d[maxs];

int cmp(node x,node y){
    return x.a<y.a;
}

int main()
{
    int n;
    long long k;
    while(~scanf("%d%lld",&n,&k))
    {
        for(int i=1;i<=n;i++)
            scanf("%d%d",&d[i].a,&d[i].b);
            
        sort(d+1,d+n+1,cmp);
        
        for(int i=1;i<=n;i++) {
            k-=d[i].b;
            if(k<=0){
                printf("%d\n",d[i].a);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val s = readLine()!!.split(" ").map(String::toInt)
    solver9(s)
}

fun solver9(s: List<Int>) {
    val ans = if (s.reduce { acc, i -> acc + i } > 21 ) "bust" else "win"
    println(ans)
}

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

main() {
    int A,B,K; cin >> A >> B >> K;
    for(int i=A;i<=B;i++){
        if(i>=A+K && i<=B-K) continue;
        else cout << i << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
using namespace std ; 
int main ()
{
	int a,b;
	cin>>a>>b ; 
	if(a>b)
	{
		for(int i=0 ; i<a ;i++)
			cout<<b;
	}
	else if (a<=b)
	{
		for(int i =0;i<b;i++)
			cout<<a;
	}
	return 0 ;

}

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

using namespace std;

char s[20], t[20];

int main() {
	scanf("%s", s);
	scanf("%s", t);
	for (int i = 0; s[i]; ++i) {
		if (s[i] != t[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3688
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

#cnt = 0
#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

K = int(input())
S = str(input())

if K >= len(S):
    print(S)
else:
    print(S[0:K]+"...")

Measured memory_bytes: 9160
# coding=utf-8

class Node:
    def __init__(self, ID, left, right):
        ### ?????¬?????± ###
        self.id = ID
        self.parent = -1 #??????
        self.sibling = -1 #??????
        self.degree = -1 #??????
        self.depth = 0 #??????
        self.height = 0 #??????
        self.type = None #??????

        ### ?£??¶??????± ###
        self.left_child = left
        self.right_child = right

def calc_depth(i):
    global node_list

    if node_list[i].depth != 0:
        return node_list[i].depth

    depth = 0
    if node_list[i].parent != -1:
        depth = calc_depth(node_list[i].parent) + 1

    node_list[i].depth = depth
    return depth


def calc_height(i):
    global node_list

    if node_list[i].height != 0:
        return node_list[i].height

    h1 = h2 = 0
    if node_list[i].right_child != -1:
        h1 = calc_height(node_list[i].right_child) + 1
    if node_list[i].left_child != -1:
        h2 = calc_height(node_list[i].left_child) + 1

    height = max(h1, h2)
    node_list[i].height = height
    return height

n = int(input())
data = [tuple(map(int, input().split())) for x in range(n)]
node_list = []

for data_row in data:
    ID, left, right = data_row
    node = Node(ID, left, right)
    node_list.append(node)

node_list.sort(key = lambda node: node.id)

for i, node in enumerate(node_list):
    left = node.left_child
    right = node.right_child
    degree = 0

    ### ???????????± ###
    if left != -1:
        degree += 1
        node_list[left].parent = i
        node_list[left].sibling = right

    if right != -1:
        degree += 1
        node_list[right].parent = i
        node_list[right].sibling = left

    ### ??????????????± ###
    node.degree = degree

for i in range(n):
    calc_depth(i)
    calc_height(i)

    node = node_list[i]

    if node.depth == 0:
        node.type = 'root'
    elif node.height == 0:
        node.type = 'leaf'
    else:
        node.type = 'internal node'

    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.id, node.parent, node.sibling, node.degree, node.depth, node.height, node.type))

Measured memory_bytes: 7832
import java.util.*;
public class Main{
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt(), X = scan.nextInt();
		int min = Integer.MAX_VALUE , total=0;
		
		for(int i=0; i<N; i++) {
			int curr = scan.nextInt();
			if(curr < min) {
				min = curr;
			}
			total = total + curr;
		}
		
		System.out.println((int)((X-total)/min)+N);
		
	}

}


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (a+b+c >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
    return 0;
}

	

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

dp = [[0]*3 for i in range(n)]
dp[0][0], dp[0][1], dp[0][2] = map(int, input().split())

for i in range(1,n):
    l = [int(x) for x in input().split()]
    for j in range(3):
        dp[i][j] = max(dp[i-1][j-1], dp[i-1][j-2]) + l[j]

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

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

#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
const mint inv9 = mint(1)/9;
struct S{
	mint x, w;
	S(mint x=0, mint w=1): x(x), w(w) {}
};
S op(S a, S b){ return S(a.x*b.w + b.x, a.w*b.w); }
S e(){ return S(); }
S mapping(int f, S a){
	if(f == 0) return a;
	return S((a.w-1)*inv9 * f, a.w);
}
int composition(int f, int g){
	if(f == 0) return g;
	return f;
}
int id(){ return 0; }
using F = int;
// (1) lazy_segtree<S, op, e, F, mapping, composition, id> seg(int n);
using LZ_SegT = lazy_segtree<S, op, e, F, mapping, composition, id>;

int main(){
	int N, Q; cin>>N>>Q;
	LZ_SegT lz(N);
	rep(i, N) lz.set(i, S(1, 10));
	rep(q, Q){
		int l, r, d; cin>>l>>r>>d;
		lz.apply(l-1, r, d); // [l-1,r)
		S ans = lz.prod(0, N); // [0,N)
		cout<< ans.x.val() <<endl;
	}
}


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

int main() {
	ll H, W, N, a, b;
	cin >> H >> W >> N;
	map<pair<int, int>, int> A;
	for (int i = 0;i < N;i++) {
		cin >> a >> b;
		for (int j = a - 1;j < a + 2;j++) {
			for (int k = b - 1;k < b + 2;k++) {
				if (j < 2 || j >= H || k < 2 || k >= W) continue;
				if (A.count({ j,k })) A[{j, k}]++;
				else A.insert({ {j,k},1 });
			}
		}
	}
	vector<int> ans(10, 0);
	ll ze = (H - 2)*(W - 2);
	for (auto it = A.begin();it != A.end();it++) {
		ans[(*it).second]++;
		ze--;
	}
	cout << ze << endl;
	for (int i = 1;i < 10;i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 56448
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    int x ,a, b, c;
    cin >> a >> b >> c;

    x = min(a+b, b+c);
    x = min(x, a+c);

    cout << x << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string s;
    cin >> s;
    int siz = s.size();
    long long ans=0;
    queue<string> tq;
    string tmp;
    rep(i,1<<siz-1){
        // cout << i << endl;
        tmp=s.at(0);
        rep2(j,1,siz){
            
            // cout << "i:"<<i<<" j:"<<j<<endl;
            if(!(i&1<<j-1)){
                // cout << "koko" << endl;
                tmp+=s.at(j);
            }else{
                tq.push(tmp);
                tmp=s.at(j);
            }
        }
        tq.push(tmp);
        while(!tq.empty()){
            //  cout << tq.front() << endl;
            ans+=stol(tq.front().c_str());
            tq.pop();
        }
        //  cout << "i:"<<i<<endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int x, y;
  while (1) {
    cin >> x >> y;
    if (x == 0 && y == 0) { break; }

    int first, second;
    if (x < y) {
      first = x;
      second = y;
    } else {
      first = y;
      second = x;
    }
    cout << first << " " << second << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include<cstdio>
#include<iostream>
using namespace std;
int ans=1000000000;
int a,b,c,x,y;
int main()
{
	cin>>a>>b>>c>>x>>y;
	for(int i=0;i<=max(x,y)*2;i+=2)
	{
		int a1=0,a2=0;
		if(x>i/2) a1=a*(x-i/2);
		if(y>i/2) a2=b*(y-i/2);
		ans=min(ans,a1+a2+i*c);
	}
	cout<<ans;
        return 0;
}

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

int main(void)
{
  while (true)
  {
    int expenses;
    cin >> expenses;
    if ( expenses == 0 ) break;
    int i;
    int sum = 0;
    for (i = 0; i < 12 && sum < expenses; i++)
    {
      int revenue, spending;
      cin >> revenue >> spending;
      sum += revenue - spending;
    }
    if (i == 12 && sum < expenses)
    {
      cout << "NA" << endl;
    }
    else
    {
      cout << i << endl;
    }
    for (i = i; i < 12; i++)
    {
      int d,dm;
      cin >> d >> dm;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 1e8 + 7;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        ((num *= 10) += x - '0') %= MOD;
    return flg ? -num : num;
}
const int N = 1e5 + 10;
ll ans = 0, tot = 0;
int n;
int main()
{
	cinspu();
	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << std::min(b / a, c) << std::endl;
	return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>

using namespace std;

int n;
int a[1043][1043];
int cur[1043];
bool vis[1043];
int ans;

int main(int argc, char const *argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    cur[i] = 1;
    for (int j = 1; j < n; ++j) {
      scanf("%d", &a[i][j]);
    }
  }

  bool flag = true;
  while (flag) {
    flag = false;
    memset(vis, false, sizeof(vis));
    for (int i = 1; i <= n; ++i) {
      int j = a[i][cur[i]];
      if (vis[i] || vis[j]) continue;
      if (i == a[j][cur[j]]) {
        flag = true;
        ++cur[i];
        ++cur[j];
        vis[i] = true;
        vis[j] = true;
        continue;
      }
    }
    if (flag) {
      ++ans;
      continue;
    }
    for (int i = 1; i <= n; ++i) {
      if (cur[i] != n) {
        printf("-1\n");
        return 0;
      }
    }
  }

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

  return 0;
}


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

using namespace std;
        
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
        
#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll next(){ll x; cin >> x; return x;}
const int maxn = 3e5 + 5, intf = 2e9;
const ll inf = 1e18, mod = 998244353;
const ld eps = 1e-9;


void solve(){
  ll n; cin >> n;
  int ans = 0;
  for(ll i = 2; i*i <= n; i ++){
    ll t = 0;
    while(n % i == 0){
      t++;
      n /= i;
    }
    for (int j = 1; t - j >= 0 ; j ++){
      t -= j;
      ans++;
    }
  }

  if (n != 1){
    ans++;
  }
  cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
  
  for (int t = 1; t--;) {
    solve();
  }
        
  return 0;
}
/*

*/


Measured memory_bytes: 3648
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

A = LI()
if sum(A) >= 22:
    print("bust")
else:
    print("win")


Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;

int n, A, B, C, D, f[maxn];
char s[maxn];

inline int dp(int x, int y) {
	memset(f,0,sizeof(f));
	f[x] = 1;
	for(int i = x + 1;i <= y;i ++) {
		f[i] = 0;
		if(s[i] == '#') continue;
		if(i - 1 > 0) f[i] |= f[i - 1];
		if(i - 2 > 0) f[i] |= f[i - 2];
	}
	return f[y];
}

inline int check(int x, int y) {
	for(int i = x;i <= y;i ++) {
		if(i > 1 && s[i - 1] == '#') continue;
		if(i < n && s[i + 1] == '#') continue;
		if(s[i] == '#') continue;
		return 1;
	}
	return 0; 
}

int main() {
//	freopen("data.in","r",stdin);
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	scanf("%s", s + 1);
	int Ans = 1;
	Ans &= dp(A,C);
	Ans &= dp(B,D);
	
	if(D < C) Ans &= check(B,D);
	if(Ans) puts("Yes");
	else puts("No");
	return 0;
} 

Measured memory_bytes: 1280
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b=map(int,readline().split())

    if a==0:
        print(f(b))
    else:
        print(f(b)^f(a-1))

def f(n):
    if n%4==3:
        return 0
    elif n%4==2:
        return n^1
    elif n%4==1:
        return 1
    else:
        return n

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static boolean isPrime(int x) {
    if(x == 2) {
      return true;
    } else if(x % 2 == 0) {
      return false;
    } else {
      int i = 3;
      while(i <= Math.sqrt(x)) {
        if(x % i == 0) {
          return false;
        } else {
          i += 2;
        }
      }
      return true;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    for(int i = 0; i < n; i++) {
      if(isPrime(sc.nextInt())) {
        count++;
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 41244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <deque>

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b,x,y,i=0;
	cin >>a >>b >>x >>y;
	while (1) {
		if (i%2==0) {
			x-=b;
			if (x<=0) {
				cout <<"Yes";
				return 0;
			}
		}
		else {
			a-=y;
			if (a<=0) {
				cout <<"No";
				return 0;
			}
		}
		i++;
	} 
}
/******************************************************************************
******************************************************************************/


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

int H, W, N;
pair<int, int> bar[200010];
int g[200010], h[200010], ans[200010];

int f(int x, int y) {
    if (y == 0) {
        return x;
    } else if (y >= 2 * W) {
        return f(x, y % (2 * W));
    } else if (x % 2 != y % 2) {
        if (x == W - 1) return f(x, y - 1);
        else return f(x + min(W - 1 - x, y), y - min(W - 1 - x, y));
    } else {
        if (x == 0) return f(x, y - 1);
        else return f(x - min(x, y), y - min(x, y));
    }
}

int main() {
    while (cin >> H >> W >> N) {
        for (int i = 0; i < N; i++) {
            cin >> bar[i].first >> bar[i].second;
            --bar[i].first;
            --bar[i].second;
        }
        sort(bar, bar + N);
        iota(g, g + W, 0);
        for (int i = 0; i < N; i++) {
            int y, x;
            tie(y, x) = bar[i];
            int a = f(x, y);
            int b = f(x + 1, y);
            swap(g[a], g[b]);
        }
        for (int i = 0; i < W; i++) {
            ans[g[f(i, H)]] = i;
        }
        for (int i = 0; i < W; i++) {
            cout << ans[i] + 1 << '\n';
        }
    }
}

Measured memory_bytes: 6220
import numpy as np
H,W,K = map(int,input().split())

grid = np.array([list(map(lambda x: x == '#',input())) for _ in range(H)])

from itertools import product

res = 0
for p in product(range(2),repeat=H+W):
    ngrid = grid.copy()
    ngrid[:,[i for i,v in enumerate(p[:W]) if v]] = 0
    ngrid[[i for i,v in enumerate(p[W:]) if v],:] = 0
    if ngrid.sum() == K:
        res += 1

print(res)

Measured memory_bytes: 27280
import sys
n = int(input())
F = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
P = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
ans = -pow(10,9)-7
for i in range(1,pow(2,10)):
    b = bin(i)[2:].zfill(10)
    t = 0
    for j in range(n):
        c = 0
        for k in range(10):
            if int(b[k]) and F[j][k]:
                c += 1
        t += P[j][c]
    ans = max(ans, t)
print(ans)

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

int main()
{
  int N;cin>>N;
  vector<int> A(4);
  A[3]=N%10;
  A[2]=N/10%10;
  A[1]=N/100%10;
  A[0]=N/1000%10;
  
  for (int bit=0;bit<(1<<3);bit++)
  {
    int ans = A[0];
    char op[3];
    //集合bitを固定
    for (int k=0;k<3;k++)
    {
      if (bit & (1<<k))
      {
         ans += A[k+1];
        op[k]='+';
      }
      else{
         ans -=A[k+1];
        op[k]='-';
      }
    }
    if (ans == 7)
    {
      cout << A[0]<<op[0]<< A[1]<<op[1]<< A[2]<<op[2]<< A[3]<<"=7"<<endl; 
      return (0);
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;

int main(){
  
  pair<int, int> a[6];

  for(int i=0;i<6;i++){
    cin>>a[i].first>>a[i].second;
    if(a[i].first>a[i].second) swap(a[i].first, a[i].second);
  }

  sort(a, a+6);

  pair<int, int> b[3];

  int cnt=0;
  for(int i=0;i<6;i+=2){
    if(a[i]==a[i+1]) b[cnt++]=a[i];
    else{
      cout<<"no"<<endl;
      return 0;
    }
  }

  if(b[0].first==b[1].first&&b[1].second==b[2].second&&b[2].first==b[0].second) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_lim=(n); i<i##_lim; ++i)
#define FOR(i, a, b) for (int i=(a), i##_lim=(b); i<i##_lim; ++i)
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    int ret = B;
    if (6 <= A && A <= 12) ret /= 2;
    if (A <= 5) ret = 0;

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

struct Node{
  int num;
  Node *right,*left,*parent;
};

Node *NIL,*root;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *T;
  
  T=(Node *)malloc(sizeof(Node));
  T->num=k;
  T->left=NIL;
  T->right=NIL;
  
  while(x!=NIL){
    y=x;
    if(T->num<x->num) x=x->left;
    else x=x->right;
    
  }
  
  T->parent=y;
    
  if(y==NIL) root=T;
  else{
    if(T->num<y->num) y->left=T;
    else y->right=T;
  }
}

void inorder(Node *T){
  if(T==NIL) return;
  inorder(T->left);
  cout<<" "<<T->num;
  inorder(T->right);
}

void preorder(Node *T){
  if(T==NIL) return;
  cout<<" "<<T->num;
  preorder(T->left);
  preorder(T->right);
}

int main(){
  int m,k;
  string S;

  cin>>m;
  for(int i=0;i<m;i++){
    cin>>S;
    if(S=="insert"){
      cin>>k;
      insert(k);
    }else if(S=="print"){
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24648
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
   int l,r,d;
   cin >> l >> r >> d;

   int kcount = 0;

   for(int i = l; i <= r; i++){
        if(i % d == 0){
            kcount = kcount +1;
        }
   }

    cout << kcount;

}

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

int main(int argc, char *argv[]){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long q=a*c;
    long long w=a*d;
    long long e=b*c;
    long long r=b*d;
    q=max(q,w);
    e=max(e,r);
    q=max(q,e);
    cout << q << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, X, a[4040], dp[2020][4040], ans = INFL;

signed main()
{
    cin >> N >> X;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        a[i + N] = a[i];
    }
    for(int i = 0; i < N; i++){
        int res = i * X;
        for(int j = N; j < 2 * N; j++){
            if(i == 0){
                res += a[j];
                dp[i][j] = a[j];
                dp[i][j % N] = a[j];
            }
            else{
                dp[i][j] = min(dp[i - 1][j], a[j - i]);
                dp[i][j % N] = min(dp[i - 1][j % N], a[j - i]);
                res += dp[i][j];
            }
        }
        ans = min(res, ans);
    }
    cout << ans << endl;


    return 0;
}
/*


*/


Measured memory_bytes: 63744
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func Scan() string {
	s.Scan()
	return s.Text()
}

func main() {
	fmt.Println(p())
}

func ScanInt() int {
	a, err := strconv.Atoi(Scan())
	if err != nil {
		return 0
	}
	return a
}

func test(n int) (int, int) {
	t := n
	x := 1
	for i := 1; i < t; i++ {
		if n%i == 0 {
			x = i
		}
		t = n / i
	}
	return x, n / x
}

func p() int {
	a := ScanInt()
	x, y := test(a)
	return x + y - 2
}


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

int main()
{
	int A,B;
  	cin >> A >> B;
  	cout << max(A+B,max(A-B,A*B)) << endl;
	return 0;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << " " << x.s << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);
#define INF 10000007LL

ll pwr(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b&1) res = res*a;
		a = a*a;
		b >>= 1;
	}
	return res;
}

int main() {
    godspeed;
    ll n; cin >> n;
    vl v(n+1); _for(i,1,n+1) cin >> v[i];
    sort(all(v));

    ll ans = INF;
    _for(i,1,101) {
    	ll mx = 0;
    	_for(j,1,n+1) mx += pwr(abs(v[j] - i),2);
    	ans = min(mx,ans);
    }

    cout << ans;


}	

Measured memory_bytes: 3644