akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x) memset(x,0,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1
/*------------------------------------------------------------*/
int n,m;
int main(){
	int a,b,c,d,e,f;
	in4(a,b,c,d);in2(e,f);
	if(a>b)swap(a,b);
	if(c>d)swap(c,d);
	int c1=f/a/100;
	double k=-23333333;
	int ans1=0,ans2=0;
	FOR(i,0,c1)
		FOR(ii,0,c1){
		int c2=i*b*100+ii*a*100;
		if(c2>f)break;
		int c3=min(c2/100*e,f-c2)/c;
//		out(c2);
		FOR(j,0,c3)FOR(jj,0,c3){
			int c4=d*j+c*jj;
			if(c4>min(c2/100*e,f-c2))break;
//			out2(c2,c4);
			if(k<(double)c4*100/(double)(c2+c4)){
				k=(double)c4*100/(double)(c2+c4);
				ans1=c2+c4,ans2=c4;
			}
		}
	}
	out2(ans1,ans2);
}


































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;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  int a[4];
  a[0] = N % 10; N /= 10;//一の位を取り出す
  a[1] = N % 10; N /= 10;
  a[2] = N % 10; N /= 10;
  a[3] = N % 10; N /= 10;//千の位を取り出す
  if (a[0] == a[1] && a[1] == a[2] || a[1] == a[2] && a[2] == a[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3568
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, K, Q) = (input[0], input[1], input[2])
var cnt = (0..<N).map{_ in 0}
for _ in 0..<Q {
  cnt[Int(readLine()!)!-1] += 1
}
for i in cnt {
  print(i>Q-K ?"Yes":"No")
}

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

bool isPrime(int x)
{
    for (int i = 2; i < x; i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

void solve()
{
    int x;
    cin >> x;
    int ans = 0;
    for (int i = x;; i++)
    {
        if (isPrime(i))
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

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


int main()
{
	int N;
	cin>>N;
	vector<ll> A(N);
	vector<ll> B(N);
	rep(i,N)
	{
		cin>>A[i]>>B[i];
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	if(N%2==0)
	{
		cout<<(B[N/2-1]+B[N/2])-(A[N/2-1]+A[N/2])+1<<endl;
	}
	else
	{
		cout<<B[N/2]-A[N/2]+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <vector>

bool next_rhift(std::vector<int>& V) {
  bool res{true};
  for (int i = 0; i < static_cast<int>(V.size()); i++) {
    V[i] /= 2;
    if (V[i] % 2 != 0) res = false;
  }
  return res;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) std::cin >> A[i];
  int res{0};
  for(auto&& v:A){if(v%2!=0){
      printf("0\n");
      return 0;
    }
  }
  do {
    res++;
  } while (next_rhift(A));
  printf("%d\n", res);
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const ll inf=0x3f3f3f3f;
const ll Mod=924844033;
const ll N=4005;
ll read(){
	ll s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
ll n,m,tot;
ll fac[N],vis[N],f[N][N][2];
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();m=read();fac[0]=1;
	for(ll i=1;i<=n;i++)fac[i]=fac[i-1]*i%Mod;
	for(ll i=1;i<=m;i++){
		for(ll t=2;t>=1;t--){
			for(ll j=i;j<=n;j+=m){
				tot++;
				if(j!=i)vis[tot]=1;
			}
		}
	}
	ll ans=0;
	f[0][0][0]=1;
	for(ll i=0;i<n*2;i++){
		for(ll j=0;j<=n;j++){
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%Mod;
			if(vis[i+1])f[i+1][j+1][1]=f[i][j][0];
		}
	}
	for(ll i=0;i<=n;i++){
		ll t=i&1?-1:1;
		f[2*n][i][0]=(f[2*n][i][0]+f[2*n][i][1])%Mod*fac[n-i]%Mod;
		ans=(ans+f[2*n][i][0]*t+Mod)%Mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 249472
s = input()
s1 = s[::-1];n = len(s)
f = 0

if s == s1:
    s2 = s[:(n-1)//2]
    
    if s2 == s2[::-1]:
        
        s3 = s[(n+3)//2-1:n]
        
        if s3 == s3[::-1]:
            f = 1
        
        else:
            f = 0
    
    else:
        f = 0
        
else:
    f = 0
    
if f == 0:
    print('No')
else:
    print('Yes')
            

Measured memory_bytes: 3064
from collections import deque
N = int(input())
a = deque()
a_num = 0
b =deque()
c = deque()
for i in range(N):
  a_num = int(input())
  a.append(a_num)
  k,p=0,0
  x = [0]*N
  b_num=deque()
  for i in range(a_num):
    k,p = map(int,input().split())
    b_num.append(k-1)
    x[k-1]=p
  b.append(b_num)
  c.append(x)
max_num = 0   
for i in range(2**N):
  two = format(i,"015b")
  two = two[::-1]
  flag=True
  for i,k in enumerate(two):
    if flag == False:
      break
    if i<N:
      if k =="1":
        for l in range(a[i]):
          for j in b[i]:
            #print(b[i],c[i][j],two[j])
            if c[i][j]!=int(two[j]):
              flag =False
              break
          if flag ==False:
            break
        if flag == False:
          break
    
    else:
      break
  if flag == True:
    #print(two)
    max_num = max(max_num,two.count("1"))  
print(max_num)

Measured memory_bytes: 9448
import numpy as np

N=int(input())
W=list(map(int,input().split()))
S=list()


#W1=[i for i in Wd if i<=N]
#W2=[i for i in Wd if i>N]
for i in range(N):
	S1=sum(W[:i])
	S2=sum(W[i:])
	#print(f'S1={S1}')
	#print(f'S2={S2}')
	
	S.append(abs(S1-S2))
	#print(S)
	S1=0
	S2=0

print(min(S))

Measured memory_bytes: 12488
#include<bits/stdc++.h>
bool ok[7368792];
int main() {
int m, n;
while (scanf("%d%d", &m, &n), m) {
memset(ok, 0, sizeof(ok));
int cnt = 0;
for (int i = m;; i++) {
if (ok[i])continue;
if (++cnt > n) { printf("%d\n", i); break; }
for (int j = i; j <= 7368791; j += i)ok[j] = true;
}
}
}

Measured memory_bytes: 10388
#include<bits/stdc++.h>
#define N 100005
#define M 1000000007
#define llong long long
#define _pair  pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
int n;
string st;
llong f[100005][15];
llong cal(int i, int rem)
    {
        llong &rs=f[i][rem];
        if (rs != -1) return rs;
        if (i > n) return rs=(rem == 5);
        rs=0;
        if (st[i] == '?'){
            for (int di=0; di <= 9; di++){
                int nRem=(rem*10 + di)%13;
                rs=(rs+cal(i+1,nRem))%M;
            }
        }
        else{
            int nRem=(rem*10 + st[i]-'0')%13;
            rs=cal(i+1,nRem);
        }
        return rs;
    }
int main()
{
    ios::sync_with_stdio(0);
    cin>>st;
    n=st.length();
    st.insert(0," ");
    memset(f,-1,sizeof f);
    cout<<cal(1,0);
    return 0;
}

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

ll r=1,l=1,a[int(1e8)];
vector <ll> num;
inline void prepare(){
    for(register int i=1;i<10;i++){
            a[r++]=i;
    }
    while(r>1){//不是循环终止条件
        ll cur=a[l++];//取出一个数
        if(cur>1e11) return;//循环终止条件
        num.push_back(cur);

        ll lst=cur%10;//取尾数
        a[r++]=cur*10+lst;//加上末位，与尾数是同一个数
        if(lst<9) a[r++]=cur*10+lst+1;
        if(lst>0) a[r++]=cur*10+lst-1;
    }
}
int main(){
    prepare();
    int k;
    scanf("%d",&k);
    sort(num.begin(),num.end());
    printf("%lld",num[k-1]);
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define decsort(b) sort(all(b),greater<ll>())
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e5;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

map<ll,ll> vis;
map<ll,set<ll>> gr;
ll dfs(ll i)
{
	ll ans=1;
	vis[i]=1;
	for(auto to: gr[i])
	{
		if(vis[to])continue;
		ans+=dfs(to);
	}
	return ans;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	FAST();
 	rl(n) rl(m)
	
	ll l,r;
	while(m--)
	{
		cin>>l>>r;
		l--;r--;
		gr[l].insert(r);
		gr[r].insert(l);
	}
	
	ll mx=0;
	for(ll i=0;i<n;i++)
	{
		if(vis[i])continue;
		else
		{
			mx=max(mx,dfs(i));
		}
	}	
	cout<<mx;
}

Measured memory_bytes: 72388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20_0362_Atcorder
{
    class Program
    {
        static void Main(string[] args)
        {           
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);
            int D = int.Parse(input[3]);

            Duerist duerist1 = new Duerist();
            duerist1.Name = "高橋";
            duerist1.HP = A;
            duerist1.ATTACK = B;

            Duerist duerist2 = new Duerist();
            duerist2.Name = "青木";
            duerist2.HP = C;
            duerist2.ATTACK = D;

            while(true)
            {                
                C -= B;
                if (C <= 0)
                {
                    Console.Write("Yes");
                    break;
                }
                
                A -= D;                
                if (A <= 0)
                {
                    Console.Write("No");
                    break;
                }
            }            
            Console.Read();
        }
        public class Duerist
        {
            public string Name;
            public int HP;
            public int ATTACK;
        }        
    }
}


Measured memory_bytes: 27556
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;
  if (N % 2 == 0) {
    COUT(N);
  } else {
    COUT(N * 2);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	string a,b; cin >> a;
	for (int i = 0; i < a.length (); i++) {
		if(a[i] == '0') b+= '0';
		if(a[i] == '1') b+= '1';
		if(a[i] == 'B' && b.length() != 0) b.pop_back();
	}
	cout << b << endl;
	return 0;
}

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

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		Hashtable<Integer,String> day = new Hashtable<Integer,String>();
		day.put(1,"Thursday");
		day.put(2,"Friday");
		day.put(3,"Saturday");
		day.put(4,"Sunday");
		day.put(5,"Monday");
		day.put(6,"Tuesday");
		day.put(0,"Wednesday");
		Hashtable<Integer,Integer> month = new Hashtable<Integer,Integer>();
		month.put(1,0);
		month.put(2,31);
		month.put(3,60);
		month.put(4,91);
		month.put(5,121);
		month.put(6,152);
		month.put(7,182);
		month.put(8,213);
		month.put(9,244);
		month.put(10,274);
		month.put(11,305);
		month.put(12,335);
		
		while(true){
			int m = scan.nextInt();
			int d = scan.nextInt();
			if(m==0 &&  d==0){
				break;
			}
			int n = month.get(m) + d;
			String today = day.get(n%7);
			System.out.println(today);
		}
	}
}

Measured memory_bytes: 17212
s=list(input())
n=len(s)
for i in range(n):
  s[i]=int(s[i])
n=len(s)
a=[0]*n
b=[0]*n
cnta=0
cntb=0

for i in range(n):
  if i%2==1:
    a[i]=1
    if a[i]!=s[i]:
      cnta+=1
  else:
    if a[i]!=s[i]:
      cnta+=1

for j in range(n):
  if j%2==0:
    b[j]=1
    if b[j]!=s[j]:
      cntb+=1
  else:
    if b[j]!=s[j]:
      cntb+=1

if cnta<cntb:
  print(cnta)
else:
  print(cntb)

Measured memory_bytes: 5544
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll n;
    cin>>n;
    string ans="";
    while(n){
        ans+=('a'+((n-1)%26));
        n=(n-1)/26;
    }
    reverse(ans.begin(),ans.end());
    cout<< ans;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll x[n];
    rep(i, 0, n){
        cin >> x[i];
    }

    ll ans = 10000000000;
    rep(i, 1, 101){
        ll cost = 0;
        rep(j, 0, n){
            cost += pow(x[j] - i, 2);
        }

        ans = min(ans, cost);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;} 
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;} 
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    ulong n,k;
    scan(n,k);
    ulong sum;
    foreach(i;k..n+2){
        sum=(sum+i*(n+1-i)+1)%(10^^9+7);
    }   
    sum.writeln;
}


Measured memory_bytes: 3676
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 098 C Attention
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    d.dmp((N))
    A = input()
    d.dmp(A)
    west, east = 0, 0
    for i in range(N):
        if A[i] == 'W':
            west += 1
        else:
            east += 1
    minTurn = east
    turn = east
    for i in range(N):
        if A[i] == 'W':
            pass
        else:
            turn -= 1
        d.dmp(turn,'turn')
        minTurn = min(minTurn, turn)
        # 向きを元に戻して、立場を変える
        if A[i] == 'W':
            turn += 1
        else:
            turn += 1-1
        d.dmp(minTurn,'minTurn')
    return minTurn


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
bool debug=false;
/*---------------------------------------------------*/

int main(){
  string s;
  cin>>s;
  s[3]='8';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int cost[4][31][31];
int field[31][31];

const int INF = 1 << 28;

struct state{
	int x;
	int y;
	int dir;
	int cost;

	state(int a, int b, int c, int d){
		x = a; y = b; dir = c; cost = d;
	}

	bool operator <(const state &rhs) const{
		return cost > rhs.cost;
	}
};

int main(){
	//freopen("test.txt", "r", stdin);
	while(1){
		int w, h;
		cin >> w >> h;
		if(!w && !h) break;


		rep(i, 4){
			rep(j, h){
				rep(k, w){
					cost[i][j][k] = INF;
				}
			}
		}

		rep(i, h){
			rep(j, w){
				cin >> field[i][j];
			}
		}

		int c[4];
		rep(i, 4){
			cin >> c[i];
		}

		priority_queue<state> q;

		q.push(state(0, 0, 0, 0));

		while(!q.empty()){
			state s = q.top();
			q.pop();

			if( cost[s.dir][s.y][s.x] <= s.cost ) continue;
			cost[s.dir][s.y][s.x] = s.cost;
			//printf("(%d,%d) dir=%d cost=%d\n", s.x, s.y, s.dir, s.cost);

			rep(i, 4){	// i=>相対方向
				int d = (s.dir + i) % 4; // d=>絶対方向
				int x = s.x + dx[d];
				int y = s.y + dy[d];
				if(x < 0 || x >= w || y < 0 || y >= h) continue;
				int co = c[i];
				if(i == field[s.y][s.x]) co = 0;
				q.push(state(x, y, d, s.cost+co));
			}
		}

		int best = INF;
		rep(i, 4){
			best = min(best, cost[i][h-1][w-1]);
		}
		cout << best << endl;
	}


	return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    if (x+y<10)
        cout<<x+y<<endl;
    else
        cout<<"error\n";
    return 0;
}


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

using namespace std;

typedef long long int ll;

int main() {
  int n;
  cin >> n;
  vector<ll> monsters(n, 0);
  vector<ll> dp(n + 1, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> monsters[i];
  }
  ll tempsum = 0;
  sort(monsters.begin(), monsters.end());
  //累積和の計算
  for(int i = 1; i <= n; i++)
  {
    dp[i] = dp[i - 1] + monsters[i - 1];
  }
  for(int i = 0; i < n; i++)
  {
    for(int j = i; j < n; j++)
    {
      if(j == n - 1)
      {
        //最後まで到達
        cout << n - i << endl;
        return 0;
      }
      if(monsters[j + 1] > 2ll * (monsters[j] + dp[j]))
      {
        i = j;
        break;
      }
    }
  }
  return 0;
}


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

int main() {
	int n, data;
	while(1) {
		scanf("%d", &n);
		if (n == 0) break;
		int sum=0, max=0, min=1001;
		for (int i=0; i<n; i++) {
			scanf("%d", &data);
			sum+=data;
			if (max < data) max=data;
			if (data < min) min=data;
		}
		printf("%d\n", (sum-max-min)/(n-2));
	}
}

Measured memory_bytes: 1192
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,x[10]={0};
  cin>>a>>b>>c>>d;
  x[a]++,x[b]++,x[c]++,x[d]++;
  if(x[1]>0 && x[9]>0 && x[7]>0 && x[4]>0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 2e5 + 5;
int n, N, a[maxn], m, ans = 0;
 
int Get(int pos) {
	for(register int l = pos + 1, r = N; l < r; ++l, --r)
		if((a[l] + a[r]) < m) return false;
	return true;
}
 
int main() {
	scanf("%d%d", &n, &m), N = n << 1;
	for(register int i = 1; i <= N; ++i)
		scanf("%d", &a[i]);
	sort(a + 1, a + N + 1);
	int L = -1, R = n;
	while(L < R - 1) {
		int mid = L + R >> 1;
		if(Get(mid << 1)) R = mid;
		else L = mid;
	}
	R = R * 2;
	for(register int l = 1, r = R; l <= r; ++l, --r)
		ans = max(ans, a[l] + a[r]);
	for(register int l = R + 1, r = N; l <= r; ++l, --r)
		ans = max(ans, a[l] + a[r] - m);
	printf("%d", ans);
	return 0;
} 

Measured memory_bytes: 896
import sys
import heapq

N,M=map(int,sys.stdin.readline().split())
AList=list(map(int,sys.stdin.readline().split()))
h = []
for a in AList:
    heapq.heappush(h, -1*a)
for i in range (M):
  maxNum=heapq.heappop(h)
  heapq.heappush(h, ((maxNum*-1)//2)*-1)
print(sum(h)*-1)


Measured memory_bytes: 60952
#include<stdio.h>
#include<stdlib.h>
#define INF 99999999

void matrixChainOrder(int,int*);
int main()
{
  int *p,i,n,b;
  scanf("%d",&n);

  p = malloc(sizeof(int)*n*2+1);
  scanf("%d",&p[0]);
  for(i=1;i<n;i++)
    {
      scanf("%d%d",&p[i],&p[i]);
    }
  scanf("%d",&p[n]);
  matrixChainOrder(n,p);

  return 0;
}
void matrixChainOrder(int n,int *p)
{
  int m[n][n],q,i,j,k,l;

  for(i=0;i<n;i++)
    {
      m[i][i]=0;
    }
  for(l=2;l<=n;l++)
    {
      for(i=0;i<=n-l;i++)
        {
          j=i+l-1;
          m[i][j]=INF;
          for(k=i;k<=j-1;k++)
            {
              q=m[i][k]+m[k+1][j]+p[i]*p[k+1]*p[j+1];
              if(m[i][j]>=q) m[i][j]=q;
            }
        }
    }
  printf("%d\n",m[0][n-1]);
}


Measured memory_bytes: 2108
# A, B = gets.split(" ").map(&:to_i)
S = gets.chomp.split(//)
# N = gets.to_i

h = {}
S.each do |s|
  h[s] ||= 0
  h[s] += 1
end

# p h
ok = h.size == 2 && h.all?{|k,v| v == 2}
puts ok ? 'Yes' : 'No'


Measured memory_bytes: 3836
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, 1, 0, -1};
    char dirF[] = {'^', '>', 'v', '<'};
    char dirC[] = {'U', 'R', 'D', 'L'};

    int t;
    cin >> t;
    while(--t >= 0){
        int h, w, n;
        cin >> h >> w;
        vector<string> field(h);
        for(int i=0; i<h; ++i)
            cin >> field[i];
        string command;
        cin >> n >> command;

        int y, x, dir;
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                int d = find(dirF, dirF+4, field[i][j]) - dirF;
                if(d != 4){
                    y = i;
                    x = j;
                    dir = d;
                    field[y][x] = '.';
                }
            }
        }

        for(int i=0; i<n; ++i){
            int d = find(dirC, dirC+4, command[i]) - dirC;
            if(d < 4){
                int y1 = y + dy[d];
                int x1 = x + dx[d];
                if(0 <= y1 && y1 < h && 0 <= x1 && x1 < w && field[y1][x1] == '.'){
                    y = y1;
                    x = x1;
                }
                dir = d;
            }else{
                int y1 = y;
                int x1 = x;
                for(;;){
                    y1 += dy[dir];
                    x1 += dx[dir];
                    if(y1 < 0 || y1 >= h || x1 < 0 || x1 >= w)
                        break;
                    if(field[y1][x1] == '*'){
                        field[y1][x1] = '.';
                        break;
                    }
                    if(field[y1][x1] == '#')
                        break;
                }
            }
        }

        field[y][x] = dirF[dir];
        for(int i=0; i<h; ++i)
            cout << field[i] << endl;
        if(t > 0)
            cout << endl;
    }
}

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

const int mod = 'z' - 'a' + 1;

char next_alphabet(char p, int step) {
    return char((p -'a' + step)%mod + 'a');
}

int distance(char a, char b) { // a -> bまでの距離(剰余環)
    return (b - a + mod)%mod;
}

int main()
{
    string S;
    int K;
    cin >> S >> K;
    // 大きいビットから、'a'にする余力があるのなら'a'にしていく
    // さらに余力(K)が余ったら、最下位ビットに全振りする
    for(int i = 0, i_len = S.size(); i < i_len; ++i) {
        int dist = distance(S[i], 'a');
        if(K < dist) { continue; }
        K -= dist;
        S[i] = next_alphabet(S[i], dist);
    }
    S[S.size()-1] = next_alphabet(S[S.size()-1], K);
    cout << S << endl;
    return 0;
}

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

main()
{
	long long n,a,b;
	scanf("%lld %lld %lld",&n,&a,&b);
	if((n==1&&a!=b)||a>b)
	{
		printf("0");
		return 0;
	}
	else if(n==2)
	{
		printf("1");
		return 0;
	}
	long long mn=a+b+(n-2)*a,mx=a+b+(n-2)*b;
	//printf("%lld %lld",mn,mx);
	long long ans=mx-mn+1;
	printf("%lld",ans);
}

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

ll man,cost[1005],key[1005],dp[1005][5000];
ll n,m,a,b,c;
	
ll on(ll p, ll pos)
{
	ll ans = (1<<pos);
	p = (p|ans);
	return p;
}

ll func_dp(ll indx, ll val)
{
	if(indx > m)
	{
		if(val==man)
		{
			return 0;
		}
		else return 1e9;
	}
	
	if(dp[indx][val] != -1) return dp[indx][val];
	
	ll a1 = func_dp(indx+1,val|key[indx]) + cost[indx];
	ll a2 = func_dp(indx+1,val);
	
	return dp[indx][val] = min(a1,a2);
}

int main()
{	
	cin >> n >> m;
	
	man = (1 << n) - 1; 
	
	for(int i = 1; i <= m; i++)
	{
		cin >> a >> b;
		cost[i] = a;
		ll bit = 0;
		for(int j = 1; j <= b; j++)
		{
			cin >> c;
			bit = on(bit,c-1);
		}
		key[i] = bit;
	}
	
	memset(dp,-1,sizeof(dp));
	
	ll ans = func_dp(1,0);
	
	if(ans >= 1e9) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}


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

int main(){
    string s; cin >> s;
    rep(i,3){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int n;
int m[7]={1,2,4,8,16,32,64};
int main(){
	cin>>n;
	for(int i=6;i>=0;i--)
	    if(n>=m[i]){
	    	cout<<m[i]<<endl;
	    	break;
		}
	return false;
}

Measured memory_bytes: 256
r,c = map(int,input().split())

L = [list(map(int,input().split())) for i in range(r)]

for i in range(r) :
    L[i].append(sum(L[i]))
L2 = []
for i in range(c+1) :
    l2 = 0
    for j in range(r) :
        l2 += L[j][i]
    L2.append(l2)
    
L.append(L2)

for i in range(len(L)) :
    for j in range(len(L[i])) :
        L[i][j] = str(L[i][j])
for i in range(len(L)) :
    ans = " ".join(L[i])
    print(ans)
    


Measured memory_bytes: 6260
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000LL;
typedef long long ll;
typedef pair<int,int> Q;
typedef pair<int,Q> Pa;
ll N,A[100005],D[2][8005]={},B[200005]={};
ll L,ans=0;
int a=0;
string str;
string s[100002];
string n[100002];
bool v[100002];
bool dp[2][8000][16000]={};
int main(){
	cin>>N>>L;
	ans=1;
	while(1){
		N*=2;
		if(N>L)break;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
function Main(input) {
  var s = input.split('\n')[0].split(" ")[1];
  var p = input.split('\n')[1].split(" ").map(el => parseInt(el)).sort(
    function(a,b){return a<b?-1:a>b?1:0;
  });
  console.log(p.slice(0,s).reduce((sum,cV)=>sum+cV))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29628
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <utility>
//#include <functional>
//#include <cmath>

int main(){
    int32_t N;
    std::cin >> N;
    //required time for Time[i]
    // sort with B incremental order
    // for(i=0;i<N;i++) Sum[i] += A[i];
    // if(Sum[i] > A[i]) No;
    // Yes;
    // sort for NlogN, check for N -> feasible
    std::vector< std::pair<int64_t, int64_t>> time_dl_vec;
    for(int32_t i = 0; i < N; i++){
        std::pair<int64_t, int64_t> tmp;
        std::cin >> tmp.second >> tmp.first;
        time_dl_vec.push_back(tmp);
    }
    std::sort(time_dl_vec.begin(), time_dl_vec.end());

    //debug
    //std::cout << "sorted result" << std::endl;
    //for(int32_t i = 0; i < N; i++){
    //    std::cout << time_dl_vec[i].second << " " << time_dl_vec[i].first << std::endl;
    //}

    int64_t sum_work = 0;
    for(int32_t i = 0; i < N; i++){
        int64_t deadline = time_dl_vec[i].first;
        sum_work += time_dl_vec[i].second;
        while(i < N - 1 && time_dl_vec[i].first == time_dl_vec[i+1].first){
            i++;
            sum_work += time_dl_vec[i].second;
        }
        if(sum_work > deadline){
            std::cout << "No";
            return 0;
        }
    }

    std::cout << "Yes";
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    int n,m;
    cin>>n>>m;
    int s=0;
    int a[n];
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    int c=0;
    rep(i,n){
        if (a[i]>=double(s)/double(4*m)){
            c+=1;
        }
    }
    if (c>=m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N=int(input())
H=list(map(int,input().split()))
def dp(L):
    dp=[0]*N
    dp[1]=abs(L[1]-L[0])
    for i in range(N-2):
        dp[i+2]=min(dp[i]+abs(L[i+2]-L[i]),dp[i+1]+abs(L[i+2]-L[i+1]))
    return dp[N-1]
    
print(dp(H))

Measured memory_bytes: 52208
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

vector<P> kaiten(vector<P> line){
    vector<P> ret;
    REP(i, line.size()) ret.pb(P(-line[i].second, line[i].first));
    return ret;
}

bool f(vector<P> l0, vector<P> li){
    if(l0.size() != li.size()) return false;

    bool flag = false;
    
    REP(i, l0.size()) l0[l0.size()-i-1].first -= l0[0].first, l0[l0.size()-i-1].second -= l0[0].second;
    vector<P> l1;
    l1.pb(P(0, 0));
    FOR(i, 1, li.size()) l1.pb(P(li[i].first - li[0].first, li[i].second - li[0].second));
    
    REP(i, l0.size()){
        if(l0[i].first != l1[i].first || l0[i].second != l1[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }
    
    l1 = kaiten(l1);
    REP(i, l0.size()){
        if(l0[i].first != l1[i].first || l0[i].second != l1[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }

    l1 = kaiten(l1);
    REP(i, l0.size()){
        if(l0[i].first != l1[i].first || l0[i].second != l1[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }

    l1 = kaiten(l1);
    REP(i, l0.size()){
        if(l0[i].first != l1[i].first || l0[i].second != l1[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }
    
    reverse(all(li));
    vector<P> l2;
    l2.pb(P(0, 0));
    FOR(i, 1, li.size()) l2.pb(P(li[i].first - li[0].first, li[i].second - li[0].second));

    REP(i, l0.size()){
        if(l0[i].first != l2[i].first || l0[i].second != l2[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }

    l2 = kaiten(l2);
    REP(i, l0.size()){
        if(l0[i].first != l2[i].first || l0[i].second != l2[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }

    l2 = kaiten(l2);
    REP(i, l0.size()){
        if(l0[i].first != l2[i].first || l0[i].second != l2[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }

    l2 = kaiten(l2);
    REP(i, l0.size()){
        if(l0[i].first != l2[i].first || l0[i].second != l2[i].second) break;
        if(i >= l0.size()-1) flag = true;
    }

    return flag;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int n; cin >> n;
        if(n == 0) break;
        vector<vector<P>> lines(n+1);
        REP(i, n+1){
            int m; cin >> m;
            REP(j, m){
                P p; cin >> p.first >> p.second;
                lines[i].pb(P(p.first, p.second));
            }
        }
        
        FOR(i, 1, n+1){
            if(f(lines[0], lines[i])) cout << i << endl;
        }
        cout << "+++++" << endl;
    }
}



Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
const ll MOD=1000000007;
int N,P;
int A[50];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>P;
    rep(i,0,N) cin>>A[i];
    int e=0,o=0;
    rep(i,0,N){
        if(A[i]%2) o++;
        else e++;
    }
    if(o==0){
        if(P==0) cout <<(1LL<<N)<<"\n";
        else cout<<0<<"\n";
    }
    else cout <<(1LL<<(N-1))<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;	
int main(){
	int n,a;
	cin>>n;
	vs in(n);
	rep(i,n)cin>>in[i];
	int t=-1;
	rep(i,n){
		int co=0;
		rep(j,n)if(in[i][j]=='o')co++;
		if(co==n-1){
			t=i;
			break;
		}
	}
	rep(i,1000){
		cout<<(t+1?t+1:rand()%n+1)<<endl;
		cin>>a;
	}
}

Measured memory_bytes: 3364
# G = ()|(G)|GG
N = gets
S = gets.chomp
s = []
ans = ""
a = 0
S.chars.each do |c|
  case c
  when "("
    s.push c
  when ")"
    if s.size > 0
      s.pop
    else
      a += 1
    end
  end
end

puts ("(" * a) + S + (")" * s.size)


Measured memory_bytes: 1788
L,R = map(int, input().split())
ql, modl = divmod(L,2019)
qr, modr = divmod(R,2019)
min = 3000
if qr-ql>0 :
    min=0
else:
    for i in range(modl,modr):
        for j in range(i+1,modr+1):
            min = min if (i*j) % 2019 > min else (i*j) % 2019
print(min)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstring> 
#include <vector>
#include <algorithm>

using namespace std;
#define mod 1000000007

vector<vector<char>> grid(1001,vector<char>(1001));
vector<vector<int>> ans(1001,vector<int>(1001,0));
int rows,cols;

int findMaxAns(){
    grid[0][0] = 1;
    
    for(int i=1;i<cols;i++){
        if(grid[0][i]!='#'){
            ans[0][i] = 1;
        }
        else{
            break;
        }
    }
    
    for(int i=1;i<rows;i++){
        if(grid[i][0]!='#'){
            ans[i][0] = 1;
        }
        else{
            break;
        }
    }
    
    for(int i=1;i<rows;i++){
        for(int j=1;j<cols;j++){
            if(grid[i][j]!='#'){
                ans[i][j] = (ans[i-1][j]%mod + ans[i][j-1]%mod)%mod;
            }
        }
    }
    return ans[rows-1][cols-1];
}

void solve(){
    cin>>rows>>cols;
    for(int i=0;i<rows;i++){
        for(int j=0;j<cols;j++){
            cin>>grid[i][j];
        }
    }
    
    cout<<findMaxAns();
}

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


Measured memory_bytes: 8612
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll N;
    cin >> N;
    ll dp[111][4][4][4]={};
    ll i, j, k, l, m;
    
    for(j=0; j<4; j++) {
        for(k=0; k<4; k++) {
            for(l=0; l<4; l++) {
                if(j==0 && k==1 && l==2) continue;
                if(j==0 && k==2 && l==1) continue;
                if(j==2 && k==0 && l==1) continue;
                
                dp[3][j][k][l]=1;
            }
        }
    }
    
    for(i=3; i<=N; i++) {
        
        for(j=0; j<4; j++) {
            for(k=0; k<4; k++) {
                for(l=0; l<4; l++) {
                    for(m=0; m<4; m++) {
                        if(j==0 && k==1 && l==2) dp[i][j][k][l]=0;
                        if(j==0 && k==2 && l==1) dp[i][j][k][l]=0;
                        if(j==2 && k==0 && l==1) dp[i][j][k][l]=0;
                        
                        if(j==0 && k==2 && m==1) continue;
                        
                        if(j==0 && l==2 && m==1) continue;
                        
                        else moC(dp[i+1][k][l][m], +, dp[i][j][k][l]);
                    }
                    
                }
            }
        }
    }
    
    ll ans=0;
    for(j=0; j<4; j++) {
        for(k=0; k<4; k++) {
            for(l=0; l<4; l++) {
                moC(ans, +, dp[N][j][k][l]);
            }
        }
    }
    
    pt(ans);
}








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

int solve(vector<int> v){
int n=v.size();
int cost[n];
cost[0]=0;
cost[1]=cost[0]+abs(v[1]-v[0]);
for(int i=2;i<n;i++){
    cost[i]=min(cost[i-1]+abs(v[i]-v[i-1]),cost[i-2]+abs(v[i]-v[i-2]));
}
return cost[n-1];
}
int main() {
   int n;
   cin>>n;
   vector<int> v;
   while(n--){
       int k;
       cin>>k;
       v.push_back(k);
   }
   cout<<solve(v)<<endl;
   return 0;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
 
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b < c + d) {
    cout << "Right" << endl;
  } else if (a + b > c + d) {
    cout << "Left" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

void printResult(std::vector<std::vector<char> > arr) {
    for (int i = 0; i < arr.size(); i++) {
        for (int j = 0; j < arr[i].size(); j++) {
            std::cout << arr[i][j];
        }
        std::cout << std::endl;
    }
}

std::vector<std::vector<char> > f(std::vector<std::vector<char> > c) {
    std::vector<std::vector<char> > result;
    for (int i = 0; i < c.size(); i++) {
        result.push_back(c[i]);
        result.push_back(c[i]);
    }
    return result;
}

int main() {

    int h, w;
    std::cin >> h >> w;

    std::vector<std::vector<char> > c;
    for (int i = 0; i < h; i++) {
        std::vector<char> v;
        for (int j = 0; j < w; j++) {
            char tmp;
            std::cin >> tmp;
            v.push_back(tmp);
        }
        c.push_back(v);
    }

    std::vector<std::vector<char> > result = f(c);
    printResult(result);

    return 0;
}


Measured memory_bytes: 384
import math
def digit():
    return int(input())
def list1():
    return list(map(int,input().split()))
def isperfectsquare(n):
    return True if int(math.sqrt(n)+0.5)**2==n else False

def main():
    s,t,d=list1()
    print('Yes' if s/d<=t else 'No')
main()


Measured memory_bytes: 9168
#include<stdio.h>
int main(void){
    int n,a[1000]={0},i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        if(i==0)
            printf("%d\n",a[i]);
    else
        printf("%d ",a[i]);
    }
    return 0;
}




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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    string s, t; cin >> s >> t;
    int len = s.size();
    bool flag = false;
    rep(i, s.size()){
        if(s == t){
            flag = true;
            break;
        }
        char tmp = s[len - 1];
        for(int j = len; j >= 0; j--){
            s[j + 1] = s[j];
        }
        s[0] = tmp;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using ll = long long;

void solve() {
    ll k;
    string ans;
    cin >> k;
    for(int i=1; i<=k; ++i) {
        ans += "ACL";
    }

    cout << ans << "\n";
}


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

Measured memory_bytes: 3564