akhauriyash/Code-Regression huggingface dataset:
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    string s;
    cin >> s;
    if(s=="ABC")
        cout << "ARC";
    else 
        cout << "ABC";
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3612
#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(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans=0;
  rep(i,a)rep(j,b)rep(k,c){
    if(x==i*500+j*100+k*50) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
package main

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

type pair struct {
	x, y int
}

func main() {
	a, b := getInt(), getInt()

	g := gcd(a, b)

	ans := len(factorize(g)) + 1
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func factorize(n int) []pair {
	ret := make([]pair, 0)
	for i := 2; i*i <= n; i++ {
		if n%i != 0 {
			continue
		}

		ret = append(ret, pair{i, 0})
		for n%i == 0 {
			n /= i
			ret[len(ret)-1].y++
		}
	}

	if n != 1 {
		ret = append(ret, pair{n, 1})
	}

	return ret
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    A, B = list(map(int,input().split()))
    if (A+B)%2==0:
        print(int((A+B)/2))
    else:
        print("IMPOSSIBLE")



if __name__ == "__main__":
    main()

Measured memory_bytes: 24736
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,sum;
    scanf("%d%d%d",&a,&b,&c);
    
    sum = a + b + c;
    
    if(a >= b && a >= c){
        printf("%d",sum-a);
    }else if(b >= a && b >= c){
        printf("%d",sum-b);
    }else{
        printf("%d",sum-c);
    }
    
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;
int mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
  cin.tie(NULL);
//  OJ;
  int n;
  cin>>n;
  int a[n];
  ll int sum=0;
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
      sum+=a[i];
      sum%=mod;
  }
  ll int ans=0;
  for(int i=0;i<n;i++)
  {
      sum-=a[i];
      if(sum<0)
      {
          sum+=mod;
      }
      ans+=sum*a[i];
      ans%=mod;

  }
  cout<<ans;
  
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 5000010
int main()
{
	int n;cin>>n;int f=0;
	while(n) 
	{
		if(n%10==7) f=1;
		n/=10;
	}
	if(f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def Bellman_Ford(s,n,w,es,ppp):
    #s→iの最短距離
    # s:始点, n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [Max] * n
    #d[i] : s→iの最短距離
    d[s] = 0
    po = 0
    while po < 2*N + 2*M:
        update = False
        for p,q,r in es:
        # e: 辺iについて [from,to,cost]
            if d[p] != Max and d[q] > d[p] + r:
                d[q] = d[p] + r
                update = True
                if (ppp[q] != 0 and po > N):
                    d[-1] = None
                    update = False
                    break
        if not update:
            break
        po += 1
    return d

import heapq

def dijkstra(n,w,e):
    #n:辺数,w:スタート一

    edge = [[] for i in range(n)]
    dg = 10**18
    # edge[i]:[コスト]
    for i in e:
        x,y = i
        z = 1
        x -= 1
        y -= 1
        edge[x].append(dg + y)
        
    
    s = w-1
    d = [-1]*n
    
    d[s] = 0

    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)

        

    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        v,c = minedge%dg,minedge//dg
        if d[v] >= 0:
            continue
        d[v] = c
        for e in edge[v]:
            vNext = e%dg
            if d[vNext]:
                heapq.heappush(edgelist, (e//dg+d[v])*dg + vNext)

    return d


def warshall_floyd(n,d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d




N,M,P = m()

es = []
ess = []

gr = [[] for i in range(N)]

ok = [0 for i in range(N)]

for _ in range(M):

    x,y,z = map(int,input().split())

    x -= 1
    y -= 1
    es.append([x,y,-z+P])
    gr[y].append(x)


ok[-1] = 1
po = cl.deque([N-1])
while po:
    o = po.popleft()
    
    for i in gr[o]: 
        if not ok[i]:
            po.append(i)
            ok[i] = 1





po = Bellman_Ford(0,N,M,es,ok)


print(-1 if po[-1] == None else -po[-1] if po[-1] <= 0 else 0)




Measured memory_bytes: 44012
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

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

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

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

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

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

int main() {
   ll N;
   cin >> N;
   ll max = 1;
   for(int i=1;i<=sqrt(N);i++){
       if(N%i==0){
           max = N/i;
       }
   }
   cout << (max-1)+(N/max-1) << endl;



}




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

int enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    return res.size();
}

int main() {
  int n; cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i+=2) {
    int num = enum_divisors(i);
    if (num == 8) cnt++;
  }
  cout << cnt << endl;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  string s;
  cin >> s;

  ll ans = 0;
  ll cnt = 0;
  rep(i, 3) {
    if (s[i] == 'R') {
      cnt++;
    } else {
      chmax(ans, cnt);
      cnt = 0;
    }
  }

  chmax(ans, cnt);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define N 21
int f[N][1<<N],nex[1<<N][2],len[1<<N];
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
inline char Getchar() {
    char ch=getchar();
    while (ch!='1' && ch!='0') ch=getchar();
    return ch;
}
int main() {
    int n=read(),k=read(),lim=2<<n;
    for (int i=0;i<=n;i++) 
        for (int j=0;j<1<<i;j++) f[i][1<<i^j]=Getchar()-'0';
    len[0]=-1;
    for (int i=1;i<lim;i++) len[i]=len[i>>1]+1;
    for (int i=2;i<lim;i++) {
        if (i>>(len[i]-1)&1) nex[i][1]=i^1<<len[i],nex[i][0]=nex[nex[i][1]][0]/* ,printf("%d %d\n",i,nex[i][1]) */;
        else nex[i][0]=i^3<<(len[i]-1),nex[i][1]=nex[nex[i][0]][1];
        // printf("%d %d %d\n",i,nex[i][0],nex[i][1]);
    }
    // for (int i=2;i<lim;i++) 
    for (int i=n;i>=1;i--)
        for (int A=1<<i;A<lim;A++) {
            if (!f[i][A]) continue;
            int C=A>>i,B=(A&((1<<i)-1))^1<<i;
            if (nex[B][0]) f[len[nex[B][0]]][(C<<1^1)<<len[nex[B][0]]^nex[B][0]]+=f[i][A];
            if (nex[B][1]) f[len[nex[B][1]]][(C<<1^0)<<len[nex[B][1]]^nex[B][1]]+=f[i][A];
            f[0][C]+=f[i][A];
            // printf("%d %d %d\n",i,A,B);
        }
    int ans=1;
    for (int i=2;i<lim;i++)
        if (f[0][i]>=k && len[i]>len[ans]) ans=i;
    // printf("%d\n",ans);
	while (~ans>>n&1) --n;
	while (n--) printf("%d",ans>>n&1);
	puts("");
    return 0;
}


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


int main(void){
    int n;
    cin>>n;
    string ox;
    cin>>ox;
    vector <int> ss(n+1);
    ss[0]= 1;ss[1]= 1;
    
    for(int j=0;j<4;j++){
    
    for(int i=2;i<=n;i++){
        if(ss[i-1]==1){
            if(ox[i-1]=='o'){
                ss[i]=ss[i-2];
            }else{
                ss[i]=ss[i-2]*(-1);
            }
        }else{
            if(ox[i-1]=='o'){
                ss[i]=ss[i-2]*(-1);
            }else{
                ss[i]=ss[i-2];
            }
        }
    }

    if((ss[0]==ss[n])&&(
        ((ox[0]=='o')&&(ss[0]==1)&&(ss[1]==ss[n-1]))||((ox[0]=='x')&&(ss[0]==1)&&(ss[1]!=ss[n-1]))||((ox[0]=='o')&&(ss[0]==-1)&&(ss[1]!=ss[n-1]))||((ox[0]=='x')&&(ss[0]==-1)&&(ss[1]==ss[n-1]))
        )){
        for(int i=0;i<n;i++){
            if(ss[i]==1) cout<<'S';
            else cout<<'W';
        }
        cout<<endl;
        return 0;
    }
    
    if(j%2==0) ss[0]*=(-1);
    else ss[1]*=(-1);
    
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 896
N, M = gets.chomp.split.map(&:to_i)

ans = Array.new(N, nil)

M.times do
  s, c = gets.chomp.split.map(&:to_i)
  s -= 1

  if ans[s] && ans[s] != c
    puts '-1'
    exit
  end

  ans[s] = c
end

if N >= 2 && ans[0].nil?
  ans[0] = 1
end

if N >= 2 && ans[0] == 0
  puts '-1'
  exit
end


ans.each {|c| print c ? c : 0 }


Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;
int go[N][26];

void solve(int test)
{
  string s, t;
  cin >> s >> t;
  int n = (int)s.size();
  memset(go, -1, sizeof(go));
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) {
      if (s[i] - 'a' == j) {
        go[i][j] = i;
      }
      else {
        go[i][j] = go[i + 1][j];
      }
    }
  }
  int ans = 0;
  int pos = 0;
  for (char c : t) {
    c -= 'a';
    if (go[pos][c] == -1) {
      ++ans;
      pos = 0;
    }
    if (go[pos][c] == -1) {
      ans = -1;
      break;
    }
    pos = go[pos][c] + 1;
  }
  if (ans == -1) {
    cout << ans << '\n';
  }
  else {
    cout << ans * 1ll * s.size() + pos << '\n';
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 31056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N,x,b=1E9;
  cin >> N;

  for (int i=0;i<N;i++){
	cin>>x;
    int j;
    for (j=0 ;j<1E9;j++){
      if(x%2==0){
          x/=2;
      }else{
        break;
      }
    }
    if(j<b)	b=j;
    if(b==1)break;
  } 
  	cout << b << endl;
}

Measured memory_bytes: 256
def main():
    N,M = map(int,input().split())
    A = sorted(list(map(int,input().split())))
    BC = []
    for i in range(M):
        a = list(map(int,input().split()))
        BC.append(a)
    BC = sorted(BC, key = lambda x:x[1],reverse = True)
    sum = 0
    for b,c in BC:
        if sum + b <= N:
            sum += b
            for i in range(b):
                A.append(c)
        else:
            sub = N - sum
            for i in range(sub):
                A.append(c)
    A = sorted(A,reverse = True)
    suma = 0
    for i in range(N):
        suma += A[i]
    print(suma)    

main()

Measured memory_bytes: 124716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll mem[2][100005];
int n;
ll evaluateTable(int i,int w){
    if(w<0) return LONG_LONG_MIN;
    if(i==n){
        if(w==0) return 0;
        return LONG_LONG_MIN;
    }
    return mem[i%2][w];
}
void setmem(int target){
    int w[n];
    ll v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<=target;j++){
            mem[i%2][j]=max(evaluateTable((i+1)%2,j),v[i]+evaluateTable((i+1)%2,j-w[i]));
        }
    }
    cout<<mem[0][target]<<endl;
}
main(){
    int value;
    cin>>n>>value;
    setmem(value);
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
#define f(i,p,q) for(int i=p;i<q;i++)
using namespace std;
typedef long long ll;
long long int ar[64];
int main()
{//freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
  long long  int n,k;cin>>n>>k;
  long long  int t; int l=0;
	long long  int m=n;
	vector<long long int>v;
   for(int i=0;i<n;i++)
   {  long long int x;cin>>x;
      v.push_back(x);
     t=x;
  long long int index=0;
   	 while(t!=0)
   	 {   
		if((t&1)==1)
   	      ar[index]++;
   	 	index++;
        t=t>>1;
		}
   }
  long long  int ans=0;
  
  
   for(int i=40;i>=0;i--)
   { long long int u=(1ll<<i);
      if(m-ar[i]>ar[i]&&((ans^u)<=k))
          ans=ans^u;
   	  
   	   //cout<<i<<" "<<ar[i]<<"  "<<ans<<"\n";
   }  
  
 
  long long  int res=0;
   for(int i=0;i<m;i++)
     res+=ans^v[i];
      cout<<res;
}

Measured memory_bytes: 1400
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;
    bool ok = true;
    if ((s.length() & 0x1) == 0) {
        int n = s.length();
        for (int i = 0, j = n / 2; i * 2 < n; ++i, ++j) {
            if (s[i] != s[j]) {
                ok = false;
            }
        }
    } else {
        ok = false;
    }

    if (ok) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char ch[20];
int main(){
	scanf("%s",ch+1);
	for (int i=1;i<=4;i++) putchar(ch[i]);
	putchar(' ');
	for (int i=5;i<=12;i++) putchar(ch[i]);
	putchar('\n');
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

char s[maxn];
int n, A, W, T, R;

int main() {

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s);
		if (s[0] == 'A') A++;
		if (s[0] == 'W') W++;
		if (s[0] == 'T') T++;
		if (s[0] == 'R') R++;
	}
	printf("AC x %d\n", A);
	printf("WA x %d\n", W);
	printf("TLE x %d\n", T);
	printf("RE x %d\n", R);

	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const int maxn = 2e5+5;

int a[50][2];
int dp[50];
int num[maxn];
int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<(n/(a+b))*a+min(n%(a+b),a)<<endl;
	return 0;
}

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

bool isOK(int k, string s) {
    int len = (int)s.size();
    if (k * 2 <= len) return true;

    int cnt = 0;
    for (int i = len - k; i < k; i++)
    {
        if (s.at(i) == '0') cnt++;
    }
    if (cnt == k * 2 - len || cnt == 0) return true;
    else return false;
}

int binary_search(int len, string s) {
    int ng = len + 1;
    int ok = 1;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, s)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    string s;
    cin >> s;

    int ans = binary_search((int)s.size(), s);
    cout << ans << endl;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;



int main() {

	int n;
	cin >> n;
	int a = 0; int b = 0,c=0;
	for (int i = 0; i < n; i++) {
		int r;
		cin >> r;
		if (r % 4==0)a++;
		else if (r % 2 == 0)b++;
		else c++;
	}

	if (a-c < -1)cout << "No" << endl;
	else if (a-c == -1 && b == 0)cout << "Yes" << endl;
	else if (a - c == -1 && b)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int main(int argc, char const *argv[])
{
    cin >> n;
    if (n % 10 == 9 || n / 10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

stack<int> st;

int main()
{
    string str;
    while (cin >> str)
    {
        
        int a,b;
        if(str == "+"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a+b);
        }
        else if(str == "-"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a-b);
        }
        else if(str == "*"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a*b);
        }
        else if(str == "/"){
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            st.push(a/b);
        }else{
            st.push(atoi(str.c_str()));
        }
        // if(getchar()=='\n') cout << st.top() << endl;
    }
cout << st.top() << endl;
    return 0;
}


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

using namespace std;

const int MAX = 1000100;
bool prime[MAX];

void sieve(){
	fill(prime, prime+MAX, true);
	prime[0] = prime[1] = false;

	for(int i=2; i*i < MAX; i++){
		if(!prime[i]) continue;
		for(int j=i*i; j < MAX; j += i) prime[j] = false;
	}
}


int main(){
	sieve();
	int n;
	while(cin >> n, n){
		int ret = 0;
		for(int i=0; i<= n/2; i++){
			if(prime[i] && prime[n-i]) ret++;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 2136
def dfs(G,n):

	global ptr
	
	#探索済
	seen[n] = True

	#行き
	F[n] = ptr
	ptr += 1

	for i in G[n]:
		#次に行けるかを判定
		if seen[i] == True :
			continue
		dfs(G,i)

	#帰り
	L[n] = ptr
	ptr += 1

if __name__ == '__main__':

	n = int(input())
	
	G = [[] for _ in range(n+1)] 
	F = [0 for _ in range(n+1)]
	L = [0 for _ in range(n+1)]

	#深さ優先探索
	#探索済配列
	seen = [False for _ in range(n+1)]

	for i in range(n):
		cmd = list(map(int,input().split()))
		m = cmd[1]
		if m != 0:
			for j in range(m):
				G[i+1].append(cmd[j+2])
	ptr = 1
	for i in range(1,n):
		if seen[i] == False :
			dfs(G,i)

	for i in range(1,n+1):
		print(i,F[i],L[i])




Measured memory_bytes: 5716
n=int(input())
s=[int(input()) for _ in range(n)]

sum=0
for i in s:
      sum+=i

if sum%10!=0:
      print(sum)
      exit()

s.sort()
for i in s:
      if i%10!=0:
            sum-=i
            print(sum)
            exit()

print(0)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  int sum = 0;
  int min = 100;
  int max = 1;
  for(int &x : X){
    cin >> x;
    sum += x;
    if(x > max){
      max = x;
    }
    if(x < min){
      min = x;
    }
  }
  int min_total = 1000000;
  for(int p = min; p <= max; p++){
    int total = 0;
    for(int x : X){
      total += (x - p) * (x - p);
    }
    if(total < min_total){
      min_total = total;
    }
  }
  cout << min_total << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

struct card {
	char Mark;
	int Number;
};

int main() {
	int n = 0;
	scanf("%d", &n);

	struct card data[54];
	for (int i = 0; i < n; i++) {
		(void)getchar();
		scanf("%c %d", &data[i].Mark, &data[i].Number);
	}

	char Mark[4] = { 'S', 'H', 'C', 'D' };
	int flag = 0;
	for (int c = 0; c < 4; c++) {
		for (int x = 1; x <= 13; x++) {
			flag = 0;
			for (int i = 0; i < n; i++) {
				if (Mark[c] == data[i].Mark && x == data[i].Number) {
					flag = 1;
				}
			}

			if (flag == 0) {
				printf("%c %d\n", Mark[c], x);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll ans;
ll M=1000000007;
ll s[200005];
int main(void){
	ll n,k; cin>>n>>k;
	for(int i=1;i<200005;i++){
		s[i]=s[i-1]+i;
	}
	for(int i=k;i<=n+1;i++){
		ans=(ans+(s[n]-s[n-i])-s[i-1]+1)%M;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	
}


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

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

int main(){
  int n,x;
  cin >> n;
  rep1(i,n){
    if(i%3==0)cout << ' ' << i;
    else if(i%10==3)cout << ' ' << i;
    else if((i/10)%10==3)cout << ' ' << i;
    else if((i/100)%10==3)cout << ' ' << i;
    else if((i/1000)%10==3)cout << ' ' << i;
  }
  cout << endl;
}



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

int head = 0;
int tail = 0;
int num;

typedef struct
{
    char name[10];
    int time;

} queue;

queue *p;

void enqueue(queue a)
{
    p[tail] = a;
    tail = (tail + 1) % num;
}

queue dequeue()
{
    int tmp = head;
    head = (head + 1) % num;
    return p[tmp];
}

int main()
{

    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int q;
    int n_time = 0;
    int count = 0;

    cin >> num >> q;

    p = new queue[num];

    for (tail = 0; tail < num; tail++)
    {
        cin >> p[tail].name >> p[tail].time;
    }
    tail = 0;

    while (count != num)
    {
        //後ろに送る
        if ((p[head].time) > q)
        {
            n_time += q;
            p[head].time -= q;
            enqueue(dequeue());
        }
        //注意
        else
        {
            count++;
            n_time += p[head].time;
            queue tmp = dequeue();
            cout << tmp.name << ' ' << n_time << endl;
        }
    }

    return 0;
}


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

int gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}


int main()
{
    long long a,b;
    cin>>a>>b;
    long long c;
    c=a*b/gcd(a,b);
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		ll n;
		cin >> n;
		vector<ll> dp(n + 1, 0);
		dp[0] = dp[1] = 1;
		FOR(i, 1, n) {
			dp[i + 1] = dp[i] + dp[i - 1];
		}
		put(dp[n]);
	}
} // namespace idaten

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



Measured memory_bytes: 3152
import sys
a=list(map(int,input().split()))
a.sort()
l0=a[0]-a[2]
l1=a[1]-a[2]
l2=0
c=0
while(c<1000):
    if l2==l1 and l2==l0:
        print(c)
        break
    elif l1==l0:
        l1+=1
        l0+=1
    elif (l1-l0)%2==0:
        l0+=2
    else:
        l0+=1
        l2+=1
    c+=1

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;
const ll oo = 1e18;

int n;
string s;
set<int> ls, rs;
int ans[N];

void solve() {
  cin >> s;
  n = s.length();
  for(int i = 1; i < n; ++i) {
    if(s[i - 1] == 'R' && s[i] == 'L') {
      rs.insert(i - 1), ls.insert(i);
    }
  }
  for(int i = 0; i < n; ++i) {
    if(s[i] == 'L') {
      int first_l = *prev(ls.upper_bound(i));
      int dist = i - first_l;
      vector<int> pos = {first_l, first_l - 1};
      int d = dist % 2;
      ans[pos[d]]++;
    } else {
      int first_r = *rs.lower_bound(i);
      int dist = first_r - i;
      vector<int> pos = {first_r, first_r + 1};
      int d = dist % 2;
      ans[pos[d]]++;
    }
  }
  for(int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  solve();
  return 0;
}


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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

// グラフ(隣接リスト)
typedef vector<int> Edges;
typedef vector<Edges> Graph;
const int INF = 1<<28;
Graph g;

int visited[100000+3][3];

int main() {
  int N, M; cin>>N>>M;
  g = Graph(N);
  REP(i,M) {
    int u, v; cin>>u>>v;
    u--; v--;
    g[u].push_back(v);
  }
  int S, T; cin>>S>>T; S--; T--;
#ifdef DEBUG
  REP(i,N) {
    cout << i << ":";
    REP(j,g[i].size()) {
      cout << g[i][j] << " "; 
    }
    cout << endl;
  }
  cout << "Go...." << S << T << endl;
#endif
  REP(i,N) REP(j,3) visited[i][j] = INF;
  visited[S][0] = 1;
  vector<int> q[2];
  q[0].push_back(S);
  for(int step = 0; ; step++) {
    int from = step%2, to = 1-from;
    if(q[from].empty()) break;
#ifdef DEBUG
    cout << step << ":"; REP(i,q[from].size()) cout << q[from][i] << " " ; cout << endl;
#endif
    q[to].clear();
    int nstep = step+1;
    REP(i, q[from].size()) {
      int cur = q[from][i];
      REP(j, g[cur].size()) {
	int dst = g[cur][j];
#ifdef DEBUG
	cout << cur << "," << dst << endl;
#endif
	if(visited[dst][nstep%3] == INF) {
	  visited[dst][nstep%3] = nstep;
	  if(dst == T && nstep%3 == 0) {
	    cout << nstep/3 << endl;
	    return 0;
	  }
	  q[to].push_back(dst);
	}
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


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


int main()
{
	int r, c, a[101][101] = {};
	cin >> r >> c;
	for (int i = 0;i < r;i++) {
		for (int j = 0;j < c;j++)
			cin >> a[i][j];
	}

	for (int I=0;I<=c;I++)
		for (int x=0;x<r;x++)
			a[r][I] = a[r][I] + a[x][I];
	for (int J = 0;J <= r;J++)
		for (int y = 0;y < c;y++)
			a[J][c] = a[J][c] + a[J][y];

	for (int A = 0;A <= r;A++) {
		for (int B=0;B <= c;B++) {
			if (B == c)
				cout << a[A][B];
			else
				cout << a[A][B]<<" ";
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n, k;
    bool d[10] = {false};
    cin >> n >> k;
    REP(i, k)
    {
        int tmp;
        cin >> tmp;
        d[tmp] = true;
    }

    int ans = n;
    while (true)
    {
        int tmp = ans;
        bool check = true;
        while (tmp > 0)
        {
            if (d[tmp % 10])
                check = false;

            tmp /= 10;
        }

        if (check)
        {
            cout << ans << endl;
            return 0;
        }

        ans++;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  if(a==b&&b!=c){
    puts("Yes");
  }else if(b==c&&c!=a){
    puts("Yes");
  }else if(c==a&&a!=b){
    puts("Yes");
  }else{
    puts("No");
  }
}

Measured memory_bytes: 1644
n = int(input())
original = list(map(int, input().split(" ")))
lengths = list(set(original))

count=0
lengths.sort()
for i in range(0, len(lengths)-2):
    a=original.count(lengths[i])
    for j in range(i+1,len(lengths)-1):
        b = original.count(lengths[j])
        for k in range(j+1,len(lengths)):
            if lengths[k]<lengths[i]+lengths[j]:
                c = original.count(lengths[k])
                count+=a*b*c

print(count)

Measured memory_bytes: 73368
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"

using namespace std;

int main()
{
	int a, b;
	cin >> a>> b;
	if (a == 2 || b == 2)
		cout << "No" << endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }


map<int,int> m;
const int limit = pow(10,5);
const ll mod = pow(10,9)+7;

int main() {
  int N;
  scanf("%d", &N);
  ll ans = 1;
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
    m[a[i]]++;
  }

  bool flug = true;

  if(N%2==0){
    FOR(i,1,limit){
      if(m[i]!=2 && m[i]!=0) flug = false;
    }
    if(flug == true){
      FOR(i,1,N/2){
        ans = ans*2%mod;
      }
      cout << ans << endl;
    }
    else cout << 0 << endl;
  }

  if(N%2!=0){
    if(m[0]!=1) flug = false;
    FOR(i,1,limit){
      if(m[i]!=2 && m[i]!=0) flug = false;
    }
    if(flug == true){
      FOR(i,1,(N-1)/2){
        ans = ans*2%mod;
      }
      cout << ans << endl;
    }
    else cout << 0 << endl;
  }
}



Measured memory_bytes: 5376
// 5/10 リアルタイム参加
#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>;
using Graph = vector<vector<int>>;

int A[15][15];
int C[15];
int N, M, X;

const int INF = 1000000009;

int dfs(int i, int sum_price, vector<int> rikai) {
    if (i == N) {
        bool b = true;
        for (auto v : rikai) {
            if (v < X) b = false;
        }

        if (b) return sum_price;
        else return INF;
    }

    // i番目の教科書を買わない場合
    int ans1 = dfs(i + 1, sum_price, rikai);

    // i番目の教科書を買う場合
    rep(j, M) {
        rikai[j] += A[i][j];
    }
    int ans2 = dfs(i + 1, sum_price + C[i], rikai);

    return min(ans1, ans2);
}

int main() {
    cin >> N >> M >> X;

    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }

    vector<int> rikai(M, 0);

    int ans = dfs(0, 0, rikai);

    if (ans != INF) {
        cout << ans << endl;
    } else {
        cout << "-1" << endl;
    }    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
const int mod=1e9+7;
using namespace std;
int main() {
	ll n,k,i,ans1,ans2,ans=0;
	cin>>n>>k;
	for (i=k;i<=n+1;i++) {
		ans1=(n+(n-i+1))*i/2;
		ans2=(0+i-1)*i/2;
		ans=(ans+ans1-ans2+1+mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int a,b,c,d,e,f,g,h,s,t;
int main()
{



	cin >> a >> b >> c >> d;
	cin >> e >> f >> g >> h;
	s = a+b+c+d;
	t = e+f+g+h;
	if(s > t){
		cout << s;
	}else{
		cout << t;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 3104
def read_input():
	n = int(input())
	alist = list(map(int, input().split()))
	
	return n, alist

	
def count_dividable_by_2(x):
	count = 0
	
	while x % 2 == 0:
		count += 1
		x /= 2
		
	return count
	
	
def submit():
	n, alist = read_input()

	blist = [count_dividable_by_2(x) for x in alist]
	print(sum(blist))	
	
submit()

Measured memory_bytes: 4148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int temp=1;
		for(int i=0;i<3;i++) {
			temp*=n;
		}
		System.out.println(temp);
	}

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main (){
	vector <int> tiempos;
	vector <pair <int, int> > bebidas;
	pair <int, int> pares;
	vector <long long> r;
	int n, t, m, p ,x; long long suma;
	cin >>n;
	for (int i=0;i<n;i++){
		cin >> t;
		tiempos.push_back(t);
	}
	cin >> m;
	for (int i=1; i<=m;i++){
		cin >>p >>x;
		suma =0;
		
		for (int i=0; i<n; i++){
			if (i+1 != p) {
				suma += tiempos[i];
			}
			else {
				suma += x;
			}
		}
		r.push_back(suma);
	}
	
	for (int i=0;i<m;i++){
		cout << r[i] <<endl;
	}
	
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n):
        s = min(a[i], b[i])
        a[i] -= s
        b[i] -= s
        cnt += s

        s = min(a[i+1], b[i])
        a[i+1] -= s
        b[i] -= s
        cnt += s
    print(cnt)


if __name__ == '__main__':
    slove()


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 100005;
const LL MOD = 1e9 + 7;

LL bigmod(LL b,LL p,LL m)
{
    LL ret = 1;
    while(p > 0){
        if(p % 2 == 1)ret = (ret * b) % m;
        p = p >> 1;
        b = (b * b) % m;
    }
    return ret;
}
int n , m;
int main()
{
    cin >> n >> m;

    int sq = sqrt(m);
    vector<pii>fac;
    for(int i = 2;i <= sq;i++){
        int cnt = 0;
        while(m % i == 0){
            cnt++;
            m/=i;
        }
        if(cnt > 0)fac.push_back(mk(i,cnt));
    }
    if(m > 1){
        fac.push_back(mk(m,1));
    }
    LL ret = 1;
    for(int i = 0;i < fac.size();i++){
        int up = n + fac[i].second - 1;
        int d1 = n - 1;
        int d2 = fac[i].second;
        LL ans = 1;
        for(int j = d1 + 1;j <= up;j++)ans = (ans * j) % MOD;
        for(int j = 1;j <= d2;j++)ans = (ans * bigmod(j,MOD-2,MOD)) % MOD;
        ret = (ret * ans) % MOD;
    }
    cout << ret << "\n";


}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int[] arr = new int[5];
        for(int i=0;i<5;i++){
            arr[i] = nextInt();
        }
        for(int i=0;i<5;i++){
            if(arr[i]==0){
                print(i+1);
                break;
            }
        }
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

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

using namespace std;

int main() {
    unsigned long long n, c, k;
    cin >> n >> c >> k;
    vector<unsigned long long> arrive_time(n);
    for (unsigned long long i = 0; i < n; ++i) cin >> arrive_time[i];
    sort(arrive_time.begin(), arrive_time.end());
    size_t num_bus = 0;
    unsigned long long passengers = 0;
    double start_time = .0;
    for(unsigned long long i = 0; i < n; ++i) {
        if (passengers == 0) {
            start_time = arrive_time[i];
            ++passengers;
            ++num_bus;
        }
        else if (arrive_time[i] - start_time <= k) {
            ++passengers;
        }
        else {
            start_time = arrive_time[i];
            passengers = 1;
            ++num_bus;
        }

        if (passengers == c) {
            passengers = 0;
        }
    }

    cout << num_bus << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl L(n);
    rep(i, n) 
    {
        cin >> L[i];
    }

    sort(rall(L));

    ll ans = 0;
    rep(i, k) {
        ans += L[i];
    }
        
    out(ans);
    re0;
}

Measured memory_bytes: 256