akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX=51;

int main(){
    int N;
    cin >> N;
    vector<int> a(N),b(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,N){
        if (b[i]!=a[i]&&b[i]>(a[i]-1)/2){
            cout << -1 << endl;
            return 0;
        }
    }
    bool same=true;
    rep(i,N) if (a[i]!=b[i]) same=false;
    if (same){
        cout << 0 << endl;
        return 0;
    }
    vector<int> candidate;
    ll ans=0;
    for (int i=50;i>=0;--i){
        vector<vector<bool>> G(MAX,vector<bool>(MAX,false));
        rep(i,MAX) G[i][i]=true;
        for (auto x:candidate){
            rep(j,MAX){
                rep(k,MAX){
                    if (G[j][k]) G[j][k%x]=true;
                }
            }
        }
        for (int x=i;x>0;--x){
            rep(j,MAX){
                rep(k,MAX){
                    if (G[j][k]) G[j][k%x]=true;
                }
            }
        }
        rep(j,N){
            if (!G[a[j]][b[j]]){
                candidate.push_back(i+1);
                ans|=1LL<<i+1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll ans = 0, n, k;std::cin >> n >> k;
  vll a(n);
  init();
  re(i, n) std::cin >> a[i];
  sort(all(a));
  for(int i=0;i<n;i++){
    if(n-1-i<k-1) continue;
    ll r = (abs(a[i])*comb(n-1-i, k-1))%P;
    if(a[i]<0) ans = (ans + r)%P;
    else ans = (ans - r + P)%P;
  }
  reverse(all(a));
  for(int i=0;i<n;i++){
    if(n-1-i<k-1) continue;
    ll r = (abs(a[i])*comb(n-1-i, k-1))%P;
    if(a[i]<0) ans = (ans - r + P)%P;
    else ans = (ans + r)%P;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 47872
import sys

def main():
    N = int(input())
    W = list(map(int, input().split()))
    min_diff = sys.maxsize
    for i in range(1, N+1):
        diff = abs(sum(W[:i]) - sum(W[i:]))
        if diff < min_diff:
            min_diff = diff
    print(min_diff)


if __name__ == '__main__':
    main()


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

typedef long long ll;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];
int siz[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
        siz[i] = 1;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int s = siz[x] + siz[y];
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    siz[find(x)] = s;
}

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

int size(int x) {
    return siz[find(x)];
}

int main() {
    ll N, M, x, y;
    cin >> N >> M;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    init(N);
    rep(i, M) {
        cin >> x >> y;
        unite(x, y);
    }
    ll c = 0;
    vector<vector<ll>> b(N);
    rep(i, N) {
        if (find(i) == i) c++;
        b[find(i)].push_back(a[i]);
    }
    if ((c - 1) * 2 > N) {
        cout << "Impossible\n";
        return 0;
    }
    if (c == 1) {
        cout << "0\n";
        return 0;
    }
    ll ans = 0;
    vector<ll> v;
    rep(i, N) {
        if (b[i].size() == 0) continue;
        sort(b[i].begin(), b[i].end());
        ans += b[i][0];
        rep(j, b[i].size() - 1) {
            v.push_back(b[i][j + 1]);
        }
    }
    sort(v.begin(), v.end());
    rep(i, (c - 1) * 2 - c) {
        ans += v[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 7680
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <numeric>
#include <cassert>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef vector<PII > VPII;
typedef vector<VPII> VVPII;

#define FOR(k,a,b) for(int k(a); k < (b); ++k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define ABS(a) ((a)>0?(a):-(a))

long double calcDist(LL x, LL y, LL r, LL x2, LL y2, LL r2)
{
	LL d = (x - x2)*(x - x2) + (y - y2)*(y - y2);
	long double res = sqrt((long double) d);
	return max<long double>(res - r - r2,0);
}

int main(int argc, char** argv) {
#ifdef HOME
	freopen("in.txt", "rb", stdin);
	freopen("out.txt", "wb", stdout);
#endif
	int x1, x2, y1, y2, N;
	scanf("%d %d %d %d %d", &x1, &y1, &x2, &y2,&N);
	vector<int> x(N+2), y(N+2), r(N+2);
	REP(i, N)
	{
		scanf("%d %d %d", &x[i], &y[i], &r[i]);
	}
	x[N] = x1, y[N] = y1, x[N + 1] = x2, y[N + 1] = y2;
	vector<vector<long double > > dist(N + 2,vector<long double>(N+2) );
	REP(i, N+2) REP(j,N+2)
	{
		dist[i][j] = calcDist(x[i], y[i], r[i], x[j], y[j], r[j]);
	}
	const long double INF = 1e11;
	vector<long double> d(N+2,INF);
	set<pair<long double, int > > Q;
	d[N] = 0;
	Q.insert(make_pair(0, N));
	while(!Q.empty())
	{
		long double actd = Q.begin()->first;
		int act = Q.begin()->second;
		Q.erase(Q.begin());
		REP(i, N + 2)
		{
			long double nd = actd + dist[act][i];
			if (d[i] > nd)
			{
				if (d[i] != INF)
				{
					Q.erase(make_pair(d[i], i));
				}
				d[i] = nd;
				Q.insert(make_pair(nd, i));
			}
			
		}
	}
	printf("%.11Lf\n", d[N + 1]);
	return 0;
}

Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#define inf 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  string n;
  std::cin >> n;
  std::cout << (n[0] == '9' || n[1] == '9' ? "Yes" : "No") << '\n';

  return;
}

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

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto s = readln.chomp;
  auto p = ["dreamer", "dream", "eraser", "erase"];
  int i = s.length.to!int;
  a:while (i > 0) {
    foreach (e; p) {
      if (e.length > i) {
        continue;
      }

      if (s[i-e.length..i] == e) {
        i -= e.length;
        continue a;
      }
    }
    break a;
  }

  if (i == 0) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 2428
#include <iostream>
    #define int long long
    #define MOD 1000000007
    using namespace std;
     
    signed main(){
    	int n,c,dp[401][401] = {},pow[401][401] = {};
    	for(int i = 0;i <= 400;i++){
    		int tmp = 1;
    		for(int j = 0;j <= 400;j++){
    			pow[i][j] = tmp;
    			tmp = tmp * i % MOD;
    		}
    	}
    	for(int i = 0;i <= 400;i++){
    		for(int j = 1;j <= 400;j++) pow[j][i] = (pow[j][i] + pow[j - 1][i]) % MOD;
    	}
    	cin >> n >> c;
    	dp[0][0] = 1;
    	int a[400],b[400];
    	for(int i = 0;i < n;i++) cin >> a[i];
    	for(int i = 0;i < n;i++) cin >> b[i];
    	for(int i = 0;i < n;i++){
    		for(int j = 0;j <= c;j++){
    			for(int k = 0;k <= j;k++){
    				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - k] * (pow[b[i]][k] - pow[a[i] - 1][k] + MOD)) % MOD;
    			}
    		}
    	}
    	cout << dp[n][c] << endl;
    }

Measured memory_bytes: 2816
from math import*
n=factorial(int(input()))

def dv(n):
    if n==1:
        return 1
    divisorsNum=1
    i=2
    while i*i<=n:
        cnt=1
        while n%i==0:
            cnt+=1
            n//=i
        divisorsNum*=cnt
        i+=1
    return divisorsNum*2
mod=(10**9+7)
print(dv(n)%mod)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){
    ll x,y;
    cin >> x >> y;
    rep(i,0,1000){
        if(i > x) break;
        if(2*(x-i)+4*i == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, T;
  cin >> n >> T ;
  const int INF = 10005;
  int mcost = INF;

  REP(i,n){
    int c, t;
    cin >> c >> t;
    if(t > T) continue;

    mcost = min(mcost, c);
  }

  if(mcost == INF){
    cout << "TLE" << endl;
    return 0;
  }

  cout << mcost << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <time.h>
#pragma comment (linker, "/STACK:200000000")
#define ll long long
#define mod 1000000007ll
#define maxn 1000000ll
using namespace std;


//fstream cin("input.txt"); ofstream cout("output.txt");
//fstream cin("hobby.in"); ofstream cout("hobby.out");
ll gcd(ll a, ll b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	map<int, bool> m;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (m[a] == 0) m[a] = 1;
		else m[a] = 0;
	}
	int k = 0;
	for (auto i : m) {
		if (i.second == 1) {
			k++;
		}
	}
	cout << k;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int arr[100005],dp[100005];
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++) {
            cin >> arr[i];
            dp[i]=1000000000;
    }
    dp[0]=0;
    for(int i=1;i<n;i++) {
            //cout <<i<<endl;
            for(int j=1;j<=min(i,k);j++) {
                    dp[i]=min(dp[i],min(dp[i-j]+abs(arr[i-j]-arr[i]),dp[i-j]+abs(arr[i-j]-arr[i])));
                    //cout<<dp[i]<<endl;
            }
            //cout <<endl;
            //cout<<dp[i]<<endl;
    }
    cout <<dp[n-1];
    //cin >> n;
    return 0;
}
    
    


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

using namespace std;

#define INF 1e9

int w,h,sy,sx,gy,gx;
int field[30][30];
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};

bool contain(int y,int x){
    return (0<=y && y<h && 0<=x && x<w);
}

int solve(int y,int x,int T,int F[30][30]){
    if(T>10)return T;

    int res=INF;

    for(int i=0;i<4;i++){
        int ny=y+dy[i],nx=x+dx[i];

        if(F[ny][nx]==1 || !contain(ny,nx))continue;

        bool f=false,c=false;

        while(1){
            ny+=dy[i];nx+=dx[i];

            if(ny-dy[i]==gy && nx-dx[i]==gx){
                c=true;
                break;
            }
            if(!contain(ny,nx))break;
            if(F[ny][nx]==1){
                F[ny][nx]=0;
                f=true;
                break;
            }
        }

        if(!f && !c)continue;

        ny-=dy[i];nx-=dx[i];

        if(ny==gy && nx==gx)res=T+1;
        else res=min(res,solve(ny,nx,T+1,F));

        if(f)F[ny+dy[i]][nx+dx[i]]=1;

    }

    return res;

}

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

    while(1){
        cin>>w>>h;

        if(w==0)break;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>field[i][j];

                if(field[i][j]==2){
                    sy=i;sx=j;
                }
                if(field[i][j]==3){
                    gy=i;gx=j;
                }
            }
        }

        int ans=solve(sy,sx,0,field);
        if(ans>10)ans=-1;

        cout<<ans<<endl;

    }

}


