akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll n ,h;
  cin >> n >> h;
  Vector a,b;
  rep(i,n){
    ll ta, tb;
    cin >> ta >> tb;
    a.pb(ta);
    b.pb(tb);
  }
  dsort(a);
  dsort(b);
  ll ct = 0;
  each(ib,b){
    if(a[0] < ib){
      h -= ib;
      ct++;
      if(h <= 0)break;
    }
    else break;
  }
  while(h > 0){
    ct++;
    h -= a[0];
  }
  cout << ct << endl;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	vector<int>ans;
	if (N % 2 == 0) {
		for (int i = N - 1; i > 0; i -= 2)ans.push_back(v[i]);
		dump(ans);
		for (int i = 0; i < N; i += 2)ans.push_back(v[i]);
	}
	else {
		for (int i = N - 1; i >= 0; i -= 2)ans.push_back(v[i]);
		dump(ans);
		for (int i = 1; i < N; i += 2)ans.push_back(v[i]);
	}
	rep(i, 0, N)cout << ans[i] << (i == N - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
long long n,a[202020],ans,l,r,k;
bool ck(long long xx)
{
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==0)//检查0
		{
			if(xx>=0)
			{
				sum+=n-1;
			}
		}
		else if(a[i]<0)
		{
			long long mx=xx/a[i];
			if(mx*a[i]>xx)
			{
				mx++;
			}
			int id=lower_bound(a,a+n,mx)-a;
			sum+=n-id;
			if(id<=i)
			{
				sum--;
			}
		}
		else
		{
			long long mx=xx/a[i];//a[j]的最大值
			if(mx*a[i]>xx)
			{
				mx--;
			}
			int id=upper_bound(a,a+n,mx)-a-1;
			if(id<0)
			{
				continue;
			}
			sum+=id+1;
			if(id>=i)
			{
				sum--;//a[i]*a[i]肯定是不行的
			}
		}
	}
	return (sum/2)>=k;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	l=-1e18-100;
	r=1e18+100;
	while(l<r)
	{
		long long md=l+(r-l)/2;
		if(ck(md))
		{
			r=md;
		}
		else
		{
			l=md+1;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
typedef long long ll;
ll a,b,c;
int main(){
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	ll ans=0;
	ll turn=min(c,b);
	b-=turn;
	c-=turn;
	ans+=turn*2;
	ll turn2=min(c,a);
	ans+=turn2;
	c-=turn2;
	a-=turn2;
	if(c>0) ans++;
	else ans+=b;
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, c = na()
print(c, a, b)

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

int main() {
  int n;
  cin >> n;
  int res = 0;
  rep(i, n) {
    int left, right;
    cin >> left >> right;
    res += (right - left + 1);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
void aaa(int, int, int, int);
int a0[10][3]={{0}} ,a1[10][3]={{0}}, a2[10][3]={{0}}, a3[10][3]={{0}};

void aaa(int b, int f, int r, int v)
{
	if (b==1)
	{
		a0[r-1][f-1]=a0[r-1][f-1]+v;
		
	}
	else if (b==2)
	{
		a1[r-1][f-1]=a1[r-1][f-1]+v;
	}
	else if (b==3)
	{
		a2[r-1][f-1]=a2[r-1][f-1]+v;
	}
	else if (b==4)
	{
		a3[r-1][f-1]=a3[r-1][f-1]+v;
	}
	return ;
}

int main(void)
{
	int i, y, n, b, f, r, v;

	scanf("%d", &n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d%d", &b, &f, &r, &v);
		aaa(b, f, r, v);
	}

	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a0[y][i]);
		}
		printf("\n");
	}
	printf("####################\n");
	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a1[y][i]);
		}
		printf("\n");
	}
	printf("####################\n");
	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a2[y][i]);
		}
		printf("\n");
	}
	printf("####################\n");
	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a3[y][i]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 612
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N = ir()
A = lr()
# lcm
lcm = 1
answer = 0
for a in A:
    coef =  a // gcd(lcm, a)
    answer *= coef
    lcm *= coef
    answer += lcm // a
    answer %= MOD

print(answer%MOD)


