akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#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,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	int sum = 0;
	REP(i, n)sum += v[i] - 1;
	cout << sum << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
dst = list(map(int, input().split()))
log = [1]
log_set=set(log)
current = 1
for i in range(1, K+1):
    current = dst[current-1]
    if current in log_set:
        loop_start_ind = log.index(current)
        loop_len = i-loop_start_ind
        current = log[loop_start_ind+(K-i) % loop_len]
        break
    else:
        log.append(current)
        log_set.add(current)
print(current)

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

namespace kaijouA
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string adana = input.Substring(0, 3);
            Console.WriteLine(adana);

        }
    }
}


Measured memory_bytes: 25788
#include <stdio.h>
#define ll long long int
int main(void){
	ll a,b,c,max=0;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a+b < c)max = a+2*b+1;
	else max = b+c;
	printf("%lld",max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// 素数かどうかの判定
bool IsPrime(ll num){
    if(num<2) return false;
    else if(num==2) return true;
    else if(num%2==0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for(ll i=3; i<=sqrtNum; i+=2){
        if(num%i==0) return false;
    }
    return true;
}


signed main() {
	char a; cin>>a;
	int k = a-'a';
	if(0<=k&&k<=25) cout<<'a'<<endl;
	else cout<<'A'<<endl;
	return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<array>
#include<utility>

using namespace std;
int main(){
    int a[3] = {0,0,0},n,m;
    int s[5],c[5];
    bool flag[3] = {false,false,false},answer = true;
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        cin>>s[i]>>c[i];
        if(s[i] == 1 && c[i] == 0 && n != 1){answer = false;}
    }
    for(int i = 0; i < m; i++){
        if(flag[s[i]-1]){
            if(a[s[i]-1] != c[i]){
                answer = false;
                break;
            }
        }else{
            a[s[i]-1] = c[i];
            flag[s[i]-1] = true;
        }
    }
    if(!flag[0] && n != 1){a[0] = 1;}                                            if(answer){
        for(int i = 0; i < n; i++){
            cout<<a[i];
        }
        cout<<endl;
    }else{
        cout<<-1<<endl;
    }

}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())

    if H == 0 and W == 0:
        break

    for h in range(H):
        for w in range(W):
            if h % 2 == 0:
                if w % 2 == 0:
                    print('#', end="")
                else:
                    print('.', end="")
            else:
                if w % 2 != 0:
                    print('#', end="")
                else:
                    print('.', end="")
        print()
    print()



Measured memory_bytes: 7004
N, K = map(int, input().split())
d = dict(zip(range(1, N+1), [[] for i in range(N)]))

for i in range(K):
    dk = int(input())
    A = list(map(int, input().split()))
    for a in A:
        d[a].append(i)

ans = 0
for i in d:
    if d[i] == []:
        ans += 1

print(ans)

Measured memory_bytes: 9252
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll a, b;
    double k;
    cin >> a >> b;
    k = (a+b)/2.0;
    if (k == (a+b)/2) {
        cout << (ll)k << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	double ans = (n+1) / 2;
	ans /= (double)n;
	cout << setprecision(7) << ans;
	return 0;
}

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

typedef long long ll;

int main(void)
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum = 0;
    if(a == k)
        cout<<a<<"\n";
    else if(a > k)
        cout<<k<<"\n";
    else if(a+b >= k)
        cout<<a<<"\n";
    else
    {
        k = k - (a+b);
        cout<<a-k<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTP(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int v[3];
    for (int i = 0; i < 3; i++)
        cin >> v[i];
    cout << v[2] << ' ' << v[0] << ' ' << v[1];

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 256
def abc045_b():
    A,B,C = [input() for i in range(3)] #入力
    A = list(A)
    B = list(B)
    C = list(C)
    D = len(A) + len(B) + len(C)
    Var = A[0] #Aスタート
    for d in range(D):
        if Var == 'a' and len(A) == 0:
            print('A')
            break
        elif Var == 'a':
            Var = A[0]
            del A[0]
        elif Var == 'b' and len(B) == 0:
            print('B')
            break
        elif Var == 'b':
            Var = B[0]
            del B[0]
        elif Var == 'c' and len(C) == 0:
            print('C')
            break
        elif Var == 'c':
            Var = C[0]
            del C[0]
if __name__ == '__main__':
    abc045_b()

Measured memory_bytes: 9032
cookie = list(map(int, input().split()))
if cookie[1] == cookie[2] and cookie[0]==cookie[1]:
    if cookie[0] %2 == 1:
        print(0)
    else:
        print(-1)
else:
    count = 0
    a,b,c = cookie[0], cookie[1], cookie[2]
    while True:
        a,b,c = b+c, c+a, a+b
        if a%2==0 and b%2 == 0 and c%2 == 0:
             a,b,c = a//2, b//2, c//2
             count += 1
        else:
            print(count)
            break


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;
const int N=100050;

int gcd(int a,int b){
	if(!b)return a;
	return gcd(b,a%b);
}

int main(){
	
	int i,j,k,h,n,mx;
	scanf("%d%d%d",&n,&k,&j);
	for(i=1,mx=j;i<n;i++){
		scanf("%d",&h);
		if(h>mx)mx=h;
		j=gcd(j,h);
	}
	
	if(k>mx||k%j)puts("IMPOSSIBLE");
	else puts("POSSIBLE"); 

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader masae = new BufferedReader(new InputStreamReader(System.in));
	String masae2[] = masae.readLine().split(" ");
	int A = Integer.parseInt(masae2[0]);
	int B = Integer.parseInt(masae2[1]);
	if (A >= 13) {
	    System.out.println(B);
	} else if (A >= 6 && A <= 12) {
	    System.out.println(B / 2);
	} else if (A <= 5) {
	    System.out.println(0);
	}
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N+1);
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i+1]=B[i]+A[i];
  }
  vector<vector<int>> C(N,vector<int>(N,100000000000000000));
  for(int i=0;i<N;i++)
    C[i][i]=0;
  for(int i=1;i<N;i++){
    for(int j=0;j<N-i;j++){
      for(int k=0;k<i;k++)C[j][j+i]=min(C[j][j+i],C[j][j+k]+C[j+k+1][j+i]);
      C[j][j+i]+=B[j+i+1]-B[j];
    }
  }
  cout<<C[0][N-1]<<endl;
}