Measured memory_bytes: 3136
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc119/editorial.pdf
・前計算しないで直接やる版
・INFがfloat('inf')だとダメで10**18にしたらいけた。INF-INFがnanになるからだった。
・上記を考慮して修正版
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B,Q=MAP()

S=[-INF]*(A+2)
for i in range(A):
    S[i+1]=INT()
T=[-INF]*(B+2)
for i in range(B):
    T[i+1]=INT()
S[-1]=T[-1]=INF

for i in range(Q):
    dist1=dist2=dist3=dist4=INF
    x=INT()
    # 地点xから左に一番近い神社
    idx1=bisect_right(S, x)-1
    # 右に一番近い神社
    idx2=bisect_left(S, x)
    idx3=bisect_right(T, x)-1
    idx4=bisect_left(T, x)
    # idx1番目の神社に行く
    dist1=x-S[idx1]
    # idx1番目の神社から、xから右か左に一番近かった寺に行く
    if dist1!=INF: dist1+=min(abs(S[idx1]-T[idx3]), abs(S[idx1]-T[idx4]))
    dist2=S[idx2]-x
    if dist2!=INF: dist2+=min(abs(S[idx2]-T[idx3]), abs(S[idx2]-T[idx4]))
    dist3=x-T[idx3]
    if dist3!=INF: dist3+=min(abs(T[idx3]-S[idx1]), abs(T[idx3]-S[idx2]))
    dist4=T[idx4]-x
    if dist4!=INF: dist4+=min(abs(T[idx4]-S[idx1]), abs(T[idx4]-S[idx2]))
    print(min(dist1, dist2, dist3, dist4))


