akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max);
void s_count_alphabet(unsigned char * str, unsigned short * num_check, unsigned short length);

int main(){
	unsigned short usW_D_length;        	/* 文字列長格納の変数 */
	unsigned char ubW_D_str[1200];      	/* 文字列格納の配列 */
	unsigned short usW_D_num_check[26]; 	/* アルファベットの数を記録する配列 */
	unsigned short usW_C_i;             	/* ループ変数 */
	
	/* 文字列配列の初期化 */
	for(usW_C_i = 0;usW_C_i < 1200;usW_C_i++){
		ubW_D_str[usW_C_i] = 0;
	}
	/* アルファベットの数を記録する配列の初期化 */
	for(usW_C_i = 0;usW_C_i < 26;usW_C_i++){
		usW_D_num_check[usW_C_i] = 0;
	}
	
	/* 文字列入力 */
	usW_D_length = s_scan_sentence(ubW_D_str, 1200);
	
	/* アルファベットの数をカウント */
	s_count_alphabet(ubW_D_str, usW_D_num_check, usW_D_length);
	
	/* カウントした結果を出力 */
	for(usW_C_i = 0;usW_C_i < 26;usW_C_i++){
		/* a : (aの個数) の形式で出力 */
		printf("%c : %d\n", (usW_C_i + 97), *(usW_D_num_check + usW_C_i));
	}
	
	return 0;
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。その長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = 0;	/* 文字列長カウンタ */
	unsigned short usW_C_i;             	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = 0;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if(*(str + usW_C_i) == EOF){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

/* 関数名：アルファベットカウント */
/* 概要：渡された文字列に各アルファベットが何文字含まれるか調べる */
/* 引数：文字列が格納された配列の先頭アドレス、アルファベットの数を記録する配列の先頭アドレス、文字列の長さ */
/* 戻り値：なし */
void s_count_alphabet(unsigned char * str, unsigned short * num_check, unsigned short length)
{
	unsigned short usW_C_i;      	/* ループ変数 */
	unsigned char ubW_D_alphabet;	/* 計算用変数 */
	
	/* 文字列中に各アルファベットが何文字含まれるか調べる */
	for(usW_C_i = 0;usW_C_i < length;usW_C_i++){
		/* アルファベットの場合カウント */
		if(((65 <= *(str + usW_C_i)) && (*(str + usW_C_i) <= 90)) || ((97 <= *(str + usW_C_i)) && (*(str + usW_C_i) <= 122))){
			/* アルファベットを配列の添え字として使える形に加工 */
			ubW_D_alphabet = (*(str + usW_C_i) & 0x1F) - 1;
			/* 文字列中に含まれていたアルファベットをカウント */
			*(num_check + ubW_D_alphabet) += 1;
		}
	}
}




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

#define int                long long
#define all(v)             v.begin(),v.end()
#define rep(i,a,b)         for(int i=a;i<b;i++)
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(n)              (int)(n.size())
#define min3(a,b,c)        fmin(a,fmin(b,c))
#define max3(a,b,c)        fmax(a,fmax(b,c))
#define IOS                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define hell               1000000007
#define dec(a)             fixed<<setprecision(a)
#define tr(container, it)  for(auto it = container.begin(); it != container.end(); it++)
#define vec                vector

int solve()
{
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<endl;
  else
  {
    cout<<"No"<<endl;
  }
  
}

signed main()
{
  IOS;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int tc=1;
  // cin>>tc;
  while(tc--)
  {
    solve();
  }
}

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


int main(){
    double L; cin >> L;

    cout << setprecision(10);
    cout << pow(L/3.0,3) << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void){
    
    char str [201];
    scanf("%s",str);
    int n=strlen(str);
    for (int i=n-2;i;i-=2){
        if(strncmp(str,str+i/2,i/2)==0){
            printf("%d\n" ,i) ;
            return 0;
        }
    }
    return 0;
}


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

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

    int N;
    cin >> N;

    for (int a=0; a<=N; a+=4) {
        if ((N-a) % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
H,W = map(int,readline().split())
S = ''.join(read().decode().split())
 
INF = 10 ** 9
N = H*W
U = 250
dp = [[INF] * U for _ in range(N)]
# そのマスをいじる回数 → 総回数の最小値
dp[0] = list(range(U))
for n in range(H*W):
    for i in range(U-1,0,-1):
        if dp[n][i-1]> dp[n][i]:
            dp[n][i-1] = dp[n][i]
    for i in range(1,U):
        if dp[n][i-1] + 1 < dp[n][i]:
            dp[n][i] = dp[n][i-1] + 1
    s = S[n]
    if s == '#':
        for i in range(0,U,2):
            dp[n][i] = INF
    else:
        for i in range(1,U,2):
            dp[n][i] = INF
    x,y = divmod(n,W)
    to = []
    if y < W - 1:
        to.append(n+1)
    if x < H - 1:
        to.append(n+W)
    for m in to:
        for i in range(U):
            if dp[m][i] > dp[n][i]:
                dp[m][i] = dp[n][i]
 
print(min(dp[-1]))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) cout << "Left" << endl;
    else if (A + B < C + D) cout << "Right" << endl;
    else cout << "Balanced" << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i]%2==0){
      if(a[i]%3 == 0 || a[i]%5 == 0){
        continue;
      }
      else{
        cout << "DENIED"; return 0;
      }
    }
  }
  cout << "APPROVED";

  return 0;
}

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