Measured memory_bytes: 4864
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var result float64
	for i := 1; i <= n; i++ {
		l := 0
		for j := i; j < k; l++ {
			j *= 2
		}
		result += float64(1) / float64(n) * math.Pow((float64(1)/float64(2)), float64(l))
	}
	fmt.Println(result)
}

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

int main() {
	int counter[26];
	int a = (int)'a';
	int A = (int)'A';
	char temp;

	for(int i=0; i<26; i++) counter[i] = 0;

	while(cin >> temp) {
		if(islower(temp)) counter[int(temp)-a]++;
		else if(isupper(temp)) counter[int(temp)-A]++;
	}

	for(int i=0; i<26; i++) cout << char(i+a) << " : " << counter[i] << endl;

	return 0;
}


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 200010;

int n;
pll v[MAXN];

int main()
{
	
	n = inp();
	for (int i = 1; i <= n; ++ i)
	{
		ll x = inp();
		ll y = inp();
		v[i] = pll(y, x);
	}
	sort(v+1, v+n+1);
	ll cur = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cur += v[i].Y;
		if (cur > v[i].X)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct point {
    double x, y;
};

void koch(int d, point a, point b) {
    point s, t, u;
    if(d == 0) return;
    s.x = (2*a.x + 1*b.x) / 3;
    s.y = (2*a.y + 1*b.y) / 3;
    t.x = (1*a.x + 2*b.x) / 3;
    t.y = (1*a.y + 2*b.y) / 3;
    u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y)*sin(M_PI/3) + s.x;
    u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y)*cos(M_PI/3) + s.y;

    cout << fixed;
    koch(d-1, a, s);
    cout << setprecision(8) << s.x << " " << s.y << endl;
    koch(d-1, s, u);
    cout << setprecision(8) << u.x << " " << u.y << endl;
    koch(d-1, u, t);
    cout << setprecision(8) << t.x << " " << t.y << endl;
    koch(d-1, t, b);
}

int main() {
    int n;
    cin >> n;
    point l={0, 0}, m={100, 0};
    cout << fixed;
    cout << setprecision(8) << l.x << " " << l.y << endl;
    koch(n, l, m);
    cout << setprecision(8) << m.x << " " << m.y << endl;
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    if(N%1000 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1000-N%1000 << endl;
    }
}


