akhauriyash/Code-Regression huggingface dataset:
/*
  user: sky48
  language: c++
  for dream for young
*/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define N 100005
typedef long long ll;
using namespace std;
int las,n,m,a[N];
int gets()
{
	int v=0; char ch;bool f=0;
	while(!isdigit(ch=getchar())) if(ch=='-') f=1; v=ch-48;
	while( isdigit(ch=getchar())) v=(v<<1)+(v<<3)+ch-48;
	return f?-v:v;
}
int main ()
{
	n=gets(), m=gets();
	rep(i,1,n) a[i]=gets();
	rep(i,1,n-1)
		if(a[i]+a[i+1]>=m) las=i;
	if(!las){ puts("Impossible"); return 0;}
	puts("Possible");
	rep(i,1,las-1) cout<<i<<endl;
	for(int i=n-1;i>=las+1;i--) cout<<i<<endl;
	cout<<las<<endl; 
	
	return 0;
}


Measured memory_bytes: 1152
a, b, c, x, y = map(int, input().split())


if x >= y:
    tmp1 = y*2*c + (x-y)*a
    tmp2 = c*x*2
    tmp3 = a*x + b*y
    print(min(tmp1, tmp2, tmp3))
else:
    tmp1 = x * 2 * c + (y-x) * b
    tmp2 = c * y * 2
    tmp3 = a * x + b * y
    print(min(tmp1, tmp2, tmp3))


Measured memory_bytes: 61844
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int have[200010][2];
vector<int> G[200010];
int V;
bool visited[200010];
string S;

