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

using namespace std;

#define N 205
int n, m, r, arr[8], mat[N][N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> r;
    int x, y, z;
    for (int i = 0; i < r; i++)
        cin >> arr[i];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            mat[i][j] = 100000 * 200 + 1;
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> z;
        mat[x][y] = mat[y][x] = z;
    }
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (mat[i][k] + mat[k][j] < mat[i][j])
                    mat[i][j] = mat[i][k] + mat[k][j];
    sort(arr, arr + r);
    long long ans = -1;
    do {
        long long myans = 0;
        for (int i = 0; i < r - 1; i++)
            myans += mat[arr[i]][arr[i + 1]];
        if (ans == -1 || myans < ans)
            ans = myans;
    } while (next_permutation(arr, arr + r));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
### constant

MAX_D = 100

### main

loop do
    n, q = gets.split.map(&:to_i)
    break if (n | q) == 0
    
    votes = MAX_D.times.map{0}
    
    n.times do
        ns = gets.split.map(&:to_i)
        m = ns.shift
        
        for i in (0...m)
            votes[ns[i]] += 1
        end
    end
    
    maxv = 0
    mind = 0
    
    for d in (0...MAX_D)
        v = votes[d]
        if maxv < v 
            maxv = v 
            mind = d 
        end
    end
    
    puts (maxv < q ? 0 : mind)
end

Measured memory_bytes: 6140
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint N,K;
    cin >> N >> K;
    N%=K;
    cout << min(N,llabs(N-K)) << endl;
}

Measured memory_bytes: 256
import sys


N, A, B, C = map(int, input().split())
stock = [A, B, C]

s = [input().rstrip('\n') for _ in range(N)]
sum_num = sum(list([A, B, C]))
to_char = ["A","B","C"]

target = []
for i in range(N):
    if s[i] == "AB":
        target.append([0,1])
    elif s[i] == "BC":
        target.append([1,2])
    else:
        target.append([0,2])
if sum_num == 0:
    print("No")
    sys.exit()
elif sum_num == 1:
    answer = []
    for i in range(N):
        if stock[target[i][0]] == 1:
            stock[target[i][0]] -= 1
            stock[target[i][1]] += 1
            answer.append(target[i][1])
        elif stock[target[i][1]] == 1:
            stock[target[i][1]] -= 1
            stock[target[i][0]] += 1
            answer.append(target[i][0])
        else :
            print("No")
            sys.exit()
    print("Yes")
    for i in range(N):
        print(to_char[answer[i]])
elif sum_num >= 2:
    if stock[target[0][0]] == 0 and stock[target[0][1]] == 0:
        print("No")
        sys.exit()
    else:
        print("Yes")
        for i in range(N-1):
            if target[i][0] in target[i+1] and stock[target[i][1]] >= 1:
                stock[target[i][0]] += 1
                stock[target[i][1]] -= 1
                print(to_char[target[i][0]])
            elif stock[target[i][0]] >= 1:
                stock[target[i][1]] += 1
                stock[target[i][0]] -= 1
                print(to_char[target[i][1]])
            else:
                stock[target[i][0]] += 1
                stock[target[i][1]] -= 1
                print(to_char[target[i][0]])
        if stock[target[-1][0]] == 0:
            print(to_char[target[-1][0]])
        else:
            print(to_char[target[-1][1]])


Measured memory_bytes: 25536
#include<bits/stdc++.h>
/*
CE 头文件 
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>

*/
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
#define ios std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
// ios和scanf,printf不能混用.即用ios必须全部cin,cout. 
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;

ll ksm(ll a,ll b){ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main(){
	int n;
	scanf("%d",&n);
	int ans=n%1000;
	if(ans!=0)ans=1000-ans;
	printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3824
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = b / a;
        System.out.println(Math.min(d, c));
    }

}


Measured memory_bytes: 23636
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    D = sorted(readInts())
    dl = len(D)//2
    print(D[dl] - D[dl-1])
if __name__ == '__main__':
  main()


Measured memory_bytes: 14396
inp = list(map(lambda x: int(x), input().split(" ")))
H = inp[0]
W = inp[1]

field = [""]*H

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

dp = [[0]*W for i in range(H)]

if (field[0][0] == "#"):
    dp[0][0] = 1