Measured memory_bytes: 3632
<?php
  fscanf(STDIN, "%s", $s);
  $len = (int)strlen($s);
  $count = 0;
  $array = str_split($s);
  for($i = 0; $i < $len; $i ++){
  	if($array[$i] !== $array[$len - $i -1]){
    	$array[$i] = $array[$len - $i -1];
        $count += 1 ;
    }
  }
  echo $count;
  ?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h, w, k, ans = 0; cin >> h >> w >> k;
	vector<string> grid(h);
	for(int i = 0; i < h; i++) cin >> grid[i];
	for(int i = 0; i < (1<<(h + w)); i++)
	{
		vector<string> tmp = grid;
		int j = 0, c = 0, ii = i;
		while(ii && j < h)
		{
			if(ii & 1) for(int k = 0; k < w; k++) tmp[j][k] = '.';
			ii /= 2;
			j++;
		}
		j = 0;
		while(ii && j < w)
		{
			if(ii & 1) for(int k = 0; k < h; k++) tmp[k][j] = '.';
			ii /= 2;
			j++;
		}
		for(int x = 0; x < h; x++) for(int y = 0; y < w; y++) c += tmp[x][y] == '#';
		ans += c == k;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3524
#python3
def main():
    n, k = map(int, input().split())
    s = input()
    sc = 0
    
    for i in range(n-1):
        if s[i] == s[i+1]:
            sc += 1
    ans = min(sc+2*k, n-1)
    print(ans)
main()


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs32 a(n); rep (i, n) cin >> a[i];

    int ans = 0;
    rep (i, n)
    {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1) ++ans;
    }

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



Measured memory_bytes: 3656
def day_dream? (text)
  words = ['dream', 'dreamer', 'erase', 'eraser']

  # 反転
  text.reverse!
  words = words.map(&:reverse)

  i = 0
  while i < text.size
    can2 = false
    for j in 0...words.size
      word = words[j]
      if text.slice(i, word.size) == word
        can2 = true
        i += word.size
      end
    end

    unless can2
      return false
    end
  end

  true
end

s = gets.chomp

puts day_dream?(s) ? 'YES' : 'NO'


Measured memory_bytes: 2044
#include<iostream>
#include<cstdio>
#include<sstream>
#include<map>
#include<algorithm>
#include<queue>

using namespace std;

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

int x[222];
string a[222], b[222];
map<string, int> mp;
int mem[222];

int main() {
  int n;
  string buf;
  stringstream ss;
  for (;;) {
    cin >> n;
    if (n == 0) break;
    rep (i, n) {
      cin >> buf;
      cin >> a[i];
      cin >> buf;
      cin >> buf;
      ss.clear();
      ss << buf.substr(3);
      ss >> x[i];
      cin >> b[i];
      a[n + i] = b[i];
      b[n + i] = a[i];
      x[n + i] = -x[i];
    }
    mp.clear();
    rep (i, 2 * n) mem[i] = 100000000;
    bool ok = true;
    int count = 0;
    rep (i, 2 * n) {
      if (mp.count(a[i]) == 0) {
	queue<pair<string, int> > que;
	que.push(make_pair(a[i], 0));
	while (!que.empty()) {
	  pair<string, int> now = que.front();
	  //cout << now.first << " " << now.second << endl;
	  que.pop();
	  if (mp.count(now.first)) {
	    if (mem[mp[now.first]] != now.second) ok = false;
	  } else {
	    mp[now.first] = count;
	    mem[count] = now.second;
	    ++count;
	    rep (i, 2 * n) if (a[i] == now.first) que.push(make_pair(b[i], now.second + x[i]));
	  }
	}
      }
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int sum = max({a, b, c});
	for(int i=0;i<k;i++)
		sum *= 2;

	cout << a + b + c - max({a, b, c}) + sum << endl;
}

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

int main()
{
    int a, b, c;
    int count = 0;

    cin >> a >> b >> c;

    for( int i = a; i <= b; i++)
    {
        if( c % i == 0 )
            count++;
    }

    cout << count << endl;


    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n;
  cin >> n;

  vector<ll> va(n);
  int neg_cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> va[i];
    neg_cnt += va[i] < 0;
  }

  sort(va.begin(), va.end());
  int i = 0;
  for (i = 0; i < (neg_cnt - neg_cnt % 2); i++) {
    va[i] *= -1;
  }

  if (neg_cnt % 2 == 1 && neg_cnt < va.size() &&
      abs(va[neg_cnt - 1]) > va[neg_cnt]) {
    va[neg_cnt - 1] *= -1;
    va[neg_cnt] *= -1;
  }

  ll sum = accumulate(va.begin(), va.end(), 0ll, plus<ll>());
  cout << sum << '\n';
  return 0;
}

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

using namespace std;

int main(void)
{
  int a[3][3];
  int* b;
  int n;
  
  for(int i=0;i<3;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  cin>>n;
  
  b=(int*)malloc(sizeof(int)*n);
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(a[j][k]==b[i]){
          a[j][k]=-1;
        }
      }
    }
  }
  /*
  for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        cout<<a[j][k]<<" ";
      }
    cout<<endl;
  }
  */  
  if((a[0][0]==-1)&&(a[0][1]==-1)&&(a[0][2]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[1][0]==-1)&&(a[1][1]==-1)&&(a[1][2]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[2][0]==-1)&&(a[2][1]==-1)&&(a[2][2]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[0][0]==-1)&&(a[1][0]==-1)&&(a[2][0]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[0][1]==-1)&&(a[1][1]==-1)&&(a[2][1]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[0][2]==-1)&&(a[1][2]==-1)&&(a[2][2]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[0][0]==-1)&&(a[1][1]==-1)&&(a[2][2]==-1)){cout<<"Yes"<<endl;return 0;}
  if((a[0][2]==-1)&&(a[1][1]==-1)&&(a[2][0]==-1)){cout<<"Yes"<<endl;return 0;}
 
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll ans;
int main()
{
	cin >> n;
	for (int i = 1; i <=n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
			continue;
		ans += (ll)i;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    for (int i = a; i <=b ; i++)
    {
        if(i%k==0)
        {
            cout<<"OK"; return 0;
        }
    }
    cout<<"NG";
}

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

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

    int i = 0, j = n-1;
    int ctr = 0;
    while(i < j){
        while(s[i] == 'R') i++;
        while(s[j] == 'W') j--;
        if(i < j) ctr++;
        i++;
        j--;
    }
    cout << ctr << endl;
    
    return 0;
}