Measured memory_bytes: 6136
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val pairs = (0 until m).map { readLine()!!.split(' ').let { Pair(it[0].toInt(), it[1]) } }
    val group = pairs
            .groupBy { it.first }

    val ac = group.map { if(it.value.any { it.second == "AC" }) 1 else 0 }.sum()
    val wa = group
            .map {it.value}
            .map { it.indexOfFirst { it.second == "AC" }.let { if (it == -1) 0 else it } }
            .sum()
    println("$ac $wa")
}



Measured memory_bytes: 64520
n,m=list(map(int,input().split()))
ps=[input().split() for _ in range(m)]
plst=[0]*n
penlst=[0]*n
pen=0
ans=0

for p,s in ps:
    p=int(p)-1
    if plst[p]:
        continue
    if s=='AC':
        ans+=1
        pen+=penlst[p]
        plst[p]=1
    else:
        penlst[p]+=1

print('{} {}'.format(ans,pen))

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

int main(){
  int N, first_l=0;
  string S;

  cin >> N >> S;

  int left = 0;
  int right = 0;

  rep(i, N){
    if (S[i]=='(') right++;
    else if (right > 0) right--;
    else left++;
  }


  rep(i,left){
    S = '(' + S;
  }
  rep(i, right){
    S = S + ')';
  }

  cout << S << endl;

}


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

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

P Q[LEN+1];
int head,tail,n;

void initialize();
bool isEnpty();
bool isFull();
void enqueue(P);
P dequeue();


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  initialize();

  while(head != tail){
      u=dequeue();
      if(u.t > q){
          u.t -= q;
          elaps+=q;
          enqueue(u);
      }
      else{
          elaps+=u.t;
          printf("%s %d\n",u.name,elaps);
      }
  }
  
  return 0;
}

void initialize(){
    head=0;
    tail=n;
}

bool isEnpty(){
    return head == tail;
}

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

void enqueue(P x){
    if(isFull()){
        fprintf(stderr, "オーバーフロー\n");
        exit(0);
    }
    Q[tail]=x;
    if(tail+1 == LEN){
        tail=0;
    }
    else{
        tail++;
    }
}

P dequeue(){
    P x;
    if(isEnpty()){
        fprintf(stderr, "アンダーフロー\n");
        exit(1);
    }
    x=Q[head];
    if(head+1 == LEN){
        head=0;
    }
    else{
        head++;
    }
    return x;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    int len=s.length();
    cout<<s[0]<<len-2<<s[len-1]<<endl;
}


