akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N;
void input(){
    cin>>N;
    return;
}

void solve(){
    int ans=0;
    rrep(i,1,N+1){
        int digits=1;
        int tmp=i;
        while(tmp/10){
            tmp/=10;
            digits++;
        }
        if(digits%2) ans++;
    }
    cout<<ans<<endl;
    return;
}

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

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N =ii()
    A = il()
    sm = sum(A)
    for n in range(N-1):
        A[n+1] += A[n]

    ret = MAX
    for n in range(N-1):
        ret = min(ret, abs(-sm+(2*A[n])))
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31008
mod=998244353
import collections
n=int(input())
x=input()
ans=(2*n*(int(x,2)+1))%mod

def make_divisors(n):
  divisors=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      divisors.append(i)
      if i!=n//i:
        divisors.append(n//i)

  divisors.sort(reverse=True)
  return divisors
D=make_divisors(n)
CT=collections.defaultdict(int)
for d in D:
  if d%2==0 or d==1:
    continue
  else:
    k=n//d
    #下から0がk個、1がk個、、、、を繰り返す数を求める、ｙとする。
    #その周期は2*k
    y=(2**n-2**k)//(2**k+1)

    #ｙ+（ｙ＋１）*yyも同じ周期をもつ
    #x以下の個数を数える
    ct=(int(x,2)-y)//(y+1)+1
    #重複分を差し引く
    Dk=make_divisors(k)
    for dk in Dk:
      if dk<k:
        ct-=CT[dk]
    CT[k]=ct

    #ansはすべてを2nで数えているのでそこから2(n-k)を引く
    ans-=ct*2*(n-k)


print(ans%mod)

Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    ll ans = 0;
    ll N;
    cin >> N;
    string S;
    cin >> S;
    
    ll abc[26]={};
    for(ll i=0; i<N; i++){
        abc[S[i]-'a']++;
        
        ll temp = 1;
        for(int k=0; k<26; k++){
            if(k==S[i]-'a'){
                continue;
            }
    
            temp*=(abc[k]+1);
            temp%=MOD;
            
        }
        ans += temp;
        ans %= MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

const long long MOD = 1e9 + 7;

long long factmod (long long n, long long p) {
	int res = 1;
	while (n > 1) {
		res = (res * ((n/p) % 2 ? p-1 : 1)) % p;
		for (int i=2; i<=n%p; ++i)
			res = (res * i) % p;
		n /= p;
	}
	return res % p;
}

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long invs = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[i]) ++invs;
        }
    }
    long long ans = invs * k;
    ans %= MOD;
    long long bigger = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] > a[i]) ++bigger;
        }
    }
    long long pairs = k * (k - 1) / 2;
    pairs %= MOD;
    ans += (bigger * pairs) % MOD;
    ans %= MOD;
    cout << ans;
    return 0;
}


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

const int N = 123456 ;

int sum [N] ;
std :: bitset < N > isprime ;
std :: vector < int > primes ;