Measured memory_bytes: 3704
N = int(input())
M = 0
A = 0
R = 0
C = 0
H = 0

for _ in range(N):
  tmp = input()[0]
  if tmp == "M":
    M += 1
  elif tmp == "A":
    A += 1
  elif tmp == "R":
    R += 1
  elif tmp == "C":
    C += 1
  elif tmp == "H":
    H += 1

ans = 0
ans += M * A * C
ans += M * A * R
ans += M * A * H
ans += M * R * C
ans += M * R * H
ans += M * C * H
ans += A * R * C
ans += A * R * H
ans += A * C * H
ans += R * C * H

print(ans)

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

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  if (A[A.length()-1] == B[0] && B[B.length()-1] == C[0]) {
    cout << "YES";
  }
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll product = 0;
    rep(i, N) product = product ^ a[i];

    // cout << product << endl;

    ll ans;
    rep(i, N-1){
        ll ans = product ^ a[i];
        cout << ans << " ";
    }
    ans = product ^ a[N-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define max(a,b) (a)>=(b)? (a) : (b) 
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;


int main() {
	Ill(a);
	Ill(b);
	Ill(c);
	Ill(x);
	Ill(y);
	
	if(2*c>=(a+b))std::cout << a*x+b*y;
	else { if(x>y)
	{
		if(c*2<a)std::cout << 2*x*c;
		else { std::cout << c*2*y+(x-y)*a; }

	}
		else
		{
			if (c * 2<b)std::cout << 2 * y*c;
			else { std::cout << c * 2 * x + (y - x)*b; }
		}
	}
}






Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
typedef long long lld;
typedef std::vector<int> vin;
const int MAXN = 1e5+5;
enum Dir { PREV=0, NEXT=1 };
int P[MAXN];
int one[MAXN][2]; // 1st Greater [Prev, Next]
int two[MAXN][2]; // 2nd Greater [Prev, Next]
std::map<int,int> SS;
vin S;
int N;

void init() {
  int val[] = { 0, N+1 };
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < 2; ++j) {
      one[i][j] = two[i][j] = val[j];
    }
  }
}

void one_greater(Dir d, int i) {
  while (!S.empty()) {
    int k = S.back();
    if (P[k] > P[i]) break;
    one[k][d] = i;
    SS[P[k]] = k;
    S.pop_back();
  }
}

void two_greater(Dir d, int i) {
  while (!SS.empty()) {
    int k = SS.begin()->first;
    if (k > P[i]) break;
    two[SS.at(k)][d] = i;
    SS.erase(k);
  }
}

void next_greater() {
  S.clear();
  SS.clear();
  for (int i = 1; i <= N; ++i) {
    two_greater(NEXT, i);
    one_greater(NEXT, i);
    S.push_back(i);
  }
}

void prev_greater() {
  S.clear();
  SS.clear();
  for (int i = N; i >= 1; --i) {
    two_greater(PREV, i);
    one_greater(PREV, i);
    S.push_back(i);
  }
}