ans = 0
tmp = 100
flg = False
for i in range(N):
    s = int(input())
    ans += s
    if s%10 != 0:
        tmp = min(tmp, s)
        flg = True

if ans % 10 != 0:
    print(ans)
else:
    if flg:
        print(ans-tmp)
    else:
        print(0)


Measured memory_bytes: 9088
#include<iostream>
using namespace std;
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int main(){
  int a;
  cin>>a;
  int s=a*360/gcd(a,360);
  cout<<s/a<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;

int N, L;
string s[110];

int main() {
  // 入力
  cin >> N >> L;
  for (int i=0; i<N; i++) cin >> s[i];
  // バブルソートで文字列を昇順に並び替え、前から順に結合していく
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      if (i == j) continue;
      if (s[i]+s[j] > s[j]+s[i]) {
        swap(s[i], s[j]);
      }
    }
  }
  for (int i=0; i<N; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys


def sieve(n):
    is_prime = [1 for _ in range(n + 1)]
    is_prime[0] = 0
    is_prime[1] = 0

    for i in range(2, n + 1):
        if is_prime[i]:
            j = i + i
            while j <= n:
                is_prime[j] = 0
                j += i

    return is_prime


N = 10 ** 5
isPrime = sieve(N)
is2017 = [0] * (N + 1)
for i in range(N + 1):
    if 2 * i - 1 <= N and isPrime[i] and isPrime[2 * i - 1]:
        is2017[2 * i - 1] = 1

S = [0] * (N + 1)
for i in range(N):
    S[i + 1] = S[i] + is2017[i + 1]

Q = int(input())
for s in sys.stdin.readlines():
    l, r = map(int, s.split())
    print(S[r] - S[l - 1])


Measured memory_bytes: 67232
def fact(n)
  if n == 0
    return 1
  else
    return fact(n - 1) * n
  end
end
def comb(n, k)
  return fact(n) / fact(n - k) / fact(k)
end
while arg = gets
  sum = 0
  arg.chomp.split(//).map(&:to_i).each_with_index{|item, idx|sum += item * comb(9, idx)}
  puts sum % 10
end

Measured memory_bytes: 6096
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

struct block{
	int w,s,v;
	bool operator <(const block &t)const{
		return w + s < t.w + t.s;
	}
}B[1010];

long long V[20101]; int N;

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) scanf ("%d %d %d",&B[i].w,&B[i].s,&B[i].v);
	sort(B,B+N);

	for (int i=0;i<N;i++){
		for (int j=B[i].s;j>=0;j--){
			if (V[j+B[i].w] < V[j] + B[i].v)
				V[j+B[i].w] = V[j] + B[i].v;
		}
	}

	long long A = 0;
	for (int i=0;i<20101;i++) if (A < V[i]) A = V[i];
	printf ("%lld\n",A);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int n;
    string w, lw;
    map <string, bool> wl;
    cin >> n;
    bool ck = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> w;
        if(i)
        {
            //cout << lw << " " << w << endl;
            if(wl[w]) ck = 1;
            if(lw[lw.size() - 1] != w[0]) ck = 1;
        }
        lw = w;
        wl[w] = 1;
    }
    if(ck) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
