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

int i = 0;

int collatz(int x){
    
    if(x == 4 || x == 1 || x == 2){
        return 0;
    }
    
    if(x % 2 == 0){
        i++;
        collatz(x/2);
    }
    else if(x % 2 != 0){
        i++;
        collatz(3*x+1);
    }
    return i;
}

int main(){
    int s; cin >> s;
    cout << collatz(s) + 4;
}

Measured memory_bytes: 256
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)
		
def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n): 
      
    # Create a boolean array "prime[0..n]" and initialize 
    #  all entries it as true. A value in prime[i] will 
    # finally be false if i is Not a prime, else true. 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
          
        # If prime[p] is not changed, then it is a prime 
        if (prime[p] == True): 
              
            # Update all multiples of p 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    return prime
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout 
if __name__ == '__main__':
	n=int(stdin.readline())
	l=list(map(int,stdin.readline().split(" ")))
	l1=[]
	for i in range(n+1):
		l1.append(0)
	for i in range(len(l)):
		l1[l[i]]=l1[l[i]]+1
	
	for i in range(1,n+1):
		stdout.write(str(l1[i])+"\n")

Measured memory_bytes: 33588
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main() {
  long double a,b;
  in a>>b;


  cout<<(long long)(a*b)<<endl;
  return 0;
}


Measured memory_bytes: 3736
#include <cmath>
#include <iomanip>
#include <iostream>
#include <utility>

using namespace std;

#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
  double x, y;
  Point() {};
  Point(double x, double y): x(x), y(y) {}

  Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
  Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
  Point operator * (double d) { return Point(d * x, d * y); }
  Point operator / (double d) { return Point(x / d, y / d); }

  bool operator < (const Point &p) const {
    return (x == p.x ? y < p.y : x < p.x);
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

  friend ostream& operator << (ostream &os, Point &p) {
    return os << "Point(" << p.x << ", " << p.y << ")";
  }
};

class Circle {
public:
  Point c;
  double r;
  Circle() {}
  Circle(double x, double y, double r): c(x, y), r(r) {}
};

typedef Point Vector;

double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

double abs(Point p) {
  return sqrt(norm(p));
}

double atanned(Point p) {
  return atan2(p.y, p.x);
}

Vector vec(double r, double deg) {
  return Vector(r * cos(deg), r * sin(deg));
}

int main() {
  Circle cs[2];

  for (int i = 0; i < 2; i++) {
    double x, y, r; cin >> x >> y >> r;
    cs[i] = Circle(x, y, r);
  }

  double d = abs(cs[1].c - cs[0].c);
  double a = acos((cs[0].r * cs[0].r + d * d - cs[1].r * cs[1].r) / (2 * cs[0].r * d));
  double t = atanned(cs[1].c - cs[0].c);

  Point p1 = (cs[0].c + vec(cs[0].r, t + a));
  Point p2 = (cs[0].c + vec(cs[0].r, t - a));

  if (p1.x < p2.x || (p1.x == p2.x && p1.y <= p1.x))
    cout << fixed << setprecision(10) << p1.x << ' ' << p1.y << ' ' << p2.x << ' ' << p2.y << endl;
  else
    cout << fixed << setprecision(10) << p2.x << ' ' << p2.y << ' ' << p1.x << ' ' << p1.y << endl;
}

Measured memory_bytes: 1332
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True

def naive(b,k):
    a=b*k
    n=len(a)
    
    p=a[0]
    t=0
    for i in range(n-1):
        if p==a[i+1]:
            t+=1
            p=-1
        else:
            p=a[i+1]
            
    return t


b=StoI()
a=b
k=I()
n=len(a)
p=a[0]
t=0

if len(b)*k<10:
    print(naive(b,k))
    exit()


for i in range(n-1):
    if p==a[i+1]:
        t+=1
        p=-1
    else:
        p=a[i+1]