for i in range(H):
    for j in range(W):
        check1 = 0
        check2 = 0
        if (i>0 and j>0):
            if (field[i][j]=="#" and field[i-1][j]=="."):
                check1 = 1
            if (field[i][j]=="#" and field[i][j-1]=="."):
                check2 = 1
            dp[i][j] = min(dp[i-1][j]+check1, dp[i][j-1]+check2)
        elif (i>0 and j==0):
            if (field[i][j]=="#" and field[i-1][j]=="."):
                check1 = 1
            dp[i][j] = dp[i-1][j]+check1
        elif (i==0 and j>0):
            if (field[i][j]=="#" and field[i][j-1]=="."):
                check2 = 1
            dp[i][j] = dp[i][j-1]+check2

print(dp[-1][-1])

Measured memory_bytes: 42224
#include<stdio.h>
#include<vector>

int p;
std::vector<int> pre, in, pos;

void partRecon(int l, int r){
	if (l >= r) return;
	int root = pre[p++];
	int m = 0;
	for (int i = 0; i < r - l; i++){
		if (in[l + i] == root) m = l + i;
	}
	partRecon(l, m);
	partRecon(m + 1, r);
	pos.push_back(root);
}

int main(){
	int n = 0;
	scanf("%d", &n);
	int c = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &c);
		pre.push_back(c);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &c);
		in.push_back(c);
	}
	partRecon(0, pre.size());
	for(int i = 0; i < n; i++){
		printf("%d", pos[i]);
		if (i != n-1) printf(" ");
	}
	printf("\n");
}


Measured memory_bytes: 2792
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define loop(i,m,n) for(lli i=m;i<=n;i++)
#define loopr(i,m,n) for(lli i=m;i>=n;i--)
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define ii pair<int,int>
#define vii vector<ii>
#define INF 1000000000
#define mod 1000000007
#define siz 1000001
#define endl "\n"
const double PI=3.14159265358979323846264338327950288419716939937510;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;

int main()
{
	int i,j,n,m,ans=INT_MAX;
	string s,t;
	cin>>s>>t;
	n=s.size();
	m=t.size();
	for (i = 0; i <= n - m; i++)
    {
        int needchange = 0;
        for (j = 0; j < t.length(); j++)
        {
            if (s[i+j] != t[j])
            {
                needchange++;
            }
        }
            ans = min(ans, needchange);
    }
    cout<<ans<<endl;
    return 0;
}
/*
cabacc
abc

codeforces
atcoder
*/


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

#define fs first
#define sc second
#define mp make_pair
#define eb emplace_back
#define sz(s) ((int) s.size())
#define all(s) s.begin(), s.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef unsigned long long ull;

const ll linf = (ll) 1e18;

const int A = 26;
const int L = 17;
const int B = 315;
const int N = (int) 1e5;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

const int di[] = {-1, +0, +1, +0};
const int dj[] = {+0, +1, +0, -1};

const ull pr = 31;
const ull hmod = (ull) 1e9 + 7;

const double pi = acos(-1.0);
const double eps = 1e-11;

inline void init() {
	
}
inline void solve() {
	int n, m; cin >> n >> m;
	ll sx = 0;
	ll px = 0;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		px += x * i - sx; px += mod; px %= mod;
		sx += x; sx += mod; sx %= mod;
	}		
	ll sy = 0;
	ll py = 0;
	for (int i = 0; i < m; i++) {
		ll y; cin >> y;
		py += y * i - sy; py += mod; py %= mod;
		sy += y; sy += mod; sy %= mod;
	}		
	cout << px * py % mod;

}
int main() {
	#ifdef LOCAL
		#define name ""
		freopen(name".in", "r", stdin);
		freopen(name".out", "w", stdout);
	#endif
	int tests = 1;
	while (tests--) {
		init();
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int c1=0,c2=0;
	int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<3;i++)
	{
		if(a[i]==5)
		{
			c1++;
		}
		else if(a[i]==7)
		{
			c2++;
		}
	}
	if(c1==2 && c2==1)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	
	
	

	
}

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

// template {{{
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

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

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

 int maxAbsValExpr(vector<int>& x, vector<int>& y) {
        int res = 0, n = x.size(), smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0] + 0;
                for (int i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i];
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        return res;
    }
void solve()
{
    int n,i,temp1, temp2;
    cin>>n;
    vector<int>x,y;
    for(i=0; i<n; i++)
    {   
        cin>>temp1>>temp2;
        //cin>>x[i]>>y[i];
        x.push_back(temp1);
        y.push_back(temp2);
    }
    // for(auto elm: x)
    // {
    //     cout<<elm<<endl;
    // }
    // for(auto elm: y)
    // {
    //     cout<<elm<<endl;
    // }

    cout<<maxAbsValExpr(x, y)<<endl;
}
int main() {
    
      solve();

    return 0;
}