//char a[2000][2000];
using namespace std;
bool check(ll m,ll k,ll n,ll a ,ll b){
  ll rem = n-m;
  if( k > rem*b + a*m)
      return 1;
  else
    return 0;

}
int getMod(string s,int k){
  ll sum = 0;
  for(int i = 0;i<s.size();i++){
    sum = sum*10+(s[i]-'0');
    sum = sum%k;
  }
  return sum%k;

}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);            
    //std::setprecision(20);    
    int tests=1;
      //freopen("input.txt", "r", stdin);   
     // cin>>tests;
  while(tests--)
    {
      int n,k;
      cin>>n>>k;
      int color[n+1];
      vector<int> v[n+1];
      for(int i = 1;i<n;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
      }
      bool vis[n+1];
      memset(vis,0,sizeof(vis));
      queue<int> Q;
      int p = 1;
      for(int i = 0;i<v[1].size();i++){
          color[v[1][i]] = k-p;
          Q.push(v[1][i]);
          p++;
      }
      vis[1]  =  1;
      color[1] = k;
      while(!Q.empty()){
        int X = Q.front();
        Q.pop();
        vis[X] = 1;
        p = 2;
        for(int i = 0;i<v[X].size();i++){
          if(!vis[v[X][i]]){
          color[v[X][i]] = k-p;
          p++;
          Q.push(v[X][i]);}
        }
      }
      //for(int i = 1;i<=n;i++)
        //cout<<color[i]<<" ";
      ll res = 1;
      for(int i = 1;i<=n;i++){
        res = (res*color[i]%hell);
      }
      cout<<res%hell;


    }
    
}

Measured memory_bytes: 7032
import Control.Monad

main = do
    people <- readLn
    [day,left] <- map read . words <$> getLine :: IO [Int]
    a <- replicateM people readLn :: IO[Int]
    print (left + people + (sum $ map (\x->div day x + if mod day x ==0 then -1 else 0) a))


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

#define endl "\n"
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll qpow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

int a[maxn], b[maxn], dp[maxn];

void solve() {
    memset(dp, inf, sizeof(dp));
    int h, n;
    cin >> h >> n;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = a[i]; j <= 1e4; j++) {
            dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
        }
    }
    int res = dp[h], ans = h;
    for (int i = h + 1; i <= 1e4; i++) if (res >= dp[i]) {
        res = dp[i];
        ans = i;
    }
    cout << res << endl;
}

int main() {
    header();
    solve();
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	char haiku[19];

	for (int i = 0; i < 19; i++) {
		cin >> haiku[i];
	}

	for (int i = 0; i < 19; i++) {
		if (i == 5 || i == 13)
			cout << " ";
		else 
			cout << haiku[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			double a = sc.nextDouble()*Math.PI/180;
			double b = sc.nextDouble()*Math.PI/180;
			double c = sc.nextDouble()*Math.PI/180;
			double d = sc.nextDouble()*Math.PI/180;
			if(b<0 && d<0) break;
			
			double x1 = Math.cos(a)*Math.cos(b);
			double y1 = Math.cos(a)*Math.sin(b);
			double z1 = Math.sin(a);
			double x2 = Math.cos(c)*Math.cos(d);
			double y2 = Math.cos(c)*Math.sin(d);
			double z2 = Math.sin(c);
			
			double s1 = Math.sqrt(x1*x1+y1*y1+z1*z1);
			double s2 = Math.sqrt(x2*x2+y2*y2+z2*z2);
			double s12 = x1*x2+y1*y2+z1*z2;
			double rad = Math.acos(s12/(s1*s2));
			
			System.out.println((int)(6378.1*rad+0.5));
		}	
	}	
}

Measured memory_bytes: 20560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
bool k(int num){
    string s = to_string(num);
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(){
    int a, b;
    cin >> a >> b;
    int cnt=0;
    for (int i=a; i<=b; i++){
        if (k(i)) {
            cnt++;
        }
    }
    out(cnt);
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(sc.next());
			int d = (k > x)? k - x : x - k;
			ans += 2 * ((x < d)? x : d);
		}
		out.println(ans);
		out.flush();
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

ll dp[5000];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t;
    cin >> s >> t;
    int ans = INF;
    rep(i, sz(s) - sz(t) + 1){
        string tmp = s.substr(i, sz(t));

        int sum = 0;
        rep(j, sz(t)){
            if(tmp[j] == t[j]) sum++;
        }
        chmin(ans, sz(t) - sum);
    }
    print(ans);

}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;

ll INF = 10000000000;

ll gcd(ll a, ll b){
  ll na = 0, nb = 0;
  if(a < b){
    na = b;
    nb = a;
  }
  else{
    na = a;
    nb = b;
  }
  ll c = na % nb;
  ll ans = 0;
  if(c != 0) ans = gcd(nb, c);
  else ans = nb;
  return ans;
}

void show(vector<ll> vec){
  for(int i = 0; i < vec.size(); i++){
    cout << vec[i] << " ";
  }
  cout << endl;
}