Measured memory_bytes: 256
import java.util.TreeSet

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val Ps = readInputLine().split(" ").map { it.toInt() }
    
    val indices = IntArray(N)
    
    for ((i, p) in Ps.withIndex()) {
        indices[p - 1] = i + 1
    }

    val biggerIndices = TreeSet<Long>()

    var ans = 0L
    
    for (i in N - 1 downTo 0) {
        val index = indices[i].toLong()
        
        val x = biggerIndices.lower(index) ?: 0L
        val w = biggerIndices.lower(x) ?: 0L
        
        val y = biggerIndices.higher(index) ?: (N + 1).toLong()
        val z = biggerIndices.higher(y) ?: (N + 1).toLong()

        ans += ((i + 1).toLong() * ((x - w) * (y - index) + (index - x) * (z - y)))

        biggerIndices.add(index)
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 58088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClarss
{
	public const long Giri = 1000000007;
	
	public class Node
	{
		public int Index{get;set;}
		public int Counter{get;set;}
		public Node Parent{get;set;}
		public List<Node> Connected{get;set;}
		public Node()
		{
			Connected = new List<Node>();
		}
	}
	
	public static void Main(string[] args)
	{
		string[] l1  = Input();
		int n = int.Parse(l1[0]);
		int q = int.Parse(l1[1]);
		
		Node[] nodes = new Node[n];
		for(int i = 0; i < n; i++)
		{
			Node node = new Node();
			nodes[i]=node;
		}
		
		for(int i = 0; i < n-1; i++)
		{
			string[] p = Input();
			int a1 =int.Parse(p[0])-1;
			int b1 =int.Parse(p[1])-1;
			//Console.WriteLine("{0} - {1}", a1, b1);
			nodes[a1].Connected.Add(nodes[b1]);
			nodes[b1].Parent = nodes[a1];
		}
		
		for(int i = 0; i <q;i++)
		{
			string[] s = Input();
			int p1 =int.Parse(s[0])-1;
			int q1 =int.Parse(s[1]);
			nodes[p1].Counter += q1;
		}
		//Console.WriteLine("cc");
		
		a(nodes[0]);
		for(int i = 0; i < n; i++)
		{
			Console.Write(nodes[i].Counter + " ");
		}
	}

	private static void a(Node n)
	{
		if(n.Parent!=null)
		{
			n.Counter += n.Parent.Counter;
		}
		else
		{
			//Console.WriteLine("Skip" + n.Index);
		}
		foreach(Node b in n.Connected)
		{
			a(b);
		}
		
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)x += mod1;
    return x;
}

const LL mod=1e9+7;

LL a[100002],fact[100002];

void find_fact()
{
    LL i;
    fact[0]=1LL;
    for(i=1LL;i<=100000;i++)fact[i]=(fact[i-1]*i)%mod;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    find_fact();
    LL i,k,n,ans=0LL;
    cin >> n >> k;
    for(i=1;i<=n;i++)cin >> a[i];
    sort(a+1,a+n+1,greater<LL>());
    for(i=1;i<=n;i++)
    {
        if(n - i >= k - 1LL) {
          LL p = mod_inverse(fact[n - i - (k - 1)], mod);
          LL q = mod_inverse(fact[k - 1], mod);
          LL down = (p * q) % mod;
          down = (a[i] * down) % mod;
          ans = (ans + down * fact[n - i]) % mod;
          if(ans < 0) ans += mod;
        }
        if(i >= k) {
          LL p = mod_inverse(fact[i - 1 - (k - 1)], mod);
          LL q = mod_inverse(fact[k - 1], mod);
          LL down = (p * q) % mod;
          down = (a[i] * down) % mod;
          ans = (ans - down * fact[i - 1]) % mod;
          if(ans < 0) ans += mod;
        }
    }
    if(ans < 0) ans += mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  string a ="CODEFESTIVAL2016";
  string s;
  cin>>s;
  int res=0;
  rep(i,s.size()) if(s[i] != a[i]) res++;

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE],N;
bool larger(int v){
    if((a[N]>=v)==(a[N-1]>=v))return a[N]>=v;
    if((a[N]>=v)==(a[N+1]>=v))return a[N]>=v;
    int rr=N+1;
    while(rr<2*N-1&&(a[rr]>=v)!=(a[rr+1]>=v))rr++;
    int ll=N-1;
    while(ll>1&&(a[ll]>=v)!=(a[ll-1]>=v))ll--;
    if(ll==1&&rr==N-1)return (a[N]<v)^(N&1);
    if(N-ll<=rr-N)return a[ll]>=v;
    return a[rr]>=v;
}
int main(){
    RI(N);
    REPP(i,1,2*N)RI(a[i]);
    int ll=2,rr=2*N-2;
    while(ll<rr){
        int mm=(ll+rr+1)/2;
        if(larger(mm))ll=mm;
        else rr=mm-1;
    }
    printf("%d\n",ll);
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int D;
array<int, 26> C;
vector<array<int, 26>> S;
int main() {
    cin >> D;
    for (auto &c : C) cin >> c;
    S.resize(D);
    for (auto &row : S) for (auto &s : row) cin >> s;
    vector<int> T(D); for (auto &t : T) cin >> t, t--;
    vector<int> last(26);
    Int v = 0;
    for (int d = 0; d < D; d++) {
        v += S[d][T[d]];
        last[T[d]] = d + 1;
        for (int i = 0; i < 26; i++) {
            v -= C[i] * (d + 1 - last[i]);
        }
        cout << v << '\n';
    }
    return 0;
}


Measured memory_bytes: 3656
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

INF = 10 ** 10 + 7


def main():
    X, Y, Z, K = map(int, readline().split())
    A = sorted(list(map(int, readline().split())), reverse=True)
    B = sorted(list(map(int, readline().split())), reverse=True)
    C = sorted(list(map(int, readline().split())), reverse=True)

    ans = solve2(X, Y, Z, K, A, B, C)
    print('\n'.join(map(str, ans)))


def solve2(X, Y, Z, K, A, B, C):

    ABC = []
    for i in range(X):
        if (i + 1) > K:
            break
        for j in range(Y):
            if (i + 1) * (j + 1) > K:
                break
            for k in range(Z):
                if (i + 1) * (j + 1) * (k + 1) > K:
                    break
                else:
                    ABC.append(A[i] + B[j] + C[k])

    return sorted(ABC, reverse=True)[:K]


def solve1(X, Y, Z, K, A, B, C):

    AB = []
    for i in range(X):
        for j in range(Y):
            AB.append(A[i] + B[j])

    AB.sort(reverse=True)
    AB = AB[:min(X * Y, K)]

    ABC = []
    for i in range(len(AB)):
        for j in range(Z):
            ABC.append(AB[i] + C[j])

    ABC.sort(reverse=True)

    return ABC[:K]


if __name__ == '__main__':
    main()


Measured memory_bytes: 9532
while True:
    a,op,b=map(str,input().split())
    a=int(a)
    b=int(b)

    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(int(a/b))
    elif op=="?":
        break


Measured memory_bytes: 5596
N = int(input())
P = list(map(int,input().split()))

ans = 0
if True:
    for j in range(N):
        p = P[j]
        i = j + 1
        if p == i:
            if i != N:
                ans += 1
                P[j], P[j+1] = P[j+1], P[j]
            else:
                ans += 1
                P[j-1], P[j] = P[j], P[j-1]
print(ans)

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

using namespace std;

const int inf = (1 << 25);

int C, D, W, X;
int E[16][32], F[16][32];

int dp[32][64][8];

int solve(int d, int w, int x)
{
  if(w > W || x > X) return -inf;
  if(d == D) return 0;  
  if(~dp[d][w][x]) return dp[d][w][x];
  int ret = solve(d+1, w, x);
  for(int i = 0; i < C; i++){
    int le = 0, lf = 0, re = 0, rf = 0;
    for(int j = 0; j < C; j++){
      if(i - j >= 0 && le >= 0){
	le += E[i-j][d], lf += F[i-j][d];
	ret = max(ret, solve(d+1, w+lf, x+(j!=0)) + le);
      }
      if(i + j < C && re >= 0){
	re += E[i+j][d], rf += F[i+j][d];
	ret = max(ret, solve(d+1, w+rf, x+(j!=0)) + re);
      }
    }
  }
  return dp[d][w][x] = ret;
}

int main()
{
  while(cin >> C >> D >> W >> X, C || D || W || X){
    memset(E, 0, sizeof(E));
    memset(F, 0, sizeof(F));
    for(int i = 0; i < C; i++){
      for(int j = 0; j < D; j++) cin >> E[i][j], E[i][j] = (E[i][j] == 0 ? -inf : E[i][j]);
    }
    for(int i = 0; i < C; i++){
      for(int j = 0; j < D; j++) cin >> F[i][j], F[i][j] = (E[i][j] == -inf ? inf : F[i][j]);
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, A, B, K = map(int, input().split())
ans = 0
for i in range(N+1):
  m = K-A*i
  if m%B!=0:
    continue
  ans += cmb(N,i,mod)*cmb(N,m//B,mod)
  ans %= mod

print(ans)

Measured memory_bytes: 124100
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 2, 3]), 0)

    def test_2(self):
        self.assertEqual(think([1, 3, 1, 1]), 2)

    def test_3(self):
        self.assertEqual(think([27, 23, 76, 2, 3, 5, 62, 52]), 2)


def solve():
    w = read()
    result = think(w)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(w):
    s = sum(w)
    diff = 1e10
    accum = [0]
    for e in w:
        accum.append(accum[-1] + e)
    for i in range(len(accum)):
        diff = min(diff, abs(accum[i] - (s - accum[i])))
    return diff


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

pll E[55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    REP(i, M) {
        cin >> E[i].first >> E[i].second;
        E[i].first--;
        E[i].second--;
    }

    ll ans = 0;
    REP(i, M) {
        UnionFind uf(N);
        REP(j, M) {
            if (j == i)
                continue;
            uf.unit(E[j].first, E[j].second);
        }
        REP(j, N - 1) {
            if (uf.same(j, j + 1))
                continue;
            ans++;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N = 0, A, B, co = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> A >> B;
  
    co += B - A + 1;
  }
  cout << co << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int q;
    cin>>q;
    while(q--){
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        sort(a, a+3);
        if(pow(a[2], 2)==pow(a[1],2)+pow(a[0], 2))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int ks[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    --k;
    cout << ks[k] << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 384
S = input()

N = len(S)
A = [0] * N
start_r = 0
for i in range(1, N):
    if S[i - 1:i + 1] == 'RL':
        r = i - 1
        l = i
        A[i - 1] += 1
        A[i] += 1
        if start_r < r:
            d = r - start_r
            A[i - 1] += d // 2
            A[i] += d // 2 + d % 2
    elif S[i - 1:i + 1] == 'LR':
        start_r = i
    elif S[i - 1:i + 1] == 'LL':
        A[r + (i - l + 1) % 2] += 1
print(' '.join(list(map(str, A))))


Measured memory_bytes: 10484
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		if((a/c)>(b/d)){
			if(a%c==0)System.out.println(n-(a/c));
			else System.out.println(n-(a/c+1));
		}else{
			if(b%d==0)System.out.println(n-(b/d));
			else System.out.println(n-(b/d+1));
		}
	}
}

Measured memory_bytes: 17164
// https://atcoder.jp/contests/abc049/tasks/abc049_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "a" || s == "i" || s == "u" || s == "e" || s == "o") {
        cout << "vowel\n";
    } else {
        cout << "consonant\n";
    }
    return 0;
}


Measured memory_bytes: 256
import math
def combination(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N=int(input())
mem={}
for i in range(N):
    s=list(input())
    s.sort()
    s=''.join(s)
    if s in mem: mem[s]+=1
    else: mem[s]=0
    count=0
for i in mem.values():
    if i!=0: count += combination(i+1,2)
print(count)

Measured memory_bytes: 17932
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

for s in sys.stdin:
  d = map(float, s.split(","))
  dl,v1,v2 = d[:-2],d[-2],d[-1]
  L = sum(dl)
  x = L/(1+v2/v1)
  m = 0
  for i in range(len(dl)):
    m += dl[i]
    if m >= x: print i+1; break

Measured memory_bytes: 4220
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, k, c, interval = 0, interval2 = 0;
string s;
vector<ll> cntL, cntR;

int main() {
	cin >> n >> k >> c;
	cin >> s;
	auto cnt = [&]() {
		vector<ll> res;
		ll interval = 0;
		rep(i, n) {
			if ((s[i] != 'x' && interval > c) || i == 0) {
				res.pub(i);
				interval = 0;
			}
			interval++;
		}
		return res;
	};
	/*rep(i, n) {
		interval++;
		if (s[i] == 'o' && (interval > c || i == 0)) {
			cntL.pub(i);
			interval = 0;
		}
		interval2++;
		if (s[n - i - 1] == 'o' && (interval2 > c || i == 0)) {
			cntR.pub(n - i - 1);
			interval2 = 0;
		}
	}*/
	cntL = cnt();
	reverse(s.begin(), s.end());
	cntR = cnt();
	rep(i, k) {
		if (cntL[i] == n - cntR[k - i - 1] - 1)cout << cntL[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5108
#include<iostream>
#include<vector>
#include<set>
#include<utility>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<cinttypes>
#include<stack>
using namespace std;

typedef long long ll;


#define ceil(a,b)  ( !(a%b) ? a/b : a/b+1 )
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define endl '\n' 
#define debug(a) cin>>#a>>a;
//vector<ll> primes{ }

int gcd( int a, int b ) { return !a ? b : gcd( b%a, a); }
int lcm( int a, int b ) { return (a*b)/gcd(a,b); } 

int main(){
    int a,b;
    cin>>a>>b;
    vector<vector<char>> v(a+2,vector<char>(b+2));
    for( int i=0; i<a+2; i++ ){
        for( int j=0; j<b+2; j++ ){
            if( i==0 || j==0 || i==a+1 || j == b+1){
                v[i][j] = '#';
            } 
        }
    }
    char c[a][b];
    for( int i=0; i<a; i++ ){
        for( int j=0; j<b; j++ ){
            cin>>c[i][j];
        }
    }
    for( int i=0; i<a+2; i++ ){
        for( int j=0; j<b+2; j++ ){
            if( i==0 || j==0 || i==a+1 || j == b+1){
                continue;
            }
            v[i][j] = c[i-1][j-1];
        }
    }
    for( int i=0; i<a+2; i++ ){
        for( int j=0; j<b+2; j++ ){
            cout<<v[i][j];
            if( j==b+1 )
                cout<<endl;
        }
    }
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Map;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long n = Long.parseLong(br.readLine());

		ArrayList<Long> list = divisor(n);

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < list.size(); i += 2) {
			long a = 0;
			long b = 0;
			if (i == list.size() - 1) {
				a = list.get(i);
				b = list.get(i);
			} else {
				a = list.get(i);
				b = list.get(i + 1);
			}

			String A = String.valueOf(a);
			String B = String.valueOf(b);

			int max = Math.max(A.length(), B.length());

			ans = Math.min(ans, max);
		}

		System.out.println(ans);
	}

	public static final ArrayList<Long> divisor(final long n) {
		final ArrayList<Long> list = new ArrayList<>();

		for (long i = 1; i * i <= n; i++) { // √n
			if (n % i == 0) {
				list.add(i); // a x b
				if (i != n / i) {
					list.add(n / i); // b x a (逆向き)
				}
			}
		}
		return list;
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    int n; cin >> n;
    if(n == 1) cout << "Hello World" << endl;
    else {
        int a,b; cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N,K;
    N = sc.nextInt();
    K = sc.nextInt();
    int ans = 1000000007;
    int tmp;
    Integer x[] = new Integer[N];
    for(int i=0; i<N; i++) x[i] = sc.nextInt();
    for(int i=0; i<N-K+1; i++){
      if((x[i] <= 0 && x[i+K-1] > 0) || (x[i] >= 0 && x[i+K-1] < 0)){
        int a = Math.abs(x[i]);
        int b = Math.abs(x[i+K-1]);
        tmp = Math.max(a,b) + Math.min(a,b) * 2;
      }else{
        if(x[i] <= 0) tmp = Math.abs(x[i]);
        else tmp = x[i+K-1];
      }
      ans = Math.min(ans, tmp);
    }
    System.out.println(ans);
  }
  
  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  ll l,r;
  cin >> l >> r;
  rep(i,n-1){
    ll t,a;cin >> t >> a;
    ll aa = (l+t-1)/t,bb = (r+a-1)/a;
    l = max(aa,bb)*t,r = max(aa,bb)*a;
  }
  cout << l + r << "\n";
  



  return 0;
}

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

#define rep(i, n)     rep2(i, 0, n)
#define rep2(i, m, n) for (int i = (m); i < (int)(n); ++i)

int w, h;
int slx, sly, srx, sry;
int glx, gly, grx, gry;
bool visit[50][50][50][50];
string L[50], R[50];

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

struct C { int lx, ly, rx, ry; };

void bfs(int lx, int ly, int rx, int ry)
{
    queue<C> que;
    que.push((C){ lx, ly, rx, ry });
    visit[lx][ly][rx][ry] = true;
    
    while (!que.empty()) {
        C cur = que.front(); que.pop();
        
        rep(i, 4) {
            lx = cur.lx + dx[i];
            ly = cur.ly + dy[i];
            rx = cur.rx - dx[i];
            ry = cur.ry + dy[i];
            if (lx < 0 || w <= lx) lx = cur.lx;
            if (ly < 0 || h <= ly) ly = cur.ly;
            if (rx < 0 || w <= rx) rx = cur.rx;
            if (ry < 0 || h <= ry) ry = cur.ry;
            if (L[ly][lx] == '#') lx = cur.lx, ly = cur.ly;
            if (R[ry][rx] == '#') rx = cur.rx, ry = cur.ry;
            if (visit[lx][ly][rx][ry]) continue;
            
            if ((lx == glx && ly == gly && (rx != grx || ry != gry))
             || (rx == grx && ry == gry && (lx != glx || ly != gly)))
                continue;
            
            que.push((C){ lx, ly, rx, ry });
            visit[lx][ly][rx][ry] = true;
        }
    }
}

int main()
{
    while (cin >> w >> h, w && h) {
        rep(i, h) cin >> L[i] >> R[i];
        
        rep(i, h) rep(j, w) {
            if (L[i][j] == 'L') sly = i, slx = j;
            if (R[i][j] == 'R') sry = i, srx = j;
            if (L[i][j] == '%') gly = i, glx = j;
            if (R[i][j] == '%') gry = i, grx = j;
        }
        
        fill_n(***visit, 50*50*50*50, false);
        bfs(slx, sly, srx, sry);
        
        cout << (visit[glx][gly][grx][gry] ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 8256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;
vll v;


int main()
{

//     ios::sync_with_stdio(0);
//	cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll ar[n+10];
    for(ll i=1; i<=n; i++)
    {
        cin>>ar[i];
    }
    map<ll,ll>mp;
   // mp[1]=1;
    ll st,pk=1;
    for(ll i=1; ; i++)
    {
       pk= ar[pk];
       if(mp[pk]==0)
       {
          mp[pk]=1;
          v.pb(pk);
       }
       else
       {
           st=pk;
           break;
       }
    }

    vll rep;
    ll f=0,df=0;
    for(ll i=0;i<zz(v);i++)
    {
        if(v[i]==st)
        {
            f=1;
        }
        if(f)
        {
            rep.pb(v[i]);

        }
        else df++;
    }

   // cout<<st<<nn;

    if(k<=df) cout<<v[k-1]<<nn;
    else
    {
        ll md=(k-df)%zz(rep);
        ll sz=zz(rep);
        if(md==0) cout<<rep[sz-1]<<nn;
        else cout<<rep[md-1]<<nn;
    }

 // for(ll i=0;i<zz(rep);i++) cout<<rep[i]<<ss;




}




Measured memory_bytes: 20512
#import<bits/stdc++.h>
#import<atcoder/all>
using namespace std;
int I=1e9,N,K,a;
int main(){
  cin>>N>>K;int s=2*N,t=s+1;
  atcoder::mcf_graph<int,long long>G(2*N+2);
  G.add_edge(s,t,N*K,I);
  for(int i=0;i<N;i++){
    G.add_edge(s,i,K,0),G.add_edge(N+i,t,K,0);
    for(int j=0;j<N;j++)cin>>a,G.add_edge(i,N+j,1,I-a);
  }
  cout<<1LL*N*K*I-G.flow(s,t,N*K).second<<'\n';
  vector<string>A(N,string(N,'.'));
  for(auto e:G.edges())if(e.from!=s&&e.to!=t&&e.flow)A[e.from][e.to-N]='X';
  for(string S:A)cout<<S<<'\n';
}

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

map<char, int>mp;
void calc(int&a, int b, char op) {
	if (op == '+')a += b;
	else if (op == '-')a -= b;
	else if (op == '*')a *= b;
}
int num(string&s, int&i) {
	int n = 0;
	while (isdigit(s[i]))n = n * 10 + s[i++] - '0';
	return n;
}
int o1(string&, int&);
int o4(string&s, int&i) {
	if (isdigit(s[i]))return num(s, i);
	i++;
	int ret = o1(s, i);
	i++;
	return ret;
}
int o3(string&s, int&i) {
	int v = o4(s, i);
	while (mp[s[i]] == 3) {
		char op = s[i]; i++;
		int v2 = o4(s, i);
		calc(v, v2, op);
	}
	return v;
}
int o2(string&s, int&i) {
	int v = o3(s, i);
	while (mp[s[i]] == 2) {
		char op = s[i]; i++;
		int v2 = o3(s, i);
		calc(v, v2, op);
	}
	return v;
}
int o1(string&s, int&i) {
	int v = o2(s, i);
	while (mp[s[i]] == 1) {
		char op = s[i]; i++;
		int v2 = o2(s, i);
		calc(v, v2, op);
	}
	return v;
}
signed main() {
	string s; cin >> s;
	int Max = LLONG_MIN;
	rep(i, 3)rep(j, 3)rep(k, 3) {
		mp['+'] = i + 1; mp['-'] = j + 1; mp['*'] = k + 1;
		int l = 0; Max = max(Max, o1(s, l));
	}
	printf("%lld\n", Max);
}

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


const int N = 500;
int v[N];

int main(){
	int n;

	bool flag = true;
	cin >> n;
	for(int i=0; i < n; i++) cin >> v[i];
	
	for(int i=0; i < n; i++){
		if(v[i]%2 == 0 && v[i]%3 != 0 && v[i]%5 !=0) flag = false;
	}


	if(flag) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int[] v = new int[k.length];
		for (int i = 0; i < v.length; i++) {
			v[i] = Integer.parseInt(k[i]);
		}
		int count = 0;
		for (int i = v[0]; i <= v[1]; i++) {
			if (v[2] % i == 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}

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

int main(){
	int a,b,c;
	int x=0;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		x=3;
	}
	else if (a==b)
	{
		x=2;
	}
	else if(a==c){
		x=2;
	}
	else if(b==c){
		x=2;
	}
	
	if(x==2){
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll a[3][3];
   
   ll i,j;
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)cin>>a[i][j];
   }
   ll n;
   cin>>n;
   mll m;
   for(i=0;i<n;i++)
   {
       ll x;
       cin>>x;
       m[x]++;
   }
   ll b[3][3];
   clr(b);
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
       {
           if(m[a[i][j]]>0)
           {
               b[i][j]=1;
           }
       }
   }
   ll f=0;
   for(i=0;i<3;i++)
   {
      ll ff=0;
      for(j=0;j<3;j++)
      {
         if(b[i][j]==0)
         {
             ff=1;
         }
      }

      if(!ff)
      {
          f=1;
      }
      ff=0;
        for(j=0;j<3;j++)
      {
         if(b[j][i]==0)
         {
             ff=1;
             break;
         }
      }
      if(!ff)
      {
          f=1;
      }
   }

   if(b[0][0]==1&&b[1][1]&&b[2][2])
   {
       f=1;
   }
   if(b[2][0]&&b[1][1]&&b[0][2])
   {
       f=1;
   }
   if(f)
   {
       cout<<"Yes\n";
       return;
   }
   cout<<"No\n";
   


}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

int main() {
  string o,e;
  cin>>o>>e;
  frn(i,e.size()) {
    cout<<o[i]<<e[i];
  }
  if(o.size() > e.size()) cout<<o[o.size()-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;

	cout << input.front() << input.size() - 2 << input.back() << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long S = in.nextLong();
            long x1 = 0, y1 = 0, x2 = 0, y2 = 0;
            x1 = y2 = (long) Math.ceil(Math.sqrt(S));
            y1 = (x1 * y2) - S;
            x2 = 1;
            out.println("0 0 " + x1 + " " + y1 + " " + x2 + " " + y2);
        }

    }
}



Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#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()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n>k){
        cout << k*x+(n-k)*y << ENDL;
    }else{
        cout << n*x << ENDL;
    }
    
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	long long int V, E;
	cin >> V >> E;
	
	long long int cost[V][V];
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			cost[i][j] = INF;
		}
	}
	
	for(int i = 0; i < E; i++){
		int u, v, c;
		cin >> u >> v >> c;
		cost[u][v] = c;
	}
	
	long long int DP[V][(1 << V)];
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < (1 << V); j++){
			DP[i][j] = INF;
		}
	}
	DP[0][0] = 0;
	
	for(int i = 0; i < (1 << V); i++){
		for(int j = 0; j < V; j++){
			if(i & (1 << j)){
				int hoge = i - (1 << j);
				for(int k = 0; k < V; k++){
					DP[j][i] = min(DP[j][i], DP[k][hoge] + cost[k][j]);
				}
			}
			//cout << DP[j][i] << " ";
		}
		//cout << endl;
	}
	
	if(DP[0][(1 << V) - 1] == INF){
		cout << -1 << endl;
	}else{
		cout << DP[0][(1 << V) - 1] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 6932
N,K=map(int,input().split())
S=list(input())
j=0
ans=0
cnt=0
for i in range(N):
  if S[i]=="0":
    if i==0 or S[i-1]=="1":
      cnt+=1
  if cnt>K:
    while S[j]=="1":
      j+=1
    while S[j]=="0":
      j+=1
    cnt-=1
  ans=max(ans,i-j+1)

print(ans)

Measured memory_bytes: 4084