akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
// #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

int main() 
{
    // fastio;

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

    int n;
    cin>>n;

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

    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}        

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll x, y;
  cin >> x >> y;
  
  ll a = (y - x >= 0 ? y - x : INF);
  ll b = (y + x >= 0 ? y + x + 1 : INF);
  ll c = (-y - x >= 0 ? -y - x + 1 : INF);
  ll d = (-y + x >= 0 ? -y + x + 2 : INF);


  cout << min(a, min(b, min(c, d))) << endl;

  return 0;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
string s[312],s1[312];
int n;
int check(int i){
	int a,b,j;
	if(i<0){
		a=0;
		b=i*-1;
	}
	else{
		a=i;
		b=0;
	}
	rep(i,n){
		rep(j,n){
			s1[i][j]=s[(i+a)%n][(j+b)%n];
		}
	}
	rep(i,n){
		rep(j,n){
			if(s1[i][j]!=s1[j][i])
				return 0;
		}
	}
	return 1;
}
int main(){
    std::ios::sync_with_stdio(false);
    
    cin>>n;
    int i;
    rep(i,n){
    	cin>>s[i];
    	s1[i]=s[i];
    }
    ll ans=0;
    f(i,1-n,n){
    	if(check(i))
    		ans+=n-abs(i);
    }
    cout<<ans<<endl;
    return 0;  
    
}



Measured memory_bytes: 512
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm> 
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
int a, b, c, d;
map<int, int> mp;
int dp(int n) {
    if(n == 0) return 0;
    if(n == 1) return d;
    if(mp[n] != 0) return mp[n];
    int res = INF;
    if(n < res / d) res = n * d;
    int l = n / 2, r = (n + 1) / 2;
    res = min(res, d * (n - l * 2) + a + dp(l));
    res = min(res, d * (r * 2 - n) + a + dp(r));
    l = n / 3, r = (n + 2) / 3;
    res = min(res, dp(l) + d * (n - l * 3) + b);
    res = min(res, dp(r) + (r * 3 - n) * d + b);
    l = n / 5, r = (n + 4) / 5;
    res = min(res, dp(l) + c + (n - l * 5) * d);
    res = min(res, dp(r) + c + (r * 5 - n) * d);
    mp[n] = res;
    return res;
}

signed main() {
    int T;
    cin >> T;
    while(T--) {
        int n;
        mp.clear();
        cin >> n >> a >> b >> c >> d;
        cout << dp(n) << endl;
    }

    return 0;
}

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

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

    //printf("%d", a*a);
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/php
<?php
$n = trim(fgets(STDIN));
$nums = explode(' ', trim(fgets(STDIN)));

$result = true;
for ($i = 0; $i < $n; $i++) {
  if ($nums[$i] % 2 == 0) {
    if ($nums[$i] % 3 == 0 || $nums[$i] % 5 == 0) {
    } else {
      $result = false;
      break;
    }
  }
}