ll getMaxGcd(vector<ll> vec){
  ll maxGcd = 0;
  if(vec.size() == 1) maxGcd = vec[0]; 
  else  maxGcd = gcd(vec[0], vec[1]);
  for(int i = 2; i < vec.size(); i++){
    maxGcd = gcd(vec[i], maxGcd);
  }
  
  return maxGcd;
}

ll getMax(vector<ll> vec){
  ll max = 0;
  for(int i = 0; i < vec.size(); i++){
    if(max < vec[i]) max = vec[i];
  }
  return max;
}

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> vec;
  
  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    vec.push_back(tmp);
  }

  ll max = getMax(vec);
  ll maxGcd = getMaxGcd(vec);
  if(K <= max && K % maxGcd == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

ll fc(vector<int> &ld, vector<int> &c, int d){
  ll ret = 0;
  rep(i, 26){
    ret += (ll)c.at(i)*(d - ld.at(i));
  }
  return ret;
}

ll ret(vector<int> &c, vector<vector<int>> &s, vector<int> &ld, int t, int day, bool f, int &tt){
  ll ans = 0;
  tt = ld.at(t);
  ld.at(t) = day;
  ans += s.at(day).at(t);
  ans -= fc(ld, c, day);
  if(f == false)ld.at(t) = tt;
  return ans;
}

int main(){
  int D;
  cin >> D;
  vector<int> ld(26, -1);
  vector<int> c(26);
  rep(i, 26) cin >> c.at(i);
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D){
    rep(j, 26){
      int in;
      cin >> in;
      s.at(i).at(j) = in;
    }
  }
  int tt, sb, xx;
  rep(i, D){
    ll mx = -9e18;
    int jj = 0;
    if(i < D-3){
      rep(j, 26){
        rep(k, 26){
          rep(l, 26){
            ll r = ret(c, s, ld, j, i, true, tt);
            r += ret(c, s, ld, k, i+1, true, sb);
            r += ret(c, s, ld, l, i+2, false, xx);
            if(r > mx){
              mx = r;
              jj = j;
            }
            ld.at(k) = sb;
            ld.at(j) = tt;
          }
        }
      }
    }else{
      rep(j, 26){
        ll r = ret(c, s, ld, j, i, false, tt);
        if(r > mx){
          mx = r;
          jj = j;
        }
      }
    }
    cout << jj+1 << endl;
    ret(c, s, ld, jj, i, true, xx);
  }
  return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int N;
  scanf("%d ", &N);
  for (int i = 0 ;i < N; i++) {
    char num[8];
    for (int j = 0; j < 8; j++) {
      scanf("%c ", &num[j]);
      num[j] = num[j] - '0';
    }
    vector<int> v(8);
    for (int j = 0; j < 8; j++) {
      v[j] = j;
    }
    int mx = -1, mn = 100000000;
    do {
      int n = 0;
      for (int j = 0; j < 8; j++) {
	n = n * 10 + num[v[j]];
      }
      //printf("%d\n", n);
      mx = max(n, mx);
      mn = min(n, mn);
    } while (next_permutation(v.begin(), v.end())); 
    printf("%d\n", mx - mn);
  }

  return 0;
}

Measured memory_bytes: 0
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let s = input!(String);
    if !s.starts_with("A") {
        println!("WA");
        return;
    }
    let chars: Vec<_> = s.chars().collect();
    let mut count = 0;
    for c in &chars[2..chars.len() - 1] {
        if *c == 'C' {
            count += 1;
        }
    }
    if count != 1 {
        println!("WA");
        return;
    }
    let mut count = 0;
    for c in &chars {
        match *c {
            'A'...'Z' => count += 1,
            _ => (),
        }
    }
    if count != 2 {
        println!("WA");
        return;
    }
    println!("AC");
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  long N, K;
  cin>>N>>K;
  long long A[N];
  for(long long i=0;i<N;i++){
    cin>>A[i];
  }
  for(long long i=K;i<N;i++){
    if(A[i-K]<A[i]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);
bool isMultiOf(LL, LL);

int main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] = 'x';
	}
	cout << s;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}