Measured memory_bytes: 5088
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string S;
  cin >> N >> S;

  int pos = 0;
  int res = 0;
  while ((pos = S.find("ABC", pos)) != string::npos) {
    res++;
    pos++;
  }
  cout << res;
}
#endif


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
string s,ss;
int dp[1001][1001];

int levenshtein(string s,string ss){
  if(s.length()==0 && ss.length()==0)return 0;
  if(s.length()==0) return ss.length();
  if(ss.length()==0) return s.length();
  
  for(int i=1;i<=s.length();i++)dp[0][i]=dp[0][i-1]+1;
  for(int i=1;i<=ss.length();i++)dp[i][0]=dp[i-1][0]+1;


  for(int i=1;i<=ss.length();i++){
    for(int j=1;j<=s.length();j++){
      
      if(s[j-1]==ss[i-1])dp[i][j]=dp[i-1][j-1];
      else{
	dp[i][j]=min(dp[i-1][j-1],dp[i][j-1]);
	dp[i][j]=min(dp[i][j],dp[i-1][j]);
	dp[i][j]++;
      }
      //printf("%d %d %d\n",i,j,dp[i][j]);
    }
  }
  /*
  for(int i=0;i<=ss.length();i++){
    for(int j=0;j<=s.length();j++){
      printf("%d ",dp[i][j]);
    }
    printf("\n");
  }
  */
  return dp[ss.length()][s.length()];
  
}
int main(){
  cin >> s;
  cin >> ss;
  printf("%d\n",levenshtein(s,ss));
 
  return 0;
}

Measured memory_bytes: 7172
using System;
using System.Collections.Generic;