odd=naive(b,3)-naive(b,1)
even=naive(b,4)-naive(b,2)
if k%2==1:
    ans=naive(b,1)+(k//2)*odd
else:


    ans=naive(b,2)+(k//2)*even-even
print(ans)


Measured memory_bytes: 38768
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
function main(chunk){
    var arr = chunk.split("\n");
    for(var n=0;n<arr.length-1;n++){
        var a = Number(arr[n].split(" ")[0]);
        var b = Number(arr[n].split(" ")[1]);
        for(var i=0;i<a;i++){
            var str = "";
            for(var j=0;j<b;j++){
                str += "#";
            }
            console.log(str);
        }
        console.log("");
    }
}

Measured memory_bytes: 17576
#include <cstdio>
#include <algorithm> 

typedef long long int lli;

int main()
{
	lli N, move[5], ans=0;
	scanf("%lld", &N);
	for(int i=0; i<5; i++){
		scanf("%lld", &move[i]);
	}
	std::sort(move, move+5);
	ans = N/move[0] + 4;
	if(N%move[0]!=0){
		ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

    string s, t;
    cin >> s >> t;
    
    int n = s.size();
    int m = t.size();
    int t_idx = -1;
    for(int i = 0; i < n-m+1; ++i){
        bool flg = true;
        for(int j = 0; j < m; ++j){
            if(s[i+j]!='?' && s[i+j] != t[j]) flg = false;
        }

        if(flg) t_idx = i;
    }

    if(t_idx == -1) cout << "UNRESTORABLE" << endl;
    else{
        for(int i = 0; i < t_idx; ++i){
            if(s[i] == '?') cout << 'a';
            else cout << s[i];
        }
        cout << t;
        for(int i = t_idx+m; i < n; ++i){
            if(s[i] == '?') cout << 'a';
            else cout << s[i];
        }
        cout << endl;
    }
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e15;
const int off = 1e9;

struct E {
    int to, rev; ll cap;
    E(int to, ll cap, int rev) : to(to), cap(cap), rev(rev) {}
};
const int MN = 110;
int m, n, sv, tv;
vector<E> g[MN];
int dist[MN], iter[MN];

void add_edge(int a, int b, ll c) {
    g[a].push_back(E(b, c, int(g[b].size())));
    g[b].push_back(E(a, 0, int(g[a].size())-1));
}

ll dfs(int v, ll f) {
    if (v == tv) return f;
    for (int &i = iter[v]; i < int(g[v].size()); i++) {
        E &e = g[v][i];
        if (!e.cap || dist[e.to] <= dist[v]) continue;
        ll d = dfs(e.to, min<ll>(f, e.cap));
        if (!d) continue;
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
    }
    return 0;
}

ll MF() {
    ll flow = 0;
    while (true) {
        fill(dist, dist + n, -1);
        dist[sv] = 0;
        queue<int> que;
        que.push(sv);
        while (que.size()) {
            int v = que.front(); que.pop();
            for (int i = 0; i < int(g[v].size()); i++) {
                E &e = g[v][i];
                if (!e.cap || dist[e.to] != -1) continue;
                dist[e.to] = dist[v] + 1;
                que.push(e.to);
            }
        }
        if (dist[tv] == -1) break;
        
        fill(iter, iter + n, 0);
        while (true) {
            ll d = dfs(sv, INF);
            if (!d) break;
            flow += d;
        }
    }
    return flow;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> m;
    n = m+3;
    sv = n-2;
    tv = n-1;
    
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        add_edge(sv, i, off - x);
        add_edge(i, tv, off);
    }
    for (int i = 1; i <= m; i++) {
        for (int j = i+i; j <= m; j += i) {
            add_edge(i, j, INF);
        }
    }
    cout << -MF() + ll(m) * off << endl;
    return 0;
}

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

using namespace std;

int main(){

	int a, b, c, d, ta, ao;

	cin >> a >> b >> c >> d;

	ta = (c+b-1) / b;
	ao = (a+d-1) / d;

	if(ta<=ao) cout<< "Yes" << endl;
	else cout<< "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int nmax=100005;
const int INF=2e9;
struct edge{int to;int cost;};
vector<edge> tree[nmax];
vector<int> d(nmax,-INF);
bool f;
void bfs(int s){
  queue<int> q;
  q.push(s);
  d[s]=0;
  while(!q.empty()){
    int p=q.front();
    q.pop();
    for(auto x:tree[p]){
      int u=x.to,v=x.cost;
      if(d[u]==-INF){
        d[u]=d[p]+v;
        q.push(u);
      }
      else{
        if(d[u]!=d[p]+v){
          f=false;
        }
      }
    }
  }
}
int main(){
  int n,m;cin >> n >> m;
  for(int i=0;i<m;i++){
    int l,r,d;cin >> l >> r >> d;
    l--,r--;
    tree[l].push_back({r,d});
    tree[r].push_back({l,-d});
  }
  f=true;
  for(int i=0;i<n;i++){
    if(d[i]!=-INF){
      continue;
    }
    bfs(i);
    if(!f){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 9344
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
void dfs(string s,int cnt,char c){
  if(cnt==n){
    cout << s << endl;
    return;
  }
  for(int i=0;i<c-'a'+2;i++){
    char x=i+'a';
    dfs(s+x,cnt+1,max(c,x));
  }
}
int main(){
  cin >> n;
  string s="a";
  dfs(s,1,'a');
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string N; 
  cin >> N;
  
  int x = 0;
  for(char c : N){
    x += (c - '0');
  }
  
  x %= 9;
  
  if(x == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

class UnionFind {
private:
    vector<ll> data;
    vector<ll> tree_size;

public:
    UnionFind(ll n) {
        data = vector<ll>(n);
        tree_size = vector<ll>(n, 1);
        for (ll i = 0; i < n; ++i)
            data[i] = i;
        
    }

    ll root(ll a) {
        if (data[a] == a) return a;
        else return data[a] = root(data[a]);
    }

    void unite(ll a, ll b) {
        ll root_a = root(a);
        ll root_b = root(b);
        if (root_a == root_b)
            return;
        else {
            tree_size[root_b] += tree_size[root_a];
            tree_size[root_a] = 0;
            data[root_a] = root_b;
            return;
        }
        return;
    }
    ll get_tree_size(ll a)
    {
        return tree_size[root(a)];
    }
};

int main() {
    
    long N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    
    UnionFind uf = UnionFind(N);
    for(size_t i=0;i<M; i++)
    {
        cin >> A[i] >> B[i];
        uf.unite(A[i]-1, B[i]-1);
    }
    ll max_size=0;
    for(size_t i=0;i<N; i++)
        max_size = max(max_size, ll(uf.get_tree_size(i)));

    
    cout << max_size << endl;

    return 0;
}


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

int n, a, b, x[1 << 17];

void go(int i, int n, int b){
	if(n == 1){
		x[i] = 0;
		return;
	}
	
	int j = n - 1;
	while((b & (1 << j)) == 0)j--;
	
	b -= 1 << j;
	b += 1 << (n - 1);
	
	int m = (1 << (n - 1)) - 1;
	if(b == (1 << (n - 1))){
		go(i, n - 1, 1);
		x[i + m] = n - 1;
		go(i + m + 1, n - 1, 1);
	}else{
		int c = 1, b0 = 0, b1 = 0;
		for(int i = n - 2; i >= 0; i--)if(b & (1 << i)){
			if(c == 1){
				b0 += 1 << i;
				c = 0;
			}else{
				b1 += 1 << i;
			}
		}
		
		go(i, n - 1, b0);
		x[i + m] = n - 1;
		go(i + m + 1, n - 1, b1);
	}
	
	for(int k = i; k < i + (1 << n) - 1; k++){
		if(x[k] == n - 1)x[k] = j;
		else if(x[k] == j)x[k] = n - 1;
	}
}

int main(){
	scanf("%d %d %d", &n, &a, &b);
	b ^= a;
	
	int c = 0;
	for(int i = 0; i < n; i++)
		if(b & (1 << i))c ^= 1;
		
	if(c == 0){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	
	go(0, n, b);
	
	int cur = 0;
	for(int i = 0; i < (1 << n); i++){
		if(i > 0)printf(" ");
		printf("%d", cur ^ a);
		
		if(i + 1 < (1 << n))cur ^= 1 << x[i];
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 4288
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int[] x = new int[3]; x[0] = scan.nextInt(); x[1] = scan.nextInt(); x[2] = scan.nextInt(); java.util.Arrays.sort(x); System.out.println(x[0]+" "+x[1]+" "+x[2]); } } 


Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long 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;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
  	if(n==k){
      return 1;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// vector<vector<int>> A(3, vector<int>(4));
int main() {
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>>A(M);
    vector<bool>a(300000);
    vector<bool>b(300000);
    bool ans=false;
    rep(i,M){
        cin>>A[i].first;
        cin>>A[i].second;
        if(A[i].first==1||A[i].second==1){
            a[max(A[i].first,A[i].second)]=true;
        }
        else if(A[i].first==N||A[i].second==N){
            b[min(A[i].first,A[i].second)]=true;
        }
    }
    rep(i,300000){
        if(a[i]==true&&b[i]==true){
            ans=true;
            break;
        }
    }
    if(ans==true){
        cout<<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}








Measured memory_bytes: 4764
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def is_all(list_s, c):
	for cs in list_s:
		if cs != c:
			return False
	return True

def dd(s, c):
	t=list(s)
	p=0
	while not is_all(t, c):
		nt=['']*(len(t)-1)
		for i, _ in enumerate(nt):
			if t[i]==c or t[i+1]==c:
				nt[i]=c
			else:
				nt[i]=t[i]
		t=nt
		p+=1
	return p
	
	

def main():
	#a = int(input())
	#b , c = tin()
	s = input()
	ret = mod
	for c in list(set(list(s))):
		#pa(c)
		r = dd(s, c)
		ret = min(ret, r)
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 41068
while True:
    a,op,b=input().split()
    if op=="?":
        break
    else:
        a=int(a)
        b=int(b)
        if op=="+":
            print(a+b)
        elif op=="-":
            print(a-b)
        elif op=="*":
            print(a*b)
        else:
            print(a//b)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
template<typename ll_t,ll_t mod>
class basic_modint{
public:
    ll_t x_;
    basic_modint(ll_t x=0):x_((x%mod+mod)%mod){}
    basic_modint& operator+=(const basic_modint a)       { if((x_+=     a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator-=(const basic_modint a)       { if((x_+= mod-a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator*=(const basic_modint a)       { (x_*=a.x_)%=mod; return *this; }
    basic_modint  operator+ (const basic_modint a) const { basic_modint res(*this); return res+=a; }
    basic_modint  operator- (const basic_modint a) const { basic_modint res(*this); return res-=a; }
    basic_modint  operator* (const basic_modint a) const { basic_modint res(*this); return res*=a; }
    basic_modint  pow(ll_t t) const { if(t==0)return 1; basic_modint a = pow(t>>1); a*=a; if(t%2==1)a*=(*this); return a; }
    basic_modint  inv() const { return pow(mod-2); }
    basic_modint& operator/=(const basic_modint a)       { return (*this) *= a.inv(); }
    basic_modint  operator/ (const basic_modint a) const { basic_modint res(*this); return res/=a; }
    friend istream& operator>>(istream& ist, basic_modint& a) { ist>>a.x_; return ist; }
    friend ostream& operator<<(ostream& ost, basic_modint& a) { ost<<a.x_; return ost; }
    bool operator==(const basic_modint a){return x_==a.x_; }
    bool operator!=(const basic_modint a){return x_!=a.x_; }
};
using mint = basic_modint<ll,998244353>;
int main(){
    int n;
    ll a,b,k;
    cin >> n >> a >> b >> k;
    vector<mint> ncr(n+1);
    ncr[0]=1;
    rep(i,n)ncr[i+1]=ncr[i]*((mint)(n-i))/((mint)(i+1));
    //ax+by=kを満たすx,y\in[0,n]を列挙
    mint ans=0;
    for(ll x=0;x<=n;++x){
        ll y=(k-a*x)/b;
        if(y>n||y<0)continue;
        if(a*x+b*y==k){
            ans+=ncr[x]*ncr[y];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
      ll m,n,i,j;
      string s,t;
      cin>>s;
      cin>>t;
      m=s.length();
      n=t.length();
      ll x[m+2][n+3];
      vector<char>v;
      for(i=0;i<=m;i++)
      {
            for(j=0;j<=n;j++)
            {
                  if(i==0 || j==0){
                        x[i][j]=0;
                  }
                  else if(s[i-1]==t[j-1]){
                        x[i][j]=x[i-1][j-1]+1;
                      //  v.push_back(s[i]);
                  }
                  else{
                        x[i][j]=max(x[i-1][j],x[i][j-1]);
                  }
            }
      }
      i=m;j=n;
      while(i>0 && j>0){
            if(s[i-1]==t[j-1]){
                  v.push_back(s[i-1]);i--;j--;
            }
            else if(x[i-1][j]>x[i][j-1]){
                  i--;
            }
            else{
                  j--;
            }
      }
     // cout<<x[m][n]<<"\n";
      for(i=v.size()-1;i>=0;i--){
            cout<<v[i];
      }
      cout<<"\n";
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b<<" "<<a*2+b*2<<endl;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
using namespace std;

int n;
string s;

int main()
{
	cin >> n >> s;
	for (auto c : s)
	{
		int k = c - 'A';
		k += n;
		k %= 26;
		cout << (char)('A' + k);
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;


class Topological_Sort {
private:
	int n;
	vvi G;
	vi visited;
public:
	deque<int> ret;
	Topological_Sort(vvi A) {
		G = A;
		n = G.size();
		visited.resize(n);
		fill(visited.begin(), visited.end(), 0);
		mainf();
	}
	void mainf() {
		Loop(i, n) {
			if (visited[i] == 0) dfs(i);
		}
	}
	bool dfs(int a) {
		if (visited[a] == 1) {
			ret.clear();
			return -1;
		}
		else if (visited[a] == 0) {
			visited[a] = 1;
			Loop(j, G[a].size()) {
				if (dfs(G[a][j])) return -1;
			}
			visited[a] = 2;
			ret.push_front(a);
		}
		return 0;
	}
};

int main() {
	int n, m; cin >> n >> m;
	vvi A(n);
	Loop(i, m) {
		int s, t; cin >> s >> t;
		A[s].push_back(t);
	}
	Topological_Sort ts(A);
	Loop(i, ts.ret.size()) {
		cout << ts.ret[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int N, Y; cin >> N >> Y;
    int a = -1; int b = -1; int c = -1;
    for (int i = 0; i <= N; i++) {
        if (10000 * i > Y) break;
        for (int j = 0; j <= N - i; j++) {
            if (10000 * i + 5000 * j > Y) break;
            int k = N - (i + j);
            if (10000 * i + 5000 * j + 1000 * k == Y) {
                a = i;
                b = j;
                c = k;
                goto OUT;
            }
        }
    }

    OUT:
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
// RAM RAM
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	


    int x;cin>>x;
    int temp=x/11;
    int c=0;
    int rem=x%11;
    if(rem<7 && rem!=0){
    	c++;
    }else if(rem!=0){
    	c+=2;
    }
    cout<<2*temp + c<<endl;
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, Q;
    cin >> N >> Q;
    vector<unsigned long> sgtate(2 * N - 4, N - 2), sgyoko(2 * N - 4, N - 2);
    const auto& get = [&N](const auto& sgt, unsigned long x) -> unsigned long {
        unsigned long ret{N - 2};
        unsigned long L{x + N - 2}, R{2 * N - 4};
        while(L < R){
            if(L & 1){
                ret = min(sgt[L], ret);
                ++L;
            }
            if(R & 1){
                --R;
                ret = min(sgt[R], ret);
            }
            L >>= 1;
            R >>= 1;
        }
        return ret;
    };
    const auto& set = [&N](auto& sgt, unsigned long idx, unsigned long val){
        idx += N - 2;
        while(idx){
            sgt[idx] = min(val, sgt[idx]);
            idx >>= 1;
        }
    };
    const auto& put = [&get, &set, &sgtate, &sgyoko](const auto& sg1, auto& sg2, unsigned long x) -> unsigned long {
        unsigned long y{get(sg1, x)};
        if(y)set(sg2, y - 1, x);
        return y;
    };
    unsigned long ans{(N - 2) * (N - 2)};
    for(unsigned long i{0}, t, x; i < Q; ++i){
        cin >> t >> x;
        ans -= put(t == 1 ? sgtate : sgyoko, t == 1 ? sgyoko : sgtate, x - 2);
    }
    cout << ans << endl;
}


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

vector <int> path[8];
int ans;

int dfs(int n,bool past[],int now)
{
	bool flag=true;
	bool past2[8];
	for(int i=0;i<n;i++)
	{
		past2[i]=past[i];
	}
	past2[now]=true;

	//新しく経路探索
	for(int i=0;i<path[now].size();i++)
	{
		if(past2[path[now][i]]==false)
		{
			ans += dfs(n,past2,path[now][i]);
		}
	}

	//全頂点を訪れたかどうか（終了判定）
	for(int i=0;i<n;i++)
	{
		if(past2[i]==false)
		{
			flag=false;
			break;
		}
	}
	if(flag==true)
	{
		return 1;
	}else{
		return 0;
	}
}

int main()
{
	int n,m,a,b;
	ans = 0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		path[a-1].push_back(b-1);
		path[b-1].push_back(a-1);
	}
	bool past[8];//過去に訪れた頂点を記録
	for(int i=0;i<8;i++)
	{
		past[i]=false;
	}

	ans += dfs(n,past,0); //頂点1を始点として全頂点を訪れるルートを深さ優先探索
	cout<<ans<<endl;
	return 0;
}

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

def even(n):
    return n/2

def odd(n):
    return 3*n+1

flag=True
num=[s]

i=1
while flag:
    if s%2 ==0:
        s=even(s)
        if s in num:
            print(i+1)
            flag=False
        else:
            num.append(s)
            i+=1
    else:
        s=odd(s)
        if s in num:
            print(i+1)
            flag=False
        else:
            num.append(s)
            i+=1

Measured memory_bytes: 3064
H,W = map(int,input().split())
A = [input() for i in range(H)]

l = 1
x = 0
for i in range(H):
    while x<W-1 and A[i][x+1] == '#':
        x += 1
        l += 1
    if i+1<H and A[i+1][x] == '.':
        print('Impossible')
        exit()
    elif i+1<H:
        l += 1

c = sum(row.count('#') for row in A)
print('Possible' if c==l else 'Impossible')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll ten[10];

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

  ten[0] = 1;

  rep( i, 6 )
    ten[i+1] = ten[i]*10;

  ll ans = 0;

  repi( i, 1, 6 ) {
    if( i%2 == 0 )
      continue;

    ll lb = ten[i-1];
    ll ub = ten[i]-1;

    if( N < lb )
      continue;

    chmin( ub, N );

    ans += ub-lb+1;
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    while (cin >> s) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '@') {
                for (int j = 0; j < s[i + 1] - '0'; j++) {
                    cout << s[i + 2];
                }
                i += 2;
            }
            else {
                cout << s[i];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1172
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0;i<n;i++){
      a[i] = sc.nextLong();
    }
    long total = 0l;
    long now = 0l;
    for(int i = 0;i<n;i++){
      if(now <= a[i]){
        now = a[i];
      }else{
        total += now - a[i];
      }
    }
    System.out.println(total);
  }
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, k, r, a[100100];
vector<int> e[100100];

int dfs(int i = 0) {
  int d = 0;
  for (int j : e[i])
    d = max(d, dfs(j) + 1);
  if (d + 1 >= k) {
    r += a[i] != 0;
    return -1;
  }
  return d;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> a[i], a[i]--;
  r += a[0] != 0;
  a[0] = 0;
  for (int i = 1; i < n; i++)
    e[a[i]].push_back(i);
  dfs();
  cout << r << "\n";
}


Measured memory_bytes: 10752
#include<stdio.h>
int gcd(int a,int b){
	
	int r;
	if(a<b){
		int t = a;
		a = b;
		b = t;
	}
	
	for(;;){
		
		r=a%b;
		//printf("%d=%d??%d+%d\n",a,a/b,b,r);
		
		a = b;
		b = r;
		
		if(r==0)break;
	}
	
	return a;
}


int main (void){

	int a,b;
	
	scanf("%d %d",&a,&b);
	
	printf("%d\n",gcd(a,b));
	
return 0;
}

/*??? ????????¬?????°????¬??????????
??? ?????±????????????????????????????¨?????????£?¶????????????????????????¬?????°?????????
?¬?????????????????????????????????¬??????????????¬?????°????¬????????????¨?????¶???
??? ??????3?????§??? 0?????£?¶?????????????????????????????????¬?????°????¬??????§?????????
?????±????????? 1, 01, 001, 000 ??????????????? 0???????????? 0, 1, 2, 3 ??§?????????
??? ????????¬?????°????????????????????????????¬?????????????????????????
????????¬?????°????????????????¬????????????¨?????¶???
????????¬?????°????¬????????????????????¬??????????
???????????\??????????????????????????????
1, 0??????????¢??????? p, 1???p (p???1???p )???
????¨???¶?????±???????????????????????????????????¨??????
N???1?????§??? 0 ???????????¬?????°???????¬???????
???????????¨???????????????
???????????????????????¨????????????????????????N??????
?????±????????????????¬???????????????????
*/

Measured memory_bytes: 592
n, m = map(int, input().split())

xsum = 0
xx = [int(i) for i in input().split()]
for i, x in enumerate(xx):
    xsum += (2 * i - n + 1) * x

ysum = 0
yy = [int(i) for i in input().split()]
for i, y in enumerate(yy):
    ysum += (2 * i - m + 1) * y

print(xsum * ysum % 1000000007)

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

int sig( int a, int b){
    if ( b-a > 0 ) return 1;
    else if ( b-a == 0 ) return 0;
    else return -1;
}

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

    vector<int> a(n);
    for ( int i = 0 ; i < n ; i++){
        cin >> a.at(i);
    }
    int cnt = 0;
    bool judge = false;
    int tmp = 0;
    for ( int i = 1 ; i < n ; i++){
        int l = sig(a.at(i-1),a.at(i));

        if ( judge == true ){
            if ( l == tmp*(-1) ){
                cnt++;
                judge = false;
            }
        }
        else{
            if ( l != 0 ){
                 judge = true;
                 tmp = l;
            }
        }
    }
    cout << cnt+1 << endl;    
}

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

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n;
	if(n == 3){
		cout << "2 5 63";
		return 0;
	}
	else if(n < 21){
		for(int i = 1; i <= (n / 4); i++){
			cout << 12 * (i - 1) + 2 << " " << 12 * (i - 1) + 3 << " " << 12 * (i - 1) + 4 << " " << 12 * (i - 1) + 9 << " ";
		}
		for(int i = 1; i <= (n % 4); i++) cout << ((n / 4) + i) * 12 << " ";
		return 0;
	}
	for(int i = 1; i <= (n / 21); i++){
		for(int j = 1; j <= 30; j++){
			if(j == 15) continue;
			if(!(j % 2) || !(j % 3) || !(j % 5)) cout << (i - 1) * 30 + j << " ";
		}
	}
	for(int i = 1; i <= (n % 21); i++){
		cout << (((n / 21) + i) * 30) << " ";
	}
}



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

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

using namespace std;

int main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  
  cout<<(char)(s1.at(0)+'A'-'a')<<(char)(s2.at(0)+'A'-'a')<<(char)(s3.at(0)+'A'-'a');
  
  return 0;
}

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

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

int main(int argc, char const *argv[])
{
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.length())
    {
        int a = s.at(i);
        a += n;
        if (a > 'Z')
            a -= ('Z' - 'A' + 1);
        s.at(i) = a;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

d = [0] * n

for i in range(n):
    d[i] = ((1+p[i])/2)

x=r=sum(d[:k])
# print(d)

for i in range(1,n-k+1):
    # r=max(r,sum(d[i:i+k]))
    x=x-d[i-1]+d[i+k-1]
    r=max(r,x)
    # print(r,i)

print(r)


Measured memory_bytes: 25060
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int a, b;
	cin >> a >> b;

	if (a < 0 && b>0||a==0||b==0) {
		cout << "Zero" << endl;
	}
	else if (a < 0 && b < 0) {
		if ((b - a + 1) % 2 == 0){
			cout << "Positive" << endl;
		}
		else {
			cout << "Negative" << endl;
		}
	}
	else {
		cout << "Positive" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [i for i in input()]
ANS = []

for i in range(1, N+1):
    ans = 0
    A = []
    B = []
    A = list(set(S[:i]))
    B = list(set(S[i:]))
    for a in A:
        for b in B:
            if a == b:
                ans += 1
    ANS.append(ans)
print(max(ANS))

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

int main(){
  int n;
  cin >> n ;
  vector<int> a(n+1);
  vector<int> b(n+1);


  for (int i = 1; i <= n; i++)
  {
    cin >> a[i];
    b[i] = a[i];
  }

  for (int i = n/2; i > 0; i--)
  {
    int k=2*i;
    int sum=0;
    while(k<=n){
      sum+=b[k];
      k+=i;
    }
    int bit = sum%2;
    if(bit==a[i]) b[i] = 0;
    else b[i] = 1;
  }

  int m=0;
  vector<int> ans;
  for (int i = 1; i <= n; i++)
  {
    if(b[i]==1){
      m++;
      ans.push_back(i);
    }
  }

  cout << m << endl;
  for (int i = 0; i < (int)ans.size(); i++)
  {
    cout << ans[i] << " ";
  }
  
  // for (int i = 0; i < m; i++)
  // {
  //   cout << 1 << " ";
  // }
  cout << "" << endl;
  
}

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#define N 10000
int isprime(int);
int main()
{
  int num[N];
  int count=0;
  int i,n;
  while(1)
    {
      scanf("%d",&n);
      if(1<=n && n<=N)break;
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&num[i]);
      if(2>num[i] || num[i]>N*N)i=i-1;
    }
  
  for(i=0;i<n;i++)
    {
      if(isprime(num[i])==1)count++;
    }
  printf("%d\n",count);
  return 0;
}

int isprime(int x)
{
  int i=3;
  if(x==2)return 1;

  if(x<2 || x%2==0)return -1;

  
  while(i<=sqrt(x))
    {
      if(x%i==0) return -1;
      i=i+2;
    }
  return 1;
}
	   

Measured memory_bytes: 628
N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
a = [0 for i in range(N)]
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    AC[p-1] = 1
    a[p-1] = 0
  else:
    if AC[p-1] == 0:
      WA[p-1] += 1
      a[p-1] += 1
c = sum(AC)
wa = sum(WA) - sum(a)
print(c, wa, sep=' ')

  

Measured memory_bytes: 11548
#include<iostream>

using namespace std;

int main(void)

{
    int h, w, i, a;
    cin>>h>>w;
    string ara[h], s;
    for(i = 0; i < h; i++){
        ara[i].clear();
        ara[i] += "#";
        cin>>s;
        ara[i] += s;
        ara[i] += "#";
    }
    for(i = 0; i <= w+1; i++){
        cout<<"#";
    }
    cout<<"\n";
    for(i = 0; i < h; i++)
        cout<<ara[i]<<"\n";
    for(i = 0; i <= w+1; i++){
        cout<<"#";
    }
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

int modpow(int a, int n, int mod) {
    int res=1;
    while(n>0) {
        if(n&1) res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x,y; cin >> x >> y;
    if((x+y)%3!=0){
        cout<<0<<endl;

        return 0;
    }

    if(2*x-y<0 || 2*y-x<0){
        cout<<0<<endl;
        return 0;
    }

    int a=(2*y-x)/3;
    int b=(2*x-y)/3;

    int res=1;

    //cout<<a<<' '<<b<<endl;
    for(int i=1; i<=(a+b); i++){
        res=res*(i%MOD);
        res%=MOD;
    }
    for(int i=1; i<=min(a,b); i++){
        res*=modpow(i,MOD-2,MOD);
        res%=MOD;
    }
    for(int i=1; i<=max(a,b); i++){
        res*=modpow(i,MOD-2,MOD);
        res%=MOD;
    }
    
    cout<<res<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] == "W":
        whiteCount += 1
      elif s[i] == "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  white,black = calcGroup(s)
  if abs(white-black) == 0:
    return (white-1)*2+1
  else:
    return min(white,black)*2



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    ll t = 3; 
    int i = 1;
    bool v = true;
    if (s1[0] != s2[0]) {
        t += 3;
        i++;
        v = false;
    }
    while (i < n) {
        if (s1[i] == s2[i]) {
            if (v) {
                t = (t * 2) % MOD;
            }
            i++;
            v = true;
        } else {
            if (v) {
                t = (t * 2) % MOD;
            } else {
                t = (t * 3) % MOD;
            }
            i += 2;
            v = false;
        }
    }

    cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int com[51][51]{};
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }

	int N, P;
	cin >> N >> P;
	int cnt0{}, cnt1{};
	rep(i,N){
		int a;
		cin >> a;
		a %= 2;
		if(a % 2 == 1) cnt1++;
		else cnt0++;
	}
	int ans = 1;
	rep(i,cnt0){
		ans *= 2;
	}
	int tmp = 0;
	for(int i=0;i<=cnt1;i++){
		if(i%2==P){
			tmp += com[cnt1][i];
		}
	}
	cout << ans * tmp << endl;
}

Measured memory_bytes: 3652
class BIT
    def initialize(n)
        @n = n+1
        @dat = Array.new(@n+1, 0)
    end

    def sum(i)
        s = 0
        while i >= 0 do
            s += @dat[i]
            i = (i & (i + 1)) - 1
        end
        s
    end

    def add(i, x)
        while i <= @n do
            @dat[i] += x
            i |= i + 1
        end
    end
end

N, K = gets.split.map(&:to_i)
as = N.times.map{gets.to_i - K}
partsum = [0]
(0...N).each do |i|
    partsum[i+1] = partsum[i] + as[i]
end

sum2order = {}
partsum.sort.each_with_index do |sum, order|
    sum2order[sum] = order
end

compress = partsum.map{|sum|sum2order[sum]}

bit = BIT.new(N)
ans = 0
(N+1).times do |j|
    ans += bit.sum(compress[j])
    bit.add(compress[j], 1)
end

puts ans

Measured memory_bytes: 22936
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ll x,cnt[62]={0};
	for(ll i=0;i<n;i++)
	{
		cin>>x;
		for(ll j=0;j<62;j++)
			if(x&(1ll<<j))
				cnt[j]++;
	}
	ll ans=0,mul=1;
	for(ll i=0;i<62;i++)
	{
		ll tot=((n-cnt[i])*cnt[i])%mod;
		ans=(ans+(tot*mul)%mod)%mod;
		mul=(mul*2)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#define int long long
using namespace std;

int n;
int a[200000];
int nxt[200000];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	for (i = 0; i < n; ) {
		if (a[i] != 0) { nxt[i] = i + 1; i++; continue; }
		for (j = i + 1; j < n; j++) if (a[j] != 0) break;
		int val = j;
		for (j = i; j < val; j++) nxt[j] = val;
		i = val;
	}
	
	int ans = 0;
	for (i = 0; i < n; ) {
		//cout << i << " " << a[i] << endl;
		if (a[i] != 0) {
			int x = 0, su = 0;
			for (j = i; j < n; j = nxt[j]) {
				x ^= a[j]; su += a[j];
				if (x != su) break;
			}
			ans += j - i;
			i++; continue;
		}
		else {
			int x = 0, su = 0;
			for (j = nxt[i]; j < n; j = nxt[j]) {
				x ^= a[j]; su += a[j];
				if (x != su) break;
			}
			ans += (j - i) * (nxt[i] - i) - (nxt[i] - i) * (nxt[i] - i - 1) / 2;
			i = nxt[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
local n = io.read("n")
local k = io.read("n")
local list = {}
for i = 1, n do
  list[i] = io.read("n")
end
table.sort(list)
local min = nil
for i = 1, n - k + 1 do
  local d = list[i + k - 1] - list[i]
  if not min or d < min then
    min = d
  end
end
print(min)

Measured memory_bytes: 2424
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <list>

using namespace std;

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

const ll mod = 1000000007;

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

  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<vector<char> > query(q, vector<char>(3));
  for (int i = 0; i < q; i++) {
    cin >> query[i][0];
    if (query[i][0] == '2') cin >> query[i][1] >> query[i][2];
  }

  int n = s.size();

  list<char> str;
  for (int i = 0; i < n; i++) str.push_back(s[i]);

  bool flipped = false;
  for (int i = 0; i < q; i++) {
    if (query[i][0] == '1') {
      flipped = !flipped;
    }
    else {
      if (flipped != (query[i][1] == '1')) {
        str.push_front(query[i][2]);
      }
      else {
        str.push_back(query[i][2]);
      }
    }
  }

  if (!flipped) {
    for (auto it = str.begin(); it != str.end(); it++) cout << *(it);
  }
  else {
    for (auto it = str.rbegin(); it != str.rend(); it++) cout << *(it);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 20944
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  sort(A.rbegin(), A.rend());
  int total = A[0]/2;
  loop(i,1,n) total += A[i];
  cout << total << endl;
}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())

ANS=10**12
for i in range(0,max(X,Y)*2+1,2):
    XRE=max(X-i//2,0)
    YRE=max(0,Y-i//2)

    if ANS>i*C+XRE*A+YRE*B:
        ANS=i*C+XRE*A+YRE*B

    #print(i,i*C+XRE*A+YRE*B)

print(ANS)

Measured memory_bytes: 3064