bool isMultiOf(LL a, LL b) {
	return a % b == 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()


int main(){
    int n; cin>>n;
    V l(n);
    rep(i,0,n) cin>>l[i];
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    int sum=0;
    rep(i,1,n) sum+=l[i];
    if(l[0]<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        String a1 = String.valueOf(a);
        String b1 = String.valueOf(b);
        String A = b1;
        String B = a1;

        for(int i=1; i<a; i++){
            A = A + b1;
        }
        for(int i=1; i<b; i++){
            B = B + a1;
        }
        int A1 = Integer.parseInt(A);
        int B1 = Integer.parseInt(B);
        if(A1<=B1){
            System.out.println(B);
        }
        else{
            System.out.println(A);
        }
    }
}

Measured memory_bytes: 21972
k, a, b = map(int, input().split())

if a + 1 >= b:
  print(1 + k)
  
else:
  if k < a + 1:
    print(1 + k)
  else:
    
    a1 = b #a+1回
    if (k - (a + 1)) % 2 == 0:
      a2 = ((k - (a + 1)) // 2) * (b - a)
    else:
      a2 = ((k - (a + 1) - 1) // 2) * (b - a) + 1
    print(a1 + a2)

Measured memory_bytes: 9204
for i in xrange(input()):
    c, a, n = map(int, raw_input().split())
    can = min(c, a, n)
    c -= can; a -= can; n -= can;
    cca = min(c/2, a)
    c -= 2*cca; a -= cca;
    ccc = c/3
    c -= 3*ccc;
    print can+cca+ccc

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int d = scanner.nextInt();
			long sum = 0;
			int i;

			for (i = d; i <= 600 - d;i += d ) {
				sum += d * i * i;
			}
			System.out.println(sum);

		}
		scanner.close();
	}

}



Measured memory_bytes: 25884
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>

using namespace std;


int border(int w){
    for(int i=0; i<w+2; i++){
        cout<<"#";
    }
    cout<<endl;
    return 0;
}

int main(){
    int h,w;
    string s;
    cin>>h>>w;
    border(w);

    for(int i=0; i<h; i++){
        cout<<"#";
        cin>>s;
        cout<<s<<"#"<<endl;
    }

    border(w);
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] t,x,y;

    private void solve() {
        N = nextInt();

        t = new int[N+1];
        x = new int[N+1];
        y = new int[N+1];

        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        for(int i = 1;i < N + 1;i++) {
            t[i] = nextInt();
            x[i] = nextInt();
            y[i] = nextInt();
        }

        for(int i = 1;i < N + 1;i++) {

            int dx = Math.abs(x[i] - x[i-1]);
            int dy = Math.abs(y[i] - y[i-1]);

            int d = dx + dy;
            int s = t[i] - t[i-1];

            if (s > d && (s - d) % 2 != 0) {
                out.println("No");
                return;
            }

            if (s < d) {
                out.println("No");
                return;
            }
        }

        out.println("Yes");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 43652
h,w = map(int,input().split())
a=[""]*h
for i in range(h):
    a[i] = input()
row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=True
            col[j]=True
            
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end="")
        print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define MAX 111111
#define endl '\n'
#define boost ios_base::sync_with_stdio(0);cin.tie(0)
#define INF LONG_MAX
#define ONLINE_JUDGE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

int32_t main()
{
	//ONLINE_JUDGE;
    boost;

    int x,y;
    cin>>x>>y;
    int ans=0;
    int tmp=100000;
    if(x==1 && y==1)
    	ans=4*tmp;
    ans+=max(4-x,0LL)*tmp;
    ans+=max(4-y,0LL)*tmp;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#define fi first
#define se second
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define all(x) x.begin(), x.end()


using namespace std;



int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int main () {
    int n;
    cin>>n;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int g = gcd(i + 1, j + 1);
            for (int k = 0; k < n; k++) {
                int ss = gcd(g, k + 1);
                sum += ss;
            }
        }
    }
    cout<<sum;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct coord_t {
	int h, w;
};

int yukati(const void* x, const void* y) {
	struct coord_t a = *(const struct coord_t*)x, b = *(const struct coord_t*)y;
	if (a.h != b.h) return a.h > b.h ? -1 : a.h < b.h;
	return a.w > b.w ? -1 : a.w < b.w;
}

int H, W, M;
struct coord_t coords[312345];

int h_cnt[3123345], w_cnt[312345];

int h_max_cnt = 0, h_max_list[312345];
int w_max_cnt = 0, w_max_list[312345];