Measured memory_bytes: 14500
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] level = new int[n];
        int count = 1;
        int min = 0;
        for (int i = 0; i < n; i++) {
            level[i] = input.nextInt();
            if (i == 0) {
                min = level[0];
            } else {

                if (level[i] <= min) {
                    count++;
                    min = level[i];
                }
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 65988
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	N, K := readInt2()
	H := readIntArray(N)
	sort.Ints(H)

	if len(H) <= K {
		fmt.Println(0)
		return
	}

	normal := big.NewInt(0)
	for _, h := range H[:len(H)-K] {
		normal.Add(normal, big.NewInt(int64(h)))
	}

	fmt.Println(normal.String())

}


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

div=10**9+7
def po(x,n,M):
    res=1
    if n>0:
        
        res= po(x,n//2,M)
    if n%2==0:
        res=(res*res)%M
    else:
        res=(((res*res)%M)*x)%M
        
      
    return res

print(po(m,n,div))


Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int size = in.nextInt();
		int[] heap = new int[size + 1];
		for (int i = 1; i < size + 1; i++) {
			heap[i] = in.nextInt();
		}
		StringBuilder sb = new StringBuilder();
		Main.buildMaxHeap(heap);
		for (int i = 1; i < size + 1; i++) {
			sb.append(" ").append(heap[i]);
		}
		System.out.println(sb.toString());
		
	}
	
	
	
	public static void maxHeapify(int[] A, int i) {
		int l = left(i);
		int r = right(i);
		int largest;
		if (l < A.length && A[l] > A[i]) {
			largest = l;
		}
		else {
			largest = i;
		}
		
		if (r < A.length && A[r] > A[largest]) {
			largest = r;
		}
		
		if (largest != i) {
			int temp = A[i];
			A[i] = A[largest];
			A[largest] = temp;
			maxHeapify(A, largest);
		}
	}
	
	public static void buildMaxHeap(int[] A) {
		for (int i = (A.length - 1) / 2; i >= 1; i--) {
			maxHeapify(A, i);
		}
	}
	
	private static int left(int i) {
		return i * 2;
	}
	
	private static int right(int i) {
		return (i * 2) + 1;
	}
	
	
}



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