namespace Atc_0015
{
    class Program
    {
        static void Main(string[] args)
        {
            var rStr1 = Console.ReadLine();

            int N = int.Parse(rStr1.Split(' ')[0]);
            int K = int.Parse(rStr1.Split(' ')[1]);

            var rStr2 = Console.ReadLine();

            List<int> ps = new List<int>();

            for (int i = 0; i < rStr2.Split(' ').Length; i++)
            {
                ps.Add(int.Parse(rStr2.Split(' ')[i]));
            }

            ps.Sort();

            int result = 0;
            for (int j = 0; j < K; j++)
            {
                result += ps[j];
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 46976
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int x = 0, y = 0;
	std::vector<int> X(1e5 + 2, 0), Y(1e5 + 2, 0);
	for(int i = 0; i < n; i += 2) Y[a[i]]++, x++;
	for(int i = 1; i < n; i += 2) X[a[i]]++, y++;
	
	std::vector<int> Z(1e5 + 2, 1 << 30); Z[1e5] = y - Y[1e5];
	for(int i = 1e5; i >= 0; i--) {
		Z[i] = std::min(Z[i + 1], y - Y[i]);
	}
	
	int tmp = 1 << 30, mi = 1 << 30;
	for(int i = 0; i <= 1e5; i++) {
		mi = std::min(mi, std::min(tmp, Z[i + 1]) + x - X[i]);
		tmp = std::min(tmp, y - Y[i]);
	}
	
	cout << mi << endl;
	return 0;
}


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

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

int main() {
  int X;
  cin >> X;

  string ans;
  ans = X >= 30 ? "Yes" : "No";

  cout << ans << endl;

  return 0;
}


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

int main()
{
  	int a, b, n;
  	cin >> a >> b >> n;
  	int rez = n / max(a, b);
  	if (n % max(a, b) != 0) rez++;
  	cout << rez;
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <stdio.h>
typedef struct Pos
{
	int x,y;
}Pos;
Pos a[200100];
Pos idx[5];//x: 인덱스 y:값
int dx[4] = { 1, 1, -1, -1 };
int dy[4] = { 1, -1, 1, -1 };
int n;
int abs(int x) { return x < 0 ? -x : x; }
int dist(Pos a, Pos b)
{
	return abs(a.x - b.x) + abs(a.y - b.y);
}
int max(int a, int b) { return a > b ? a : b; }
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= 4; i++) idx[i] = { 0, -2000000002 };
	for (int i = 1; i <= n; i++)
	{
		scanf("%d %d", &a[i].x, &a[i].y);
		for (int j = 1; j <= 4; j++)
		{
			if (idx[j].y < a[i].x * dx[j] + a[i].y * dy[j])
			{
				idx[j].y = a[i].x * dx[j] + a[i].y * dy[j];
				idx[j].x = i;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= 4; j++)
		{
			ans = max(dist(a[idx[j].x], a[i]), ans);
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 4764
#pragma GCC optimize ("O3")
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> d(n);
		REP(i, n) cin >> d[i];
		sort(ALL(d));
		if(d[n / 2 - 1] < d[n / 2]) {
			cout << d[n / 2] - d[n / 2 - 1] << endl;
		} else {
			cout << 0 << endl;
		}
		// map<int, int> cnt;
		// REP(i, n) cnt[d[i]]++;
		// int sum = 0;
		// for(auto&& e : cnt) {
			
		// }
		// cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long INF = pow(10, 9);

long long comp(long long index, vector<long long> t, vector<long long> T, long long N, vector<long long> l){
  //cout << t[0] << ' ' << t[1] << ' ' << t[2] << endl;
  //cout << *min(t.begin(), t.end()) << endl;
  if(index == N){
    if(*min_element(t.begin(), t.end()) > 0){
      long long sum = -30;
      for(int i = 0; i < 3; ++i){
        sum += abs(t.at(i) - T.at(i));
      }
      return sum;
    } else {
      return INF;
    }
  }
  vector<long long>tmp;
  tmp.push_back(comp(index + 1, t, T, N, l));
  for(int i = 0; i < 3; ++i){
    vector<long long>next_t(3);
    for(int j = 0; j < 3; ++j){
      if(i == j){
        next_t.at(j) = t.at(j) + l.at(index);
      } else {
        next_t.at(j) = t.at(j);
      }
    }
    tmp.push_back(comp(index + 1, next_t, T, N, l) + 10);
  }
  return *min_element(tmp.begin(), tmp.end());
}

void solve(long long N, vector<long long>& T, std::vector<long long>& l){
  cout << comp(0, move(vector<long long>(3)), T, N, l) << endl;;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> l(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&l[i]);
    }
    vector<long long>T{A, B, C};
    //cout << T[0] << T[1] << T[2] << endl;
    solve(N, T, l);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n;
int dp[110][5][5][5];

int rek(int pos, int x, int y, int z) {
	if (pos == n) return 1;

	int &ret = dp[pos][x][y][z];
	if (ret != -1) return ret;
	ret = 0;

	for (int i = 0; i < 4; i ++) {
		if (y == 0 && z == 1 && i == 2) continue;
		if (y == 1 && z == 0 && i == 2) continue;
		if (y == 0 && z == 2 && i == 1) continue;
		if (x == 0 && z == 1 && i == 2) continue;
		if (x == 0 && y == 1 && i == 2) continue;
		ret += rek(pos+1, y, z, i);
		ret %= MOD;
	}

	return ret;
}

int main () {

	cin >> n;
	memset(dp, -1, sizeof dp);
	cout << rek(0, 4, 4, 4);

	return 0;
}

Measured memory_bytes: 256
N, P = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0,0] for k in range(N+1)]
dp[0][0] = 1
for k in range(N):
    if A[k]%2 == 0:
        dp[k+1][0] = dp[k][0]*2
        dp[k+1][1] = dp[k][1]*2
    else:
        dp[k+1][0] = dp[k][0] + dp[k][1]
        dp[k+1][1] = dp[k][1] + dp[k][0] 
print(dp[N][P])


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

using namespace std;

int main(){
  long long H, W;
  cin >> H >> W;
  
  if(H == 1 || W == 1){
    cout << 1;
    return 0;
  }
  
  long long time = H * W;
  if (time % 2 != 0) ++time;
  cout << time/2;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
    ll a,b,k; cin >> a >> b >>k;
    REP(i,k){
        if(i%2==0){
            if(a%2==0){
                b += a/2;
                a /= 2;
            }else{
                b += a/2;
                a = (a-1) / 2;
            }
        }else{
            if(b%2==0){
                a += b/2;
                b /= 2;
            }else{
                a += b/2;
                b = (b-1) / 2;
            }
 
        }
    }
    cout << a << " " << b << endl;

}

Measured memory_bytes: 256
a,b,k = (int(i) for i in input().split())
x = set()
y = []
for i in range(a,min(b+1,a+k)):
    x.add(i)
for i in range(b,max(a-1,b-k),-1):
    x.add(i)
for i in x:
    y.append(i)
y.sort()
for ans in y:
    print(ans)


Measured memory_bytes: 3064
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0 )
				break;

			for(int i = 1; i <= H; i++){
				for(int j = 1; j <= W; j++){
					if(i == 1||i == H||j == 1||j == W){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}


}

Measured memory_bytes: 37136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}

int counter(int x){
    if(x==0) return 0;
    return counter(x>>1)+(x&1);
}
int main(){
    fast_io

    int n;
    cin>>n;
    int A[20];
    int x[20][20];
    int y[20][20];
    
    for(int i=1;i<=n;i++){
        cin>>A[i];
        for(int j=1;j<=A[i];j++){
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans=0;
    for(int bits=1;bits<(1<<n);bits++){
        bool ok=true;
        for(int i=1;i<=n;i++){
            if(!(bits & (1<<(i-1))))continue;
            for(int j=1;j<=A[i];j++){
                if(((bits >> (x[i][j]-1)) & 1)^y[i][j]) ok=false;
            }
        }
        if(ok) ans=max(ans, counter(bits));
    }
    cout<<ans<<endl;

    return 0;
}

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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n,k;
        cin>>n>>k;
        vll v(n);
        rep(i,0,n-1) cin>>v[i];
        sort(all(v));
        int ans=0;
        rep(i,0,k-1)ans+=v[i];
        cout<<ans;



        cout<<'\n';
    return 0;
}

Measured memory_bytes: 3616
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 T[] = new int[N];
		for(int i = 0; i < N; i++){
			T[i] = Integer.parseInt(sc.next());
		}
		int M = Integer.parseInt(sc.next());
		int P[] = new int[M];
		int X[] = new int[M];
		for(int i = 0; i < M; i++){
			P[i] = Integer.parseInt(sc.next());
			X[i] = Integer.parseInt(sc.next());
		}

		for(int i = 0; i < M; i++){
			int res = 0;
			for(int j = 0; j < N; j++){
				if(P[i] == j+1) res += X[i];
				else res += T[j];
			}
			System.out.println(res);
		}

	}

}

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

using ll = long long;

using str = string;
using ss = stringstream;

ll m[5];

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