int main(void) {
	int i, j;
	int h_max = 0, w_max = 0;
	int kasanaru_dake = 0;
	if (scanf("%d%d%d", &H, &W, &M) != 3) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d%d", &coords[i].h, &coords[i].w) != 2) return 1;
	}
	qsort(coords, M, sizeof(*coords), yukati);
	for (i = 0; i < M; i++) {
		h_cnt[coords[i].h]++;
		w_cnt[coords[i].w]++;
	}
	for (i = 1; i <= H; i++) {
		if (h_cnt[i] > h_max) h_max = h_cnt[i];
	}
	for (i = 1; i <= W; i++) {
		if (w_cnt[i] > w_max) w_max = w_cnt[i];
	}
	for (i = 1; i <= H; i++) {
		if (h_cnt[i] == h_max) h_max_list[h_max_cnt++] = i;
	}
	for (i = 1; i <= W; i++) {
		if (w_cnt[i] == w_max) w_max_list[w_max_cnt++] = i;
	}

	if ((int64_t)h_max_cnt * w_max_cnt > M) {
		/* 足りないので、絶対交差点に爆破対象が無いところがある */
		kasanaru_dake = 0;
	} else {
		kasanaru_dake = 1;
		for (i = 0; i < h_max_cnt; i++) {
			for (j = 0; j < w_max_cnt; j++) {
				struct coord_t target;
				target.h = h_max_list[i];
				target.w = w_max_list[j];
				if (bsearch(&target, coords, M, sizeof(*coords), yukati) == NULL) {
					kasanaru_dake = 0;
					i = h_max_cnt;
					break;
				}
			}
		}
	}

	printf("%d\n", h_max + w_max - kasanaru_dake);
	return 0;
}


/*

..*..
.....
*.*.*
.....
..*..

.....
.***.
*....
*....
*....

*/


Measured memory_bytes: 8764
#include <iostream> 
#include <vector> 
#include <queue>
using namespace std;

int X, Y, A, B, C;

int main() {
    cin >> X >> Y >> A >> B >> C;
    priority_queue<long long> p, q, r;
    for (int i = 0; i < A + B + C; i++) {
        long long t;
        cin >> t;
        if (i < A) p.push(t);
        else if (i < A + B) q.push(t);
        else r.push(t);
    }
    for (int i = 0; i < X; i++) {
        r.push(p.top());
        p.pop();
    }
    for (int i = 0; i < Y; i++) {
        r.push(q.top());
        q.pop();
    }
    
    long long ans = 0;
    for (int i = 0; i < X + Y; i++) {
        ans += r.top();
        r.pop();
    }
    
    cout << ans << endl;
 }

Measured memory_bytes: 8048
N = int(input())
P = list(map(int,input().split()))+[0]
i,Ans = 0,0
while i<N:
    if P[i] == i+1:
        if P[i+1]==i+2:
            Ans += 1
            i += 1
        else:
            Ans += 1
    i += 1
print(Ans)


