akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int ans = 0,n,u = 0,d = 0,a[3][110],up[110] = {0},down[110] = {0};
int main()
{
    cin>>n;
    for (int i = 1; i <= 2; i++)
        for (int j = 1; j <= n; j++)
            cin>>a[i][j];
    for (int i = 1; i <= n; i++)
    {
        u+=a[1][i];
        up[i] = u;
    }

    for (int i = n; i >= 1; i--)
    {
        d+=a[2][i];
        down[i] = d;
    }

    for (int i = 1; i <= n; i++)
    {
        ans = max(ans,up[i]+down[i]);
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
    int n,m,x,ans=2000000; cin >> n >> m >> x;
    vector<int> c(n);
    int a[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int money = 0;
    for(int tmp=0;tmp < (1 << 12);tmp++){
        vector<int> check(m);
        money = 0;
        bitset<12> bit(tmp);
        for(int i=0;i<n;i++){
            if(bit.test(i)){
                for(int j=0;j<m;j++){
                    check[j] += a[i][j];  //cout << check[j] << " ";
                }money += c[i]; //out << money << endl;
            }
        }
        bool ok = true;
        for(int i=0;i<m;i++){
            if(check[i] < x) ok = false;
        }
    
        if(ok) ans = min(ans,money);
    }
    if(ans != 2000000) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {

            //int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int s = int.Parse(Console.ReadLine());
            bool flag = false;
            int answer = 0;
            var line = new List<int>();
            int count = 0;
            while (!flag)
            {
                if (line.Contains(s))
                {
                    answer = count;
                    flag = true;
                }
                else
                {
                    line.Add(s);
                    //Console.WriteLine(line[count]);
                }
                if (s % 2 == 1)
                {
                    s = 3 * s + 1;

                }
                else
                {
                    s = s / 2;
                }
                count++;

            }

            Console.WriteLine(count);


            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

class Main implements Runnable {
	public static final long MOD = 1000000007;
	private final FastScanner sc;
	private final PrintWriter out;
	int r;

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
		new Thread(null,new Main(),"",16L*1024*1024).start();
	}

	Main() {
		sc = new FastScanner();
		out = new PrintWriter(System.out);
		init();
	}
	
	private void init(){
		r = sc.nextInt();
	}
	private void solve(){
		out.print(2*r*Math.PI);
	}
	
	/*
	private void exit(int status){
		out.flush();
		out.close();
		System.exit(status);
	}
	//*/
	public void run() {
		try{
		solve();
		}catch(Exception e){
			e.printStackTrace();
		}
		out.flush();
		out.close();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	// 入力の受け取り 及び 文字が読み込めたらTRUE
	// 前回の受け取りが未処理であれば新規入力はしない
	private boolean read() {
		if (ptr < buflen) {
			return true;
		} else {
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
			return true;
		}
	}

	// 読込可能判定
	private boolean hasNext() {
		// 読込可能かつ文字以外ならポインタ加算
		while (read() && !isVisibleChar(buffer[ptr]))
			ptr++;
		// 文字が来た or EOF で結果表示
		return read();
	}

	// 次の１バイトを読む
	private int getNextChar() {
		if (read()) {
			ptr++;
			return buffer[ptr - 1];
		} else {
			return -1;
		}
	}

	// ASCIIの制御文字以外でTRUE
	private static boolean isVisibleChar(int code) {
		return code >= 33 && code <= 126;
	}

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

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean sign = true;
		int b = getNextChar();
		if (b == '-') {
			sign = false;
			b = getNextChar();
		}
		if (b < '0' || b > '9') {
			throw new NumberFormatException();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isVisibleChar(b)) {
				return sign ? n : -n;
			} else {
				throw new NumberFormatException();
			}
			b = getNextChar();
		}
	}

	public int nextInt() {
		long n = nextLong();
		if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) n;
	}

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

	public void close() {
		try {
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class IntQueue {
	protected int[] a;
	protected int head, tail;

	public IntQueue(int max) {
		a = new int[max];
	}

	public void offer(int x) {
		a[tail++] = x;
	}

	public int poll() {
		return a[head++];
	}

	public int peek() {
		return a[head];
	}
}


Measured memory_bytes: 33960
#include <bits/stdc++.h>
using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      cout<<"#x "<<x<<"\n";
#define trace(x,y)  cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          cout<<"\n";


bool SBF(const pair <int,int>&a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair<int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const int maxn = 1e9+7;
int n , k;
void solve(){
    string s, t;
    cin >> s >> t;
    bool ans = true;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i])ans = false;
    }
    if(ans )cout<<"Yes\n";
    else cout<<"No\n";
 
}
int main(){
    solve();
return 0;
}


Measured memory_bytes: 3596
let n = Scanf.scanf " %d" (+) 0
let xus = Array.init n @@ fun _ -> Scanf.scanf " %f %s" @@ fun a b -> a, b
let _ = Array.fold_left (fun s (x, u) -> if u = "JPY" then s +. x else s +. x *. 380000.) 0. xus |> Printf.printf "%.5f\n"

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

#define LINE_BUF_SIZE  1024

int main(void) {
    static char line[LINE_BUF_SIZE];

    while (fgets(line, sizeof(line), stdin) != NULL) {
        int x, a, b;
        if (sscanf(line, "%d %d %d", &x, &a, &b) != 3) {
        fputs("sscanf: Convert error\n", stderr);
        return EXIT_FAILURE;
        }   
    
        int c = b - a;
        if(c <= 0) { printf("delicious\n"); }
        else if(c <= x) { printf("safe\n"); }
        else { printf("dangerous\n"); }
    }

    return 0;
}

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

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

int main() {
  int n, x;
  cin >> n;

  bool approved = true;
  rep(i, n) {
    cin >> x;
    if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
      approved = false;
      break;
    }
  }

  if (approved) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

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

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

	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	reverse(b.begin(), b.end());
	int start = -1, fin = -1;
	for (int i = 0; i < n; ++i) {
		if (a[i] == b[i]) {
			if (start == -1) start = i;
			fin = i;
		}
	}
	bool bad = 0;
	if (start != -1) {
		for (int i = 0, j = start; j <= fin; ++i) {
			if (i == start) i = fin + 1;
			if (i == n) {
				bad = 1;
				break;
			}
			if (a[i] != b[j] && b[j] != b[i]) {
				swap(b[i], b[j++]);
			}
		}
	}
	if (bad) {
		cout << "No" << '\n';
	} 
	else {
		cout << "Yes" << '\n';
		for (int i = 0; i < n; ++i) {
			if (i) cout << " ";
			cout << b[i];
		}
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  long long N;
  cin >> N;
  vector<long long> A(N+1,0);
  for(int i = 0; i < N; ++i) cin >> A[i+1];
  long long ans = 0;
  map<long long, long long> M;
  M[0] = 1;
  for(int i = 0; i < N; ++i){
    A[i+1] += A[i];
    ans += M[A[i+1]];
    ++M[A[i+1]];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    string a,b;
    cin >> a >> b;
    if(a.length()<b.length()){
        rep(i,(b.length()-a.length()))a='0'+a;
    }
    if(a.compare(b)>0)cout << "GREATER" << endl;
    else if(a.compare(b)==0)cout << "EQUAL" << endl;
    else cout << "LESS" << endl;
}

Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
A = list(map(int, input().split()))

half = N // 2

ball = np.zeros(N, dtype=np.bool)
ball[half:] = A[half:]

for i in range(half - 1, -1, -1):
    a = A[i]
    cnt = np.count_nonzero(ball[i:: i + 1]) % 2
    if a != cnt:
        ball[i] = True

ans = np.where(ball == True)[0]
print(len(ans))

if len(ans) > 0:
    print(" ".join([str(x+1) for x in ans]))


Measured memory_bytes: 23688
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A, B, C, D;
        cin >> A >> B >> C >> D;

        cout << max(A * B, C * D) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<=b)?(a=b,1):0; }

using namespace std;

int main(void){
	int m, nmin, nmax;
	while(cin>>m>>nmin>>nmax,m,nmin,nmax) {
		int res = 0;
		int n = 0;
		int prev = 0;
		rep(i,m) {
			int cur; cin >> cur;
			if(nmin<=i && i <= nmax) if(chmax(res, prev-cur)) n=i;
			prev = cur;
		}
		cout << n << endl;
	}
        
	return 0;
}

Measured memory_bytes: 3056
#include <stdio.h>

int main(){
    int i, j, k, n, a[10000], max, sum;
    
    while(1){
        scanf("%d", &n);
        if(n == 0) break;
        for (i = 0; i < n; i++){
            scanf("%d", &a[i]);
        }
        max = a[0];
        for (j = 0; j < n; j++){
            sum = 0;
            for (k = j; k < n; k++){
                sum += a[k];
                if(sum > max) max = sum;
            }
        }
        printf("%d\n", max);
    }
    
    return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

    int n; ll w;
    cin >> n >> w;
    V<ll> dp(w + 1, 0);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        for (int j = w; j >= x; j--) {
            dp[j] = max(dp[j], dp[j - x] + y);
        }
    }
    cout << dp[w] << endl;
    return 0;
}


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