void dfs(int i) {
    //cout << i << endl;
    visited[i] = true;
    for(auto to: G[i]) {
        have[to][S[i] - 'A']--;
        if (max(have[to][0], have[to][1]) >= 1 && min(have[to][0], have[to][1]) == 0 && !visited[to]) {
            dfs(to);    
        }
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    cin >> S;
    rep(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        have[a][S[b] - 'A']++;
        have[b][S[a] - 'A']++;
    }
    V = N;
    rep(i, N) {
        if (max(have[i][0], have[i][1]) >= 1 && min(have[i][0], have[i][1]) == 0 && !visited[i]) {
            dfs(i);    
        }
    }
    rep(i, N) {
        if (min(have[i][0], have[i][1]) > 0) {
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 15568
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main() {
  string S; cin >> S;
  int N = S.size();
  
  int count =0;
  for (int i =1; i<N; i++) {
    if (S[i] != S[i-1]) count++;
  }
                            
  cout << count << endl;
}

Measured memory_bytes: 3700
#include "bits/stdc++.h"

using namespace std;

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

	string in, str;
	str = "CODEFESTIVAL2016";
	cin >> in;
	int c = 0;
	for (int i = 0; i < str.size();i++) {
		if (str[i] != in[i])
			c++;
	}

	cout << c << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//dp[i] is true if the player 1 wins if there are i stones left
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<bool> dp(k+1);
    // dp[0] = true;
    for(int i = 0;i<=k;i++){
        for(int x:a){
            if(x<=i&&!dp[i-x]){
                dp[i] = true;
            }
        }
    }
    if(dp[k])cout<<"First\n";
    else cout<<"Second\n";
    return 0;
}

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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=1e5+1e1;

lint dp[MAXN],t[MAXN],tmp=0,ans=0,n,x,y,m,cnt=0;

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%lld%lld%lld",&n,&x,&m);
	t[x]=1,tmp=x,dp[x]=x,y=x*x%m,++cnt;
	while(!t[y] && cnt<n){
		t[y]=cnt+1,tmp+=y,dp[y]=dp[x]+y,x=y,y=x*x%m,++cnt;
	}
	ans=tmp;
	if(cnt==n){
		printf("%lld\n",ans);
		return 0;
	}
	n-=cnt,ans+=(n/(cnt-t[y]+1))*(tmp-dp[y]+y),n%=(cnt-t[y]+1),cnt=0;
	while(cnt<n){
		++cnt,ans+=y,x=y,y=x*x%m;
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 5312
import sys
input = sys.stdin.readline

R, G, B, N = (int(i) for i in input().split())
#print(R, G, B, N)

cnt=0
for i in range(N//R+1):
  for j in range(N//G+1):
    k=N-R*i-G*j
    if k >=0 and k%B==0:
      cnt+=1
      
print(cnt)

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

typedef unsigned long long int uint64;
typedef long long int          int64;

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

#define ABS(a) ((a)>(0)?(a):-(a))

int main()
{
  int cnt;
  int N, K;
  int i;
  int result = 0;

  cnt = scanf("%d %d", &N, &K);

  result = (N+K) / 2;

  if ((ABS(N-result)) == (ABS(K-result))) {
    printf("%d", result);
    return 0;
  }
  
  printf("IMPOSSIBLE");

  return 0;
}



Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		boolean[] is=new boolean[10001];
		Arrays.fill(is,true);
		is[0]=is[1]=false;
		for(int i=2;i*i<=is.length;i++){
			if(is[i]){
				for(int j=i+i;j<is.length;j+=i){
					is[j]=false;
				}
			}
		}
		int[] primes=new int[5000];
		int cnt=0;
		for(int i=0;i<is.length;i++){
			if(is[i]){
				primes[cnt++]=i;
			}
		}
		while(true){
			int n=cin.nextInt();
			if(n==0)break;
			int ans=0;
			for(int i=0;i<cnt;i++){
				int sum=0;
				for(int j=i;j<cnt;j++){
					sum+=primes[j];
					if(sum>n){
						break;
					}
					if(sum==n){
						ans++;
					}
				}
			}
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 18544
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,a,b;
        cin>>n>>a>>b;
        ll p=n*a;
        ll q=b;
        cout<<min(p,q);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpp;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pair<int, int>> vpp;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define all(n) (n).begin(), (n).end()
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void out(Arg1&& arg1) {
    cout << arg1 << '\n';
}

template <typename Arg1, typename ...Args>
void out(Arg1&& arg1, Args&& ...args) {
    cout << arg1 << ' ';
    out(args...);
}


template <typename T>
void outarr(vector<T> arr) {
    for (int i = 0; i < arr.size() -1; ++i) cout << arr[i] << ' ';
    cout << arr.back() << '\n';
}

template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int R; cin >> R;
    cout << M_PI * 2 * R << endl;
    return 0;
}



Measured memory_bytes: 3784
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let s = scan.chars();
    let k = scan.read::<usize>()-1;
    let c = s[k];
    let mut t = vec![];
    for i in 0..n {
        t.push( if s[i] == c {c} else {'*'})
    }
    println!("{}", t.into_iter().collect::<String>());
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut ret = vec![];
        for _ in 0..n { ret.push(self.read::<T>()) }
        ret
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
using namespace std;

struct Card {
	char s;
	int v;
};

void babble(struct Card a[], int n) {
	for (int i = 0;i < n;i++) {
		for (int j = n-1;j > i;j--) {
			if (a[j].v < a[j - 1].v) {
				swap(a[j], a[j - 1]);
			}
		}
	}
}

void selection(struct Card a[], int n) {
	for (int i = 0; i < n;i++) {
		int minj = i;
		for (int j = i; j < n;j++) {
			if (a[j].v < a[minj].v)minj = j;
		}
		if (minj != i)swap(a[i], a[minj]);
	}
}

void print(struct Card a[], int n) {
	for (int i = 0; i < n;i++) {
		cout << a[i].s << a[i].v;
		if (i < n - 1)cout << " ";
	}
	cout << endl;
}
bool isStable(struct Card c1[],struct Card c2[], int n) {
	for (int i = 0;i < n;i++) {
		if (c1[i].s != c2[i].s)return false;
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	Card c1[36], c2[36];
	for (int i = 0; i < n;i++)cin >> c1[i].s >> c1[i].v;
	for (int i = 0;i < n;i++) c2[i] = c1[i];
	babble(c1, n);
	print(c1, n);
	cout << "Stable" << endl;
	selection(c2, n);
	print(c2, n);
	if (isStable(c1, c2, n))cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}



Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		int N = sc.nextInt();
		int T = sc.nextInt();
		String input[][] = new String[N][4];
		for (int i = 0; i < N; i++) {
			input[i] = sc2.nextLine().split(" ");
		}
		int cnt = 0;
		ArrayList<String> output = new ArrayList<String>();
		for (int i = 0; i < N - 1; i++) {
			String[] stop_time = input[i][2].split(":");
			String[] start_time = input[i + 1][0].split(":");

			int aTime = Integer.valueOf(stop_time[0]) * 60
					+ Integer.valueOf(stop_time[1]);
			int bTime = Integer.valueOf(start_time[0]) * 60
					+ Integer.valueOf(start_time[1]);
			if (bTime - aTime >= T) {
				cnt++;
				output.add(input[i][3] + " " + (bTime - aTime));
			}
		}
		System.out.println(cnt);
		for (String p : output) {
			System.out.println(p);
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 17352
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/c.in", "r", stdin);
//  freopen("../IO/c.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int val[200000 + 555];
vector<int> g[200000 + 555];
vector<int> l, r;
void dfs(int v, int p, int d) {
  (d ? l : r).push_back(v);
  for (int u : g[v]) if (u != p) dfs(u, v, d ^ 1);
}

void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  for (int i = 0, u, v; i < n - 1; ++i) {
    in >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0, 0);
  if ((int) l.size() > (int) r.size()) {
    swap(l, r);
  }
  int L = l.size();
  int st = 0;
  if (L <= n / 3) {
    int a = 3;
    for (int &i : l) {
      val[i] = a;
      st = a;
      a += 3;
    }
    a = 1;
    for (int &i : r) {
      if (a % 3 == 0) ++a;
      if (a > n) break;
      val[i] = a;
      ++a;
    }
  } else {
    int a = 1;
    for (int &i : l) {
      val[i] = a;
      if ((a += 3) > n) break;
    }
    a = 2;
    for (int &i : r) {
      val[i] = a;
      if ((a += 3) > n) break;
    }
  }
  for (int i = 1, a = st; i <= n; ++i) {
    cout << (val[i] ? val[i] : (a += 3)) << " \n"[i == n];
  }
}



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

using namespace std;

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

typedef long double Double;

int main() {
  
  typedef pair<int, int> Pii;
  typedef pair<int, Pii> Piii;
  
  int N; int const M = 256;
  while(cin >> N && N) {
    vector<int> I(N);
    rep(i, N) cin >> I[i];
    Double Entropy = 1e60;
    Piii ans;
    rep(S, 16) rep(A, 16) rep(C, 16) {
      int numofx[256] = {};
      int R = S;
      rep(i, N) {
        R = (A*R+C) % M;
        numofx[ (I[i]+R)%M ] ++;
      }
      Double H = 0.;
      rep(i, M) {
        if(numofx[i]) {
          Double x = (Double)numofx[i] / N;
          H -= x * log(x);
        }
      }
      if(H < Entropy-1e-9) {
        Entropy = H;
        ans = Piii(S, Pii(A, C));
      }
      else if(H == Entropy) {
        ans = min(ans, Piii(S, Pii(A, C)));
      }
    }
    cout << ans.first << " " << ans.second.first << " " << ans.second.second << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II()
    a_lst = sorted(MII(), reverse=True)
    while True:
        minv = a_lst[-1]
        a_lst = [a%minv for a in a_lst[:-1] if a%minv != 0]
        a_lst.append(minv)
        a_lst.sort(reverse=True)
        if len(a_lst) == 1: break
    print(a_lst[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scn = new Scanner(System.in);
        String S = scn.nextLine();
        int N = S.length();
        
        String str_before = S.substring(0,(N-1)/2);
        String str_after = S.substring((N+2)/2,N);
        StringBuffer hoge = new StringBuffer(str_before);
        String str = hoge.reverse().toString();
        if(str_after.equals(str) && str_after.equals(str_before)) System.out.println("Yes");
        else System.out.println("No");
        
    }
}


Measured memory_bytes: 35768
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int tmp,num=1;
		while((tmp=sc.nextInt())!=0){
			System.out.printf("Case %d: %d\n",num++,tmp);
		}
		sc.close();
	}
}


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

bool flag[2009];
LL n, ans = 1, now, cnt;

int main() {
	scanf("%lld", &n);
	for (int i=2; i<=n; i++) {
		if (flag[i]) continue;
		for (int j=i*i; j<=1000; j+=i) flag[j] = 1;
		now = n; cnt = 0;
		while (now) {
			cnt += now / i; now /= i;
		}
		ans = ans * (cnt+1) % 1000000007;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
n, m = (int(_) for _ in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(n)]

ab_list = sorted(ab_list)

buy = 0
money = 0
j = 0


while (buy < m):
    buy += ab_list[j][1]
    money += ab_list[j][0] * ab_list[j][1]
    j += 1

print(money-(ab_list[j-1][0]*(buy-m)))


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

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

    int WL = 0;
    int RL = 0;
    int WR = 0;
    int RR = 0;

    for(int i=0;i<N;i++) {
        if (c[i] == "W") {
            WR++;
        } else {
            RR++;
        }
    }
    int score = 100000000;
    for(int sikiri = 0; sikiri <= N; sikiri++) {
        if(sikiri >= 1) {
            if (c[sikiri - 1] == "R") {
                RR--;
                RL++;
            } else {
                WR--;
                WL++;
            }
        }
        
        int AA = WL;
        int BB = RR;
        int C = AA;
        if (C < BB) {
            C = BB;
        }
        //cout << "sikiri:" << sikiri << " R:" << RR << " W:" << WR << " C:" << C << endl;
        if (score >= C) {
            score = C;
        }
    }
    cout << score << endl;
}

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

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

  int n;
  cin >> n;

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

  sort(a, a+n, greater<int>());

  int alice = 0, bob = 0;
  for (int i = 0; i < n; ++i) {
    if (i & 1) bob += a[i];
    else alice += a[i];
  }

  cout << (alice - bob) << '\n';

  return (0);
}

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

int main(){

	int W, H, x, y, r;
	int a, b, i, j;
	cin >> W >> H >> x >> y >> r;
	a = x - r;
	b = y - r;
	i = x + r;
	j = y + r;
	if( 0<=a && 0<=b){
		if( i<=W && j<=H){
		cout << "Yes" << endl;
		}else{
		cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}

	return 0;
}

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

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

    int a,b,k;
    cin>>a>>b>>k;

    for(int i=a;i<=b;i++)
    {
        if(i<a+k||b-k<i)cout<<i<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
  int N, NN; cin >> N; NN = N;

    int fn = 0;
    while (NN > 0) {
        fn += NN%10;
        NN /= 10;
    }

    cout << ((N%fn == 0) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 2361: Sort
// 2018.4.10 bal4u

#include <stdio.h>
#include <string.h>

#define QSIZE 5000000

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int s, t; } QUE;
QUE que[QSIZE+2]; int qsize;

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x30303030
int c[8][8]; int n;
int dist[1<<24];

int main()
{
	int i, j, s, ns, t, nt, a, b, bi, bj, ans;

	n = in();
	for (i = 0; i < n; i++) for (j = 0; j < n; j++) c[i][j] = in();

	memset(dist, INF, sizeof(dist));
	s = 0; for (i = 0; i < n; i++) s = (s << 3) | i;
//printf("n %d, s %x\n", n, s);
	ans = 0, qsize = 0, enq(s, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, deq();
//printf("s %x, t %d\n", s, t);
		if (dist[s] <= t) continue;
		dist[s] = t;
		if (t > ans) ans = t;
		for (i = 0; i < n; i++) {
			bi = 3*(n-i-1), a = (s >> bi) & 7;
//printf("s %x, i %d, bi %d, a %d\n", s, i, bi, a);
			for (j = i+1; j < n; j++) {
				bj = 3*(n-j-1), b = (s >> bj) & 7;
				ns = (s ^ (a << bi) ^ (b << bj)) | (b << bi) | (a << bj);
				nt = t + c[i][j];
//printf("s %x --> ns %x, b %x, i %d, j %d, nt %d\n", s, ns, b, i, j, nt);
				if (dist[ns] <= nt) continue;
				enq(ns, nt);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 71252
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

template <typename T>
T gcd(T a, T b) {
    if (a > b) {
        T buf = a;
        a = b;
        b = buf;
    }
    return a == 0 ? b : gcd(a, b%a);
}

int main() {
    ll k;
    cin >> k;
    ll sum = 0;
    for (ll i=1; i<=k; i++) {
        for (ll j=1; j<=k; j++) {
            for (ll l=1; l<=k; l++) {
                sum += gcd(i, gcd(j, l));
            }
        }
    }
    cout << sum << '\n';
    return 0;
}

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

int main()
{
    vector<tuple<int, int, char, lli, string>> v;
    int n, i;
    int value, weight;
    char type;
    lli date;
    string name;
    cin >> n;
    while (n--)
    {
        cin >> value >> weight >> type >> date >> name;
        v.push_back(make_tuple(value, weight, type, date, name));
    }
    sort(v.begin(), v.end());
    for (i = 0; i < v.size(); i++)
    {
        cout << get<0>(v[i]) << ' ' << get<1>(v[i]) << ' ' << get<2>(v[i]) << ' ' << get<3>(v[i]) << ' ' << get<4>(v[i]) << endl;
    }
}


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

int main(){
	string s;
	while( getline(cin,s) ){
		if( s == "." ) break;

		stack<char> st;
		bool flag = true;
		for(int i=0 ; i < (int)s.size() ; i++ ){
			char c = s[i];
			if( c == '(' ){
				st.push( c );
			}else if( c == '[' ){
				st.push( c );
			}else if( c == ')' ){
				if( st.empty() ){
					flag = false;
					break;
				}else if( st.top() == '(' ){
					st.pop();
				}else{
					flag = false;
					break;
				}
			}else if( c == ']' ){
				if( st.empty() ){
					flag = false;
					break;
				}else if( st.top() == '[' ){
					st.pop();
				}else{
					flag = false;
					break;
				}
			}
		}
		if( st.empty() && flag ){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
}

Measured memory_bytes: 904
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

ss = [int(i) for i in STR()]
s = deepcopy(ss)
ans1 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        ans1 += 1
s = deepcopy(s)
s[0] = int(not s[0])
ans2 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        ans2 += 1
print(min(ans1, ans2))


Measured memory_bytes: 70360
#include<bits/stdc++.h>
using namespace std;
char s[51][51];
int b,i,j,m,n;
int main()
{
	cin>>n>>m;
	for(i=1;i<=n;++i)
	for(j=1;j<=m;++j)cin>>s[i][j];
	for(i=1;i<=n;++i)
	{
		for(j=1;j<=m;++j)
		{
			if(s[i][j]=='.')
			{
				if(s[i-1][j-1]=='#')b++;
				if(s[i-1][j]=='#')b++;
				if(s[i-1][j+1]=='#')b++;
				if(s[i][j-1]=='#')b++;
				if(s[i][j+1]=='#')b++;
				if(s[i+1][j-1]=='#')b++;
				if(s[i+1][j]=='#')b++;
				if(s[i+1][j+1]=='#')b++;
				cout<<b;
			}
			else cout<<s[i][j];
			b=0;
		}
		cout<<endl;
	}
	
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

bool calc[200000];
int n;
ll memo[200000],h[200000];
ll dp(ll x){
    if(x==n)return 0;
    else if(calc[x])return memo[x];
    else{
        ll res = INT_MAX;
        if(x+1<=n){
            res = min (res , abs(h[x]-h[x+1]) + dp(x+1));
        }
        if(x+2<=n){
            res = min (res , abs(h[x]-h[x+2]) + dp(x+2));
        }
        memo[x] = res;
        calc[x] = true;
        return res;
    }
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    cout<<dp(1)<<newl;

}



Measured memory_bytes: 4992
N = gets.chomp.to_i
a = Array.new(N)
for i in 0...N do
    str = gets.chomp
    a[i] = str
end
a.sort_by! {|x| x}
a.reverse!

b = Array.new(0)
x = 0
y = 0
for i in 1...N do
    if a[i] == a[i-1]
        x += 1
    else
        if x > y
            b.clear
            b.push(a[i-1])
            y = x
        elsif x == y
            b.push(a[i-1])
        end
        x = 0
    end
end
if x > y
    b.clear
    b.push(a[N-1])
    y = x
elsif x == y
    b.push(a[N-1])
end

while !b.empty?
    puts b.pop
end

Measured memory_bytes: 22392
a = int(input())
b = int(input())

ans = 0

if a == 1:
    if b == 2:
        ans = 3
    else:
        ans = 2
elif a == 2:
    if b == 1:
        ans = 3
    else:
        ans = 1
else:
    if b == 1:
        ans = 2
    else:
        ans = 1

print(ans)

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

int main() {
	string s;
	cin >> s;
	if (s.length() == 2) {
		if (s.at(0) == s.at(1))cout << "1 2" << endl;
		else cout << "-1 -1" << endl;
		return 0;
	}
	for (int i = 0; i < s.length() - 2; i++) {
		if (s.at(i) == s.at(i + 2)) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
		if (s.at(i) == s.at(i + 1)) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		if (s.at(i + 1) == s.at(i + 2)) {
			cout << i + 2 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 3720
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
using NUM = long double;

template<typename T>
struct Point {
	T x, y;
	Point<T> operator+(const Point<T>& rhs)const {
		Point<T> p;
		p.x = this->x + rhs.x;
		p.y = this->y + rhs.y;
		return p;
	}
	Point<T> operator-(const Point<T>& rhs)const {
		Point<T> p;
		p.x = this->x - rhs.x;
		p.y = this->y - rhs.y;
		return p;
	}
	Point<T> operator*(const T rhs) const {
		Point<T> p(*this);
		p.x = this->x * rhs;
		p.y = this->y * rhs;
		return p;
	}
};

template<typename T>
bool isZero(const T val)
{
	return fabs(val) < 1e-10;
}

template<typename T>
T innerProduct(const Point<T>& p0, const Point<T>& p1)
{
	double x0 = p0.x;
	double y0 = p0.y;
	double x1 = p1.x;
	double y1 = p1.y;
	return x0 * x1 + y0 * y1;
}

template<typename T>
T outerProduct(const Point<T>& p0, const Point<T>& p1)
{
	double x0 = p0.x;
	double y0 = p0.y;
	double x1 = p1.x;
	double y1 = p1.y;
	return x0 * y1 - y0 * x1;
}

template<typename T>
T norm(const Point<T>& p)
{
	double x = p.x;
	double y = p.y;
	return x*x + y*y;
}

template<typename T>
void readPoint(Point<T>& p)
{
	cin >> p.x;
	cin >> p.y;
}

template<typename T>
void outputComponentesOfPoint(const Point<T>& p)
{
	cout << fixed;
	cout << setprecision(8) << p.x;
	cout << " ";
	cout << setprecision(8) << p.y;
	cout << endl;
}

int main()
{

	Point<NUM> p1,p2;
	readPoint(p1);
	readPoint(p2);
	const Point<NUM> b = p2 - p1;
	const NUM b_b_ = norm(b);

	int q; cin >> q;
	for (int i = 0; i != q; ++i) {
		Point<NUM> p;
		readPoint(p);

		//projection
		const Point<NUM> a = p - p1;
		const NUM ab = innerProduct(a, b);
		const Point<NUM> projectedPoint = p1 + b*(ab / b_b_);

		//mirroring
		const Point<NUM> mirrorPoint = projectedPoint*2 - p;// = p + (projectedPoint - p) * 2;
		outputComponentesOfPoint(mirrorPoint);
	}


	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>
#define FOR(arg, ini, end) for(int arg = ini; arg < end; arg++)


using namespace std;
int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    vector<char> a(26, 0);
    
    FOR(i, 0, s.size()){
        a[s[i]-'A']++;
    }
    int cnt = 0;
    FOR(i, 0, 26){
        if (a[i] > 2) {
            cout << "No" << endl;
            return 0;
        }
        if (a[i]>0)
            cnt++;
    }

    if (cnt == 2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
    	 Scanner sc = new Scanner(System.in);
    	 sc.useDelimiter("\\n");//
    	 int setOfData = 0;// データセット数
    	 
         while(sc.hasNext()) {
        	 String str = sc.nextLine();
        	 String[] splitted = str.split(" ");// 空白で文字列を分割する
        	 int length = splitted.length;// 要素の数
        	 if(length == 1) { // データセット数
        		 setOfData = numOfSet(splitted); // データセット数をセットする
        	 } else if(length == 3) { // 三角形の三辺
        		 if(isRightAngle(splitted)) {
            		 System.out.println("YES");
            	 } else {
            		 System.out.println("NO");
            	 }        		 
        	 } else { // それ以外（現状は無視）
        		 
        	 }
         }
    	if (sc.ioException() != null) {
    	    throw sc.ioException();
    	}
    	
    }
    /** データセット数を取得するメソッド */
    public static int numOfSet(String[] string) {
    	return Integer.valueOf(string[0]);
    }
    
    /** 直角三角形かどうかを判断するメソッド */
    public static Boolean isRightAngle(String[] string) {
    	int x = Integer.valueOf(string[0]);
    	int y = Integer.valueOf(string[1]);
    	int z = Integer.valueOf(string[2]);
    	x = x*x;
    	y = y*y;
    	z = z*z;
    	
    	if(x == y+z || y == x+z || z == x+y) {
    		return true;
    	} else {
    		return false;
    	}
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int n,m,ans=0;
string s[200],t[200];
map<string,int>mp;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>s[i];
        mp[s[i]]=0;
    }
    cin>>m;
    rep(i,m){
        cin>>t[i];
        mp[t[i]]=0;
    }
    rep(i,n)mp[s[i]]++;
    rep(i,m)mp[t[i]]--;
    rep(i,n){
        ans=max(ans,mp[s[i]]);
    }
    if(ans<0)ans=0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
ans=0

for bit in range(1<<(n-1)):
    f=s[0]
    for i in range(n-1):
        if bit&(1<<i):
            f+='+'
        f+=s[i+1]
    ans+=sum (map(int, f.split('+')))
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

int main() {
  string s;
  cin >> s;
  int r = 0, n = s.size();
  rep(i,n/2) {
    r += (s[i] != s[n-1-i]);
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ND = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var (N, D) = (ND[0], ND[1]);
            var answer = 0;

            for (var i = 0; i < N; i++)
            {
                var XY = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
                var (X, Y) = (XY[0], XY[1]);
                if (D * D >= X * X + Y * Y) answer++;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 41328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;
typedef vector<int> vi;
ll ans;
int main(void)
{
  int n,k;
  cin >> n >> k;
  vi x(n),y(n);
  vi xary,yary;
  rep(i,n)
    {
      cin >> x[i] >> y[i];
      xary.push_back(x[i]);
      yary.push_back(y[i]);
    }

  sort(xary.begin(),xary.end());
  sort(yary.begin(),yary.end());
  ans=(ll)(xary[n-1]-xary[0]) * (yary[n-1]-yary[0]);
  for(int xi=0;xi<n;xi++)
    {
      for(int xj=xi+1;xj<n;xj++)
	{
	  for(int yi=0;yi<n;yi++)
	    {
	      for(int yj=yi+1;yj<n;yj++)
		{
		  int num=0;
		  ll lx=xary[xi],rx=xary[xj];
		  ll by= yary[yi],uy=yary[yj];
		  for(int i=0;i<n;i++)
		    {
		      if(lx<=x[i] && x[i]<= rx && by<=y[i] && y[i]<=uy)
			{
			  num++;
			}
		    }
		  if(num>=k) ans=min(ans,(ll)(rx-lx)*(uy-by));
		}
	    }
	}
    }
    
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void no(){
	printf("-1\n");
	exit(0);
}

ll a[112345];
ll b[112345];
ll c[112345] = {};

int main(){
	int n; scanf("%d", &n);
	REP(i, n+1) scanf("%lld", a+i);
	for(int i = n; i >= 0; i--) c[i] = c[i+1] + a[i];
	if(a[0] > 1) no();
	if(a[0] == 1) b[0] = 0;
	else b[0] = 1;
	ll ans = b[0] + a[0];
	DEBUG("b=%lld a=%lld\n", b[0], a[0]);
	FOR(i, 1, n+1){
		ll rem = b[i-1] * 2 - a[i];
		if(rem < 0) no();
		b[i] = min(rem, c[i+1]);
		DEBUG("b=%lld a=%lld\n", b[i], a[i]);
		ans += a[i] + b[i];
	}
	printf("%lld\n", ans);
}





Measured memory_bytes: 6112
from collections import deque
n,m=map(int,input().split())
r=[[] for i in range(n+1)]
R=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    r[a].append(b)
    r[b].append(a)
    R[a].append(b)
    R[b].append(a)
dep=[-1]*(n+1)
dep[0]=0
dep[1]=0
data=deque([1])
d=0
while len(data)>0:
    p=data.popleft()
    for i in r[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
    r[p]=[]
if not all(dep[i+1]>=0 for i in range(n)):
    print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        for j in R[i]:
            if dep[j]==dep[i]-1:
                print(j)
                break


Measured memory_bytes: 45620
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const H = input[0].trim().split(' ').map(Number)[0];
  const W = input[0].trim().split(' ').map(Number)[1];
  const S = input.slice(1, H+1).map(val => val.trim().split(''));

  for(let h=0; h<H; h++){
    for(let w=0; w<W; w++){
      let tmp = S[h][w];
      if(tmp === '#'){
        if (h > 0) {
          if(w > 0) S[h-1][w-1] = S[h-1][w-1] === '.' ? 1 : S[h-1][w-1] === '#' ? '#' : S[h-1][w-1] + 1;
          S[h-1][w]   = S[h-1][w] === '.' ? 1 : S[h-1][w] === '#' ? '#' : S[h-1][w] + 1;
          if(w < W - 1) S[h-1][w+1] = S[h-1][w+1] === '.' ? 1 : S[h-1][w+1] === '#' ? '#' : S[h-1][w+1] + 1;
        }

        if (w > 0) {
          S[h][w-1]   = S[h][w-1] === '.' ? 1 : S[h][w-1] === '#' ? '#' : S[h][w-1] + 1;
        }

        if (w < W - 1) {
          S[h][w+1]   = S[h][w+1] === '.' ? 1 : S[h][w+1] === '#' ? '#' : S[h][w+1] + 1;
        }

        if (h < H - 1) {
          if(w > 0) S[h+1][w-1] = S[h+1][w-1] === '.' ? 1 : S[h+1][w-1] === '#' ? '#' : S[h+1][w-1] + 1;
          S[h+1][w]   = S[h+1][w] === '.' ? 1 : S[h+1][w] === '#' ? '#' : S[h+1][w] + 1;
          if(w < W - 1) S[h+1][w+1] = S[h+1][w+1] === '.' ? 1 : S[h+1][w+1] === '#' ? '#' : S[h+1][w+1] + 1;
        }
      }
    };
  };

  console.log(S.join('\n').replace(/,/g, '').replace(/\./g, '0'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 13884
#coding:utf-8
#!/usr/bin/python

A=[raw_input().split() for i in range(3)]
b=[]
N=int(raw_input())
for i in range(N):
    b.append(raw_input())

C=[[0 for i in range(3)] for j in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if(A[j][k]==b[i]):
               C[j][k]=1

#print C
kekka='No'

for i in range(3):
    m=0
    for j in range(3):
        m=m+C[i][j]
    if(m==3):
       kekka='Yes'
       break
            
for i in range(3):
    m=0
    for j in range(3):
        m=m+C[j][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][2-i]
    if(m==3):
       kekka='Yes'
       break

print kekka

Measured memory_bytes: 2696
number= int(input())
color =input()

change_times=0
color_before=''


for index in range(number):
	if index == 0:
		color_before= color[index]
	elif color[index] == color_before:
		continue
	else:
		change_times=change_times+1
		color_before= color[index]
		
print(change_times+1)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	int t;
	cin >> t;

	for ( int lpc = 0; lpc < t; lpc++ )
	{
		int n, k; // k: ­d@ÌÂ
		cin >> n >> k;

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

		vector <int> ax( n - 1 );

		for ( int i = 1; i < n; i++ )
		{
			ax[i-1] = x[i] - x[i-1];
		}

		sort( ax.rbegin(), ax.rend() );

		int sum = 0;
		for ( int i = 0; i < min(k-1,(int)ax.size()); i++ )
			sum += ax[i];

		int kotae = (x[n-1]-x[0])-sum;

		cout << kotae << endl;

	}

	return 0;
}

Measured memory_bytes: 1692
while n = gets
  n = n.chomp.to_i
  m = 0
  (0..9).each do | i |
    (0..9).each do | j |
      (0..9).each do | k |
        (0..9).each do | l |
          if ( i + j + k + l == n )
            m += 1
          end
        end
      end
    end
  end
  puts m
end

Measured memory_bytes: 8496
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
    int D;
    int N;

    scanf("%d", &D);
    scanf("%d", &N);

    if(0 > D || D > 2 || 100 < N || N < 1) {
        exit(0);
    }

    if(D == 1) {
        if(N == 100) {
            printf("%d\n", N * 100 + 100);
        } else {
            printf("%d\n", N * 100);
        }
    }
    if(D == 2) {
        if(N == 100) {
            printf("%d\n", N * 100 * 100 + 10000);
        } else {
            printf("%d\n", N * 100 * 100);
        }
    }
    if(D == 0) {
        if(N == 100) {
            printf("%d\n", N + 1);
        } else {
            printf("%d\n", N);
        }
    }

    return 0;
}

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

using namespace std;
using ll = long long;
int n,buy;
ll money = 1000,have;
ll a[88],flag[88][88];
/*
 100원에 10개를 삼
 다음에 110원 1100
 다다음에 111원 1110
 */
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1,sell = 0; i<=n; i++){
        bool go = 0;
        if(sell || n == i){
            money += have * a[i];
            have = 0;
            sell = 0;
        }
        for(int j=i+1; j<=n; j++){
            if(a[i] < a[j]){
                sell = 1;
                have = money / a[i];
                money = money % a[i];
                i = j - 1;
                break;
            }
            if(a[i] > a[j]){
                bool go = 0;
                for(int k = j + 1; k<=n; k++) if(a[j] < a[k]) go =1;
                break;
            }
        }
    }
    cout<<money;
}


Measured memory_bytes: 3560
"""
implementation of the Insertion Sort
"""
number_of_input = int(raw_input())

numbers = [int(x) for x in raw_input().split()]

for i in range(1, len(numbers)):
    print " ".join([str(x) for x in numbers])
    target = numbers[i]
    index = i - 1
    while index >= 0 and target < numbers[index]:
        numbers[index + 1] = numbers[index]
        index -= 1
    numbers[index + 1] = target

print " ".join([str(x) for x in numbers])

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

using namespace std;

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

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

    cout << accumulate(P, P + N, 0) - *max_element(P, P + N) / 2 << endl;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

vector<pair<string, int> > v;
vector<pair<string, vector<int> > > l;
vector<string> w;

bool fa(int index) {
	for (int i = 0; i < l.size(); i++) {
		if (l[i].first == v[index].first) {
			l[i].second.push_back(v[index].second);
			return true;
		}
	}
	l.push_back({ v[index].first,vector<int>(1,v[index].second) });
	w.push_back(v[index].first);
	return false;
}

int search(int index) {
	for (int i = 0; i < l.size(); i++) {
		if (w[index] == l[i].first)
			return i;
	}
	return -1;
}

int main(){
	string s;
	int p;
	while (cin >> s >> p && p != 0) {
		v.push_back(pair<string, int>({ s,p }));
	}
	for (int i = 0; i < v.size(); i++) {
		fa(i);
	}
	sort(w.begin(), w.end());
	for (int i = 0; i < l.size(); i++) {
		sort(l[i].second.begin(), l[i].second.end());
	}
	for (int i = 0; i < w.size(); i++) {
		int index = search(i);
		cout << w[i] << endl;
		cout << l[index].second[0];
		for (int j = 1; j < l[index].second.size(); j++) {
			cout << " " << l[index].second[j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3160