#define MOD 1000000007
long long int ppow(long long int i, long long int j){
	long long int res = 1LL;
	while (j){
		if ((j & 1LL)){
			res *= i;
			if (res >= MOD){
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD){
			i %= MOD;
		}
	}
	return res;
}

#define MAX 5002

int n;
char buf[MAX];

string s;

long long int dp[MAX][MAX];
long long int dp2[MAX][MAX];
long long int dp3[MAX][MAX];
int main(){
	scanf("%d", &n);
	scanf("%s", buf);
	s = buf;
	dp[0][0] = 1;
	for (int i = 0; i <=5000; i++){
		for (int j = 0; j < MAX; j++){
			if (dp[i][j]){
				dp[i + 1][j + 1] += dp[i][j]*2LL;
				if (dp[i + 1][j + 1] >= MOD)dp[i + 1][j + 1] %= MOD;
				if (j){
					dp[i + 1][j - 1] += dp[i][j];
					if (dp[i + 1][j - 1] >= MOD){
						dp[i + 1][j - 1] %= MOD;
					}
				}
				else{
					/*dp[i + 1][j] += dp[i][j];
					if (dp[i + 1][j] >= MOD){
						dp[i + 1][j] %= MOD;
					}*/
				}
			}
		}
	}
	dp3[0][0] = 1;
	for (int i = 0; i <= 5000; i++){
		for (int j = 0; j < MAX; j++){
			if (dp3[i][j]){
				dp3[i + 1][j + 1] += dp3[i][j] * 2LL;
				if (dp3[i + 1][j + 1] >= MOD)dp3[i + 1][j + 1] %= MOD;
				if (j){
					dp3[i + 1][j - 1] += dp3[i][j];
					if (dp3[i + 1][j - 1] >= MOD){
						dp3[i + 1][j - 1] %= MOD;
					}
				}
				else{
					dp3[i + 1][j] += dp3[i][j];
					if (dp3[i + 1][j] >= MOD){
					dp3[i + 1][j] %= MOD;
					}
				}
			}
		}
	}
	int m = strlen(buf);
	long long int way = 0;
	long long int pw = ppow(2, MOD - 2);
	for (int j = 0; j < n; j++){
		long long int mt = dp3[j][0];
		int rest = n - j - 1;
		mt *= dp[rest][m - 1];
		mt %= MOD;
		if (m-1){
			long long int pp = ppow(2, m - 1);
			mt *= ppow(pp,MOD-2);
			mt %= MOD;
		}
		way += mt;
		way %= MOD;
	}
	printf("%lld\n", way);
	return 0;
}

Measured memory_bytes: 233600
#include <iostream>
#include <string>
using namespace std;
int main(){
int h,w,k;
int maincounter = 0;
char data[6][6];
cin >> h >> w >> k;
for(int i = 0;i < h;i++){
    string buf;
    cin >> buf;
    for(int j = 0;j < w;j++){
        data[i][j] = buf[j];
    }
}
for(int i = 0;i < (1 << h);i++){
    for(int j = 0;j < (1 << w);j++){
        char sub[6][6];
        for(int k = 0;k < h;k++){
            for(int l = 0;l < w;l++){
                sub[k][l] = data[k][l];
            }
        }
        for(int m = 0;m < h;m++){
            if(i & (1 << m)){
                for(int n = 0;n < w;n++){
                    sub[m][n] = 'r';
                }
            }
        }
        for(int n = 0;n < w;n++){
            if(j & (1 << n)){
                for(int m = 0;m < h;m++){
                    sub[m][n] = 'r';
                }
            }
        }
        int counter = 0;
        for(int o = 0;o < h;o ++){
            for(int p = 0;p < w;p++){
                if(sub[o][p] == '#'){
                    counter++;
                }
            }
        }
        if(counter == k){
            maincounter++;
        }
    }
}
cout << maincounter;
return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int a = A;
    int b = B;
    int max = A;
    int count = 0;
    if(A<B)max=B;
    for(int i = max;i > 0;i--){
      if(A%i==0&&B%i==0)count++;
      if(count == C){
        a = i;  
        break;
      }
    }
    System.out.println(a);
  }
}


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

