akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
  ll n;
    cin>>n;
    vector<ll>a(n + 1);
    ll res=0;
    for(int i=1;i<=n;i++)a[i]++;
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            a[j]++;
        }
    }
    for(ll i=1;i<=n;i++){
        res+=i*a[i];
    }
    cout<< res<< endl;
    return 0;
}

Measured memory_bytes: 81284
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int rsl = (b - 1) / (a - 1);
  if((b - 1) % (a - 1) != 0) rsl++;
  cout << rsl << endl;
}


Measured memory_bytes: 256
s = str(input())
d = {}
d['N'] = 0
d['W'] = 0
d['S'] = 0
d['E'] = 0
flag1 = False
flag2 = False

for i in range(len(s)):
    if s[i] == 'N' or s[i] == 'S':
        flag1 = True
        d[s[i]] = 1
    if s[i] == 'W' or s[i] == 'E':
        flag2 = True
        d[s[i]] = 1

if flag1:
    if d['N'] == 0 or d['S'] == 0:
        print('No')
        exit()

if flag2:
    if d['W'] == 0 or d['E'] == 0:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 38384
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const N = input[0]
  const A = input[1].split(' ')
  let ans = 0
  for (let i = 0; i < A.length; i++) {
    ans += 1 / A[i]
  }
  console.log(1 / ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define ALL(a) (a).begin(),(a).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

    int n1 = 0;
    int n2 = 0;
    int n3 = 0;
    int n4 = 0;
    REP(i, 6) {
        int input;
        cin >> input;
        if (input == 1) {
            n1++;
        } else if (input == 2) {
            n2++;
        } else if (input == 3) {
            n3++;
        } else if (input == 4) {
            n4++;
        }
    }
    if (n1 >= 3 || n2 >= 3 || n3 >= 3 || n4 >= 3) {
        cout << "NO" << '\n';
    } else {
        cout << "YES" << '\n';
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int a,b;
    double c;
    scanf("%d",&a);
    b = a/2;
    if(a % 2 != 0){
        b+=1;
    }
    c = (double)b/(double)a;
    printf("%lf",c);
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

long long getint(string str) {
	long long ret = 0;

	for (int i = 0; i < str.size(); i++) {
		ret = (long long)ret * 10 + (long long)(str[i] - '0');
	}

	return ret;
}

int main() {

	string s; cin >> s;

	if (s.size() == 1) {
		cout << s << endl;
		return 0;
	}
	
	int l = s.size()-1;

	long long ans = 0;

	for (int bit = 0; bit < (1 << l); bit++) {
		
		string tmp ="";
		tmp += s[s.size() - 1];
		
		for (int i = 0; i < l; i++) {
			if ((bit >> i) & 1) {
				ans += getint(tmp);
				tmp = s[l-1 - i];
			}
			else {
				tmp= s[l-1- i]+tmp;
			}

			if (i == l - 1) {
				ans += getint(tmp);
			}
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main() {
    ll K, S;
    cin >> K >> S;

    ll count = 0;
    for (ll x = 0; x <= K; ++x) {
        for (ll y = 0; y <= K; ++y) {
            ll z = S - (x + y);
            if (z < 0) continue;
            if (z > K) continue;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c;
    cin >> a >> b >> c;
    int64_t ca=a,cb=b,cc=c;
    int64_t ca_=a,cb_=b,cc_=c;
    int64_t res = 0;
    while(true){
        // cout << "ca:" << ca << " cb:" << cb << " cc:" << cc << endl;
        if(ca%2!=0 || cb%2!=0 || cc%2!=0) break;
        ca_ = cb/2 + cc/2;
        cb_ = ca/2 + cc/2;
        cc_ = ca/2 + cb/2;
        ca = ca_;
        cb = cb_;
        cc = cc_;
        res++;
        if(ca==a && cb==b && cc==c) {
            res = -1;
            break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P pair<long long,long long>//a+bx
#define MP(a,b) make_pair((long long)(a),(long long)(b))
using namespace std;
P Op[3001000];
int A[1001000];
int N,M;
int MM;
void Add(int i,int is,int it,int s,int t,P add)
{
	if(s==t||i>=2*MM)
		return ;
	if(is==s&&it==t)
	{
		Op[i].first+=add.first;
		Op[i].second+=add.second;
		return ;
	}
	int mid=(is+it)/2;
	if(t<mid)
		Add(i*2,is,mid,s,t,add);
	else if(s<mid)
	{
		Add(i*2,is,mid,s,mid,add);
		Add(i*2+1,mid,it,mid,t,add);
	}
	else	Add(i*2+1,mid,it,s,t,add);
	return ;
}
void Count(int s,int t)
{
	if(s<t)
	{
		Add(1,1,MM+1,1,s+1,MP(t-s,0));
		Add(1,1,MM+1,s+1,t+1,MP(t+1,-1));
		Add(1,1,MM+1,t+1,M+1,MP(t-s,0));
	}
	else
	{
		Add(1,1,MM+1,1,t+1,MP(t+1,-1));
		Add(1,1,MM+1,t+1,s+1,MP(M+t-s,0));
		Add(1,1,MM+1,s+1,M+1,MP(M+t+1,-1));
	}
}
int main()
{
	cin>>N>>M;
	int MMM=M;
	MM=1;
	while(MMM)
	{
		MMM/=2;
		MM*=2;
	}
	for(int i=0;i<N;i++)
		cin>>A[i];
	for(int i=0;i<N-1;i++)
		Count(A[i],A[i+1]);
	long long Min=1e18;
	for(int i=1;i<=M;i++)
	{
		int Pos=MM+i-1;
		long long Sum=0;
		while(Pos)
		{
			Sum+=Op[Pos].first+Op[Pos].second*i;
			Pos/=2;
		}
		Min=min(Min,Sum);
	}
	cout<<Min<<endl;
	return 0;
}

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

const int MAX_N=2*1e5+4;

int x[MAX_N],s[MAX_N];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
    s[i]=x[i];
  }
  sort(s,s+n);
  int l1=s[n/2-1],l2=s[n/2];
  for(int i=0;i<n;i++){
   if(l1==l2)cout<<l1<<endl;
   else if(x[i]<l2)cout<<l2<<endl;
   else cout<<l1<<endl;
  }
}
		

Measured memory_bytes: 3712
' Imports System.Collections.Generic
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim S As String = Console.ReadLine()
        Dim T As String = Console.ReadLine()
        Dim z = S.Zip(T, Function(first, second) New Char() { first, second })
        Dim ans = 0
        For Each v in z
            If v(0) = v(1) Then
                ans += 1
            End If
        Next
        Console.WriteLine(ans)
        Return
    End Sub
End Class

Measured memory_bytes: 26252
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>

using namespace std;

int a, b, c, x;
int cnt = 0;
bool memo[51][51][51];

void go(int m, int A, int B, int C) {
    if (m > x or A > a or B > b or C > c) return;
    if (memo[A][B][C]) return;
    memo[A][B][C] = true;
    if (m == x) {
        cnt++;
        return;
    }
    go(m+500, A+1, B, C);
    go(m+100, A, B+1, C);
    go(m+50, A, B, C+1);
    return;
}

int main()
{
    cin >> a >> b >> c >> x;
    go(0, 0, 0, 0);
    cout << cnt << '\n';
   
   return 0;
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


A.sort()
m = 0
for i in range(1, N-K+2):
    m += cmb(N-i, K-1, mod)*A[i-1]
    m %= mod

A.reverse()
M = 0
for i in range(1, N-K+2):
    M += cmb(N-i, K-1, mod)*A[i-1]
    M %= mod

print((M-m)%mod)


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

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const ll inf = 1e12;
const ll mod = 1e9 + 7;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  ll n;
  cin >> n;

  if (n % 2) {
    cout << "0" << endl;
    return 0;
  }

  ll p = 10, ret = 0;
  while (p <= n) {
    ret += n / p;
    p *= 5;
  }
  cout << ret << endl;

}

Measured memory_bytes: 3636
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let r: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    println!("{}", r * r);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int A,B;

    scanf("%d%d",&A,&B);
    if( A <= 8 && B <= 8 ){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 128
use std::cmp::min;

fn main() {
    let v: Vec<usize> = read_nums();
    let (H, W, N) = (v[0], v[1], v[2]);
    let mut obs: Vec<usize> = vec![W ; H];
    for i in 0..N {
        let v: Vec<usize> = read_nums();
        let (X, Y) = (v[0] - 1, v[1] - 1);
        obs[X] = min(obs[X], Y);
    }
    let mut result = H;
    let mut taka = 0;
    for h in 1..H {
        if obs[h] <= taka {
            result = h;
            break;
        } else if taka + 1 < obs[h] && taka + 1 < W {
            taka += 1;
        }
    }
    println!("{}", result);
}

fn read_str() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

fn read_num<T>() -> T where 
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {
    read_str().trim().parse().unwrap()
}

fn read_nums<T>() -> Vec<T> where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {
    let s = read_str();
    let a: Vec<&str> = s.split_whitespace().collect();
    let mut v: Vec<T> = Vec::new();
    for x in a {
        v.push(x.parse().unwrap());
    }
    v
}



Measured memory_bytes: 6396
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sorted(sc)

def f1():
    if m == 0:
        return 0
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    """
    l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    for i in l:
        for j in range(m):
            if i == s[j][1]:
                return i
    return -1
    """
    return sc[0][1]

def f2():
    if m == 0:
        return 10
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [10 * i + j for i in range(1, 10) for j in range(0, 10)]
    sl = ["1", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1]
    for i in l:
        if str(i) == s:
            return i
    return -1

def f3():
    if m == 0:
        return 100
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [100 * i + 10 * j + k for i in range(1, 10) for j in range(0, 10) for k in range(0, 10)]
    sl = ["1", "0", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1] + sl[2]
    for i in l:
        if str(i) == s:
            return i
    return -1

if n == 1:
    print(f1())
elif n == 2:
    print(f2())
else:
    print(f3())


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long X;
  cin >> X;
  long long cur = 100;
  long long  count = 0;
  while (cur < X) {
    long long deposit = (long long)((double)cur * 0.01);
    
    cur += deposit;
    count += 1;
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(){
		int H,W,a,b;
while(1){
scanf("%d %d",&H,&W);
if(H==0&&W==0)
break;
for(a=1;a<=H;a++){
for(b=1;b<=W;b++){
if(a%2>0){
if(b%2>0){
	printf("#");
}
else{
printf(".");
}
}
else{
if(b%2>0){
	printf(".");
}
else{
printf("#");
}
}
}
printf("\n");
}
printf("\n");
}
return 0;
}

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000007; //

ll A[MAX_N];
int B[2][MAX_N];
ll C[3][MAX_N];
int n;
ll x,y;

ll f(int force,int idx){
  if(idx == n) return 1;
  
  ll& ans = C[force][idx];
  if(ans >= 0) return ans;
  
  ans = 0;
  if(force != 2){
    int ind = lower_bound(A+idx,A+n,A[idx]+x)-A;
    
    if(ind == idx+1){
      ans += f(0,ind);
    } else {
      ind--;
      if(B[1][idx+1] >= ind)
        ans += f(2,ind);
    }
  }
  
  if(force != 1){
    int ind = lower_bound(A+idx,A+n,A[idx]+y)-A;
    
    if(ind == idx+1){
      ans += f(0,ind);
    } else {
      ind--;
      if(B[0][idx+1] >= ind)
        ans += f(1,ind);
    }
  }
  
  while(ans >= MODD) ans -= MODD;
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> n;
  cin >> x >> y;
  for(int i=0;i<n;i++) cin >> A[i];
  
  B[0][n-1] = B[1][n-1] = n;
  for(int i=n-2;i>=0;i--){
    if(A[i+1] - A[i] < x) B[0][i] = i;
    else B[0][i] = B[0][i+1];
    
    if(A[i+1] - A[i] < y) B[1][i] = i;
    else B[1][i] = B[1][i+1];
  }
  
  for(int i=0;i<3;i++)
    for(int j=0;j<MAX_N;j++)
      C[i][j] = -1;
  
  cout << f(0,0) << endl;
  
  return 0;
}


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

#define ll long long
#define str string

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

vector < pair<ll, ll> > v;
ll Y[10000000] = {}, X[10000000] = {},m = 0,a = 0,b = 0,n = 0, x = 0,y = 0,sum = 0;
str W[100];
str S,Sa;
bool ans = true;

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
		//Code Line
cin >> n;
for(int i = 0;i < n;i++){
	cin >> W[i];
	if(i > 0){
if(W[i - 1][W[i - 1].size() - 1] != W[i][0])ans = false;
	}
	for(int j = 0;j < n;j++){
	if(j != i){
		if(W[j] == W[i])ans = false;
	}
	}
}
	if(ans)cout << "Yes" << endl;
	else cout << "No" << endl;
		//Code Line
return 0; 
}


Measured memory_bytes: 256
X, Y = map(int, input().split())
ans = 0
x = 0
y = 0
if X == 1:
    x = 300000
if Y == 1:
    y = 300000
if X == 2:
    x = 200000
if Y == 2:
    y = 200000
if X == 3:
    x = 100000
if Y == 3:
    y = 100000
if X == 1 and Y == 1:
    ans += 400000
print(ans + x + y)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> table(n, vector<int>(m, 0));

    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            table[s - 1][i]++;
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    for (ll bit = 0; bit < (1ll << n); bit++) {
        vector<int> state(m, 0);
        for (int i = 0; i < n; i++) {
            if (bit & (1ll << i)) {
                for (int j = 0; j < m; j++) {
                    if (table[i][j]) {
                        state[j]++;
                    }
                }
            }
        }
        bool nice = true;
        for (int i = 0; i < m; i++) {
            if (p[i] != (state[i] % 2)) nice = false;
        }
        if (nice) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, a, b, c=map(int, input().split())
l=[0]*n
ch=0
ans=0

for i in range(n):
    l[i]=int(input())

ans+=abs(l[0]-a)
ans+=abs(l[1]-b)
ans+=abs(l[2]-c)

    
for i in range(4**n):
    ch=0
    mp=0
    s=[0]*4
    for j in range(n):
        for k in range(3):
            if (i>>2*j) % 2**2 ==k:
                if s[k]==0:
                    0
                else:
                    mp+=10
                s[k]+=l[j]
                    
    for p in range(3):
        if s[p]==0:
            #invalid
            ch=1
    if ch==1:
        0
        #invalid
    else:
        mp+=abs(int(s[0]-a))
        mp+=abs(int(s[1]-b))
        mp+=abs(int(s[2]-c))
        if mp<ans:
            ans=mp
            s_ans=s
            j_ans=j
    #print('bin(j),ch,s,mp',bin(i),ch,s,mp,abs(int(s[0]-a)),abs(int(s[1]-b)),abs(int(s[2]-c)))
    
print(ans)
#print(bin(j_ans),s_ans)
    
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long x,k,d,dis1,dis2;
long long jdz(long long a){
	if(a<0) return -a;
	return a;
}
int main(){
	cin>>x>>k>>d;
	if(x<0) x=-x;
	dis1=x%d;
	k-=x/d;
	if(k<0){
		dis1+=d*(-k);
		cout<<dis1;
		return 0;
	}
	dis2=dis1-d;
	if(--k<0){
		cout<<jdz(dis1);
		return 0;
	}
	if(k%2){
		cout<<jdz(dis1);
		return 0;
	}
	cout<<jdz(dis2);
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int H[] = new int[N];
        long sum = 0;
        for(int i=0;i<N;i++)
        {
            H[i] = sc.nextInt();
        }
        Arrays.sort(H);
        for(int j=0;j<N-K;j++)
        {
            sum = sum + H[j];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 65424
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
using namespace std;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	set <string> s;
	string x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
}




Measured memory_bytes: 19272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) 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> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<vector<int>> f(n,vector<int>(10));
	rep(i,n){
		rep(j,10){
			cin >> f[i][j];
		}
	}
	vector<vector<int>> p(n,vector<int>(11));
	rep(i,n) rep(j,11) cin >> p[i][j];
	ll ans = -1e10;
	rep(i,(1 << 10)){
		if(i == 0) continue;
		ll sum = 0;
		rep(j,n){
			int cnt = 0;
			rep(k,10){
				if(((1 << k) & i) && f[j][k]) cnt++;
			}
			sum += p[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


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

#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forse(i,s,e) for(int i=(int)s;i<(int)e;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using dbl=double;
using ll=long long;
using pii=pair<int, int>;
using pll=pair<ll, ll>;

dbl PI=3.141592653589793;


void solve(){
	ll out=0;
	int n,q;
	map<int,int> cnt;
	cin >> n;
	vector<int> a(n);
	forn(i,n){
	   	cin >> a[i];
		out+=a[i];
		cnt[a[i]]++;
	}
	cin >> q;
	forn(i,q){
		int b,c;
		cin >> b >> c;
		if(b==c){ 
			cout << out << '\n';
			continue;
		}
		auto it=cnt.lower_bound(b);

		if(it==cnt.end()||it->fi!=b){
			cout << out << '\n';
		   	continue;
		}
		out+=1ll*(c-b)*cnt[b];
		cnt[c]+=cnt[b];
		cnt.erase(it);
		cout << out << '\n';
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	for(int c=1;c<=T;c++){
		solve();
	}
}


Measured memory_bytes: 6628
# -*- coding: utf-8 -*-
s = raw_input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

if A+B+C+D == 7:
    print '%s+%s+%s+%s=7' % (A, B, C, D)
elif A+B+C-D == 7:
    print '%s+%s+%s-%s=7' % (A, B, C, D)
elif A+B-C+D == 7:
    print '%s+%s-%s+%s=7' % (A, B, C, D)
elif A-B+C+D == 7:
    print '%s-%s+%s+%s=7' % (A, B, C, D)
elif A+B-C-D == 7:
    print '%s+%s-%s-%s=7' % (A, B, C, D)
elif A-B+C-D == 7:
    print '%s-%s+%s-%s=7' % (A, B, C, D)
elif A-B-C+D == 7:
    print '%s-%s-%s+%s=7' % (A, B, C, D)
elif A-B-C-D == 7:
    print '%s-%s-%s-%s=7' % (A, B, C, D)

Measured memory_bytes: 2696
#include<stdio.h>
 
int main(void){
  int n,i;
  long long total=0;
  
  do{
    scanf("%d",&n);
  }while(n<1 || n>1000000);
  
  for(i=1; i<=n; i++){
    if(i%3 != 0){
      if(i%5 != 0){
        total += i;
      }
    }
  }
  
  printf("%lld",total);
  
  return 0;
}

Measured memory_bytes: 1704
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

vector<int> co(26);
vector<int> da(4);

int solve(){
	int h,w; cin >> h >> w;
	rip(i,h,0){
		string s; cin >> s;
		rip(j,w,0) co[s[j]-'a']++;
	}
	rip(i,26,0) da[co[i]%4]++;
	if(h&1 == 1 && w&1 == 1){
		if(da[1]+da[3] != 1) return false;
	}
	else{
		if(da[1]+da[3]) return false;
	}
	int k = h%2*(w/2) + w%2*(h/2);
	if(k < da[2]) return false;
	else return true;
}

int main(){
	printf((solve())?"Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N = 0;
  int sum = 0; 
  cin >> N; //Nを代入
  vector<int> vec(N - 1);
  for(int i = 0; i < N - 1; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < N - 2; i++){
      sum = sum + min(vec.at(i),vec.at(i + 1));
    }
  sum = sum + vec.at(0);
  sum = sum + vec.at(N - 2);
  cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int N=600010,mod=1e9+7;
ll n,m,T,k,cnt,x,y,z,indx,t,ans,sum;
int main()
{
	scanf("%lld",&n);
	for (ll i=1;i<=n;i++) ans+=i*(n-i+1);
	for (int i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if (x>y) swap(x,y);
		sum+=x*(n-y+1);
	}
	printf("%lld\n",ans-sum);
}

Measured memory_bytes: 3832
A,B=map(int,input().split())

def f(a):
    ret=0
    a+=1
    for i in range(40):
        cycle=2<<i
        one_count=(a//cycle)*cycle//2 + max(0, a%cycle - cycle//2)
        if one_count&1:
            ret|=1<<i
        #print(a, cycle, one_count)
    return ret

print(f(B)^f(A-1))

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

int s(int n, bool f) {
  vector<int> a;
  for (int i = 0; i < 4; ++i) {
    a.push_back(n % 10);
    n /= 10;
  }

  sort(a.begin(), a.end());
  if (f) reverse(a.begin(), a.end());

  int res = 0;
  for (int i = 0; i < 4; ++i) {
    res *= 10;
    res += a[i];
  }

  return res;
}

int main() {
  int n;

  while (cin >> n, n) {
    if (n % 1111 == 0) {
      cout << "NA" << endl;
      continue;
    }

    // cout << s(n, true) - s(n, false) << endl;

    int cnt = 0;
    while (n != 6174) {
      cnt++;
      n = s(n, true) - s(n, false);
    }

    cout << cnt << endl;
  }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

vector<bool> IsPrime;
void sieve(size_t maxv){
    if(maxv+1 > IsPrime.size()){
        IsPrime.resize(maxv+1,true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;
    for(size_t i=2; i*i<=maxv; ++i)
        if(IsPrime[i])
            for(size_t j=2; i*j<=maxv; ++j)
                IsPrime[i*j] = false;
}

int main(){
    int q, ans; sc(q)
    vector<int> l(q), r(q), dp(1e5+1,0);
    for (int i = 0; i < q; i++){
        sc(l[i]) sc(r[i])
    }
    sieve(1e5);
    dp[0] = dp[1] = 0;
    for (int i = 2; i <= 1e5; i++){
        if (IsPrime[i] && IsPrime[(i+1)/2]){
            dp[i] = dp[i - 1] + 1;
        }else dp[i] = dp[i - 1];
    }
    for (int i = 0; i < q; i++){
        cout << dp[r[i]] - dp[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
function main()
  N=parse(Int,readline())
  dp=ones(Int,N+1,4)*-1145141919810931893
  dp[1,1]=0
  A=map(x->parse(Int,x),split(readline()))
  for i=1:N
    a=A[i]
    for j=1:3
      dp[min(i+2,N+1),j+(i+2==N+1 ? 1 : 0)]=max(dp[min(i+2,N+1),j+(i+2==N+1 ? 1 : 0)],dp[i,j]+a)
      dp[i+1,j+1]=max(dp[i+1,j+1],dp[i,j])
    end
  end
  println(dp[N+1,2+N%2])
end
main()

Measured memory_bytes: 224196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
inline LL Gcd(LL a,LL b)
{
	if(a%b==0)return b;
	return Gcd(b,a%b);
}
inline LL Calc(LL a,LL b,LL num)
{
	return num-num/a-num/b+num/a*Gcd(a,b)/b;
}
int main(void)
{
	LL A,B,C,D;
	scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
	printf("%lld\n",Calc(C,D,B)-Calc(C,D,A-1));
	return 0;
}


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

using namespace std;

int main(){
    long long n,tmp,count=0;
    cin >> n;
    unordered_map<long long, long long> m;
    for(long long i = 0; i< n;i++){
        cin >> tmp;
        if(m.find(tmp) != m.end())
            m[tmp]++;
        else
            m[tmp] = 1;
    }
    for(auto it = m.begin(); it != m.end(); it++){
        if(it->first <= it->second){
            count += it->second - it->first;
        } else {
            count += it->second;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 4260
// https://atcoder.jp/contests/keyence2020/tasks/keyence2020_a
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn main() {
    input! {
        h: i32, w: i32, n: i32
    };
    let ans = min((n+w-1)/w, (n+h-1)/h);
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
Blist = list(map(int, input().split()))

ans = Blist[0]
if N > 2:
    for i in range(N-2):
        if Blist[i] > Blist[i+1]:
            ans += Blist[i+1]
        else:
            ans += Blist[i]
    
    ans += Blist[N-2]

else:
    ans += Blist[0]

print(ans)

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

#define int long long

signed main() {
  int n;
  cin >> n;

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

  bool flag = true;
  int cnt = 0;
  while ( flag ) {
    flag = false;
    for ( int i = n-1; i >= 1; i-- ) {
      if ( a[i] < a[i-1] ) {	
	swap(a[i], a[i-1]);
	flag = true;
	cnt++;
      }
    }
  }

  for ( int i = 0; i < n; i++ ) {
    if ( i ) cout << " ";	        
    cout << a[i];
  }
  cout << endl;

  cout << cnt << endl;
  
  return 0;
}



Measured memory_bytes: 3096
n=int(input())
h=list(map(int,input().split()))
if n==1:
  print("Yes")
else:
  min=0
  for i in range(n):
    if h[i]>min:
      min=h[i]-1
    if h[i]<min:
      print("No")
      break
  else:
      print("Yes")

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

int main(){
    string S;
    cin >> S;
    if (S == "SUN") cout << 7 << endl;
    if (S == "MON") cout << 6 << endl;
    if (S == "TUE") cout << 5 << endl;
    if (S == "WED") cout << 4 << endl;
    if (S == "THU") cout << 3 << endl;
    if (S == "FRI") cout << 2 << endl;
    if (S == "SAT") cout << 1 << endl;
    return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define RFOR(i, k, j) for (int i = k - 1; i >= j; i--)
#define RREP(i, j) RFOR(i, j, 0)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

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;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
  
    ll n, x;
    cin >> n >> x;
  
    vll a(n);
    cin >> a;
  
    ll ans = (1LL << 50);
    vll b(n, (1LL << 50));
    REP(i, n) {
        REP(j, n) {
            b[j] = min(b[j], a[(j - i + n) % n]);
        }

        ll s = 0;
        REP(j, n) s += b[j];
        ans = min(ans, s + i * x);
    }

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


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N;
vector<int> a;

void init()
{
	cin >> N;
	a.resize(N);
	rep(i, N) cin >> a[i];
}

void solve()
{
	int res = 1;
	int state = 0;
	reps(i, 1, N) {
		if (state == 0) {
			if (a[i] < a[i-1]) state = -1;
			if (a[i] > a[i-1]) state = 1;
		} else if (state == 1) {
			if (a[i] < a[i-1]) {
				res++;
				state = 0;
			}
		} else {
			if (a[i] > a[i-1]) {
				res++;
				state = 0;
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 640
d = int(input())
cs = list(map(int, input().split()))
sm = [list(map(int, input().split())) for _ in range(d)]
ts = [int(input()) for _ in range(d)]
ls = [0] * 26

s = 0
for i in range(d):
    t = ts[i]
    t -= 1
    s += sm[i][t]
    ls[t] = i + 1
    #print('contest',t+1)
    #print('plus',sm[i][t])
    #print(ls)
    #print(cs)

    dis = sum(c * ((i+1) - l) for c, l in zip(cs, ls))
    #print('dis',dis)
    s -= dis

    print(s)


Measured memory_bytes: 9152
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <set>
using namespace std;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j, k, l, m, n;
  int c;

  for ( c = 1; ; ++c )
  {
    int d[ 5 ][ 5 ][ 5 ];
    set<int> a;
    set<int> b;
    int N;

    scanf ( "%d", &N );
    if ( N == 0 ) break ;
    for ( i = 0; i < 5; ++i )
    for ( j = 0; j < 5; ++j )
    {
      scanf ( "%d", &d[ i ][ j ][ 4 ] );
      d[ i ][ j ][ 0 ] = ( d[ i ][ j ][ 4 ] / 10000 ) % 10;
      d[ i ][ j ][ 1 ] = ( d[ i ][ j ][ 4 ] / 1000 ) % 10;
      d[ i ][ j ][ 2 ] = ( d[ i ][ j ][ 4 ] / 100 ) % 10;
      d[ i ][ j ][ 3 ] = ( d[ i ][ j ][ 4 ] / 10 ) % 10;
      d[ i ][ j ][ 4 ] = ( d[ i ][ j ][ 4 ] / 1 ) % 10;
    }
    scanf ( "%d", &m );
    for ( i = 0; i < m; ++i )
    {
      int d;
      scanf ( "%d", &d );
      a.insert ( d );
    }
    scanf ( "%d", &m );
    for ( i = 0; i < m; ++i )
    {
      int d;
      scanf ( "%d", &d );
      b.insert ( d );
    }

    while ( N-- )
    {
      int r[ 5 ][ 5 ][ 5 ] = { 0 };

      for ( i = 0; i < 5; ++i )
      for ( j = 0; j < 5; ++j )
      for ( k = 0; k < 5; ++k )
      {
        for ( l = max ( 0, i - 1 ); l < min ( 5, i + 2 ); ++l )
        for ( m = max ( 0, j - 1 ); m < min ( 5, j + 2 ); ++m )
        for ( n = max ( 0, k - 1 ); n < min ( 5, k + 2 ); ++n )
        {
          if ( l == i && m == j && n == k ) continue ;
          r[ i ][ j ][ k ] += d[ l ][ m ][ n ];
        }
      }

      for ( i = 0; i < 5; ++i )
      for ( j = 0; j < 5; ++j )
      for ( k = 0; k < 5; ++k )
      {
        if ( d[ i ][ j ][ k ] )
        {
          if ( b.find ( r[ i ][ j ][ k ] ) == b.end ( ) )
            d[ i ][ j ][ k ] = 0;
        }
        else
        {
          if ( a.find ( r[ i ][ j ][ k ] ) != a.end ( ) )
            d[ i ][ j ][ k ] = 1;
        }
      }
    }

    if ( c != 1 ) puts ( "" );
    printf ( "Case %d:\n", c );
    for ( i = 0; i < 5; ++i )
    {
      if ( i ) puts ( "" );
      for ( j = 0; j < 5; ++j )
      {
        for ( k = 0; k < 5; ++k )
          printf ( "%d", d[ i ][ j ][ k ] );
        puts ( "" );
      }
    }
  }

  return ( EXIT_SUCCESS );
}

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

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

    int ans = 15;

    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            ll a = i, b = n/i;
            int len = max(to_string(a).size(), to_string(b).size());
            ans = min(ans, len);
        }
    }

    cout << ans << endl;

}


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

using namespace std;

int main() {
  int n,t;cin>>n>>t;
  int ans=1e9;
  bool f=false;
  rep(i,n){
    int a,b;cin>>a>>b;
    if(b<=t){
      ans=min(ans,a);
      f=true;
  }
  }
  if(f)cout<<ans<<endl;
    else cout<<"TLE"<<endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}


int n;
vll a;
vll accum;

vll calc(int bi, int ei) {
  ll sum = accum[ei] - accum[bi];
  int lb = lower_bound(all(accum), accum[bi] + sum/2) - accum.begin();
  ll fir = accum[lb] - accum[bi];
  ll dif1 = max(sum - fir, fir) - min(sum - fir, fir);
  ll sec = accum[lb - 1] - accum[bi];
  ll dif2 = max(sum - sec, sec) - min(sum - sec, sec);
  vll ret;
  if (dif1 < dif2) {
    ret = {sum - fir, fir};
  } else {
    ret = {sum - sec, sec};
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  a.assign(n, 0);
  accum.assign(n+1, 0);
  rep(i, n) {
    scanf("%lld", &a[i]);
    accum[i+1] = accum[i] + a[i];
  }

  ll ans = 11234567890123456;
  FOR (i, 2, n-1) {
    vll v1 = calc(0, i);
    vll v2 = calc(i, n);
    vll v0 = {v1[0], v1[1], v2[0], v2[1]};
    sort(all(v0));
    ans = min(ans, v0[3] - v0[0]);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#include <queue>
#include<map>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define PI 3.14159265358979323846264338327950


int main() {
	ll N, mod = 1000000007, x = 0, ten = 1, nine=1, ei=1,ans = 0;

	cin >> N;


	rep(i, N){
		ten = (ten*10)%mod;
		nine = (nine*9) % mod;
		ei = (ei*8) % mod;
	}
	x = (ten+ei-nine*2)%mod;
	if (x < 0)x += mod;

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	string a,b;
	cin>>a>>b;
	bool ok=true;
	ok&=sz(a)<=sz(b);
	if(ok) for(int i=0;i<sz(a);++i) ok&=a[i]==b[i];
	cout<<(ok?"Yes":"No")<<"\n";
	return 0;	
}


Measured memory_bytes: 3612