Measured memory_bytes: 14004
#include<stdio.h>
int main(void)
{
    int x,i;
    i=1;
    while(1){
        scanf("%d",&x);
    if(x==0){
        break;
    }
    printf("Case %d: %d\n",i,x);
    i=i+1;
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

unsigned long long numAtack(unsigned long long h, unsigned long long counter) {
    if (h == 1) {
        return 1;
    }
    else {
        return 2 * numAtack(h / 2, ++counter) + 1;
    }
}

int main() {
    unsigned long long h;
    cin >> h;
    cout << numAtack(h, 0) << endl;
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 998244353;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9; 
const int N = 2e5+5;                                         
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
#define int ll
int n, q;
ll t[N*4];
ll sum[N*4];
ll pw[N];
int add[N*4];

void push (int v, int tl, int tr) {
	if(!add[v]) return;
	sum[v] %= mod;
	t[v] = add[v] * (ll)sum[v];
	t[v] %= mod;
	if(tl != tr) {
		add[v<<1] = add[v<<1|1] = add[v];
	}
	add[v] = 0;
}

void build (int v = 1, int tl = 1, int tr = n) {
	add[v] = 0;
	if(tl == tr) {
		t[v] = sum[v] = pw[n-tl];		
		return;
	}
	
	int tm = (tl+tr)>>1;
	
	build(v<<1, tl, tm);
	build(v<<1|1, tm + 1, tr);
	
	sum[v] = (sum[v<<1] + sum[v<<1|1]) % mod;
	t[v] = (t[v<<1] + t[v<<1|1]) % mod; 
}

void upd (int l, int r, int d, int v = 1, int tl = 1, int tr = n) {
	push(v, tl, tr);
	
	if(tl > r || l > tr || l > r) return;
	if (tl >= l && tr <= r) {
		add[v] = d;
		push(v, tl, tr);
		return;
	}
	
	int tm = (tl+tr)>>1;
	upd(l, r, d, v<<1, tl, tm);
	upd(l, r, d, v<<1|1, tm + 1, tr);
	t[v] = t[v<<1] + t[v<<1|1];
	t[v] %= mod;
}

int32_t main () {
	SpeedForce;
	
	cin >> n >> q;
	pw[0] = 1;
	for (int i = 1; i <= n; ++i) {
		pw[i] = (pw[i-1] * 10) % mod;
	}
	build();
	
	for (int i = 1; i <= q; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		upd(l, r, d);
		cout << t[1] << '\n';
	}
	
	return Accepted;
}

// B...a


Measured memory_bytes: 17544
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ciphered = sc.next();
        String substring = sc.next();

        if (ciphered.length() < substring.length()) {
            System.out.println("UNRESTORABLE");
            return;
        }

        char[] chars = ciphered.toCharArray();
        char[] subChars = substring.toCharArray();
        List<String> candidates = new ArrayList<>();
        for (int i = 0; i < chars.length - subChars.length + 1; i++) {
            boolean continueFlag = false;
            char[] tmp = ciphered.toCharArray();
            for (int j = 0; j < subChars.length; j++) {
                tmp[i + j] = subChars[j];
            }
            for (int j = 0; j < chars.length; j++) {
                if (chars[j] != '?' && chars[j] != tmp[j]) {
                    continueFlag = true;
                    break;
                }
            }
            if (continueFlag) {
                continue;
            }
            candidates.add(String.valueOf(tmp).replace("?", "a"));
        }
        if (!candidates.isEmpty()) {
            candidates.sort(Comparator.naturalOrder());
            System.out.println(candidates.get(0));
            return;
        }
        System.out.println("UNRESTORABLE");
    }
}


Measured memory_bytes: 23252
n, yen = map(int, input().split())

for x in range(n + 1):
    for y in range(n + 1):
        if x + y > n:
            break
        z = (yen - x * 10000 - y * 5000) / 1000
        if x + y + z == n:
            print(x, y, int(z))
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3316
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=9e5+10;
const int Mod=1e9+7;

int N,M,K,Max;
long long Fac[maxm],Inv1[maxm],Inv2[maxm],P[maxm];

long long C(int x,int y){
	return Fac[x]*Inv2[y]%Mod*Inv2[x-y]%Mod;
}

int main(){
	register int i,j;
	register long long Ans=0;
	scanf("%d%d%d",&N,&M,&K);
	Max=N+M+K;
	Fac[0]=Fac[1]=Inv1[0]=Inv1[1]=Inv2[0]=Inv2[1]=1;
	P[0]=1,P[1]=3;
	for(i=2;i<=Max;i++){
		Fac[i]=Fac[i-1]*i%Mod;
		Inv1[i]=(Mod-Mod/i)*Inv1[Mod%i]%Mod;
		Inv2[i]=Inv2[i-1]*Inv1[i]%Mod;
		P[i]=P[i-1]*3%Mod;
	}
	if(M<K) swap(M,K);
	for(i=0,j=1;i<=M+K;i++){
		Ans=(Ans+C(N-1+i,N-1)*P[M+K-i]%Mod*j)%Mod;
        if(i<K) j=j*2%Mod;
        else if(i>=M) j=((j<<1)-C(i,K)-C(i,i-M)+(Mod<<1))%Mod;
		else j=((j<<1)-C(i,K)+Mod)%Mod;
	}
	printf("%lld",Ans);
	return 0;
}

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

int main() {
  int l[11];
  char c;
  while (1) {
    for ( int i = 1; i < 11; i++ ) {
      cin >> l[i] >> c;
      if ( cin.eof() ) return 0;
    }
    int v1,v2;
    cin >> v1 >> c >> v2;

    double sum = 0;
    for ( int i = 1; i < 11; i++ ) {
      sum += l[i];
    }
    double f = 0,b = 0;
    int pos;
    for ( int i = 1; i < 11; i++ ) {
      f += l[i];
      b += l[i]*(1.0*v2/v1);
      if ( f + b >= sum ) {
	pos = i;
	break;
      }
    }
    cout << pos << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
n = int(input())
x = list(map(int, input().split()))
hpmin = (100 ** 2) * 100
for p in range(1, 101):
    hp = 0
    for j in range(n):
        hp += (x[j] - p) ** 2
    if hp < hpmin:
        hpmin = hp
print(hpmin)

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

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

    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] = 'a' + S[K-1] - 'A';
    cout << S << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	nums := make([]int, 0, 2)
	for _, str := range strings.Split(sc.Text(), " ") {
		n, _ := strconv.Atoi(str)
		nums = append(nums, n)
	}

	if nums[2] >= nums[0] && nums[2] <= nums[1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int[][] dp;
	static int n;
	static int m;
	static int[] c;
	static int[] x;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			n = stdIn.nextInt();
			m = stdIn.nextInt();
			if(n == 0 && m == 0) break;
			c = new int[m];
			for(int i = 0; i < m; i++) {
				c[i] = stdIn.nextInt();
			}
			x = new int[n];
			for(int i = 0; i < n; i++) {
				x[i] = stdIn.nextInt();
			}
			
			System.out.println(dp());
		}
	}
	static int INF = 2 << 28;
	public static int dp() {
		dp = new int[n+1][256];
		
		for(int i = 0; i < n+1; i++) {
			Arrays.fill(dp[i], INF);
		}
		dp[0][128] = 0;
		int ans = INF;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 256; j++) {
				if(dp[i][j] == INF) continue;
				for(int k = 0; k < m; k++) {
					int tmp = Math.max(0, Math.min(255, j + c[k]));
					dp[i+1][tmp] = Math.min(dp[i+1][tmp], dp[i][j] + (tmp-x[i])*(tmp-x[i]) );
				}
			}
		}
		for(int i = 0; i < 256; i++) {
			ans = Math.min(ans, dp[n][i]);
		}
		return ans;
		
		
	}
}
	

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