int main(){
  string s;
  cin >> s;
  ll ans=0,res;
  int a=s.length();
  
  for(int bit=0;bit<(1<<(a-1));bit++){
    res=s[0]-'0';
    r(j,a-1){
      if(bit&(1<<j)){
        ans+=res;
        res=0;
      }
      res=res*10+(s[j+1]-'0');
    }
    ans+=res;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll long long
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    int sum = A + B + C;
    int mx = max(A,max(B,C));
    sum -= mx;
    for(int i=0;i<K;i++){
        mx *= 2;
    }
    cout << mx + sum << endl;
}

Measured memory_bytes: 256
NA = [ "1111", "2222", "3333", "4444", "5555",
              "6666", "7777", "8888", "9999" ]
while True:
    st = input()
    if st == "0000":
        break
    if st in NA:
        print("NA")
        continue
    cnt = 0
    while st != "6174":
        cnt += 1
        l = "".join(sorted(st,reverse=True))
        s = "".join(sorted(st))
        st = str(int(l) - int(s)).zfill(4)
    print(cnt)



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

#define LL 					long long
#define ULL 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define mp 					make_pair
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = (1<<30)-1+(1<<30);
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

int n, m;

int main() {
	gi(n); gi(m);
	if (abs(n-m)>1) {
		printf ("0\n");
		return 0;
	}
	int ans = 1;
	for (int i=2; i<=n; i++)
		ans = (1LL * ans * i)%mod;
	for (int i=2; i<=m; i++)
		ans = (1LL * ans * i)%mod;
	if (n==m) ans = (1LL * ans * 2)%mod;
	printf ("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

void binary(vector<int> &B,int N){
    B[0]++;
    for(int i=0;i<N;i++){
        if(B[i]==2){
            B[i] = 0;
            B[i+1]++;
        }
    }
}

int main(){
    int N,M,X;cin>>N>>M>>X;
    vector<int> B(N+1);
    vector<vector<int>> A(N);
    vector<int> C(N);
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
            int a;cin>>a;
            A[i].push_back(a);
        }
    }
    vector<int> sum(N);
    int min = 100000000;
    while(B[N]!=1){
        int money = 0;
        for(int i=0;i<N;i++){
            sum[i] = 0;
        }
        for(int i=0;i<N;i++){
            if(B[i]==1){
                money += C[i];
            }
        }
        for(int i=0;i<N;i++){
            if(B[i]==1){
                for(int j=0;j<M;j++){
                    sum[j] += A[i][j];
                }
            }
        }
        bool good = true;
        for(int i=0;i<M;i++){
            if(sum[i]<X) good = false;
        }
        if(min>money&&good) min = money;
        binary(B,N);
    }
    if(min!=100000000){
        cout << min << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
class Main {
public static void main(String[] args) {

try (Scanner sc = new Scanner(System.in)) {
String line = sc.nextLine();
String answer=" " ;
int length = line.length();
for (int i = 0; i < length; i++) {
char ch = line.charAt(i); 
if(Character.isLowerCase(ch))
ch=Character.toUpperCase(ch);
else{
ch=Character.toLowerCase(ch);

}
answer+=String.valueOf(ch);

}

System.out.println(answer.trim());
}
}
}




Measured memory_bytes: 31344
N = int(input())

list = []
list.append((0, 0, 0))
for i in range(N):
    t, x, y = [int(x) for x in input().split()]
    list.append((t, x, y))


def isReachable(t1, x1, y1, t2, x2, y2):
    if (t2 - t1) < abs(x1 - x2) + abs(y1 - y2):
        return False
    if ((t2 - t1) - (abs(x1 - x2) + abs(y1 - y2))) % 2 == 0:
        return True
    else:
        return False


ret = True
for i in range(0, N):
    t1, x1, y1 = list[i]
    t2, x2, y2 = list[i + 1]
    b = isReachable(t1, x1, y1, t2, x2, y2)
    if b == False:
        ret = False
        break

if ret == True:
    print("Yes")
else:
    print("No")


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i=0; i<n; i++) cin >> v.at(i);
  for (int i=0; i<n; i++) cin >> c.at(i);
  vector<int> vc(n);
  for (int i=0; i<n; i++) vc.at(i) = v.at(i) - c.at(i);
  sort(vc.begin(), vc.end(), greater<int>());
  int ans = 0;
  for (int i=0; i<n; i++) 
    if (vc.at(i) > 0)
      ans += vc.at(i);
    else
      break;
  cout << ans << endl;
}

Measured memory_bytes: 256
import fractions

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

a, b = map(int, input().split())

c = fractions.gcd(a, b)
f = factorization(c)

print(len(f)+1 if c > 1 else 1)


Measured memory_bytes: 5088
n,k=list(map(int,input().split()))
m=list(map(int,input().split()))
import math
def pos(h):
    p=0
    for i in range(n):
        p+=math.ceil(m[i]/h)-1
    return bool(p<=k)
l,r=1,max(m)
while l<r:
    mid=(l+r)//2
    if pos(mid):
        r=mid
    else:
        l=mid+1
print(l)
    

Measured memory_bytes: 104508
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

int main(){
  int n,v,j;
  int a[1000];
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  for (int k=0;k<n;k++) {
    cout << a[k];
    if(k!=n-1){
      cout << " ";
    }
  }
  cout << endl;
  for (int i=1;i<n;i++) {
    v = a[i];
    j = i-1;
    while ((j>=0)&&(a[j]>v)) {
      a[j+1]= a[j];
      j--;
    }
    a[j+1] = v;
    for (int k=0;k<n;k++) {
        cout << a[k];
      if(k!=n-1){
        cout << " ";
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    ll cnt=0;
    string s,t;
    cin >> s>> t;
    ll len=s.length();
    for(ll i=0;i<len;i++){
        if(s[i]!=t[i])cnt++;
    }
    cout << cnt << "\n";
}



Measured memory_bytes: 3792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      bb: [usize; n-1],
    }

    const INF: usize = 1 << 30;
    let mut aa = vec![INF; n];
    for i in 0..n-1 {
        let b = bb[i];
        aa[i] = min(aa[i], b);
        aa[i+1] = min(aa[i+1], b);
    }
    // debug!(aa);
    let ans: usize = aa.iter().sum();
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

int calculate(string expr) {
	map<char,int> op_pd {{'+',0},{'-',0},{'*',1},{'/',1}}; // operator precedence
	vector<string> pf; // postfix expression
	stack<char> op_s;
	// turn infix to postfix
	string unit;
	for (char ch : expr) {
		if (ch >= '0' && ch <= '9') {
			unit.push_back(ch);
		} else {
			if (!unit.empty()) {
				pf.push_back(unit);
				unit.clear();
			}
			if (ch == '(') {
				op_s.push('(');
			} else if (ch == ')') {
				while (op_s.top() != '(') {
					pf.push_back(string().assign(1,op_s.top()));
					op_s.pop();
				}
				op_s.pop();
			} else { // '+','-','*','/'
				while (!op_s.empty() && op_s.top() != '(' && op_pd[ch] <= op_pd[op_s.top()]) {
					pf.push_back(string().assign(1,op_s.top()));
					op_s.pop();
				}
				op_s.push(ch);
			}
		}
	}
	if (!unit.empty()) {
		pf.push_back(unit);
	}
	while (!op_s.empty()) {
		pf.push_back(string().assign(1,op_s.top()));
		op_s.pop();
	}
	// calculate the postfix expression
	stack<int> num_s;
	num_s.push(stoi(pf.front()));
	for (auto i = pf.begin() + 1;i != pf.end();++i) {
		if (i->front() >= '0' && i->front() <= '9') {
			num_s.push(stoi(*i));
		} else {
			int second = num_s.top();
			num_s.pop();
			int first = num_s.top();
			num_s.pop();
			switch (i->front()) {
				case '+':
					num_s.push(first + second);
					break;
				case '-':
					num_s.push(first - second);
					break;
				case '*':
					num_s.push(first*second);
					break;
				default: // '/'
					num_s.push(first/second);
			}
		}
	}
	return num_s.top();
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string expr;
		cin >> expr;
		cout << calculate(expr.substr(0,expr.size()-1)) << endl;
	}
}

Measured memory_bytes: 3164
A, B, C, D, E, F = map(int, input().split())
W, S = 0, 0
conc = 0

for a in range(0, F+1, 100):
    a *= A
    for b in range(0, F+1, 100):
        b *= B
        water = a+b
        if water == 0 or water > F:
            break
        limit = water/100 * E

        for c in range(100):
            c *= C
            if c > limit or water+c > F:
                break

            for d in range(100):
                sugar = c + d*D
                if sugar > limit or water+sugar > F:
                    break
                tmp = 0
                if sugar != 0:
                    tmp = 100*sugar / (water+sugar)
                if tmp >= conc:
                    conc = tmp
                    W = water
                    S = sugar

print(W+S, S)

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

ac = 0
wa = [0]*n
d = [False]*n

for _ in range(m):
    p, s = input().split()
    p = int(p)-1
    if not d[p] and s == 'AC':
        ac += 1
        d[p] = True
    elif not d[p] and s == 'WA':
        wa[p] += 1
p = 0
for i in range(n):
    if d[i]:
        p += wa[i]
print(ac, p)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

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

    string s;
    cin >> s;
    int x = 0;
    for(char c:s){
        x += (c - '0');
        x %= 9;
    }
    x %= 9;
    cout << (x ? "No":"Yes") << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	string S;
	cin>>S;

	const int N = 13;

	long dp[13] = {};
	dp[0] = 1;
	int mul = 1;

	for(int i = S.length() - 1; i >=0; i--){
		long nextDP[13] = {};
		char c = S[i];
		if(c == '?'){
			rep(k,10){
				rep(j, N){
					nextDP[(k*mul+j)%N] += dp[j];
					nextDP[(k*mul+j)%13]%=mod;
				}
			}
		}

		else{
			int k = (int)(S[i]-'0');
	
			rep(j,N){
					nextDP[(k*mul+j)%N] += dp[j];
					nextDP[(k*mul+j)%13]%=mod;
			}
		}

		rep(j,N){
			dp[j] = nextDP[j];
		}

		mul  *= 10;
		mul %= N;
	}

	cout<<dp[5]<<endl;
}
 
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

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

const int INF = 1001001001;
int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> to(N);
    rep(i,M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        to.at(A).push_back(B);
        to.at(B).push_back(A);
    }
    vector<int> dist(N, INF);
    queue<int> q;
    vector<int> pre(N, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,N) {
        if(i==0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
}

Measured memory_bytes: 10732
using System;
using System.Linq;

class Bmondai
{
    static void Main()
    {
        var array = new int[4];
        for (int i=0;i<3;++i)
        {
            var line=Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            array[line[0] - 1]++;
            array[line[1] - 1]++;
        }
        Console.WriteLine(array.Any(x=>2<x)?"NO":"YES");
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
ll arr[500005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    while(cin>>n)
    {
        bool chk=0;
        ll res;
        for(ll i=1;i<=n;i++)
        {
            ll y=(i*1.08);
            if(y==n)
            {
                chk=1;
                res=i;
                break;
            }
        }
        if(chk) cout<<res<<endl;
        else cout<<":("<<endl;
    }
    return 0;
}


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

int main() {
    int A[32] = {1,
                 1,
                 1,
                 2,
                 1,
                 2,
                 1,
                 5,
                 2,
                 2,
                 1,
                 5,
                 1,
                 2,
                 1,
                 14,
                 1,
                 5,
                 1,
                 5,
                 2,
                 2,
                 1,
                 15,
                 2,
                 2,
                 5,
                 4,
                 1,
                 4,
                 1,
                 51};
    int K;
    cin >> K;
    cout << A[K - 1] << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

string N;
int K;
set <string> nd[3];

int dp[110][5][2]; // 

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> K;

    dp[0][0][0] = 1;
    for (int i = 0; i < N.length(); i++)
    {
        int d = N[i] - '0';
        for (int j = 0; j <= 3; j++)
            for (int k = 0; k < 2; k++)
            {
                if (k == 1)
                {
                    for (int l = 0; l < 10; l++)
                    {
                        if (l) dp[i+1][j+1][k] += dp[i][j][k];
                        else dp[i+1][j][k] += dp[i][j][k];
                    }
                }
                else
                {
                    for (int l = 0; l < d; l++)
                    {
                        if (l) dp[i+1][j+1][1] += dp[i][j][k];
                        else dp[i+1][j][1] += dp[i][j][k];                        
                    }

                    if (d == 0)
                    {
                        dp[i+1][j][0] += dp[i][j][k];
                    }
                    else
                        dp[i+1][j+1][0] += dp[i][j][k];
                }
            }
    }

    int nres = 0;
    for (int i = 0; i < 2; i++)
        nres += dp[N.length()][K][i];
    cout << nres << "\n";
}


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

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;

	vector<int> e_dir(310000, 0), w_dir(310000, 0);
	for(int i = 2; i <= S.length() + 1; i++) {
		char s = S[i-2];
		int count = 0;
		if (s == 'W') count++;

		e_dir[i-1] = e_dir[i-2] + count;
	}

	for(int i = S.length() - 2; i >= 0; i--) {
		char s = S[i+1];
		int count = 0;
		if (s == 'E') count++;

		w_dir[i] = w_dir[i+1] + count;
	}

	int ans = 300000;
	repeat(i, S.length()) {
		int sum = e_dir[i] + w_dir[i];
		if (sum < ans) ans = sum;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3076
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        m: usize,
        cakes: [(isize, isize, isize); n],
    }

    let mut max = 0;
    for bit in 0..8 {
        let mut reverse = vec![false; 3];
        for i in 0..3 {
            if (bit >> i) & 1 != 0 {
                reverse[i] = true;
            }
        }
        let mut sum = vec![0; n];
        for i in 0..n {
            if !reverse[0] {
                sum[i] += cakes[i].0;
            } else {
                sum[i] += cakes[i].0 * -1;
            }
            if !reverse[1] {
                sum[i] += cakes[i].1;
            } else {
                sum[i] += cakes[i].1 * -1;
            }
            if !reverse[2] {
                sum[i] += cakes[i].2;
            } else {
                sum[i] += cakes[i].2 * -1;
            }
        }
        sum.sort_by(|a, b| b.cmp(a));
        let v = sum.iter().take(m).sum();
        max = cmp::max(max, v);
    }

    println!("{}", max);
}


Measured memory_bytes: 2268
n = int(input())
s = list(input())
r = 0
g = 0
b = 0

for c in s:
    if c == "R":
        r += 1
    if c == "G":
        g += 1
    if c == "B":
        b += 1
ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = 2*j - i
        if k > n-1:
            continue
        x = s[i]
        y = s[j]
        z = s[k]
        if x!= y and y != z and z != x:
            ans -= 1

print(ans)

Measured memory_bytes: 68568
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


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

    double m, n;
    cin >> n >> m;

    vector<double> a(n);

    ll all = 0;

    for0(i, n)cin >> a[i], all += a[i];

    ll res = 0;

    for0(i, n){
        if (a[i] >= double(all) / 4 / m) {
            res++;
        }
    }

    cout << (res >= m ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256