int main(){
  int n;

  while(cin>>n,n){
    vector<int> card[2];
    card[0].resize(n);
    for(int i=0;i<n;i++)cin>>card[0][i];
    sort(card[0].begin(),card[0].end());

    for(int i=1;i<=2*n;i++){
      int flg=1;
      for(int j=0;j<n&&flg;j++) if(i==card[0][j]) flg=0;
      if(flg) card[1].push_back(i);
    }
    int turn=0,num=-1;
    while(card[0].size()&&card[1].size()){
      int nx=-1;
      for(int i=0;i<card[turn].size();i++){
	if(card[turn][i]>num) {
	  nx=card[turn][i];
	  card[turn].erase(card[turn].begin()+i);
	  break;
	}	
      }
      num=nx;
      turn=!turn;
    }

    cout << card[1].size()<<endl;
    cout << card[0].size()<<endl;
   
  }
  return 0;
}

Measured memory_bytes: 3108
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 200005

using namespace std;

char str[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	int ans=0,nm=0;
	for(int i=0;i<n;i++)
	{
		if(str[i]=='S') nm++;
		else
		{
			if(nm>0) nm--;
			else ans++;
		}
	}
	printf("%d\n",ans+nm);
	return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
ab = list(map(int, input().split()) for i in range(n))
cd = list(list(map(int, input().split())) for i in range(m))

for a, b in ab:
    md = 1001001001
    res = 0
    for i in range(m):
        tmp = abs(a - cd[i][0]) + abs(b - cd[i][1])
        if tmp < md:
            md = tmp
            res = i + 1
    print(res)
            

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

int main()
{
    int p[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
    int p2[15]; rep(i,15) p2[i] = 0;
    int n;
    cin >> n;
    int a = 0,b = 0,c = 0,d = 0,e = 0,cnt = 0;
    rep(i,15){
        for (int j = p[i];j<=n;j*=p[i]) p2[i] += n/j;
        
        if (p2[i] >= 74) e += 1;
        if (p2[i] >= 24) d += 1;
        if (p2[i] >= 14) c += 1;
        if (p2[i] >= 4)  b += 1;
        if (p2[i] >= 2)  a += 1;
    }
    cnt += e;
    cnt += ((a-b)*b*(b-1))/2 + (b*(b-1)*(b-2))/2;
    cnt += (a-d)*d + d*(d-1);
    cnt += (b-c)*c + c*(c-1);

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

Measured memory_bytes: 256
n, q = gets.split(" ").map(&:to_i)

processes = []
total_time = 0

class Processs
  attr_accessor :name, :time

  def initialize(name, time)
    @name = name
    @time = time.to_i
  end
end


n.times do
  name, time = gets.split(" ")
  processes << Processs.new(name, time)
end


class RoundRobinScheduling
  def initialize(processes, quantum)
    @processes = processes
    @quantum = quantum
    @total_time = 0
  end

  def execute
    while @processes.length > 0 do
      process = @processes.shift
      if process.time <= @quantum
        @total_time += process.time
        puts "#{process.name} #{@total_time}"
      else
        @total_time += @quantum
        process.time -= @quantum
        @processes << process
      end
    end
  end
end

queue = RoundRobinScheduling.new(processes, q)
queue.execute



Measured memory_bytes: 11684
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64));
    if a % 2 != 0 && b % 2 != 0 {
        "Yes"
    } else {
        "No"
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 1" => "Yes",
    test2: "1 2" => "No",
    test3: "2 2" => "No",
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++)
        for(int j = 1; j <= 9; j++)
            if(i * j == n)
                return cout << "Yes", 0;
    cout << "No";
    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Xi = Sarray();
            var Xis = new List<long>(Xi);
            Xis.Sort();
            var cen = Xis[(Xis.Count + 1) / 2];
            var precen = Xis[(Xis.Count + 1) / 2 - 1];
            for(var i=0;i<Xi.Length;++i)
            {
                if (Xi[i] < cen)
                    WriteLine(cen);
                else
                    WriteLine(precen);
            }
            Out.Flush();
        }
    }
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(15);
  u32 N, M;
  cin >> N >> M;
  vector<u32> s(M), c(M);
  for (u32 i = 0; i < M; ++i) cin >> s[i] >> c[i];
  if (N == 1) {
    u32 res = 10;
    for (u32 i = 0; i < 10; ++i) {
      bool flag = true;
      for (u32 j = 0; j < M; ++j) {
        if (i != c[j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        res = i;
        break;
      }
    }
    if (res != 10)
      cout << res << endl;
    else
      cout << -1 << endl;
  } else {
    u32 Mlim = 1;
    for (u32 i = 0; i < N; ++i) Mlim *= 10;
    u32 res = Mlim;
    for (u32 i = Mlim / 10; i < Mlim; ++i) {
      bool flag = true;
      for (u32 j = 0; j < M; ++j) {
        u32 tmp = Mlim;
        for (u32 k = 0; k < s[j]; ++k) tmp /= 10;
        if (((i / tmp) % (10)) != c[j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        res = i;
        break;
      }
    }
    if (res != Mlim)
      cout << res << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, long long A, long long B){
    if((B-A) % 2 == 0){
        cout << "Alice" << endl;
    } else{
        cout << "Borys" << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
import sys 

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))
A.sort()

max_a = max(A)
counts = [0 for _ in range(max_a + 1)]
ans = 0

for a in A:
    counts[a] += 1

for a in A:
    if counts[a] == 1:
        ans += 1
    n = 1
    while n * a <= max_a:
        counts[n * a] += 2
        n += 1

print(ans)

Measured memory_bytes: 164968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

//二分累乗法 modを設定すること

ll dp[2100][2100];

signed main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> s(n,0),t(m,0);

    for(int i=0;i < n;i++)
    {
        cin>>s.at(i);
    }
    for(int i=0;i < m;i++)
    {
        cin>>t.at(i);
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0]=1;

    for(int i=0;i < n+1;i++)
    {
        for(int j=0;j < m+1;j++)
        {
            if (i>0 && j>0 && s[i-1] == t[j-1]) dp[i][j] += dp[i-1][j-1];
            if(j>0)dp[i][j]+=dp[i][j-1];

            if(i>0)dp[i][j]+=dp[i-1][j];
            
            if (i-1 >= 0 && j-1 >= 0) dp[i][j] += mod-dp[i-1][j-1];
          
            dp[i][j]%=mod;
        }
    }
    cout << dp[n][m]%mod << endl;
}
/*共通文字列のDPは、それぞれの文字列をどこまで見たかに対応する二つの添え字をもってやる */


Measured memory_bytes: 34688
def Z():
 m=-1;I=input;N,M,K=map(int,I().split());W=2000000;s=[0]*W;t=[0]*W;L=max(N,M)-1;R=range;p=lambda x:print(*reversed(x),sep='')
 for i,c in zip(R(N-1,m,m),I()):s[i]=int(c)
 for i,c in zip(R(M-1,m,m),I()):t[i]=int(c)
 for i in R(L,m,m):
  j=i;z=K
  while s[j]and t[j]and z:
   s[j]=t[j]=0;s[j+1]+=1;t[j+1]+=1;j+=1;z-=1;x=y=j
   while s[x]==2:s[x]=0;s[x+1]+=1;x+=1
   while t[y]==2:t[y]=0;t[y+1]+=1;y+=1
   j=max(x,y)
  L=max(L,j)
 s=s[:L+1];t=t[:L+1]
 while s[m]==0:s.pop()
 while t[m]==0:t.pop()
 p(s);p(t)
Z()

Measured memory_bytes: 199668
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T>
struct Kruskal{
  
  struct edge{
    int from,to;
    T cost;
    int used;
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<int> r,p;
  vector<edge> es;

  Kruskal(){}
  Kruskal(int n):n(n),r(n,1),p(n){
    iota(p.begin(),p.end(),0);
  }
  
  int find(int x){
    if(x!=p[x]) p[x]=find(p[x]);
    return p[x];
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
  }
  
  T build(){
    sort(es.begin(),es.end());
    T res=0;
    for(auto &e:es){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};
//END CUT HERE
int main(){
  int V,E;
  scanf("%d %d",&V,&E);
  Kruskal<int> ksk(V);
  for(int i=0;i<E;i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    ksk.add_edge(a,b,c);
  }
  printf("%d\n",ksk.build());
  return 0;
}

/*
  verified on 2018/10/22
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp
*/



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

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

    int n,k,num,snu;
    cin>>n>>k;

    int arr[n];
    for (int i = 0; i < n; ++i) {
        arr[i]=0;
    }

    for (int j = 0; j < k; ++j) {
        cin>>num;
        for (int i = 0; i < num; ++i) {
            cin>>snu;
            snu--;
            arr[snu]++;
        }
    }

    int count=0;
    for (int l = 0; l < n; ++l) {
        if(arr[l]==0)
            count++;
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int[] a = new int[1000001];

        a[1] = 7 % K;
        for (int i = 2; i <= K; i++) {
            a[i] = (a[i-1] * 10 + 7) % K;
        }

        for(int i = 1; i <= K; i++) {
            if (a[i] == 0) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }

}


Measured memory_bytes: 39452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

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

  int n,m;
  cin >> n >> m;
  vector<int> a;
  vector<bool> b(1000000001,false);
  for(int i = 0; i < m; i++){
    int x,y;
    cin >> x >> y;
    if(x == 1) a.push_back(y);
    if(y == 1) a.push_back(x);
    if(x == n) b[y] = true;
    if(y == n) b[x] = true;
  }
  for(auto x : a) {
    if (b[x]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 123004
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i;
  	cin>>a>>b;
  	string s;
  	cin>>s;
  
  	for(i=0;i<a+b+1;i++){
      	if(i==a){
			if(s[i]!='-'){
              	cout<<"No"<<endl;
              	return 0;
            }
        }else{
          if(s[i]=='-'){
            	cout<<"No"<<endl;
            	return 0;
          }
        }
    }
	
  	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = n//100
b = (n-100*a)//10
c = (n-100*a-10*b)

if a > b:
  print("{0}{0}{0}".format(a))
elif a==b and b>=c:
  print("{0}{0}{0}".format(a))
else:
  print("{0}{0}{0}".format(a+1))

Measured memory_bytes: 3060
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
xyh = [lr() for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for i in range(0,101):
    for j in range(0,101):
        H = abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        flag = True
        for k in range(1,n):
            h = abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
            if not ((h>H and xyh[k][2]==0) or h==H):
                flag = False
                break
        if flag:
            print(i,j,H)
            sys.exit()

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

int main(){

  int A,B;

  cin>>A>>B;

  if((A+B)>(A-B)){

    if((A+B)>(A*B)){
        cout<<A+B<<endl;
      }
      else{
        cout<<A*B<<endl;
      }
      }
    else{

      if((A-B)>(A*B)){
        cout<<A-B<<endl;
      }
      else{
        cout<<A*B<<endl;
      }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<int> cnt(100010, 0);
    cnt[0] = 3;
    ll ans = 1;
    rep(i, N) {
        ans *= min(cnt[A[i]], cnt[A[i]] - cnt[A[i] + 1]);
        ans %= mod;
        cnt[A[i] + 1]++;
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 1024
package main

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

func main() {
	N := getStdinInt()

	for x := 1; x <= 9; x++ {
		for y := 1; y <= 9; y++ {
			if x*y == N {
				fmt.Printf("Yes\n")
				return
			}
		}
	}

	fmt.Printf("No\n")
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    ll ans = K;
    REP(i,N-1){
        ans *= K-1;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n,m;
    cin>>n>>m;
    int left=-1;
    int right=n+1;
    rep(i,m){
        int l,r;
        cin>>l>>r;
        left=max(left,l);
        right=min(right,r);
    }
    cout<<max(0,right-left+1)<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

int main(){
    int ans = 0;
    for(int i = 0; i < 3; i++){
        char a;
        cin >> a;
        if(a == '1') ans++;
    }
    cout << ans << endl;
}

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

int main(){

  int n, i;
  string s;

  cin>>n;
  cin>>s;

  for(i=0;i<n;i++){
    if(s[i]=='x'&&s[i-1]=='x'){
      break;
    }
  }

  cout<<i<<endl;
  
  return 0;
}

Measured memory_bytes: 3336
S=input()
slist=[S[0]]
numlist=[1]
for i in range(1,4):
    if not S[i] in slist:
        slist.append(S[i])

if len(slist)!=2:
    ans='No'
else:
    numlist=[0,0]
    for i in range(4):
        for j in range(2):
            if S[i]==slist[j]:
                numlist[j]+=1
    if numlist[0]==2 and numlist[1]==2:
        ans='Yes'
    else:
        ans='No'

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

struct State{
	int bits, f, x, y;
	State(int bits_, int f_, int x_, int y_){
		bits = bits_; f = f_; x = x_; y = y_;
	}
	State(){}
};

const int INF = 1e+8;
// 入力
int w, h, s;
// m[y][x] := (x,y) の状態が返ってくる.
char m[51][51];
// ms[k][y][x] := k 番目のスイッチについて(x,y)が移動するときは '*' が返ってくる
char ms[10][51][51];
// スタートとゴール
int sx, sy, gx, gy;

// d[bits][f][y][x] := スイッチを押した状態bits, f 階の(x,y) までの最小の step数
int d[(1<<10)+1][2][51][51];
// 4近傍
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

// (スイッチの押した状態,階,x座標,y座標)を状態にして幅優先探索
int bfs(){
	// 初期化
	for(int i=0 ; i < (1<<s) ; i++ ){
		for(int f=0 ; f < 2 ; f++ ){
			for(int y=0 ; y < h ; y++ ){
				for(int x=0 ; x < w ; x++ ){
					d[i][f][y][x] = INF;
				}
			}
		}
	}
	queue<State> q;
	q.push( State(0,0,sx,sy) );
	d[0][0][sy][sx] = 0;
	
	int res = -1;
	while( !q.empty() ){
		int x = q.front().x;
		int y = q.front().y;
		int f = q.front().f;
		int bits = q.front().bits;
		int cost = d[bits][f][y][x];
		q.pop();
		// ゴールのとき
		if( x == gx && y == gy ){
			res = cost;
			break;
		}
		
		// 4 方向に移動
		for(int i=0 ; i < 4 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			// (mx,my) が何階にあるか (2Fにいるのは'^'か大文字のアルファベットのときのみ)
			int f2 = ( m[my][mx] == '^' || isupper(m[my][mx])? 1 : 0 );
			// すべてのONのスイッチをチェックして自分の階を調べる
			for(int j=0 ; j < s ; j++ ){
				if( bits & (1<<j) && ms[j][my][mx] == '*' ){
					f2 = (f2+1) % 2;
				}
			}
			// 階段はどちらの階からも行き来可能
			if( m[my][mx] == '|' ) f2 = f;
			
			// 侵入できないとき
			if( m[my][mx] == '#' || f2 != f ) continue;
			
			if( cost + 1 < d[bits][f][my][mx] ){
				d[bits][f][my][mx] = cost + 1;
				q.push( State(bits, f, mx, my) );
            }
			if( m[my][mx] == '#' ) continue;
			
			State next(bits, f, mx, my);
			if( d[bits][f][my][mx] == INF ){
				d[bits][f][my][mx] = cost + 1;
				q.push( next );
			}
		}
		
		// はしごにいるとき
		if( m[y][x] == '|' ){
			int next_f = (f+1) % 2;
			if( cost + 1 < d[bits][next_f][y][x] ){
				d[bits][next_f][y][x] = cost + 1;
				q.push( State(bits, next_f, x, y) );
			}
		}
		
		// スイッチがあるとき
		if( isalpha(m[y][x]) ){
			int k = tolower(m[y][x]) - 'a';
			int f2 = f;
			// xor でk番目のスイッチを ON => OFF か OFF => ON に変更
			int next_bits = bits ^ (1<<k);
			// 自分のいる位置が変わるとき
			if( ms[k][y][x] == '*' ){
				f2 = (f2+1) % 2;
			}
			
			if( cost + 1 < d[next_bits][f2][y][x] ){
				d[next_bits][f2][y][x] = cost + 1;
				q.push( State(next_bits, f2, x, y) );
			}
        }
	}
	return res;
}

int main(){
	cin >> w >> h;
	for(int y=0 ; y < h ; y++ ){
		cin >> m[y];
	}
	cin >> s;
	for(int i=0 ; i < s ; i++ ){
		for(int y=0 ; y < h ; y++ ){
			cin >> ms[i][y];
		}
	}
	// スタートとゴールの位置をチェック.
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( m[y][x] == '%' ){
				sx = x; sy = y;
				m[y][x] = '_';
			}else if( m[y][x] == '&' ){
				gx = x; gy = y;
				m[y][x] = '_';
			}
		}
	}
	
	// 解を出力
	cout << bfs() << endl;
}

Measured memory_bytes: 22568
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n+2), b(n+2);
	for(ll i=1; i<=n+1; i++) {
		cin >> a[i];
	}
	for(ll i=1; i<=n; i++) {
		cin >> b[i];
	}
	ll ans = 0;
	for(ll i=1; i<=n; i++) {
		if (b[i] < a[i]) ans += b[i];
		else {
			ans += a[i];
			b[i] -= a[i];
			if (a[i+1] >= b[i]) {
				a[i+1] -= b[i]; 
				ans += b[i];
			}
			else {
				ans += a[i+1];
				a[i+1] = 0;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, k;
char s[60];
int main() {
	scanf("%d %d", &n, &k);
	scanf("%s", s);
	s[k - 1] = (s[k - 1] - 'A' + 'a');
	printf("%s\n", s);
}

Measured memory_bytes: 256
import java.util.Scanner;
//086C
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n =sc.nextInt();
		int preT =0;
		int preX =0;
		int preY =0;
		boolean isReachable =true;
		
		for (int i=0;i<n;i++) {
			int postT =sc.nextInt();
			int postX =sc.nextInt();
			int postY =sc.nextInt();
			
			int manDis =postT-preT;
			int x =Math.abs(postX-preX);
			int y =Math.abs(postY-preY);
			
			if (x+y>manDis||(manDis-(x+y))%2!=0) {
				isReachable =false;
				break;
			}
			preT =postT;
			preX =postX;
			preY =postY;
		}
		
		if (isReachable) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
}

Measured memory_bytes: 87336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];

    int ans = 0;
    rep(i, n){
        ans += min(x[i] - 0, k - x[i]) * 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
h, n = map(int, input().split())

ab = [[0, 0] for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    ab[i][0] = a
    ab[i][1] = b

INF = 1 << 60
dp = [INF for _ in range(h+10001)]

dp[0] = 0

for i in range(1, h+10001):
    for j in range(n):
        if(i >= ab[j][0]):
            dp[i] = min(dp[i-ab[j][0]] + ab[j][1], dp[i])

res = INF
for i in range(h, h+10001):
    res = min(res, dp[i])
print(res)


Measured memory_bytes: 44080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
ll MOD = 1e9+7;
ll INF = 1LL<<60;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	ll n; cin>>n;
    vector<ll> x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll ans = n;
    rep(i,n-1){
        rep2(j,i+1,n){
            ll p=x[i]-x[j];
            ll q=y[i]-y[j];
            ll a = n;
            rep(k,n){
                rep(l,n){
                    if(x[k]-x[l]==p&&y[k]-y[l]==q)a--;
                }
            }
            ans=min(ans,a);

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

Measured memory_bytes: 256
n, k = map(int, input().split())

h = [0] * n
for i in range(n):
    h[i] = int(input())

h.sort()
ans = h[k - 1] - h[0]
for i in range(n - (k - 1)):
    if h[i + k - 1] - h[i] < ans:
        ans = h[i + k - 1] - h[i]
        
    if ans == 0:
        break

print(ans)


Measured memory_bytes: 7472
import itertools
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]


ans = 10000
for x in itertools.product(range(4), repeat=N):
    a, b, c, mp = 0, 0, 0, 0
    for i in range(N):
        if x[i] == 1:
            if a != 0:
                mp += 10
            a += L[i]

        if x[i] == 2:
            if b != 0:
                mp += 10
            b += L[i]

        if x[i] == 3:
            if c != 0:
                mp += 10
            c += L[i]

    if a == 0 or b == 0 or c == 0:
        continue

    mp += abs(A-a)+abs(B-b)+abs(C-c)
    ans = min(ans, mp)
print(ans)


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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, l;
	cin>>n>>l;
	int a[n + 1];
	for(int i = 1; i <= n; i++){
		cin>>a[i];
	}
	int ind = -1;
	for(int i = 1; i < n; i++){
		if(a[i] + a[i + 1] >= l){
			ind = i;
			break;
		}
	}
	if(ind == -1){
		cout<<"Impossible\n";
		exit(0);
	}
	cout<<"Possible\n";
	for(int i = 1; i < ind; i++){
		cout<<i<<'\n';
	}
	for(int i = n - 1; i > ind; i--){
		cout<<i<<'\n';
	}
	cout<<ind<<'\n';

	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  string s;
  cin>>s;
  string r="CODEFESTIVAL2016";
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=r[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256