int matrix[11][1001];
int h,w,k;

void acumSum (){
   for( int i=1 ; i<h+1 ; ++i ){
      for( int j=1 ; j<w+1 ; ++j ){
         matrix[i][j] += matrix[i][j-1];
      }
   }
   for( int i=1 ; i<h+1 ; ++i ){
      for( int j=1 ; j<w+1 ; ++j ){
         matrix[i][j] += matrix[i-1][j];
      }
   }
}

int sum ( int r1 , int c1 , int r2 , int c2 ){
   return matrix[r2][c2] - matrix[r2][c1] - matrix[r1][c2] + matrix[r1][c1];
}

bool keepCols( vector<int> rows , int prevColum , int actuColum ){
   for(int i = 1 ; i < rows.size() ; ++i ){
      if( sum ( rows[i-1] , prevColum , rows[i] , actuColum ) > k ) return false;
   }
   return true;
}

int calculTotColum( vector<int> rows ){
   int prevColum = 0 , totCol = 0;
   for(int actuColum = 1 ; actuColum <= w ; ){
      if(keepCols ( rows , prevColum , actuColum )){
         actuColum ++ ;
      }
      else{
         if(actuColum == prevColum + 1 ) {
            return -1;
         }
         else{
            totCol ++;
            prevColum = actuColum - 1;
            actuColum;
         }
      }
   }
   return totCol ;
}

int main(){

   scanf( "%d %d %d" , &h , &w , &k );

   for( int i=1 ; i<h+1 ; ++i ){
      char str[w+1] ;
      scanf( "%s" , str );
      for( int j=0 ; j<w+1 ; ++j ){
         matrix[i][j+1] = str[j]-'0';
      }
   }
   acumSum();
   int ans = (int) 1e9;
   vector<int> rows;

   for( int mask = 0 ; mask < 1<<(h-1) ; ++mask ){ 

      rows.push_back(0);
      for(int i=0 ; i<h-1 ; ++i) {
         if( (mask>>i)&1 ) {
            rows.push_back(i+1);
         }
      }
      rows.push_back(h);
      
      if(calculTotColum ( rows ) >= 0 ){
         int total = calculTotColum( rows ) + __builtin_popcount(mask);
         ans = min ( ans , total );  
      }
      rows.clear();    
   } 

   cout << ans ;

   return 0;
}

Measured memory_bytes: 256
N = list(map(int, "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ")))
n = int(input())
print(N[n-1])

Measured memory_bytes: 2940
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N, max, f = 0;
    in >> N;
    vector<ll> H(N);
    REP(i,N){
        in >> H[i];
    }
 
    max = H[0];
    REP_AB(i,1,N-1){
        if(max < H[i]){
            max = H[i] - 1;
        }
        else if(max > H[i]){
            f = 1;
            break;
        }
    }
 
 
    if(f == 0){
           out << "Yes" << endl;
    }else if(f == 1){
           out << "No" << endl;
    }
 
 
 
 
 
 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP(i, N) { cin >> V[i]; }
    int res = 0;
    REP(A, min(N, K) + 1) {
        REP(B, min(N, K) - A + 1) {
            int sum = 0;
            priority_queue<int> pq;
            REP(i, A) {
                sum += V[i];
                if (V[i] < 0) pq.emplace(-V[i]);
            }
            REP(i, B) {
                sum += V[N - 1 - i];
                if (V[N - 1 - i] < 0) pq.emplace(-V[N - 1 - i]);
            }
            REP(i, K - A - B) {
                if (pq.empty()) break;
                sum += pq.top();
                pq.pop();
            }
            res = max(res, sum);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256