lld solve() {
  lld res = 0LL;
  for (int i = 1; i <= N; ++i) {
    // Include next / prev element greater than P[i]
    res += 1LL * P[i] * (two[i][NEXT] - one[i][NEXT]) * (i - one[i][PREV]);
    res += 1LL * P[i] * (one[i][NEXT] - i) * (one[i][PREV] - two[i][PREV]);
  }
  return res;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &P[i]);
  }
  init();
  next_greater();
  prev_greater();
  printf("%lld\n", solve());
  return 0;
}

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

int main(){
  int sum,a,b,c,d,e,h,k;
  vector<int> ve[6];
  while(1){
    cin>>h;
    if(h==0)break;
    ve[1].clear();
    ve[2].clear();
    ve[3].clear();
    ve[4].clear();
    ve[5].clear();
    for(int i=1;i<=h;i++){
      cin>>a>>b>>c>>d>>e;
      ve[1].push_back(a);
      ve[2].push_back(b);
      ve[3].push_back(c);
      ve[4].push_back(d);
      ve[5].push_back(e);
    }
    reverse(ve[1].begin(),ve[1].end());
    reverse(ve[2].begin(),ve[2].end());
    reverse(ve[3].begin(),ve[3].end());
    reverse(ve[4].begin(),ve[4].end());
    reverse(ve[5].begin(),ve[5].end());
    for(int i=0;i<h;i++){
      ve[1].push_back(-1);
      ve[2].push_back(-1);
      ve[3].push_back(-1);
      ve[4].push_back(-1);
      ve[5].push_back(-1);
    }
    //for(int i=0;i<h;i++)cout<<ve[1][i];
    sum=0;
    while(1){
      k=0;
      for(int i=h-1;i>=0;i--){
	if(ve[1][i]==ve[2][i]&&ve[1][i]==ve[3][i]&&ve[1][i]==ve[4][i]&&ve[1][i]==ve[5][i]&&ve[3][i]!=-1){
	  sum+=ve[3][i]*5;
	  ve[1].erase(ve[1].begin()+i);
	  ve[2].erase(ve[2].begin()+i);
	  ve[3].erase(ve[3].begin()+i);
	  ve[4].erase(ve[4].begin()+i);
	  ve[5].erase(ve[5].begin()+i);
	  k++;
	}else if(ve[1][i]==ve[2][i]&&ve[1][i]==ve[3][i]&&ve[1][i]==ve[4][i]&&ve[3][i]!=-1){
	  sum+=ve[3][i]*4;
	  ve[1].erase(ve[1].begin()+i);
	  ve[2].erase(ve[2].begin()+i);
	  ve[3].erase(ve[3].begin()+i);
	  ve[4].erase(ve[4].begin()+i);
	  k++;
	}else if(ve[2][i]==ve[3][i]&&ve[2][i]==ve[4][i]&&ve[2][i]==ve[5][i]&&ve[3][i]!=-1){
	  sum+=ve[3][i]*4;
	  ve[2].erase(ve[2].begin()+i);
	  ve[3].erase(ve[3].begin()+i);
	  ve[4].erase(ve[4].begin()+i);
	  ve[5].erase(ve[5].begin()+i);
	  k++;
	}else if(ve[1][i]==ve[2][i]&&ve[1][i]==ve[3][i]&&ve[3][i]!=-1){
	  sum+=ve[3][i]*3;
	  ve[1].erase(ve[1].begin()+i);
	  ve[2].erase(ve[2].begin()+i);
	  ve[3].erase(ve[3].begin()+i);
	  k++;
	}else if(ve[2][i]==ve[3][i]&&ve[2][i]==ve[4][i]&&ve[3][i]!=-1){
	  sum+=ve[3][i]*3;
	  ve[2].erase(ve[2].begin()+i);
	  ve[3].erase(ve[3].begin()+i);
	  ve[4].erase(ve[4].begin()+i);
	  k++;
	}else if(ve[3][i]==ve[4][i]&&ve[3][i]==ve[5][i]&&ve[3][i]!=-1){
	  sum+=ve[3][i]*3;
	  ve[3].erase(ve[3].begin()+i);
	  ve[4].erase(ve[4].begin()+i);
	  ve[5].erase(ve[5].begin()+i);
	  k++;
	}
      }
      if(k==0)break;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
    ll n,ans=0;
    string s;
    cin >> n >> s;
    for (ll i=0;i<10;i++){
        for (ll j=0;j<10;j++){
            for (ll k=0;k<10;k++){
                char a[3];
                a[0]='0'+i;
                a[1]='0'+j;
                a[2]='0'+k;
                ll c=0;
                for (ll l=0;l<s.size();l++){
                    if (a[c]==s[l]){
                        a[c]='0'-1;
                        c++;
                    }
                }
                bool f=true;
                for (ll l=0;l<3;l++){
                    if (a[l]!='0'-1)f=false;
                }
                if (f)ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}    


Measured memory_bytes: 3656
n = int(input())
h = list(map(int, input().split()))

up = 0
flag = 1
for i in range(n-1):
    ma = h[i]+up
    if ma<=h[i+1]:
        up = 0
    elif ma<=h[i+1]+1:
        up = 1
    else:
        flag = 0
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define T ll t = 1; cin>>t; while(t--)
#define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
#define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
#define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
#define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
#define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
#define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
#define F first
#define S second
#define I insert
#define pb push_back
#define ppb pop_back
#define AISORT sort(a,a+n)
#define ADSORT sort(a,a+n,greater<ll>())
#define VISORT sort(x.begin(),x.end())
#define VDSORT sort(x.begin(),x.end(),greater<ll>())

const ll maxs = 3e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
inline ll add(ll a, ll b) {
    return (mod + a + b) % mod;
}
inline ll sub(ll a, ll b) {
    return (a - b + mod) % mod;
}
inline ll mul(ll a, ll b) {
    return (1ll * a * b) % mod;
}

//POWER
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if(y & 1)
            res = (res * x) % mod; 
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

//MODULAR INVERSE
ll inv(ll x) {
    return fastpow(x, mod - 2);
}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
bool vis[maxs];
vector < ll > graph[maxs];
//ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
//ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin >> s >> t;
    ll flg = 0;
    for(ll i = 0;i < s.size();++i)
    {
        if(s[i] != t[i])
        {
            flg = 1;
            break;
        }
    }
    
    if(flg)
        cout << "No";
    else
        cout << "Yes";
}



Measured memory_bytes: 10680
#include <stdio.h>
#include <string.h>

int main()
{
    int n,m,p,i,j,ac[100000] = {0},wa[100000] = {0},pena_num = 0,ac_num = 0;
    char s[3];

    scanf("%d %d",&n,&m);
    for (i = 0; i < m; i++)
    {
        scanf("%d %s",&p,s);
        if(ac[p - 1] == 0)
        {
            if(strcmp(s,"AC") == 0)
            {
                ac[p - 1] = 1;
            }
            else
            {
                wa[p - 1]++;
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        if(ac[i] == 1)
        {
            ac_num++;
            pena_num += wa[i];
        }
    }
    
    printf("%d %d",ac_num,pena_num);
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, ans;
    cin >> N;

    string S;
    int P;
    vector<pair<pair<string, int>, int>> res(N);

    for (int i = 0; i < N; i++)
    {
        cin >> S >> P;
        res.at(i) = make_pair(make_pair(S, -P), i);
    }

    sort(res.begin(), res.end());

    for(int i =0; i<N;i++){
        /*
        tie(S, P, ans) = res.at(i);
        cout << S << " " << P << " "  << ans << endl;
        */
       cout << res.at(i).second +1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
M=10**9+7
m=2*n
fact=[1]*(m+1)
ifact=[1]*(m+1)
r=1
for i in range(1,m+1):fact[i]=r=r*i%M
ifact[m]=r=pow(fact[m],M-2,M)
for i in range(m,0,-1):ifact[i-1]=r=r*i%M
r=pow(a+b,M-2,M) 
p=0
d=b*r%M
e=1
for k in range(n):
    v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M
    e=e*d%M
    p+=v
p*=pow(a*r%M,n,M)*100*r%M
q=0
d=a*r%M
e=1
for k in range(n):
    v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M
    e=e*d%M
    q+=v
q*=pow(b*r%M,n,M)*100*r%M
print((p+q)%M)

Measured memory_bytes: 43996
# coding: utf-8

N, M= (int(x) for x in input().split())

pS = [[] for x in range(M)]
for i in range(M):
	p, S = input().split()
	pS[i] = [int(p), S]

check = [[0, False] for x in range(N)]

for ps in pS:
	if ps[1] == "WA":
		if check[ps[0] - 1][1] == False:
			check[ps[0] - 1][0] += 1
	else: # "AC"
		check[ps[0] - 1][1] = True

ans = 0
penalty = 0
for c in check:
	if c[1] == True:
		ans += 1
		penalty += c[0]

print(str(ans) + " " + str(penalty))


Measured memory_bytes: 32176
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;

typedef long long ll;

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

    ll cake[n][3];
    for(int i = 0; i < n; i++){
        cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
    }

    ll ans = LLONG_MIN;

    for(int i = 0; i < 8; i++){
        ll score[n] = {};
        for(int j = 0; j < n; j++){
            if(i & 1 == 1)      score[j] += cake[j][0];
            else                score[j] -= cake[j][0];
            if(i/2 & 1 == 1)    score[j] += cake[j][1];
            else                score[j] -= cake[j][1];
            if(i/4 & 1 == 1)    score[j] += cake[j][2];
            else                score[j] -= cake[j][2];
        }

        sort(score, score+n);
        reverse(score, score+n);

        ll can = 0;
        for(int i = 0; i < m; i++)  can += score[i];

        ans = max(can, ans);
    }

    cout << abs(ans) << endl;

    return 0;
}

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

struct abc{
  int first;
  int last;
};

int main(){
  int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  vector <abc> a(Q);
  for(int i=0;i<Q;i++)
    cin>>a[i].first>>a[i].last;
  vector <int> count(N);
  int k=0;
  count[0]=0;
  for(int n=1;n<N;n++){
    count[n]=0;
    if((S[n-1]=='A')&&(S[n]=='C')){
      k++;
      count[n]=k;
    }
    else{
      count[n]=k;
    }
  }

  vector <int> ans(Q);

  for(int i=0;i<Q;i++){
    ans[i]=(count[a[i].last-1]-count[a[i].first-1]);
  }
  for(int j=0;j<Q;j++){
    cout<<ans[j]<<endl;
  }
  return 0;
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

typedef bitset<128> bset;
namespace std{
	bool operator<(const bset& a,const bset& b){
		rep(i,a.size()) if(a[i]!=b[i]) return a[i]<b[i];
		return false;
	}
	bool operator>(const bset& a,const bset& b){
		rep(i,a.size()) if(a[i]!=b[i]) return a[i]>b[i];
		return false;
	}
}

int solve(const vs& ss,bset mask,map<bset,int>& memo)
{
	if(memo.count(mask)) return memo[mask];
	if(mask.count()==1) return memo[mask]=0;
	
	int n=ss.size(),m=ss[0].size();
	int res=INF;
	rep(i,m){
		bset b;
		rep(j,n) if(mask[j] && ss[j][i]=='1') b[j]=1;
		if(b.none() || b==mask) continue;
		res=min(res,1+max(solve(ss,b,memo),solve(ss,mask^b,memo)));
	}
	return memo[mask]=res;
}

int main()
{
	for(int m,n;cin>>m>>n && m|n;){
		vs ss(n);
		rep(i,n) cin>>ss[i];
		
		map<bset,int> memo;
		cout<<solve(ss,bset(string(n,'1')),memo)<<endl;
	}
}

Measured memory_bytes: 2316
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1e5;
const int base=1e8;
const int limit=8;
char S[500008];

ll read()
{
    ll x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

struct Bignum
{
    int v[maxn+8],len;
    void clear(){len=1,memset(v,0,sizeof(v));}
    void read()
    {
	scanf("%s",S);int n=strlen(S),now;
	reverse(S,S+n);len=-1;
	for (int i=0;i<n;i++)
	    {
		if (i%limit==0) len++,now=1;
		v[len]+=now*(S[i]-'0');
		now*=10;
	    }
	len++;
    }
    void write()
    {
	printf("%d",v[len-1]);
	for (int i=len-2;~i;i--) printf("%0*d",limit,v[i]);
	puts("");
    }
    int num()
    {
	int tmp=0;
	for (int i=0;i<len;i++)
	    for (int j=0,now=1;j<limit;j++,now*=10)
		tmp+=v[i]/now%10;
	return tmp;
    }
}A;

Bignum operator +(Bignum x,int y)
{
    Bignum z=x;
    z.v[0]+=y;
    for (int i=0;z.v[i]>=base;i++,z.len=max(z.len,i+1)) z.v[i+1]+=z.v[i]/base,z.v[i]%=base;
    return z;
}

Bignum operator *(Bignum x,int y)
{
    Bignum z;z.len=x.len+1;
    for (int i=0;i<=z.len;i++) z.v[i]+=x.v[i]*y,z.v[i+1]+=z.v[i]/base,z.v[i]%=base;
    while(z.len>1&&z.v[z.len]==0) z.len--;
    while(z.v[z.len]) z.v[z.len+1]+=z.v[z.len]/base,z.v[z.len++]%=base;
    return z;
}

bool check(int x)
{
    Bignum z=A+(9*x);
    //printf("check:%d %d\n",9*x,z.num());
    //z.write();
    return z.num()<=9*x;
}
int main()
{
    A.read();
    A=A*9;
    int l=1,r=500000,ans;
    while(l<=r)
	{
	    int mid=(l+r)>>1;
	    if (check(mid)) ans=mid,r=mid-1;
	    else l=mid+1;
	}
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2176
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long arr[] = new long[n], xor = 0;
		
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
			xor ^= i < 2 ? 0 : arr[i];
		}
		
		long sum = arr[0] + arr[1];
		long and = (sum - xor) >> 1;
		long a = 0, b = 0;
		
		for(int i = 60; i >= 0; i--) {
			boolean xi = (xor & (1L << i)) > 0;
			boolean ai = (and & (1L << i)) > 0;
			
			if(!xi && ai) {
				a |= 1L << i;
				b |= 1L << i;
			}
		}
		
		
		for(int i = 60; i >= 0; i--) {
			boolean xi = (xor & (1L << i)) > 0;
			boolean ai = (and & (1L << i)) > 0;
			
			if(xi && !ai) {
				if((a | 1L << i) <= arr[0]) {
					a |= 1L << i;
				}else {
					b |= 1L << i;
				}
			}
		}
		
		boolean flag = (a + b) == sum && (a ^ b) == xor;
		flag &= a >= 1 && a <= arr[0] && b >= arr[1];
		
		out.println(flag ? arr[0] - a : -1);
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 32892
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k;
	int n;
	string s;
	cin>>n>>s;
	stack<char>st;
	int temp=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='(')
			st.push(s[i]);
		else
		{
			if(st.size()>0)
				st.pop();
			else
			{
				temp++;
			}
		}
	}
	while(!st.empty())
	{
		st.pop();
		s+=')';
	}
	while(temp--)
	{
		s='('+s;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String c1 = sc.next();
        String c2 = sc.next();

        System.out.println(solve(c1, c2) ? "YES" : "NO");

        sc.close();
    }

    static boolean solve(String c1, String c2) {
        return c1.equals(new StringBuilder(c2).reverse().toString());
    }
}

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

int main()
{
  int d;
  cin >> d;
  if(d == 25){
      cout << "Christmas" << endl;
  }else if(d == 24){
      cout << "Christmas Eve " << endl;
  }else if(d== 23){
      cout << "Christmas Eve Eve" << endl;
  }else if(d == 22){
      cout << "Christmas Eve Eve Eve  " << endl;
  }
    
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	REP(i, a) {
		REP(q, b) {
			string c;
			cin >> c;
			if (c == "snuke") {
				cout << (char)('A' + q) << i + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main() {
    int n, k; cin >> n >> k;
    int h[n + k + 1];
    for (int i = 0; i < n; i++) cin >> h[i];
    ll dp[n + k + 1];
    for (int i = 0; i < n + k + 1; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <map>

using namespace std;

int main(void) {
  long N;
  cin >> N;

  map<long, long> pool;

  for (long i = 1; i <= N; i++) {
    long tmp = i;
    long divider = 2;
    while (tmp > 1) {
      if (tmp % divider == 0) {
        tmp /= divider;
        pool[divider]++;
      } else {
        divider++;
      }
    }
  }

  long ans = 0;

  for (auto it : pool) {
    if (it.second >= 74) ans++;
  }

  for (auto it1: pool) {
    for (auto it2: pool) {
      if (it1.first != it2.first and it1.second >= 4 and it2.second >= 14) ans++;
    }
  }

  for (auto it1: pool) {
    for (auto it2: pool) {
      if (it1.first != it2.first and it1.second >= 2 and it2.second >= 24) ans++;
    }
  }

  for (auto it1: pool) {
    for (auto it2: pool) {
      for (auto it3: pool) {
        if (it1.first != it2.first and it1.first != it3.first and it2.first != it3.first and it2.first > it3.first and it1.second >= 2 and it2.second >= 4 and it3.second >= 4) ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long lli;
lli n;
vector<bool> ex;
lli c,k;
int main(int argc, char const *argv[]) {
    cin >> n;
    ex = vector<bool> (100001);
    for(lli i = 0;i < n;i++){
        lli a;
        cin >> a;
        if(ex[a]) c++;
        else ex[a] = true,k++;
    }
    cout << (c%2?k-1:k) << endl;
    return 0;
}


Measured memory_bytes: 256