    int n;cin>>n;

    for(int i=0;i<n;i++)
    {
        str s;cin>>s;

        if(s[0]=='M')m[0]++;
        else if(s[0]=='A')m[1]++;
        else if(s[0]=='R')m[2]++;
        else if(s[0]=='C')m[3]++;
        else if(s[0]=='H')m[4]++;
    }

    ll ans=0;

    ans+=m[0]*m[1]*m[2];
    ans+=m[0]*m[1]*m[3];
    ans+=m[0]*m[1]*m[4];
    ans+=m[0]*m[2]*m[3];
    ans+=m[0]*m[2]*m[4];
    ans+=m[0]*m[3]*m[4];
    ans+=m[1]*m[2]*m[3];
    ans+=m[1]*m[2]*m[4];
    ans+=m[1]*m[3]*m[4];
    ans+=m[2]*m[3]*m[4];

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    while(cin >> N){
        if(N == 0) break;
        string S; cin >> S;
        
        vector<ll> maisuu(N);
        ll ba = 0;
        for(int i = 0; i< 100;i++){
            if(S[i] == 'M'){
                maisuu[i%N]++;
            }
            if(S[i] == 'S'){
                ba += maisuu[i%N] + 1;
                maisuu[i%N] = 0;
            }
            if(S[i] == 'L'){
                maisuu[i%N] += 1 + ba;
                ba = 0;
            }
        }
        sort(maisuu.begin(),maisuu.end());
        for(auto v:maisuu){
            cout << v << " ";
        }
        cout << ba << endl;
    }
	return 0;
}



Measured memory_bytes: 3208
# 入力 : 数字3つ
N, A, B = map(int, input().split())

# 1 以上 N 以下の整数のうち、10 進法での各桁の和が A 以上 B 以下
# であるものの総和を出力せよ。

def keta_wa(n) :
    sum = 0
    while n :
        sum += n%10
        n = int(n/10)
    return sum

ans = 0

for i in range(1,N+1) :
    if A <= keta_wa(i) <= B :
        ans += i

print(ans)


Measured memory_bytes: 2940
// AtCoder Beginner Contest 089 - Problem A: Grouping 2 (https://abc089.contest.atcoder.jp/tasks/abc089_a?lang=en) 
#include <iostream>

using namespace std;

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