int main ( )  {

	isprime.set ( ) ;

	for ( int i = 2 ; i < N ; ++ i )  {
		if ( isprime.test ( i ) )  {
			primes.push_back ( i ) ;
		}
		for ( std :: vector < int > :: iterator it = primes.begin ( ) ; i * ( *it ) < N && it != primes.end ( ) ; ++ it )  {
			isprime.reset ( i * ( *it ) ) ;
			if ( i % *it == 0 )  break ;
		}
	}

	for ( int i = 3 ; i < N ; ++ i )  {
		sum [i] = sum [i - 1] + ( isprime.test ( i ) && isprime.test ( i + 1 >> 1 ) ) ;
	}

	int Q ;

	scanf ( "%d", & Q ) ;

	while ( Q -- )  {
		static int l, r ;
		scanf ( "%d%d", & l, & r ) ;
		printf ( "%d\n", sum [r] - sum [l - 1] ) ;
	}

	return 0 ;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		for(int i = 0; i< 3; i++){
			sum += sc.nextInt();
		}

		if(sum < 22){
			System.out.print("win");

		}else {
			System.out.print("bust");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main() {
    int n;
    int cntr=0, cntg=0, cntb=0;
    ll ans=0;
    string s;
    cin >> n >> s;
    vector<int> br(n), gr(n), rr(n);
    for(int i=n-1;i>=0;i--){
        if(s[i]=='B'){
            cntb++;
        }else if(s[i]=='G'){
            cntg++;
        }else{
            cntr++;
        }
        rr.at(i)=cntr;
        gr.at(i)=cntg;
        br.at(i)=cntb;
    }
    rep(i,n){
        if(s[i]=='R'){
            for(int j=i+1;j<n;j++){
                if(s[j]=='G'){
                    ans+=br.at(j);
                    if(j+j-i<n)if(s[j+j-i]=='B') ans--;
                }else if(s[j]=='B'){
                    ans+=gr.at(j);
                    if(j+j-i<n)if(s[j+j-i]=='G') ans--;
                }
            }
        }else if(s[i]=='G'){
            for(int j=i+1;j<n;j++){
                if(s[j]=='R'){
                    ans+=br.at(j);
                    if(j+j-i<n)if(s[j+j-i]=='B') ans--;
                }else if(s[j]=='B'){
                    ans+=rr.at(j);
                    if(j+j-i<n)if(s[j+j-i]=='R') ans--;
                }
            }
        }else if(s[i]=='B'){
            for(int j=i+1;j<n;j++){
                if(s[j]=='G'){
                    ans+=rr.at(j);
                    if(j+j-i<n)if(s[j+j-i]=='R') ans--;
                }else if(s[j]=='R'){
                    ans+=gr.at(j);
                    if(j+j-i<n)if(s[j+j-i]=='G') ans--;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
n = int(input())

l = []
a = {}
b = {}

for i in range(n):
    x,y,h = map(int,input().split())
    if h > 0 :
        l.append([x,y,h])

for cx in range(100+1):
    for cy in range(100+1):
              
        count = 0
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 
            if preheight != height:
                break
            count = count + 1

        if count >= len(l) :
            if preheight in a:
                a[preheight] += 1
                b[preheight] = [cx,cy]
            else:
                a[preheight] = 1
                b[preheight] = [cx,cy]

for ans in a.keys() :
    if a[ans] == 1 :
        print(b[ans][0],b[ans][1],ans)
        exit(0)

Measured memory_bytes: 3064
from heapq import heappop, heappush

N, M, S = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
Y = [list(map(int, input().split())) for _ in range(N)]

lim = 2501
graph = [[] for _ in range((N + 1) * lim)]

for u, v, a, b in X:
    for n in range(a, lim):
        graph[u * lim + n].append((v * lim + (n - a), b))
        graph[v * lim + n].append((u * lim + (n - a), b))

for n, (c, d) in enumerate(Y):
    for x in range(lim - 1):
        graph[(n + 1) * lim + x].append(
            ((n + 1) * lim + min(lim - 1, x + c), d))


INF = 10 ** 20
start = lim + min(S, lim - 1)
dist = [INF] * ((N + 1) * lim + 1)
dist[start] = 0
pq = []
heappush(pq, (0, start))

while pq:
    _, u = heappop(pq)
    for v, c in graph[u]:
        if dist[v] > dist[u] + c:
            dist[v] = dist[u] + c
            heappush(pq, (dist[v], v))

ans = []
for i in range(2, N + 1):
    ans.append(min(dist[i * lim:i * lim + lim]))

print(*ans, sep="\n")


Measured memory_bytes: 120392
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    int x[N],y[M];
    for(int i=0;i<N;i++)
    cin>>x[i];
    for(int i=0;i<M;i++)
    cin>>y[i];
    bool ans;
    for(int z=-100;z<101;z++)
    {
        ans=true;
        if(X>=z)
        ans=false;
        if(z>Y)
        ans=false;
        if(!ans)
        continue;
        for(int i=0;i<N;i++)
        {
            if(x[i]>=z)
            ans=false;
            if(!ans)
            break;
        }
        for(int i=0;i<M;i++)
        {
            if(y[i]<z)
            ans=false;
            if(!ans)
            break;
        }
        if(ans)
        {
            cout<<"No War"<<endl;return 0;
        }
    }
    cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

const long long MULTILIMIT	= 1 << 32;
const int MOD				= static_cast<int>(1e9+7);
const int MAXARRAY			= 100;

int Combination(int n, int k)
{
	k = (k >= n - k) ? n - k : k;
	int i, j, index = 1;
	long long comb[MAXARRAY] ={ 1 };

	for (i = 0; i < k; i++) {
		for (j = 0; j < index; j++)
			comb[j] *= n - i;

		for (j = 0; j < index; j++)
			if (comb[j] >= MULTILIMIT) {
				comb[j+1] += comb[j] / MOD;
				comb[j] %= MOD;
			}

		if (comb[j])
			index++;
	}

	for (i = 2; i <= k; i++) {
		for (j = index-1; j > 0; j--) {
			comb[j-1] += (comb[j] % i) * MOD;
			comb[j] /= i;
		}
		comb[j] /= i;
	}

	return static_cast<int>(comb[0] % MOD);
}

int main()
{
	int N, M, i, j, comb, count = 0, factor = 3, factnum[30] = { 0 };
	long long ans = 1;
	std::scanf("%d%d", &N, &M);
	
	while (!(M & 1))
		count++, M >>= 1;
	factnum[count]++;

	while (M != 1) {
		count = 0;
		while (!(M % factor))
			count++, M /= factor;
		factnum[count]++, factor += 2;
	}

	for (i = 1; i < 30; i++) {
		if (factnum[i]) {
			comb = Combination(i + N - 1, i);
			for (j = 0; j < factnum[i]; j++) {
				ans *= comb;
				ans %= MOD;
			}
		}
	}

	std::printf("%d\n", static_cast<int>(ans));

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
int a[N];
int b[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    if(n%2==1)
    {
        ll ans=0;
        for(int i=1;i<=n/2-1;i++)
        {
            ans-=2*a[i];
        }
        ans=ans-a[n/2+1]-a[n/2];
        for(int i=n/2+2;i<=n;i++)
        {
            ans+=2*a[i];
        }
        ll tem=0;
        for(int i=n/2+3;i<=n;i++)
        {
            tem+=2*a[i];
        }
        tem+=a[n/2+1]+a[n/2+2];
        for(int i=1;i<=n/2;i++)
        {
            tem-=2*a[i];
        }
        ans=max(ans,tem);
        cout<<ans<<endl;
    }
    else
    {
        ll ans=0;
        for(int i=1;i<=n/2-1;i++)
        {
            ans-=2*a[i];
        }
        ans=ans-a[n/2+1]-a[n/2];
        for(int i=n/2+1;i<=n;i++)
        {
            ans+=2*a[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4040
<?php
$N=fgets(STDIN);
$A=[];
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  $A[$i]=fgets(STDIN);
}
$k=1;
$count=0;
$i=0;
while(true){
  $k=$A[$k-1];
  if($k==1||$i==$N){
    echo -1;
    break;
  }
  if($k==2){
    echo $count+1;
    break;
  }
 $count++;
 $i++;
}



 ?>


Measured memory_bytes: 21364
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

char s[1001], t[1001];
int main(void){
	int n=nextstr(s);
	int m=nextstr(t);
	int ans=m;
	for(int i=n-m; i>=0; i--){
		int now=0;
		for(int j=0; j<m; j++){
			now+=(s[i+j]!=t[j]);
		}
		if(now<ans) ans=now;
	}
	printf("%d\n", ans);
}


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

int main() {
  string str;
  int ans = 0;
  cin >> str;
  for (int i = 0; i < 3; i++) {
    if (str[i] == '1') {
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll r1, r2;
	cin >> r1 >> r2;
	cout <<fixed << setprecision(39) << r1 * r2 / (ld)(r1 + r2) << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> STreap;

ll A, B; 
int main(){
	cin >> A >> B;
	if(A > B) swap(A, B);
	if((B - A + 1) % 2) cout << A + (B - A + 1) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}



Measured memory_bytes: 764
program face_produces_unhappiness
  implicit none
  integer :: n, k, nl = 0, nr = 0, i = 1, j = 1
  character(100000) :: s
  read(*,*) n, k
  read(*,*) s
  do while (i <= n)
    do while (s(j:j) == s(i:i))
      j = j+1
    end do
    if (s(i:i) == "L") then
      nl = nl+1
    else
      nr = nr+1
    end if
    i = j
  end do
  if (nl <= k .or. nr <= k) then
    write(*,'(i0)') n-1
  else
    write(*,'(i0)') n-nl-nr+2*k
  end if
end program face_produces_unhappiness

Measured memory_bytes: 700
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;


int main()
{
    int H,N;
    cin >> H >> N;
    vector< ll > cost(H+1, -1);
    ll ans=1e13;
    ll magic[N][2];
    for(int i=0; i<N; i++){
        cin >> magic[i][0] >> magic[i][1];
        if(magic[i][0]>=H) ans=min(ans,magic[i][1]);
        else if(cost[magic[i][0]]==-1) cost[magic[i][0]]=magic[i][1];
        else cost[magic[i][0]]=min(cost[magic[i][0]],magic[i][1]);
    }

    cost[0]=0;
    for(int h=0; h<H; h++){
        if(cost[h]==-1) continue;
        for(int n=0; n<N; n++){
            if(h+magic[n][0]>=H) ans=min(cost[h]+magic[n][1],ans);
            else if(cost[h+magic[n][0]]==-1) cost[h+magic[n][0]]=cost[h]+magic[n][1];
            else{
                cost[h+magic[n][0]]=min(cost[h+magic[n][0]],cost[h]+magic[n][1]);
            }
        }
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    double w,h,x,y;cin >> w >>h >> x >> y;
    printf("%lf ",w*h/2);
    if(w/2 == x && h/2 == y)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
struct dat
{
	int a, b;
	bool operator<(const dat& next)const
	{
		return a < next.a;
	}
};
int main()
{
	int n, i;
	dat s[100005];
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &s[i].a);
		s[i].b = i;
	}
	sort(s + 1, s + n + 1);
	for (i = 1; i <= n; i++)
		printf("%d%c", s[i].b, i == n ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,u,v,w;
ll bismarck[(1<<15)][15],e[15][15],sum[(1<<15)];
int main()
{
	cin>>n>>m;
	while(m--)
	{
		cin>>u>>v>>w;
		u--,v--;
		e[u][v]=e[v][u]=w;
	}
	for(int i=0;i<1<<n;i++)
	{
		for(int j=0;j<n;j++){
		if((i>>j)&1)
		{
            for(int k=j+1;k<n;k++)
		    if((i>>k)&1) sum[i]+=e[j][k];			
		}
		bismarck[i][j]=-1e18;}
	}
	bismarck[1][0]=0;
	for(int i=1;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		if((i>>j)&1)
		{
			int l=i^(1<<j);
			for(int k=0;k<n;k++)
			if((i>>k)&1&&e[j][k]) bismarck[i][j]=max(bismarck[i][j],bismarck[l][k]+e[k][j]);
			for(int k=l;k>0;k=(k-1)&l) bismarck[i][j]=max(bismarck[i][j],bismarck[i^k][j]+sum[k^(1<<j)]); 
		}
	}
	cout<<sum[(1<<n)-1]-bismarck[(1<<n)-1][n-1];
}

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

int main() {
  vector<vector<int>> a(3,vector<int>(3));
  REP(i,3){
    REP(j,3){
      cin >> a[i][j];
    }
  }
  vector<vector<bool>> a_check(3,vector<bool>(3,false));
  int n; 
  cin >> n;
  REP(i,n){
    int b;
    cin >> b;
    REP(j,3){
      REP(k,3){
        if(b == a[j][k]){
          a_check[j][k] = true;
        }
      }
    }
  }
    
  bool ok = false;
  if(a_check[0][0] && a_check[1][0] && a_check[2][0]){
    ok = true;
  }
  if(a_check[0][1] && a_check[1][1] && a_check[2][1]){
    ok = true;
  }
  if(a_check[0][2] && a_check[1][2] && a_check[2][2]){
    ok = true;
  }
  if(a_check[0][0] && a_check[0][1] && a_check[0][2]){
    ok = true;
  }
  if(a_check[1][0] && a_check[1][1] && a_check[1][2]){
    ok = true;
  }
  if(a_check[2][0] && a_check[2][1] && a_check[2][2]){
    ok = true;
  }  
  if(a_check[0][0] && a_check[1][1] && a_check[1][1]){
    ok = true;
  }     
  if(a_check[2][0] && a_check[1][1] && a_check[0][2]){
    ok = true;
  }
  
 if(ok) cout << "Yes" << endl;
 else cout << "No" << endl;
     
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/

/*signed*/int main() {
    int a, b;
    cin >> a >> b;
    int sum = max(0,a-b*2);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
int main()
{
	int N, K;
	std::cin >> N >> K;
	std::set<int> have;
	for (int j = 0; j < K; ++j) {
		int d;
		std::cin >> d;
		for (int i = 0; i < d; ++i) {
			int A;
			std::cin >> A;
			have.insert(A);
		}
	}
	std::cout << N - have.size() << std::endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, C;
	cin >> N >> M >> C;
	vector<vector<int> > A(N, vector<int>(M));
	vector<int> B(M);
	int res = 0;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}


	for (int i = 0; i < N; i++) {
		int a = 0;
		for (int j = 0; j < M; j++) {
			a += A[i][j] * B[j];
		}
		a += C;
		if (a > 0)res++;
	}
	cout << res << endl;
}

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

int main(){

 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++)cin>>a[i];

 for(int i=0;i<n;i++){
  
   if(a[i]%2==0){
       if(a[i]%3!=0 && a[i]%5!=0){
           cout<<"DENIED";
           return 0;
       }
   }


 }

 cout<<"APPROVED";

 

}

Measured memory_bytes: 256
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 2e5 + 10;

vll adj[N], counter(N);

int bfs(int s) {
  queue<int> q;
  vector<bool> used(N);
  vector<int> d(N), p(N);

  q.push(s);
  used[s] = true;
  p[s] = -1;
  while (!q.empty())
  {
    int v = q.front();
    q.pop();
    for (int u : adj[v])
    {
      if (!used[u])
      {
        counter[u] += counter[v];
        used[u] = true;
        q.push(u);
        d[u] = d[v] + 1;
        p[u] = v;
      }
    }
  }
}

int32_t main() {
  fast_io();

  int n, q; cin >> n >> q;
  f (i, 0, n-1) {
    int u, v; cin >> u >> v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  while (q--) {
    int p, x; cin >> p >> x;
    counter[p] += x;
  }
  bfs(1);
  f (i, 1, n+1) {
    cout << counter[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 21120
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		ll ans = -1;
		REP(i, 10000) {
			if(i*8/100==A&&i*10/100==B) {ans=i;break;}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/

/*signed*/int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << (a + b) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3612
A, B, C, D, E, F = gets.chomp.split.map(&:to_i)

x = []
y = []

31.times do |i|
  31.times do |t|
    amount = 100*A*i + 100*B*t
    x.push(amount) if amount <= F && amount > 0
  end
end
x.uniq!

3001.times do |i|
  3001.times do |t|
    amount = i*C + t*D
    y.push(amount) if amount <= F
  end
end
y.uniq!

ans_amount = 0
ans_suger = 0
ans_rate = 0
limit_rate = (E.to_f * 100) / (100 + E)
x.each do |xx|
  y.each do |yy|
    amount = xx + yy
    next if amount > F
    rate = (100 * yy).to_f / amount
    next if rate > limit_rate
    if rate >= ans_rate
      ans_amount = amount
      ans_suger = yy
      ans_rate = rate
    end
  end
end
puts "#{ans_amount} #{ans_suger}"


Measured memory_bytes: 3836
H,W=map(int,input().split())

MAP=[None]*H

for i in range(H):
    MAP[i]=input()


ANSH=[]
for i in range(H):
    if "#" in MAP[i]:
        ANSH.append(i)

ANSW=[]
for i in range(W):
    check=0
    for j in range(H):
        if MAP[j][i]=="#":
            check=1

    if check==1:
        ANSW.append(i)


for i in ANSH:
    for j in ANSW:
        print(MAP[i][j],end="")

    print()
        


Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

LL solve2(LL h, LL w, LL x) {
    LL res=1e18;
    if ( h%2==0 ) {
        chmin(res, abs((h/2*w)-x));
    }
    if ( w%2==0 ) {
        chmin(res, abs((w/2*h)-x));
    }
    if ( h%2 && w%2 ) {
        if ( h>1 ) {
            LL y=(h/2)*w;
            LL z=(h-h/2)*w;
            LL t=max({x,y,z})-min({x,y,z});
            chmin(res, t);
        }
        if ( w>1 ) {
            LL y=(w/2)*h;
            LL z=(w-w/2)*h;
            LL t=max({x,y,z})-min({x,y,z});
            chmin(res, t);
        }
    }
    return res;
}

LL solve(LL h, LL w) {
    LL res=1e18;
    for ( int i=1; i<=h/2; i++ ) {
        chmin(res, solve2(h-i, w, w*i));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL h,w;
    cin >> h >> w;
    if ( h%3==0 || w%3==0 ) {
        cout << 0 << '\n';
        return 0;
    }
    LL ans=1e18;
    chmin(ans, solve(h,w));
    chmin(ans, solve(w,h));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define inf 1e9

using namespace std;


struct edge{
	int to, cap, cost, rev;
	edge(){}
	edge(int a, int b, int c, int d){
		to = a, cap = b, cost = c, rev = d;
	}
};


int n;
string s[105];
int S, T;
vector<edge> G[205];
int dist[205];
int prevv[205], preve[205];

void BellmanFord()
{
	for(int i = 1; i <= T; i++) dist[i] = inf;
	dist[S] = 0, prevv[S] = -1;

	bool update = true;
	while(update){
		update = false;
		for(int i = 1; i <= T; i++){
			for(int j = 0; j < G[i].size(); j++){
				if(G[i][j].cap == 0) continue;
				if(dist[G[i][j].to] > dist[i] + G[i][j].cost){
					dist[G[i][j].to] = dist[i] + G[i][j].cost;
					prevv[G[i][j].to] = i;
					preve[G[i][j].to] = j;
					update = true;
				}
			}
		}
	}
}

void add_edge(int from, int to, int cap, int cost)
{
	G[from].push_back( edge(to, cap, cost, G[to].size()) );
	G[to].push_back( edge(from, 0, -cost, G[from].size()-1) );
}


int main()
{
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> s[i];
  int len = 0;
  for(int i = 1; i <= n; i++) len += (int)s[i].size();

  S = 2*n+1, T = 2*n+2;
  for(int i = 1; i <= n; i++){
    add_edge(S, i, 1, 0);
    add_edge(i+n, T, 1, 0);
    for(int j = 1; j <= n; j++){
      int x = 0;
      for(int k = 1; k < min(s[i].size(), s[j].size()); k++){
        if(s[i].substr((int)s[i].size()-k) == s[j].substr(0, k)) x = k;
      }
      add_edge(i, n+j, 1, -x);
    }
  }

	int f = n, ans = 0;
	while(f > 0){
		BellmanFord();
		int p = T, flow = f;
		while(prevv[p] != -1){
			flow = min(flow, G[prevv[p]][preve[p]].cap);
			p = prevv[p];
		}
		p = T;
		while(prevv[p] != -1){
			G[prevv[p]][preve[p]].cap -= flow;
			G[p][G[prevv[p]][preve[p]].rev].cap += flow;
			p = prevv[p];
		}
		f -= flow;
		ans += dist[T] * flow;
	}
	cout << len + ans << endl;

  return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int arr[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 << arr[K-1] << endl;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int x[100005];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,m){
		int a,b;
		scanf("%d%d",&a,&b);a--;b--;
		x[a]^=1;
		x[b]^=1;
	}
	bool r=true;
	fore(i,0,m){
		r=r&&x[i]==0;
	}
	puts(r?"YES":"NO");
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int x;cin>>x;
	if(x>=30)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int n, x, a[110], cr, b = 1;

int main(){
    cin >> n >> x;
    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=1; i<=n && cr + a[i] <= x; i++) b++, cr += a[i];
    cout << b;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
  int n;
  int r;

  scanf("%d %d", &n, &r);

  if (n >= 10) {
    printf("%d\n", r);
    return (0);
  }

  printf("%d\n", r + 100 * (10 - n));
  return (0);
}


Measured memory_bytes: 128
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
     count += 1 if x == 500 * i + 100 * j + 50 * k
    end
  end
end

puts count

Measured memory_bytes: 1788
(h, w) = gets.chomp.split(' ').map(&:to_i)

s = []
h.times {|y| s[y] = gets.chomp}

t = []

def in_board(h, w, y, x)
  0 <= y and y < h and 0 <= x and x < w
end

def count(s, y, x)
  h = s.size
  w = s[0].size
  
  c = 0
  
  [-1, 0, 1].each do |dy|
    [-1, 0, 1].each do |dx|
      if in_board(h, w, y + dy, x + dx) then
        if s[y + dy][x + dx] == '#' then
          c += 1
        end
      end
    end
  end
  
  return c
end

h.times do |y|
  t[y] = []
  w.times do |x|
    if s[y][x] == '#' then
      t[y][x] = '#'
    else
      t[y][x] = count(s, y, x).to_s
    end
  end
end

t.size.times do |y|
  puts t[y].join
end

Measured memory_bytes: 2044
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

s = input()
n = len(s)
k = I()
q = []
for i in range(n):
    heappush(q,(s[i],i))
d = defaultdict(lambda : 1)
while k:
    si,i = heappop(q)
    if d[si]:
        k -= 1
        d[si] = 0
    if not k:
        print(si)
        quit()
    if i < n-1:
        si += s[i+1]
        i += 1
        heappush(q,(si,i))


Measured memory_bytes: 50520
#include<bits/stdc++.h>
using namespace std;
int a[30]={0};
int main()
{
	int id=0;
	string str;
	cin>>str;
	for(int i=0;i<str.length();i++){
		if(a[str[i]-'a']==0) a[str[i]-'a']=1;
		else continue;
	}
	for(int i=0;i<=25;i++){
		if(a[i]==0){
			char cha='a'+i;
			cout<<cha;
			id=1;
			break;
		}
	}
	if(id==0) cout<<"None";
}

Measured memory_bytes: 512
#include <stdio.h>
int main () 
{
int n,i;
int p=0,q=1;
int x = 0,sub = 0,tmp = 0;
int a[110];

scanf("%d",&n);

for(i=0;i<n;i++)
{
    scanf("%d",&a[i]);
}

int j = 0;
while(1)
{
    int max = 0;
    for(i=j;i<n;i++)
    {    
        if(max<a[i])
        {
            max = a[i];
            x = i;
        }
    }
    tmp = a[j];
    a[j] = a[x];
    a[x] = tmp;
    j++;
    if(j == n-1)
    break;
}
    int alice = 0,bob = 0;
while(p<n)
{
    alice += a[p];
    p += 2;
}
while(q<n)
{
    bob += a[q];
    q += 2;
}
sub = alice - bob;
printf("%d\n",sub);
return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))

amax = []
amin = []

for i in range(n):
    amax.append(a[i] + 1)
    amin.append(a[i] - 1)

m = 3 ** n

for z in range(3 ** n):
    asearch = []
    amulti = 1
    x = z
    for i in range(n):
        asearch.append(x % 3)
        x = x // 3
    for i in range(n):
        if asearch[i] == 0:
            amulti *= a[i]
        elif asearch[i] == 1:
            amulti *= amax[i]
        else:
            amulti *= amin[i]
    if amulti % 2 != 0:
        m -= 1

print(m)

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int a[100100]={};
    int b[100100]={};
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        b[a[i]]=i;
    }
    for(int i=1;i<=n;i++){
        cout<<b[i]<<endl;
    }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define endl '\n'
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 2005
#define mod 1000000007
#define inf 1e17
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

int32_t main()
{
   // boost
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        cin>>a[i];
        int dp[n+1];
        memset(dp,0,sizeof(dp));
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        if(n>2)
        {
        for(int i=2;i<n;i++)
        {
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
        }
        }
        cout<<dp[n-1];
            }


    

}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int X, Y, Z;

int main()
{
	in>>X>>Y>>Z;
	out<<(X-Z)/(Y+Z)<<std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int[] s = new int[n];
			for(int i = 0;i < n;i++){
				s[i] = scan.nextInt();
			}
			int q = scan.nextInt();
			int[] t = new int[q];
			for(int i = 0;i < q;i++){
				t[i] = scan.nextInt();
			}
			int count = 0;
			for(int i = 0;i < q;i++){
				for(int j = 0;j < n;j++){
					if(t[i] == s[j]){
						count++;
                                                break;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 31076
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

using Pair = pair<int, int>;
using Vector = vector<int>;


vector<Vector> junjo{};
vector<Pair> P{};

void rec(int i, Vector &v){
  if(i == P.size()){
    junjo.push_back(v);
    return;
  }
  for(int j = 0; j < P.size(); j++){
    if (std::find(v.begin(), v.end(), j) != v.end()) {
      continue;
    }
    v.push_back(j);
    rec(i+1,v);
    v.pop_back();
  }
}

void solve(void)
{
  int N; cin >> N;
  P.resize(N);
  for(auto& i : P) cin >> i.first >> i.second;

  Vector tmp{};
  rec(0, tmp);

  vector<double_t> res{};
  for (const auto& michi : junjo) {
    double_t r{};
    for (int i = 1; i < michi.size(); ++i) {
      Pair &p1 = P[michi[i - 1]];
      Pair &p2 = P[michi[i]];
      auto a = p1.first - p2.first;
      auto b = p1.second - p2.second;
      a *= a;
      b *= b;
      double_t r0 = std::sqrt(a + b);
      r += r0;
    }
    res.push_back(r);
  }

  auto sum = boost::accumulate(res, (double_t)0);
  auto ans = sum / res.size();
  cout
    << std::setprecision(15) 
    << ans << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 3892
from collections import defaultdict as dd
from sys import exit
n = int(input())
if n == 1:
    print(0)
    exit()

counter = dd(int)
for num in range(2, int(n**0.5) + 3):
    while n % num == 0:
        n //= num
        counter[num] += 1
if n != 1:
    counter[n] += 1

total = 0
for key, val in counter.items():
    for i in range(1, 10**10):
        if i * (i + 1) // 2 > val:
            total += i-1
            break
print(total)


Measured memory_bytes: 66552