if ($result) {
  echo 'APPROVED';
} else {
  echo 'DENIED';
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll sum = 0;
    rep2(i, 1, N-1){
        if(A[i] < A[i-1]) sum += A[i-1]-A[i], A[i] = A[i-1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 5192
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

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

        int x = sc.nextInt();
        int y = sc.nextInt();

        if(x==2 || y==2){
            System.out.println("No");
        }
        else if((x==4 || x==6 || x==9 || x==11) && (y==4 || y==6 || y==9 || y==11)){
            System.out.println("Yes");
        }
        else if((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) && (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21332
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

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

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

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

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  ll n, a, b; cin >> n >> a >> b;
  if ((b-a)%2 == 0) {
    cout << (b-a)/2 << endl;
  } else if (a-1 < n-b) {
    cout << a + (b-a)/2 << endl;
  } else {
    cout << (n-b+1) + (b-a)/2 << endl;
  }
}


/* -------- <programs end> -------- */


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


Measured memory_bytes: 256
Q = int(input())

p = [True] * (10 ** 5 + 1)
p[0] = p[1] = False
for i in range(2, 10 ** 5 + 1):
    for j in range(2 * i, 10 ** 5 + 1, i):
        p[j] = False

pp = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5 + 1):
    pp[i] = int(p[i] and p[(i + 1) // 2]) + pp[i - 1]

res = 0
for _ in range(Q):
    l, r = map(int, input().split())
    print(pp[r] - pp[l - 1])


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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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


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

    int n;
    cin >> n;

    double x;
    string s;
    double ans = 0;
    rep (i, n)
    {
        cin >> x >> s;
        if (s == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += x * 380000.0;
        }
    }

    cout << setprecision(10) << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let d: f64 = read();

    let mut ans = 0;
    for _ in 0..n {
        let a: f64 = read();
        let b: f64 = read();
        let d2 = ((a).powi(2) + (b).powi(2)).sqrt();
        if d2 <= d {
            ans +=1;
        }
    }
    print!("{}", ans);
}


Measured memory_bytes: 2184
#include<stdio.h>
int main(void)
{
	int t1,t2,t3,t4,n1,n2,n3,n4,i;
	scanf("%d %d",&t1,&n1);
	scanf("%d %d",&t2,&n2);
	scanf("%d %d",&t3,&n3);
	scanf("%d %d",&t4,&n4);
	if(t1==1){
		printf("%d\n",n1*6000);
	}
	else if(t1==2){
		printf("%d\n",n1*4000);
	}
	else if(t1==3){
		printf("%d\n",n1*3000);
	}
	else if(t1==4){
		printf("%d\n",n1*2000);
	}
	if(t2==1){
		printf("%d\n",n2*6000);
	}
	else if(t2==2){
		printf("%d\n",n2*4000);
	}
	else if(t2==3){
		printf("%d\n",n2*3000);
	}
	else if(t2==4){
		printf("%d\n",n2*2000);
	}
	if(t3==1){
		printf("%d\n",n3*6000);
	}
	else if(t3==2){
		printf("%d\n",n3*4000);
	}
	else if(t3==3){
		printf("%d\n",n3*3000);
	}
	else if(t3==4){
		printf("%d\n",n3*2000);
	}
	if(t4==1){
		printf("%d\n",n4*6000);
	}
	else if(t4==2){
		printf("%d\n",n4*4000);
	}
	else if(t4==3){
		printf("%d\n",n4*3000);
	}
	else if(t4==4){
		printf("%d\n",n4*2000);
	}
	return 0;
}


Measured memory_bytes: 2756
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(len(a)):
  counter=0
  while 1:
    
    if a[i]%2==0:
      counter+=1
      a[i]=a[i]//2
    else:
      break
  count+=counter
print(count)

Measured memory_bytes: 10104
import itertools
Ops = ["+","-","*"]
Formulae = ["(({3}{0}{4}){1}{5}){2}{6}",
            "({3}{0}{4}){1}({5}{2}{6})",
            "({3}{0}({4}{1}{5})){2}{6}",
            "{3}{0}(({4}{1}{5}){2}{6})",
            "{3}{0}({4}{1}({5}{2}{6}))",]

while True:
    nums = list(map(int,input().split()))
    if nums==[0,0,0,0]: break
    flag = False
    for numpair in itertools.permutations(nums):
        if flag: break
        for op in itertools.product(Ops, repeat=3):
            if flag: break
            for form in Formulae:
                if eval(form.format(op[0], op[1], op[2], numpair[0], numpair[1], numpair[2], numpair[3])) == 10:
                    print(form.format(op[0], op[1], op[2], numpair[0], numpair[1], numpair[2], numpair[3]))
                    flag = True
                    break
    else: print(0)

Measured memory_bytes: 7488
#include <stdio.h>

int main(void) {
  int ans, i, j, k, a, b, n;
  while(scanf("%d%d%d", &a, &b, &n) != EOF) {
    ans = 0;
    a %= b;
    for(i = 0; i < n; ++i) {
      a *= 10;
      ans += a / b;
      a %= b;
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2736
#include <iostream>
using namespace std;
int F[100];
int main() 
{
int n;
F[0] = 1;
F[1] = 1;
for (int i=2; i<45; ++i) 
{ // ???????????????
F[i] = F[i-2]+F[i-1];
}
cin>>n;
cout<<F[n]<<endl;
}

Measured memory_bytes: 3104
# ALDS1_3_C.py
'''
本来はlinkedList を自前実装する必要がありそうだが、Python だとDequeで実装できる。
'''
from collections import deque
N = int(input())
linkedList = deque([])
for i in range(N):
    command = input().split()
    if command[0] == "insert":
        linkedList.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in linkedList:
                linkedList.remove(command[1])
    elif command[0] == "deleteFirst":
        linkedList.popleft()
    elif command[0] == "deleteLast":
        linkedList.pop()
print(" ".join(list(linkedList)))


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

using namespace std;

#define LL long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string n;
    cin>>n;
    char ost = n[n.size()-1];
    if(ost == '3')
        cout<<"bon";
    else if(ost=='0' || ost=='1' || ost=='6' || ost=='8')
        cout<<"pon";
    else
        cout<<"hon";
}


Measured memory_bytes: 3608
unittest
{
	assert( [ "11 3 2", "ooxxxoxxxoo" ].parse.expand.solve == "6" );
	assert( [ "5 2 3", "ooxoo" ].parse.expand.solve == "1\n5" );
	assert( [ "5 1 0", "ooooo" ].parse.expand.solve == "" );
	assert( [ "16 4 3", "ooxxoxoxxxoxoxxo" ].parse.expand.solve == "11\n16" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nkc = input.front.split.to!( long[] );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( nkc[ 1 ], nkc[ 2 ], s );
}

auto solve( long k, long c, dchar[] s )
{
	// 一番早く働く場合の働く日を判定
	long[] fs;
	for( auto i = 0L; i < s.length; i++ )
	{
		if( s[ i ] == 'o' )
		{
			fs ~= i;
			i += c;
		}
	}
	
	// 働く日の最大日数がkを超えるときは全ての働く日が確定しない
	if( k < fs.length ) return "";
	
	// 一番遅く働く場合の働く日を判定
	long[] ds;
	for( auto i = s.length.signed - 1; 0 <= i; i-- )
	{
		if( s[ i ] == 'o' )
		{
			ds ~= i;
			i -= c;
		}
	}
	
	// 一番早く働く場合と一番遅く働く場合で働く日が同じなら確定
	long[] anss;
	foreach( f, d; lockstep( fs, ds.retro ) )
	{
		if( f == d ) anss ~= f + 1;
	}
	return anss.empty ? "" : anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 20220
import java.awt.geom.Line2D;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    class P {
        double x, y;
        
        P(double x_, double y_) {
            x = x_;
            y = y_;
        }
        
        P add(P p) {
            return new P(x + p.x, y + p.y);
        }
        
        P sub(P p) {
            return new P(x - p.x, y - p.y);
        }
        
        P mul(double v) {
            return new P(x * v, y * v);
        }
        
        P div(double v) {
            return new P(x / v, y / v);
        }
        
        double dot(P p) {
            return x * p.x + y * p.y;
        }
        
        double det(P p) {
            return x * p.y - y * p.x;
        }
        
        double abs2() {
            return x * x + y * y;
        }
        
        double abs() {
            return Math.sqrt(abs2());
        }
        
        P norm() {
            return div(abs());
        }
        
        P rot90() {
            return new P(-y, x);
        }
        
        P proj(P src, P dst) {
            P p_sd = dst.sub(src).norm();
            return src.add(p_sd.mul(sub(src).dot(p_sd)));
        }
        
        P reflect(P src, P dst) {
            P middle = proj(src, dst);
            return add(middle.sub(this).mul(2));
        }
        
        public String toString() {
            return String.format("%f %f", x, y);
        }
    }
    
    P isLL(P p1, P p2, P q1, P q2) {
        double d = p2.sub(p1).det(q1.sub(q2));
        if(Math.abs(d) < 1e-10) return null;
        return p1.add(p2.sub(p1).mul(q1.sub(q2).det(p1.sub(q2)) / d));
    }
    
    boolean intersect(P p1, P p2, P q1, P q2) {
        return Line2D.linesIntersect(p1.x, p1.y, p2.x, p2.y, q1.x, q1.y, q2.x, q2.y);
    }
    
    double distSS(P p1, P p2, P q1, P q2) {
        if(intersect(p1, p2, q1, q2)) return 0;
        
        double dist = Double.MAX_VALUE;
        for(double d : new double[] {distSP(p1, p2, q1), distSP(p1, p2, q2), 
                                     distSP(q1, q2, p1), distSP(q1, q2, p2)}) {
            dist = Math.min(d, dist);
        }
        return dist;
    }
    
    double distSP(P p1, P p2, P p) {
        return Line2D.ptSegDist(p1.x, p1.y, p2.x, p2.y, p.x, p.y);
    }
    
    void run() {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        
        while(q-- > 0) {
            P p1 = new P(sc.nextDouble(), sc.nextDouble());
            P p2 = new P(sc.nextDouble(), sc.nextDouble());
            P q1 = new P(sc.nextDouble(), sc.nextDouble());
            P q2 = new P(sc.nextDouble(), sc.nextDouble());
            
            System.out.println(distSS(p1, p2, q1, q2));
        }
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
    
    static void tr(Object... objects) {
        System.out.println(Arrays.deepToString(objects));
    }
}


Measured memory_bytes: 55872
#define _DEBUG
#include "bits/stdc++.h"
#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K;
	ll A[51][51];
	scan(N>>K);
	mcf_graph<int,ll> g(2*N+2);
	g.add_edge(2*N,2*N+1,N*K,INF);//流せるだけ流せばよいとは限らないので、sからtへ利益0の逃げ道を作る
	rep(i,N) g.add_edge(2*N,i,K,0);//sから行へ
	rep(i,N) g.add_edge(N+i,2*N+1,K,0);//列からtへ
	rep(i,N){
		rep(j,N){
			scan(A[i][j]);
			g.add_edge(i,N+j,1,INF-A[i][j]);//行から列へ、それぞれ1つしか選択できない
		}
	}
	char s[51][51]={};
	rep(i,N) rep(j,N) s[i][j]='.';
	pll capcost=g.flow(2*N,2*N+1,N*K);//流せる最大量はN*K
	ll ans=(ll)N*K*INF-capcost.second;//全体を通して必ずN*Kだけ流れている
	for(const auto& e:g.edges()){
		//debug(e.from,e.to,e.flow,e.cost);
		if(e.cap==1&&e.flow==1){
			s[e.from][e.to-N]='X';
		}
	}
	prin(ans);
	rep(i,N) prin(s[i]);
	return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, p;
int a[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	scanf("%d", &p);

	forn (i, n)
		scanf("%d", a + i), a[i] %= 2;

	return true;
}

void solve()
{
	if (n == 1)
	{
		if (a[0] % 2 == p)
			printf("%d\n", 1 + (p ^ 1));
		else
			printf("%d\n", p ^ 1);
	}
	else
	{
		int ev = count(a, a + n, 0);
		int od = n - ev;

		if (od == 0)
		{
			if (p == 0)
				printf("%lld\n", 1ll << ev);
			else
				printf("0\n");
		}
		else
			printf("%lld\n", (1ll << ev) * (1ll << (od - 1)));
	}
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
void rebirth(int a[], int b[], int n);
int main(void){
    int i, n, a[10000], b[10000];
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
        }
    rebirth(a, b, n);
    for(i = 1, printf("%d", b[0]); i < n; i++){
        printf(" %d", b[i]);
    }
    printf("\n");
    return 0;
}
void rebirth(int a[], int b[], int n){
    int i;
    for(i = 0; i < n; i++){
        b[i] = a[n -1 -i];
    }
    return;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
const int INF = 1e9+10;
typedef long long ll;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0;i < N;i++)cin >> h[i];
  vector<int> dp(N,INF);
  dp[0] = 0;
  for(int i = 1;i < N;i++){
    for(int j = 1;j <= min(i,K);j++){
      dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    char s[4];
    int c=0,i;
    scanf("%s",&s);
    if(strcmp(s,"RSR")==0)
    printf("1\n");
    else{
    for(i=0;i<3;i++){
        if(s[i]=='R')
        c++;
    }
    printf("%d\n",c);}
}

Measured memory_bytes: 1736
require 'complex'

N = gets.to_i
a_xy = []
sum = 0.to_f

N.times do
  xy = gets.to_s.chomp.split.map(&:to_i)
  a_xy.push(xy)
end

keiros = a_xy.permutation(N).to_a

keiros.each do |keiro|
  i = 0
  bx = 0
  by = 0
  
  keiro.each do |machi|
    x = machi[0]
    y = machi[1]
    
    if i > 0
      k = (x - bx) * (x - bx) + (y - by) * (y - by)
      kyori = Math.sqrt(k).to_f
      sum += kyori
    end
    
    bx = machi[0]
    by = machi[1]
    i += 1
  end
end

p sum / keiros.length

Measured memory_bytes: 8828
s = input()
q = int(input())

for i in range(q):
    command = list(input().split())
    a = int(command[1])
    b = int(command[2])
    if command[0] == "print":
        print(s[a:b + 1])
    elif command[0] == "reverse":
        t = s[a:b + 1]
        t = t[::-1]
        s = s[:a] + t + (s[b + 1:])
    elif command[0] == "replace":
        s = s[:a] + command[3] + s[b + 1:]



Measured memory_bytes: 5612
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[200001], P1[200001];
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

ll root[200001];
void pakuripair_sort(int N, ll A[], int B[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint(), K = getint(), L = getint();
	rep1(i, N) P[i] = -1;
	rep(i, K) {
		int p = getint(), q = getint();
		p = Find(p);
		q = Find(q);
		if (p != q) {
			if (P[p] > P[q]) swap(p, q);
			P[p] += P[q];
			P[q] = p;
		}
	}
	rep1(i, N) root[i] = Find(i);

	rep1(i, N) P[i] = -1;
	rep(i, L) {
		int p = getint(), q = getint();
		p = Find(p);
		q = Find(q);
		if (p != q) {
			if (P[p] > P[q]) swap(p, q);
			P[p] += P[q];
			P[q] = p;
		}
	}
	rep1(i, N) root[i] += (ll)Find(i) << 20;

	rep1(i, N) P[i] = i;
	pakuripair_sort(N, root + 1, P + 1);

	int mae = 1;
	for (int i = 2; i <= N; i++) {
		if (root[mae] != root[i]) {
			for (int j = mae; j < i; j++) P1[P[j]] = i - mae;
			mae = i;
		}
	}
	for (int j = mae; j <= N; j++) P1[P[j]] = N + 1 - mae;

	rep1(i, N) putint(P1[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int a[9];
  bool hit[9];
  fill_n(hit, 9, false);
#define A(i, j) a[(i) * 3 + (j)]
#define Hit(i, j) hit[(i) * 3 + (j)]
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      std::cin >> a[i * 3 + j];
    }
  }
  int N;
  std::cin >> N;
  for (int k = 0; k < N; ++k) {
    int b;
    std::cin >> b;
    auto it = find(begin(a), end(a), b);
    if (it != end(a)) {
      int pos = it - begin(a);
      hit[pos] = true;
    }
  }
  const char* res = nullptr;
  // horisontal check
  for (int i = 0; i < 3; ++i) {
  	if (Hit(i, 0) && Hit(i, 1) && Hit(i, 2)) {
      res = "Yes";
      break;
    }
  }
  // vertical check
  for (int j = 0; !res && j < 3; ++j) {
    if (Hit(0, j) && Hit(1, j) && Hit(2, j)) {
      res = "Yes";
      break;
    }
  }
  // cross check
  if (!res && Hit(0, 0) && Hit(1, 1) && Hit(2, 2)) {
    res = "Yes";
  }
  if (!res && Hit(0, 2) && Hit(1, 1) && Hit(2, 0)) {
    res = "Yes";
  }
  if (!res) {
    res = "No";
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
if (a%2 + b%2) %2 == 0:
    print(abs(a-b) // 2)
elif n - b < a - 1:
    p = n-b+1
    a += n-b
    b = n
    print(abs(a-b) // 2 + p)
else:
    p = a
    b -= a-1
    a = 1
    print(abs(a-b) // 2 + p)


Measured memory_bytes: 9156
n, m = map(int, input().split())
req = [list(map(int, input().split())) for i in range(m)]
for i in range(10000):
	st = str(i)
	if len(st) != n:
		continue
	ok = True
	for s, c in req:
		if int(st[s-1]) != int(c):
			ok = False
	if ok:
		print(st)
		exit(0)

print(-1)


Measured memory_bytes: 39408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

#define fs first
#define sc second

int main() {
    int N;
    cin >> N;
    int x[N];
    for(int i = 0; i < N; i++) {
        cin >> x[i];
    }

    int ans = 1000000000;
    for(int i = 1; i <= 100; i++) {
        int tmp = 0;
        for(int j = 0; j < N; j++) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto L = RD;

	long ans, best = long.max;
	foreach (i; 0..N)
	{
		if (abs(L+i) < abs(best))
			best = L+i;

		ans += L+i;
	}

	writeln(ans - best);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn gcd(a: i64, b: i64) -> i64 {
    let mut a = a;
    let mut b = b;
    if a < b {
        std::mem::swap(&mut a, &mut b);
    }
    if b == 0 {
        return a;
    }
    let mut r;
    while (a % b) != 0 {
        r = a % b;
        a = b;
        b = r;
    }
    b
}
#[test]
fn test_gcd() {
    assert_eq!(gcd(10, 5), 5);
    assert_eq!(gcd(20, 30), 10);
    assert_eq!(gcd(100, 3), 1);
    assert_eq!(gcd(3, 60), 3);
    assert_eq!(gcd(30, 20), 10);
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let gcd = gcd(a, b);
    let mut set: HashSet<i64> = HashSet::new();
    let sqrt = (gcd as f64).sqrt().ceil() as usize;
    let mut now = gcd;
    for i in 2..sqrt + 100 {
        let i = i as i64;
        while now % i == 0 {
            set.insert(i);
            now = now / i;
        }
        if now == 1 {
            break;
        }
    }
    // dbg!(gcd, now);
    if now != 1 {
        set.insert(now);
    }
    // dbg!(gcd, sqrt, set.clone());
    println!("{}", set.len() + 1);
}


Measured memory_bytes: 4352
def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr

mod=10**9+7
n=int(input())
l=[]
for i in range(1,n+1):
 l+=factorization(i)

ans=1
for i in set(l):
 ans*=l.count(i)+1
print(ans%mod)

Measured memory_bytes: 3064
k,a,b = gets.split.map(&:to_i)

ans = 1

if a+2>=b || k<=a
  #k回叩いて増やす
  ans += k
else
  #aまで増やす
  k -= a-1
  ans += a-1
  #円へ交換→ビスケットへ交換
  ans += (k/2)*(b-a)
  ans += 1 if k%2==1
end

p ans

Measured memory_bytes: 1788
def string_transformation():
    s = input()
    t = input()

    f = True
    dep = {}

    for sc,tc in zip(s,t):
        if (dep.get(tc) is not None or sc in dep.values()) and sc != dep.get(tc):
            print("No")
            f = False
            break
        else:
            dep[tc] = sc

    if f:
        print("Yes")

if __name__ == "__main__":
    string_transformation()

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> _P;
typedef pair<_P,int> P;
char map[1000][1001];
bool vst[1000][1000];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int H,W,N,X,Y;
int bfs(int target) {
	queue<P> Q;
	Q.push(P(_P(X,Y),0));
	vst[Y][X]=1;
	while(!Q.empty()) {
		P p=Q.front(); Q.pop();
		if(map[p.first.second][p.first.first]==('0'+target)) {
			X=p.first.first,Y=p.first.second;
			return p.second;
		}
		for(int i=0;i<4;i++) {
			int nx=p.first.first+dx[i],ny=p.first.second+dy[i];
			if(0>nx||nx>=W||0>ny||ny>=H) continue;
			if(vst[ny][nx]) continue;
			if(map[ny][nx]=='X') continue;
			Q.push(P(_P(nx,ny),p.second+1));
			vst[ny][nx]=1;
		}
	}
}
int main() {
	scanf("%d %d %d",&H,&W,&N);
	int x,y;
	for(int i=0;i<H;i++) {
		scanf("%s",map[i]);
		for(int j=0;j<W;j++) if(map[i][j]=='S') X=j,Y=i;
	}
	int ans=0;
	for(int i=1;i<=N;i++) {
		ans+=bfs(i);
		memset(vst,0,sizeof(vst));
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3008
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "No"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[6] == "O":
    over = "Yes"
  if seen[4] == "O" and seen[8] == "O":
    over = "Yes"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[2] == "O" and seen[5] == "O":
    over = "Yes"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[1] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[5] == "O":
    over = "Yes"
print(over)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, a, N);
  ll ans = 0;
  each(x, a) {
    while (x > 1 && x % 2 == 0) {
      ans++;
      x /= 2;
    }
  }
  print(ans);
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
       int n = sc.nextInt();
       int[] d = new int[n];
       for (int i = 0; i < n; i++) {
           d[i] = sc.nextInt();
       }
       int ans = 0;
       Arrays.sort(d);
       int b = d[n/2];
       int c = d[n/2 - 1];
       System.out.println(b-c);
    }

}


Measured memory_bytes: 51656
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int X1 = 0;
        int X2 = 0;
        X1 = (int) Math.floor(N / 1.08);
        X2 = (int) Math.ceil(N / 1.08);
        int trueN1 = 0;
        int trueN2 = 0;
        trueN1 = (int) Math.floor(X1 * 1.08);
        trueN2 = (int) Math.floor(X2 * 1.08);
        PrintWriter out = new PrintWriter(System.out);

        if (trueN1 != N && trueN2 != N) {
            out.println(":(");
            out.flush();
            sc.close();
            return;
        }

        if (trueN1 == N) {
            out.println(X1);
            out.flush();
        } else {
            out.println(X2);
            out.flush();
        }

        sc.close();
    }
}

Measured memory_bytes: 35772
#include <iostream>
#include <vector>

int main(){
    int n, m, x;
    std::cin >> n >> m >> x;
    std::vector<int> c(n);
    std::vector<std::vector<int>> a(n, std::vector<int>(m));
    for(int i = 0; i < n; ++i){
        std::cin >> c[i];
        for(int j = 0; j < m; ++j){
            std::cin >> a[i][j];
        }
    }
    int ans = 1e9;
    for(int bit = 0; bit < (1 << n); ++bit){
        std::vector<int> now(m);
        int tmp = 0;
        for(int i = 0; i < n; ++i){
            if(bit & (1 << i)){
                for(int j = 0; j < m; ++j) now[j] += a[i][j];
                tmp += c[i];
            }
        }
        bool ok = true;
        for(int i = 0; i < m; ++i){
            if(now[i] < x) ok = false;
        }
        if(ok) ans = std::min(ans, tmp);
    }
    std::cout << (ans == 1e9 ? -1 : ans) << std::endl;
}

Measured memory_bytes: 3592
import std.stdio,
      std.array,
      std.conv;

void main(){
  string s;
  int i = 0,j = 0;
  int[] result;
  for(;;){
    s=readln();
    if(stdin.eof()) break;
    result.length += 1;
    string[] input = split(s);
    int a = to!int(input[0]);
    int b = to!int(input[1]);
    int k = 0;
    int keta = 1;
    while(a+b >= keta){
      keta *= 10;
      ++k;
    }
    result[i] = k;
    ++i;
  }
  while(j < result.length){
    writeln(result[j]);
    ++j;
  }
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9+7;
int grid[1005][15];

int main() {

	int h, w, k;
	cin >> h >> w >> k;

	for(int i = 0; i < h; i++) {
		string row;
		cin >> row;
		for(int j = 0; j < w; j++) {
			grid[j][i] = row[j]-'0';
		}
	}	

	int ans = oo;
	for(int mask = 0; mask < (1<<(h-1)); mask++) {
		vector<int> cur;
		for(int idx = 0; idx < h; idx++) {
			//idx = 0 means after 0, so idx can get up to h-1 	
			if(idx == h-1 || mask&(1<<idx)) {
				cur.push_back(0);
			} 
		}

		bool invalid = false;
		int running = 0;
		for(int row = 0; row < w && !invalid; row++) {
			//add all the row

			vector<int> new_row((int)cur.size());
			for(int cnt = 0, idx = 0; idx < h; idx++) {
				new_row[cnt] += grid[row][idx];
				if(idx == h-1 || mask&(1<<idx)) {
					cnt++;	
				}	
			}

			//dow we need a new one? or is it invalid?
			bool need_new_row = false;
			//only stop looping for invalid because it eliminates this mask completely
			for(int idx = 0; idx < (int)cur.size() && !invalid; idx++) {
				if(new_row[idx] > k) invalid = true;	
				else if(new_row[idx]+cur[idx] > k) need_new_row = true;
			}
			
			if(need_new_row) {
				running++;
				cur = new_row;
			} else {
				for(int idx = 0; idx < (int)cur.size(); idx++) {
					cur[idx] += new_row[idx];
				}
			}
		}	

		if(!invalid) {
			int n_in_mask = 0;
			for(int idx = 0; idx < (h-1); idx++) if(mask&(1<<idx)) n_in_mask++;
			ans = min(ans, running+n_in_mask);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n >= 1000) {
			System.out.println("ABD");
		} else {
			System.out.println("ABC");
		}

		sc.close();
	}

}


Measured memory_bytes: 35656
#include <stdio.h>
#include <string.h>
 
int main() {
  int K;
  char S[101];
  scanf("%d\n", &K);
  scanf("%[^\n]", &S);
  int len = strlen(S);
 
  if(len <= K) {
    printf("%s", S);
  }
  else {
    for(int i = 0; i < K; i++) {
      printf("%c", S[i]);
    }
    printf("...");
  }
 
  return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int x = a * b;
		int y = (a + b) * 2;

		System.out.println(x + " " +y);
		scan.close();
	}
}


Measured memory_bytes: 26140
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int ans,a[100005],b[100005];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int mini=1e9;
	int A,B,m,x;
	cin>>A>>B>>m;
	FOR(i,1,A){
		cin>>a[i];
		mini=min(mini,a[i]);
	}
	ans=mini;mini=1e9;
	FOR(i,1,B){
		cin>>b[i];
		mini=min(mini,b[i]);
	}
	ans+=mini;
	int y,c;
	FOR(i,1,m){
		cin>>x>>y>>c;
		gmin(ans,a[x]+b[y]-c);
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = int64_t;
using ld = long double;
using namespace std;

const int MAXN = 1000001;

int p[MAXN];
int f[MAXN];

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int n;
    string s;
    cin >> n >> s;
    p[0] = 0;
    f[0] = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i - 1] == '0') {
            p[i] = i;
        } else {
            p[i] = p[i - 1];
        }

        int c = i - p[i];
        f[i] = f[i - 1];

        if (c && p[i] > 1 && s[p[i] - 2] == '1') {
            f[i] = max(f[i], c + f[p[i] - 2]);
        }

        if (c == 1 && i >= 3) {
            int np = p[i - 2];
            if (np != i - 1) {
                f[i] = max(f[i], f[np + 1] + i - 3 - np);
            }

            f[i] = max(f[i], f[np] + i - 2 - np);
        }
    }

    cout << f[n] << "\n";
    return 0;
}

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

string s, t;
int n;

bool ok() {
  for(int r = 0; r < n; r++) {
    bool yes = true;
    for(int i = 0; i < n; i++) {
      yes &= (s[(i+r)%n] == t[i]);
    }
    if(yes) return true;
  }
  return false;
}

int main () {
  cin >> s >> t;
  n = s.size();

  cout << (ok() ? "Yes" : "No") << endl;
  return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;


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

	int N, M, ai;
	int sum = 0;

	cin >> N >> M;
	for(int i = 0; i < M; i++){
		cin >> ai;
		sum += ai;
	}

	cout << (N-sum >= 0 ? N-sum : -1) << "\n";

	return 0;		
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define maxn 500100
using namespace std;
typedef long long ll;
struct Data{
	ll sz,ans,id;
	double sum;
	ll sum0,sum1;
	Data(){}
	Data(ll sz,ll sum,ll sum0,ll sum1,ll ans,ll id):sz(sz),sum(sum),sum0(sum0),sum1(sum1),ans(ans),id(id){}
	bool operator<(const Data& d)const{return sum>d.sum;}
}d[maxn];
vector<int>G[maxn];
int n,fa[maxn],f[maxn],a[maxn],val[maxn],id[maxn];
priority_queue<Data>Q;
int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
void dfs(int u){
	for(auto p:G[u])if(p!=fa[u])
		fa[p]=u,dfs(p);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<=n;++i)f[i]=i;
	for(int i=2;i<=n;++i){
		scanf("%d",&a[i]);
		f[find(i)]=find(a[i]),G[a[i]].push_back(i);
	}
	G[0].push_back(1);
	fa[0]=-1,dfs(0);
	for(int i=0;i<=n;++i)f[i]=i;
	for(int i=1;i<=n;++i)scanf("%d",&val[i]),id[i]=i;
	sort(id,id+n+1,[](int a,int b){return val[a]<val[b];});
	for(int i=0;i<=n;++i){
		d[id[i]]=Data(1,val[id[i]],val[id[i]]==0,val[id[i]]==1,0,id[i]);
		if(id[i])Q.push(d[id[i]]);
	}
	ll ans=0;
	while(Q.size()){
		Data nw=Q.top();
		Q.pop();
		if(d[nw.id].sz!=nw.sz)continue;
		int x=nw.id;//cout<<x<<' ';
		x=f[x]=find(fa[x]);//cout<<x<<endl;
		ans+=(ll)nw.sum0*d[x].sum1;
		d[x].sz+=nw.sz;
		d[x].sum0+=nw.sum0;
		d[x].sum1+=nw.sum1;
		d[x].sum=(double)d[x].sum1/d[x].sz;
		if(x!=0)Q.push(d[x]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 61932
#include <stdio.h>

int main(void) {
	int a,b,d,r;
	double f;

	scanf("%d %d\n",&a,&b);
	
	d = a/b;
	r = a%b;
	f = (double)a/b;
	
	printf("%d %d %f\n",d,r,f);
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll k,s,x,y,z,ans=0;
    cin>>k>>s;
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            z=s-x-y;
            if(z>=0 && z<=k) ans++;
        }
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#input
N = int(input())
#B = int(input())
#C = int(input())
#X = int(input())
A = list(map(int,input().split()))
#b = int(input())
#N,A,B = map(int,input().split())
 
turn = 0 # 0:Alice,1:Bob
Alice = 0
Bob = 0
Dif = 0
#flag = 0

top = [0,0]
while (1):
  flag = N
  top = [0,0]
  
  #seeking the top
  for i in range(N): #loop for N
    if A[i] > top[0]:
      top[0] = A[i]
      top[1] = i
    elif A[i] == 0:
      flag -= 1
  
  #point
  if turn == 0:
    turn = 1
    Alice += top[0]
    A[top[1]] = 0
    #print('Alice')
  elif turn == 1:
    turn = 0
    Bob += top[0]
    A[top[1]] = 0
    #print('Bob')
  
  #print(flag)
  #all pointed
  if flag <= 1:
    #print(flag)
    break

#judge
 
#print('result')
#print('Alice = '+str(Alice))
#print('Bob = '+str(Bob))
#print('Alice-Bob = '+str(Alice-Bob))
print(Alice-Bob)

Measured memory_bytes: 3064