    cout << N/3 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
const unsigned long long mod=1e9+7;
int x[100005];
int y[100005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    unsigned long long lx=0,k=0,ly=0;
    for(int i=0;i<n;++i)
        scanf("%d",&x[i]);
    for(int i=0;i<m;++i)
        scanf("%d",&y[i]);
    for(int i=1;i<n;++i)
    {
        k=(k+(long long)(x[i]-x[i-1])*i)%mod;
        lx=(lx+k)%mod;
    }
    k=0;
    for(int i=1;i<m;++i)
    {
        k=(k+(long long)(y[i]-y[i-1])*i)%mod;
        ly=(ly+k)%mod;
    }
    cout<<((lx*ly)%mod+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/knuth_morris_pratt.hpp"



#include <vector>
#include <string>

// Find a string t from a string s.
// For each element i in returned vector,
// s.substr(i, t.size()) == t holds.
// Assume '#' is not in s and t.
// Actually, this is the Morris-Pratt algorithm.
std::vector<int> kmp(const std::vector<int> &s, std::vector<int> t) {
    int n = s.size(), m = t.size();
    std::vector<int> id(m + 1);
    id[0] = -1;
    int j = -1;
    for (int i = 0; i < m; i++) {
        while (j >= 0 && t[i] != t[j]) j = id[j];
        id[i + 1] = ++j;
    }
    t.push_back(-1);
    std::vector<int> ret;
    int is = 0, it = 0;
    while (is < n) {
        if (s[is] == t[it]) is++, it++;
        else if (it == 0) is++;
        else it = id[it];
        if (it == m) {
            ret.push_back(is - m);
        }
    }
    return ret;
}


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) std::cin >> b[i];
    std::vector<int> ad(2 * n - 2), bd(n - 1);
    for (int i = 0; i < 2 * n - 2; i++) ad[i] = a[i%n] ^ a[(i + 1) % n];
    for (int i = 0; i < n - 1; i++) bd[i] = b[i] ^ b[i + 1];
    auto ks = kmp(ad, bd);
    for (int k : ks) {
        std::cout << k << " " << (a[k]^b[0]) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 9168
#include <cstdio>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
char s[40], r[40], b[40];
int n;
map<pair<string, string>, long long> m;
void go2(int i, int lr, int lb) {
	if (i == n * 2) {
		string u(r), t(b);
		m[make_pair(u, t)]++;
		return;
	}
	r[lr] = s[i];
	go2(i + 1, lr + 1, lb);
	r[lr] = 0;
	b[lb] = s[i];
	go2(i + 1, lr, lb + 1);
	b[lb] = 0;
}
long long go(int i, int lr, int lb) {
	if (i == n) {
		string u(r), t(b);
		reverse(u.begin(), u.end());
		reverse(t.begin(), t.end());
		pair<string, string> p(t, u);
		return m.count(p) ? m[p] : 0;
	}
	long long res = 0;
	r[lr] = s[i];
	res += go(i + 1, lr + 1, lb);
	r[lr] = 0;
	b[lb] = s[i];
	res += go(i + 1, lr, lb + 1);
	b[lb] = 0;
	return res;
}
int main() {
	scanf("%d%s", &n, s);
	go2(n, 0, 0);
	printf("%lld\n", go(0, 0, 0));
}


Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> A(N);
	for (auto& x : A) cin >> x;
	vector<long long> B(N-K+1);
	for (int i = 0; i < K; ++ i) B[0] += A[i];
	for (int i = K; i < N; ++ i) B[i-K+1] = B[i-K] - A[i-K] + A[i];
	vector<long long> C(N+1);
	for (int i = 0; i < N; ++ i) C[i+1] = C[i] + max(0LL, A[i]);
	vector<long long> D(N+1);
	for (int i = N-1; i >= 0; -- i) D[i] = D[i+1] + max(0LL, A[i]);
	long long r = 0;
	for (int i = 0; i <= N-K; ++ i) {
		r = max(r, C[i] + D[i+K] + max(0LL, B[i]));
	}
	cout << r << endl;
}


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

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>p(n);
    rep(i,n)cin>>p[i];
    ll maxSum,maxPtr=0,sum = 0;

    rep(i,k)sum += p[i];
    maxSum = sum;
    repi(i,1,n-k + 1){
        sum -= p[i - 1];
        sum += p[i + k - 1];
        if(maxSum < sum){
            maxSum = sum;
            maxPtr = i;
        }
    }
    double ans = 0;
    rep(i,k){
        double num = p[i + maxPtr];
        ans += (num + 1) / 2;
    }
    printf("%.7f\n",ans);

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int s,res,f[2001];
int qp(int x,int y)
{
	if(y==0)
		return 1;
	if(y==1)
		return x;
	int ans=qp(x,y/2);
	ans=ans*ans%mod;
	if(y&1)
		ans=ans*x%mod;
	return ans;
}
int C(int x,int y)
{
	y=min(y,x-y);
//	cout<<x<<" "<<y<<endl;
	return (f[x]*qp(f[x-y],1e9+5)%mod)*qp(f[y],1e9+5)%mod;
}
signed main()
{
	scanf("%lld",&s);
//	cout<<qp(1,1e9)<<endl;
	f[1]=f[0]=1;
	for(int i=2;i<=2000;i++)
		f[i]=f[i-1]*i%mod;
	for(int i=1;i*3<=s;i++)
	{
		int ss=s-i*2;
		res=(res+C(ss-1,i-1))%mod;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

class PrimeList {
  private:
    u64 max;
    Vec<u64> vals;
    Vec<bool> is_prime;
  public:
    PrimeList(u64 val): max(val), is_prime(val + 1, true) {
        is_prime[0] = false; is_prime[1] = false;
        for(int i = 4; i <= max; i += 2) is_prime[i] = false;
        for(int i = 3; i * i <= max; i += 2) {
            if(!is_prime[i]) continue;
            for(int j = 3; i * j <= max; j += 2)
                if(is_prime[i * j]) is_prime[i * j] = false;
        }
        for (int i = 0; i <= max; i++) if (is_prime[i]) vals.push_back(i);
    }
    bool exists(u64 x) const { return is_prime[x]; }
    u64 size() const noexcept { return (u64)vals.size(); }
    u64 range_max() const noexcept { return max; }
    u64 operator[](u64 index) const { return vals[index]; }
    decltype(vals)::const_iterator begin() const noexcept { return vals.cbegin(); }
    decltype(vals)::const_iterator end() const noexcept { return vals.cend(); }
};

Vec<pair<u64, u32>> factorization(u64 num) {
    u64 n = sqrt(num);
    PrimeList p(n);
    Vec<pair<u64, u32>> res;
    for (auto it = p.begin(); it != p.end(); it++) {
        u32 sum = 0;
        u64 i = *it;
        while (num % i == 0) {
            sum++;
            num /= i;
        }
        if (sum > 0) res.push_back(make_pair(i, sum));
    }
    if (num > n) res.push_back(make_pair(num, 1));
    return res;
}

void Main() {
    u64 N;
    cin >> N;
    Vec<pair<u64, u32>> l = factorization(N);
    u32 sum = 0;
    for (u32 i = 0; i < l.size(); i++) {
        u32 n = l[i].second;
        for (u32 j = 1; j * (j + 1) / 2 <= n; j++) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 4424
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(), k = sc.nextInt();
			if((n|k) == 0)break;
			LinkedList<Integer> cards = new LinkedList<Integer>();
			for(int i=1;i<=n;i++) cards.add(n-i+1);
			for(int i=0;i<k;i++) {
				int p = sc.nextInt(), c = sc.nextInt();
				for(int j=0;j<c;j++) cards.addFirst(cards.remove(p+c-2));
			}
			System.out.println(cards.get(0));
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 31904
#include <bits/stdc++.h>
using namespace std;
#define mod 1e9+7
typedef long long ll; 
 
 int main(){
  ios_base::sync_with_stdio(false); 
  ll n;
   cin>>n;
   if(n>=400&&n<=599) cout<<8;
   else if(n>=600&&n<=799) cout<<7;
   else if(n>=800&&n<=999) cout<<6;
   else if(n>=1000&&n<=1199) cout<<5;
   else if(n>=1200&&n<=1399) cout<<4;
   else if(n>=1400&&n<=1599) cout<<3;
   else if(n>=1600&&n<=1799) cout<<2;
   else if(n>=1800&&n<=1999) cout<<1;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  if(n >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int gcd(int x,int y){
  return y ? gcd(y,x%y) : x;
}

int main(){
  int N,X,i;
  cin >> N >> X;
  int ma=0;
  vector<int> x(N);
  for(i=0;i<N;++i){
    cin >> x[i];
    ma=max(ma,x[i]);
  }
  int ans=0;
  ans=abs(X-x[0]);

  for(i=0;i<N;++i){
    ans=gcd(ans,abs(X-x[i]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++) cin >> S[i];

    vector<string> s(N);
    for(int i=0;i<N;i++){
        string tmp="";
        vector<ll> mp(26,0);
        
        for(int j=0;j<10;j++){
            mp[S[i][j]-'a']++;
        }
        
        for(int j=0;j<26;j++){
            while(mp[j]>0){
                tmp+=(char)(j+'a');
                mp[j]--;
            }
        }
        s[i]=tmp;
        
    }
    sort(s.begin(),s.end());
    ll ans=0;
    string cmp=s[0];
    ll ct=1;
    
    for(int i=1;i<N;i++){
        if(cmp==s[i]){
            ct++;
        }
        else{
            ans+=ct*(ct-1)/2;
            cmp=s[i];
            ct=1;
        }
    }
    if(ct!=1){
        ans+=ct*(ct-1)/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	long long int y,count;
	vector<int> v;
	cin>>n;
	for( i=0 ; i<n ; i++)
	{
		count=0;
		cin>>y;
		while(y!=0)
		{
			if(y%2==0)
			count++;
			else
			break;
			y/=2;
		}
		v.push_back(count);
		
	}
	cout<<*min_element( v.begin() , v.end() );
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	int n;
	int a,b;
	int _a = 0,_b = 0,_c = 0;
	cin >> n >> a >> b;
	int p[n];
	int ans = 0;
	for (int i = 0;i < n;i++) {
		cin >> p[i];
		if (p[i] <= a) _a++;
		else if (a < p[i] && p[i] <= b) _b++;
		else if (b < p[i]) _c++;
	}
	cout << min({_a,_b,_c}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N,Y;
  cin >> N >> Y;
  int res1 = -1, res2 = -1, res3 = -1;
  
  for(int a = 0; a <= N; a++){
    for(int b = 0; a + b <= N; b++){
      int c = N - a - b;
      int total = 10000 * a + 5000 * b + 1000 * c;
      if(total == Y){
	res1 = a;
	res2 = b;
	res3 = c;
	break;
      }
    }
  }

  cout << res1 << " " << res2 << " " << res3 << endl;
  
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007
using namespace std;
int gcd(int a, int b){return (a == 0) ? b : gcd(b%a, a);}
/*ios_base::sync_with_stdio(false);cin.tie(0);*/
 
 map<char,int>m1;
 
int main (){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;
    cin>>s;
   
     for (int i = 0; i <s.size(); i++) {
     	m1[s[i]]++;
     }
    for (int i = 0; i <s.size(); i++) {
        if(m1[s[i]]!=2){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,X;

string ans = "No";
vector<LL> param;

void solve(){
	if(X==1 || X==2*N-1) return;
	ans = "Yes";
	param = vector<LL>(2*N-1,0);
	for(int i=0;i<param.size();i++){
		param[i] = i+1;
	}
	swap(param[N-1],param[X-1]);
	swap(param[N-2],param[0]);
	swap(param[N],param[2*N-2]);
}

int main(){
    cin >> N >> X;

    solve();

    cout << ans << endl;
    if(ans=="No") return 0;
    for(int i=0;i<param.size();i++) cout << param[i] << endl;
    return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
using namespace std;
const int Maxn=300+5;
int n,x,cnt[4];
double dp[Maxn][Maxn][Maxn];
bool vis[Maxn][Maxn][Maxn];
double w(int i,int j,int k)
{	if(!i&&!j&&!k)return 0;
	if(vis[i][j][k])return dp[i][j][k];
	vis[i][j][k]=1;
	if(i)dp[i][j][k]+=w(i-1,j,k)*i/n;
	if(j)dp[i][j][k]+=w(i+1,j-1,k)*j/n;
	if(k)dp[i][j][k]+=w(i,j+1,k-1)*k/n;
	dp[i][j][k]++;
	dp[i][j][k]/=1.0*(i+j+k)/n;
	return dp[i][j][k];
}
int main()
{	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{	scanf("%d",&x);
		cnt[x]++;
	}
	printf("%.10lf",w(cnt[1],cnt[2],cnt[3]));
	return 0;
}

Measured memory_bytes: 246144
from collections import deque
from bisect import bisect_left, bisect_right

s = list(input())
q = int(input())

count = 0
l = []
reverse = []
for i in range(q):
	tmp = list(map(str,input().split()))
	if len(tmp) == 1:
		count += 1
		if len(l) != 0:
			reverse.append(len(l))
	elif tmp[1] == '1':
		l.append([1, tmp[2]])
	elif tmp[1] == '2':
		l.append([2, tmp[2]])

#print(reverse)
#print(l)
for i in range(len(l)):
	#print(bisect_right(reverse,i))
	l[i][0] += len(reverse) - bisect_right(reverse,i)
	l[i][0] %= 2

if count % 2 == 1:
	s = s[::-1]
s = deque(s)

for i in range(len(l)):
	if l[i][0] == 0:
		s.append(l[i][1])
	else:
		s.appendleft(l[i][1])
print("".join(s))


Measured memory_bytes: 110712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<string> A(N),B(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }
    int cnt = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            if(A[i][j] != B[i][j]) cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 11344