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

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

/* define const */
const long long INF = (1LL << 60);
/* end defineing */

int func(int i)
{
    int tmp = i;
    while (tmp % 10 != 0)
        tmp++;
    return tmp;
}

int main()
{
    int a, b, c, d, e;
    int a_, b_, c_, d_, e_;
    cin >> a >> b >> c >> d >> e;

    a_ = func(a);
    b_ = func(b);
    c_ = func(c);
    d_ = func(d);
    e_ = func(e);
    // cout << "-" << a_ << b_ << c_ << d_ << e_ << endl;

    int min = 10000;

    int tmp;
    tmp = a_ + b_ + c_ + d_ + e;
    if (tmp < min)
        min = tmp;

    tmp = a_ + b_ + c_ + d + e_;
    if (tmp < min)
        min = tmp;

    tmp = a_ + b_ + c + d_ + e_;
    if (tmp < min)
        min = tmp;

    tmp = a_ + b + c_ + d_ + e_;
    if (tmp < min)
        min = tmp;

    tmp = a + b_ + c_ + d_ + e_;
    if (tmp < min)
        min = tmp;

    cout << min << endl;
}

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

void print(int curr, int depth, vector<vector<int> > list, vector<string> res){
    string dots = "";
    for(int i=0; i<depth; i++){
        dots += ".";
    }
    cout << dots << res[curr] << endl;

    for(int i=0; i<(int)list[curr].size(); i++){
        print(list[curr][i], depth+1, list, res);
    }
}

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

    vector<vector<int> > list(n+1);
    vector<string> res(n+1);
    for(int i=1; i<=n; i++){
        int k;
        cin >> k >> res[i];
        list[k].push_back(i);
    }

    print(1, 0, list, res);
    return 0;
}

Measured memory_bytes: 66820
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
#define SEG_LEN (1 << 18)
 
int seg[SEG_LEN * 2];
 
// one point
long long int get(int ind){
    ind += SEG_LEN;
    long long int sum = 0;
    sum += seg[ind];
    while(true){
        ind /= 2;
        if(ind == 0)break;
        sum += seg[ind];
    }
    return sum;
}
 
// range
void add(int l, int r, int x){
    l += SEG_LEN;
    r += SEG_LEN;
    while(l < r){
        if(l % 2 == 1){
            seg[l] += x;
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            seg[r-1] += x;
            r--;
        }
        r /= 2;
    }
}
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
 
    rep(i, n){
        add(i, i+1, a[i]);
    }
 
    rep(c, 200){
        if(c == k) break;
        vector<pair<ll, ll>> addd(n);
        rep(i, n){
            int l = max(i - get(i), 0ll);
            int r = min(i + get(i), n-1);
 
            addd[i] = make_pair(l, r);
        }

        vector<int> tmp(n);
        rep(i, n) tmp[i] = get(i);

        rep(i, n){
            int l = addd[i].first;
            int r = addd[i].second;
            add(l, r+1, 1);
        }

        rep(i, n){
            add(i, i+1, -tmp[i]);
        }
        bool flg = true;
        rep(i, n){
            if(get(i) != n){
                flg = false;
                break;
            }
        }

        if(flg) break;
    }


    rep(j, n-1){
    cout << get(j) << " ";
    }
    cout << get(n-1) << endl;
 
 
    return 0;
}

Measured memory_bytes: 10324
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+4;
int x,n,y;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline void smax(int &x,int y) {
	x=x<y?y:x;
}
inline void smin(int &x,int y) {
	x=x>y?y:x;
}
int main() {
//	freopen("in.txt","r",stdin);
	x=read(),n=read();
	for (register int i=1;i<=n;++i) y+=read();
	puts(x<=y?"Yes":"No");
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    string s; cin >> s;
    ll k; cin >> k;
    char target = '1';
    for(int i = 0; i < s.size(); i++){
        if(s[i] != '1'){
            target = s[i];
            break;
        }
    }
    char ans = target;
    if(k == 1) ans = s[0];
    if(k < s.size() && s[k - 1] == '1') ans = '1';
    cout << ans << endl;
}



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

while (len(aryNum) > 1):
    """ 公式ドキュメントと提出サンプルを参考に
    aryNum.sort()
    a = aryNum[0]
    b = aryNum[1]
    aryNum.remove(a)
    aryNum.remove(b)
    """
    aryNum.sort(reverse=True)
    a = aryNum.pop()
    b = aryNum.pop()

    aryNum.append((a + b) / 2)

print(aryNum[0])

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

int main()
{
    int n;
    cin>>n;
    double circum,pi=3.14159;
     circum=2*pi*n;
    cout.setf(ios::fixed);
    cout.precision(2);
    cout<<circum<<endl;
    return 0;
}



Measured memory_bytes: 3788
#include <iostream>

using namespace std;

int main()
{
	long long time,cost,product;
	cin >> time >> cost >> product;

	//money効率
	if ((product - cost) / 2 >= 1 && 1+time >= cost + 2) {
		cout << (product - cost)*((time + 1 - cost) / 2) + (time - cost + 1) % 2 + cost;
	}
	else {
		cout << 1 + time;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int[] a = {1, 3, 5, 7, 8, 10, 12};
		int[] b = {4, 6, 9, 11};
		
		int counta = 0;
		int countb = 0;
		
		for(int i = 0; i < a.length; i++) {
			if(x == a[i]) {
				counta++;
			} else if(y == a[i]) {
				counta++;
			}
		}
		
		for(int i = 0; i < b.length; i++) {
			if(x == b[i]) {
				countb++;
			} else if(y == b[i]) {
				countb++;
			}
		}
		
		if(counta == 2 || countb == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 23124
#include<vector>
#include<map>
#include<set>

#include<iostream>
#include<fstream>

int main(){
  int N, M, p;
  std::string S;
  std::cin >> N >> M;
  std::set<int> question_set;
  std::map<int, std::vector<int> > question_dict;
  int correct_num = 0;
  int false_num = 0;
  for(int i = 0; i < M; i++){
    std::cin >> p >> S;
    if(question_set.find(p) == question_set.end()){
      question_set.insert(p);
      question_dict[p].push_back(0);
      question_dict[p].push_back(0);
    }
    if(question_dict[p][0] == 1){
      continue;
    }else if(S == "AC"){
      question_dict[p][0] = 1;
    }else{
      question_dict[p][1] += 1;
      //std::cout << question_dict[p][1] << std::endl;
    }


  }

    //std::cout << "a" << std::endl;
    //for(auto i : question_dict){
    for(auto itr = question_dict.begin(); itr != question_dict.end(); ++itr){
      //std::cout << itr->first << std::endl;
      //std::cout << itr->second[0] << " " << itr->second[1] << std::endl;
      //std::cout << std::endl;
      if(itr->second[0] == 1){
        correct_num++;
        false_num += itr->second[1];
      }
    }

    std::cout << correct_num << " " << false_num << std::endl;
  return 0;
}


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

using namespace std;

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


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const ll mod=1000000007;
const ll nmax=200005;
ll fac[nmax],finv[nmax],inv[nmax];

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(long i=2;i<nmax;i++){
  fac[i]=fac[i-1]*i%mod;
  inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  finv[i]=finv[i-1]*inv[i]%mod;
}
}

auto com(auto n, auto k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 ll h,w,a,b;
  cin >> h >> w >> a >> b;
  comint();
  ll res=0;
  rep(i,b,w) {
    res+=(com(h-a-1+i,i)*com(a+w-i-2,w-i-1))%mod;
    res%=mod;
  }
  cout << res <<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for (int i = (a), i##_end_ = (b); i >= i##_end_; ++i)
typedef long long LL;

const int Maxn = 3009;
char s[Maxn], t[Maxn];
int len1, len2;
int dp[Maxn][Maxn], fa[Maxn][Maxn];

void output(int Fr, int Fr1) {
	if (Fr == 0 || Fr1 == 0) return ;
	if (fa[Fr][Fr1] == 1) output(Fr - 1, Fr1);
	if (fa[Fr][Fr1] == 2) output(Fr, Fr1 - 1);
	if (fa[Fr][Fr1] == 3) {
		output(Fr - 1, Fr1 - 1);
		printf("%c", s[Fr]);
	}
}

int main() {
   // freopen("F.in", "r", stdin);
   // freopen("F.out", "w", stdout);

	scanf("%s", s + 1); scanf("%s", t + 1);
	len1 = strlen(s + 1), len2 = strlen(t + 1);

    rep(i, 1, len1) 
        rep(j, 1, len2) {
			if (dp[i - 1][j] > dp[i][j - 1]) fa[i][j] = 1; else fa[i][j] = 2;
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

            if(s[i] == t[j]) {
				if (dp[i - 1][j - 1] + 1 > dp[i][j]) fa[i][j] = 3;
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
        }

	if (dp[len1][len2]) output(len1, len2);
    return 0;
}


Measured memory_bytes: 71040
import math
A,B,C=map(int,input().split())
s=[A,B,C]
t=sorted(s)
u=(t[2]-t[0],t[2]-t[1],0)
if u[0]%2==0 and u[1]%2==0:
    print(round(((u[0]+u[1])/2)))
elif u[0]%2==1 and u[1]%2==1:
    print(round((1+u[0]//2+u[1]//2)))
elif u[0]%2==1 and u[1]%2==0:
    print(round(((u[0]+1)/2+u[1]/2+1)))
else:
    print(round(((u[1]+1)/2+u[0]/2+1)))
    

Measured memory_bytes: 3064
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

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

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGNUM(x) printf("%d\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORNUM(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPNUM(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int num, top;
    int train[1024];
    int i;

    top = 0;

    while (scanf("%d", &num) != EOF){
        if (num == 0){
            printf("%d\n", train[top - 1]);
            train[top - 1] = 0;
            top--;
        }
        else { 
            train[top] = num;
            top++;
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(int argc, char const *argv[])
{
  int n,x;cin>>n>>x;
  ll cnt = 1, last = 0;
  for(int i = 0; i < n; ++i){
    int l;cin>>l;
    cnt += (last + l)<=x;
    last += l;
  }
  cout<<cnt<<endl;
  return 0;	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		long sum=0;
		
		for(long i=0;i<=N;i++) {
			if(i%5!=0 && i%3!=0) {
				sum+=i;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 35592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long int N,d,ans=1,count=0;
    vector<int> a;
    string s;

    cin >> s;
    //先頭と最後を照合する
    int left = 0;
    int right = s.length()-1;
    while (left < right){
        if (s[left] != s[right]){
            if (s[left] == 'x' && s[right] != 'x'){
                left += 1;
                count += 1;
            }else if (s[left] != 'x' && s[right] == 'x'){
                right -= 1;
                count += 1;
            }else{
                cout << "-1" << endl;
                return 0;
            }

        }else{
            left += 1;
            right -= 1;
        }

    }

/*
    for (int i = 0; i < double(s.length()/2); i++){
        if ((s[i] == 'x' && s[s.length()-i-1] != 'x') || (s[i] != 'x' && s[s.length()-i-1] == 'x')){
            count += 1;
        }else if (s[i] != s[s.length()-i]){
            cout << "-1" << endl;
            return 0;
        }
    }
*/
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int cnt[3000];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int i;
    rep(i, k) {
        int d, j;
        cin >> d;
        rep(j, d) {
            int w;
            cin >> w;
            cnt[w]++;
        }
    }
    int ans(0);
    xrep(i,1,n+1) {
        if (cnt[i] ==0) {
            ans++;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[1]);
		if(h==0&&w==0){
			break;
		}
	
		for(int i=0;i<h;i++){

			for(int j=0;j<w;j++){
				sb.append("#");
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
}

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

main() {
  int N, A, B, P1;
  cin >> N >> A >> B;
  P1 = N*A;
  if(P1 <= B){
    cout << P1 << endl;
  }
  else{
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long

int main() {
	LL N, num = 1000000007, ans = 1;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		ans = (ans * i) % num;
	}
	cout << ans << endl;
}


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

const int MAX = 50;

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

    int cnt = 0;
    rep(i,n){
        cin >> a; 
        if(i != a - 1) cnt++;
    } 

    if(cnt == 2 || cnt == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
 }

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  
 if(S == U){
  A--;
 }
 else{
  B--;
 }

cout << A << " " << B << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 3e6 + 5;

ll fact[N], inv[N];

ll nCr(ll n, ll r) {
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

ll fpow(ll a, ll b) {
    a %= MOD;
    if (b == 0)
        return 1;
    ll ret = fpow(a * a, b / 2);
    if (b & 1)
        ret *= a;
    return ret % MOD;
}

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

    fact[0] = inv[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = (fact[i - 1] * i) % MOD;
        inv[i] = fpow(fact[i], MOD - 2);
    }

    int k;
    string s;
    
    cin >> k >> s;

    int n = (int) s.size();

    ll ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans += fpow(25, i) * fpow(26, k - i) % MOD * nCr(n + i - 1, n - 1) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 51164
import java.util.Scanner;

public class Main{	
	public static void main(String[] arts){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a;
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++){
			if(i!=n-1)
				System.out.printf("%d ",a[n-i-1]);
			else
				System.out.println(a[n-i-1]);
		}
		sc.close();
	}
}


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  
  bool poor = false;
  // AとBだけが同じ
  if (A == B && A != C) {
    poor = true;
  } else if (A == C && A != B) { //AとCだけが同じ
    poor = true;
  } else if (B == C && A != B) { //BとCだけが同じ
    poor = true;
  }
  
  if (poor) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define INFTY 2000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int minv,i,u,v;
  int d[MAX],p[MAX],color[MAX];

  for(i=0 ; i<n ; i++)
  {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1)
  {
    minv = INFTY;
    u = -1;
    for(i=0 ; i<n ; i++)
    {
      if(minv>d[i] && color[i] != BLACK){
        u=i;
        minv = d[i];
      }
    }
    if(u==-1)break;
    color[u] = BLACK;
    for(v=0 ; v<n ; v++){
      if(color[v]!=BLACK && M[u][v]!= INFTY)
      {
        if(d[v]>d[u]+M[u][v]){
          d[v] = d[u]+M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0 ; i<n ; i++)
  {
    if(d[i]==INFTY) d[i] = -1;
    printf("%d %d\n",i,d[i]);
  }
}

int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++)
  {
    for(j=0 ; j<n ; j++)
    {
      M[i][j] = INFTY;
    }
  }

  for(i=0 ; i<n ; i++){
    scanf("%d %d",&u,&k);
    for(j=0 ; j<k ; j++){
      scanf("%d %d",&v,&c);
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
#define N 45

int A[N],x;

void fibonacci(){

int i;
A[0]=1;
A[1]=1;
for(i=2;i<=x;i++){
A[i] = A[i-2] + A[i-1];
}
}
int main(){

scanf("%d",&x);

fibonacci();

printf("%d\n",A[x]);

return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;

  for (int i=0; i<s.length(); i++) {
    s[i] = 65 + (s[i] - 65 + n) % 26;
  }
  cout << s << endl;
  return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_M = 20;
const int MAX_N = 50000;
int n, m;
int d[MAX_M];
int dp[MAX_N+1];

int main()
{
  cin >> n >> m;
  rep(i, m) cin >> d[i];

  erep(j, 0, n) dp[j] = INF;
  dp[0] = 0;
  rep(i, m) erep(j, 0, n) if(j - d[i] >= 0) minup(dp[j], dp[j-d[i]] + 1);

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x; cin >> n >> m >> x;
  vector<int> ai(m);
  for(int &c : ai) {
    cin >> c;
  }
  int smaller = 0, bigger = 0;
  for(int i = 0; i < m; i++) {
    if(ai.at(i) < x) {
      smaller++;
    }
    else {
      bigger++;
    }
  }
  cout << min(smaller, bigger) << endl;
}

Measured memory_bytes: 3600
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()

range_W = range(W)
range_H = range(H)
# nomal
# L = [[0 for _ in range_W] for _ in range_H]
# R = [[0 for _ in range_W] for _ in range_H]
# U = [[0 for _ in range_W] for _ in range_H]
# D = [[0 for _ in range_W] for _ in range_H]
# res = [[0 for _ in range_W] for _ in range_H]

# Pypy
L = [[0] * W for _ in range_H]
R = [[0] * W for _ in range_H]
U = [[0] * W for _ in range_H]
D = [[0] * W for _ in range_H]
res = [[0] * W for _ in range_H]
grid = []

append = grid.append
for i in range_H:
    row = list(" ".join(input()).split())
    append(row)

def solve():
    ans = 0
    for i in range_H:
        for j in range_W:
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 341000
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define MAXN 100001
#define MOD -1
#define INF 1e9+5
#define FastCin	ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

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

void swap(int *a, int *b){
    int t = *a;
    *a = *b; *b = t;
}

int main(){
    int n, k;
    vi h(MAXN, INF);
    vi dp(MAXN, INF);
    scanf("%d", &n);
    scanf("%d", &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j <= i+k; j++){
            if(j < n)
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n-1]);
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int main(){
    int N,M;
    cin >> N >> M;
    vector<int>P(M),Y(M);
    vector<vector< Pi > > table(N);
    rep(i,0,M){
        cin >> P[i] >> Y[i];
    }
    rep(i,0,M){
        table[P[i] - 1].push_back( Pi(Y[i],i) );
    }
    rep(i,0,N){
        sort(table[i].begin(), table[i].end());
    }
    vector<string> ans(M);
    rep(i,0,N){
        rep(j,0,table[i].size()){
        //for(auto p:table[i]){
            //cout << p.first << endl;
            //for(auto p:v){
                Pi p = table[i][j];
                stringstream ss1,ss2;
                string s1,s2;
                ss1 << setw(6) << setfill('0') << (i + 1);
                ss2 << setw(6) << setfill('0') << (j + 1);
                s1 = ss1.str();
                s2 = ss2.str();
                ans[p.second] = s1 + s2;
            //}
        }
    }
    rep(i,0,M){
        cout << ans[i] << endl;
    }
}


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

int main() {

    char c;
    cin >> c;

    string vowel = "aiueo";

    string ans = "consonant";

    for(auto k : vowel){
        if(c == k){
            ans = "vowel";
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sp std::fixed<<std::setprecision
#define MOD 1000000007
#define MAX 1e18
#define N 1000005
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n , cnt = 0;
    cin >> n;
    ll a[n], ans[n + 1] = {0};
    for( int i = 0 ; i < n ; i++ )
        cin >> a[i];
    for( int i = 1 ; i < n - 1 ; i++ )
    {
        if( a[i] > a[i - 1] && a[i] < a[i + 1] )
            ans[i] = 1;
        else if( a[i] < a[i - 1] && a[i] > a[i + 1] )
            ans[i] = 1;
    }
    for( int i = 1 ; i <= n ; i++ )
    {
        if( ans[i] )
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a>=10||b>=10)
			System.out.println(-1);
		else
			System.out.println(a*b);



	}

}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  for(int i=0;i<s.size();i++){
   	if(s[i]=='1'){
     cout << '9'; 
    }
    else if(s[i]=='9'){
     cout << '1'; 
    }
  }
  cout << endl;
}

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

int main(void){
    int n;cin>>n;
    int sum=0;
    int x[n]={0};
    int min=101, max=-1;
    for(int i=0;i<n;i++){
        cin>>x[i];
        if(min>x[i])min=x[i];
        if(max<x[i])max=x[i];
    }
    int ans=100000000;
    for(int i=min;i<=max;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=((x[j]-i)*(x[j]-i));
        }
        if(sum<ans)ans=sum;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
   int x,n;
   cin>>x>>n;
   if(n==0)
   {
   cout<<x;
   return 0;
   }
   for(int i=1;i<=n;i++)
   cin>>a[i];
   sort(a+1,a+n+1);
   int s=0,mins=100000,mini=0;
   bool pd=true;
   for(int i=0;i<=10000;i++)
   {
    pd=true;
    for(int j=1;j<=n;j++)
	if(i==a[j])
	{
	pd=false;
	break;	
	}
	if(pd==true)
	{
	  s=fabs(x-i);
      if(s<mins)
      {
        mini=i;
        mins=s;
      }			
	}   	 
    }
   cout<<mini;
   return 0;
}

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

char S[100010];
int ans = 0;

int main()
{
    scanf("%s",S);
    char mem = 0;
    for(int i = 0; i < strlen(S); i++)
    {
        if(mem != S[i])
        {
            ans++;
            mem = S[i];
        }
    }
    printf("%d\n",ans - 1);
    return 0;
}


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

five = 5
ten = 10
cnt5 = 0
cnt10 = 0

if N % 2 == 1:
    ans = 0
else:
    while True:
        cnt5 += (N // 2) // five
        five *= 5
        if five > N:
            break
    ans = cnt5
print(int(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans=0;
  long long D;
  cin >> N >> D;
  vector<long long> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    cin >> Y[i];
  }
  
  for (int i = 0; i < N; i++) {
    if (X[i]*X[i]+Y[i]*Y[i] <= D*D) {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6372
#include <stdio.h>
#include <math.h>

int main(){

    int len,Max=-1000000,Min=1000000;
    long int Sum=0;
    scanf("%d",&len);
    int BUFF;

    for(int i = 0;i<len;i++){
        scanf("%d",&BUFF);
        Sum += BUFF;
        if(Max < BUFF){
            Max = BUFF;
        }
        if(Min > BUFF){
            Min = BUFF;
        }
    }

    printf("%d %d %ld\n",Min,Max,Sum);


    return 0;
}



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

using namespace std;

long a[3333], d[3333333];
int main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++)
		cin >> a[i];
	for (int i = 0; i < y; i++) {
		long b;
		cin >> b;
		for (int j = 0; j < x; j++)
			d[i*x + j] = a[j] + b;
	}
	int l = min(k, x*y);
	nth_element(d, d + l, d + x * y, greater<long>());
	copy(d, d + l, a);
	for (int i = 0; i < z; i++) {
		long b;
		cin >> b;
		for (int j = 0; j < l; j++)
			d[i*l + j] = a[j] + b;
	}
	nth_element(d, d + k, d + l * z, greater<long>());
	sort(d, d + k, greater<long>());
	for (int i = 0; i < k; i++)
		cout << d[i] << '\n';
	cout << flush;
	return 0;
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define n 3005
ll mod=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N,K;
	cin>>N>>K;
	ll a[N+5];
	for(ll i=1;i<=N;i++)
		cin>>a[i];
	sort(a+1,a+N+1);
	ll dp[N+5][K+5];
	memset(dp,0,sizeof(dp));
	ll pre[K+5];
	memset(pre,0,sizeof(pre));
	dp[0][0]=1;
	pre[0]=1;
	for(ll i=1;i<=K;i++)
	{
		pre[i]=pre[i-1]+dp[0][i];
		if (pre[i]>=mod)
			pre[i]%=mod;
	}
	for(ll i=1;i<=N;i++)
	{
		dp[i][0]=1;
		for(ll j=1;j<=K;j++)
		{
			if (j<=a[i])
			{
				dp[i][j]+=pre[j];
			}
			else
			{
				dp[i][j]+=(pre[j]-pre[j-a[i]-1]+mod);
			}
			//cout<<dp[i][j]<<" ";
			if (dp[i][j]>=mod)
				dp[i][j]%=mod;
		}
		//cout<<endl;
		memset(pre,0,sizeof(pre));
		pre[0]=dp[i][0];
		for(ll j=1;j<=K;j++)
		{
			pre[j]=pre[j-1]+dp[i][j];	
			if (pre[j]>=mod)
			pre[j]%=mod;
		}
	}
	cout<<dp[N][K];
}

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

using namespace std;
using ll = long long;

vector<int> path[100010];
int d[100010];
// 各頂点を0と1で塗り分ける

// 二部グラフならtrue
bool dfs(ll v, ll t) {
    if (d[v] >= 0) {
        return t == d[v];
    }

    d[v] = t;
    bool ret = true;
    for (ll sv : path[v]) {
        ret &= dfs(sv, 1 - t);
    }

    return ret;
}

int main() {
    ll N, M;
    cin >> N >> M;

    for (ll i = 0; i < M; ++i) {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    // 未探索なら-1にする
    fill(d, d + N, -1);

    ll odd = 0, even = 0, one = 0;
    // 二部グラフ、二部グラフでない、孤立点の連結成分

    for (ll v = 0; v < N; ++v) {
        // 探索済みならパス
        if (d[v] >= 0) continue;

        // 孤立点判定
        if (path[v].empty()) {
            ++one;
            continue;
        }

        // 二部グラフ判定
        if (dfs(v, 0)) {
            ++even;
        } else {
            ++odd;
        }
    }

    cout << N * N - (N - one) * (N - one) + (odd + even) * (odd + even) + even * even << endl;
    return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<stack>
#include<vector>

using namespace std;

#define MAX 8

struct S{
	int field[MAX][MAX];
	int cnt;
};

struct S2{
	int x, y;
};

int main(){

	int h, w, c;
	S panel,tmp;
	stack<S> sv;

	S2 point,tmp2;
	stack<S2> n;
	int color;
	int dx[] = { 0, 0, 1, -1 };
	int dy[] = { 1, -1, 0, 0 };
	int cnt;
	int max;
	while (1){

		cin >> h >> w >> c;
		if (h == 0 && w == 0 && c == 0) break;

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> panel.field[i][j];
			}
		}

		max = -1;
		panel.cnt = 0;

		sv.push(panel);

		while (!sv.empty()){
			panel = sv.top();
			sv.pop();

			if (panel.cnt == 5){
				if (panel.field[0][0] != c) continue;
				point.x = 0, point.y = 0;
				panel.field[0][0] = -1;
				cnt = 1;
				n.push(point);
				while (!n.empty()){
					point = n.top();
					n.pop();
					for (int i = 0; i < 4; i++){
						if (point.x + dx[i] >= 0 && point.x + dx[i] < w && point.y + dy[i] >= 0 && point.y + dy[i] < h){
							if (panel.field[point.y + dy[i]][point.x + dx[i]] == c){
								panel.field[point.y + dy[i]][point.x + dx[i]] = -1;
								cnt++;
								tmp2.x = point.x + dx[i], tmp2.y = point.y + dy[i];
								n.push(tmp2);
							}
						}
					}
				}
				if (cnt>max) max = cnt;
				continue;
			}

			for (int i = 1; i <= 6; i++){
				tmp = panel;
				point.x = 0, point.y = 0;
				n.push(point);
				color = tmp.field[0][0];
				tmp.field[0][0] = i;
				if (i == color) continue;
				while (!n.empty()){
					point = n.top();
					n.pop();
					for (int j = 0; j < 4; j++){
						if (point.x + dx[j] >= 0 && point.x + dx[j] < w && point.y + dy[j] >= 0 && point.y + dy[j] < h){
							if (tmp.field[point.y + dy[j]][point.x + dx[j]] == color){
								tmp.field[point.y + dy[j]][point.x + dx[j]] = i;
								tmp2.x = point.x + dx[j], tmp2.y = point.y + dy[j];
								n.push(tmp2);
							}
						}
					}
				}
				tmp.cnt = panel.cnt + 1;
				sv.push(tmp);
			}
		}
		cout << max << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		sc.close();
		for (i = 0; i < s.length(); i++) {
			out.print("x");
		}
		out.println();
	}
}


Measured memory_bytes: 23124
#include <cstdio>
#include <stack>
#include <string>
#include <utility>

using namespace std;

int main()
{
    stack<int> s;

    auto popPair = [&s]() {
        auto rhs = s.top();
        s.pop();
        auto lhs = s.top();
        s.pop();
        return make_pair(lhs, rhs);
    };

    string buffer;
    while (true) {
        char c = getchar();
        if (c == '\n') {
            break;
        }
        else if ('0' <= c && c <= '9') {
            buffer += c;
        }
        else if (c == '+') {
            auto p = popPair();
            s.push(p.first + p.second);
        }
        else if (c == '-') {
            auto p = popPair();
            s.push(p.first - p.second);
        }
        else if (c == '*') {
            auto p = popPair();
            s.push(p.first * p.second);
        }
        else if (c == ' ') {
            if (buffer != "") {
                s.push(stoi(buffer));
                buffer = "";
            }
        }
    }
    printf("%d\n", s.top());
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s;
	cin >> s;
	vector<ll>arr(s.size() + 1);
	rep(i, s.size() + 1) {
		if (i == 0)arr[i] = (s[i] == '<') ? 0LL : 1LL;
		else if (i == s.size())arr[i] = (s[i-1] == '>') ? 0 : arr[i - 1] +1LL;
		else {
			if (s[i - 1] == '>' && s[i] == '<')arr[i] = 0;
			else if (s[i - 1] == '<')arr[i] = arr[i - 1] + 1LL;
		}
	}

	for (ll i = s.size()-1; i >=0;i--) {
		if (s[i] == '>')arr[i] = max(arr[i + 1] + 1LL,arr[i]);
	}
	if (s[0] == '>')arr[0] = arr[1] + 1LL;

	ll sum = accumulate(all(arr),0LL);
	cout << sum << endl;
}


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

int main(){
  int N, tmp;
  cin >> N;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> A;
  for(int i=0; i<N; i++){
    cin >> tmp;
    A.push(make_pair(tmp, i)); //出席番号と人数のペア
  }

  pair<int, int> ptmp;
  while(!A.empty()){
    cout << A.top().second+1;
    A.pop();
    if(!A.empty()){
      cout << " ";
    }else{
      cout << endl;
    }
  }
}

Measured memory_bytes: 1780
from collections import defaultdict

while True:
  n = int(input())
  if n == 0:
    break
  dic = defaultdict(int)
  for _ in range(n):
    dic[int(input())] += 1
  for i in range(10):
    if dic[i] != 0:
      print(dic[i] * "*")
    else:
      print("-")


Measured memory_bytes: 6000
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<cassert>
#include<queue>
#include<map>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 101
#define inf (1<<29)
using namespace std;
int a[MAX];
int A[10001];
int n;
double b,r,v,e,f;
double mincost[MAX][10001];

struct P
{
  int last;
  double x,cost,now;
  P(double now=-1,double x=-1,double cost=-1,int last=-1):now(now),x(x),cost(cost),last(last){}
  bool operator < (const P &a)const
  {
    return cost >= a.cost;
  }
};

double getCost(double x)
{
  if(x >= r)return 1.0/(v - e * (x - r));
            return 1.0/(v - f * (r - x));    
}

void dijkstra()
{
  double ans = inf;
  rep(i,n)rep(j,10001)mincost[i][j] = inf;
  mincost[0][0] = 0;

  priority_queue<P> Q;
  Q.push(P(0,0,0,0));

  while(!Q.empty())
    {
      P p = Q.top(); Q.pop();
      if(p.now >= a[n-1])
	{
	  ans = min(ans,p.cost);
	  continue;
	}    

      if(ans <= p.cost)continue;

      assert(0 <= p.cost);
      double ncost = p.cost + getCost(p.x);
      assert(0 <= ncost);

      if(mincost[p.last][(int)p.now+1] > ncost)
	{
	  mincost[p.last][(int)p.now+1] = ncost;
	  Q.push(P(p.now+1,p.x+1,ncost,p.last));
	}

      if(A[(int)p.now+1] != -1)
	{
	  double change_cost = (A[(int)p.now+1]==n?0:b);
	  ncost += change_cost;
	  Q.push(P(p.now+1,0,ncost,A[(int)p.now+1]));
	}

    }

  cout << setiosflags(ios::fixed) << setprecision(4) << ans << endl;
}

int main()
{
  while(cin >> n,n)
    {
      rep(i,10001)A[i] = -1;
      rep(i,n)
	{
	  cin >> a[i];	 
	  A[a[i]] = i+1; 
	}
      cin >> b >> r >> v >> e >> f;
   

      dijkstra();

    }
  return 0;
}

Measured memory_bytes: 9540
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = 0;
		int s = 0;
		while ( (n=sc.nextInt()) != 0 | (s=sc.nextInt()) != 0) {
			if (s > 45) {
				System.out.println(0);
				continue;
			}
			int count = 0;
			HashSet< LinkedList<Integer> > combs = choose(n);
			for (LinkedList<Integer> seq : combs) {
				int sum = 0;
				for (int i : seq) {
					sum += i;
				}
				if (sum == s) {
					count++;
				}
			}
			System.out.println(count);
		}
	}

	public static HashSet< LinkedList<Integer> > choose(int n) {
		if (n == 1) {
			HashSet< LinkedList<Integer> > combs = new HashSet<>();
			for (int i=0; i < 10; i++) {
				LinkedList<Integer> seq = new LinkedList<>();
				seq.add(i);
				combs.add(seq);
			}
			return combs;
		}

		if (n > 1) {
			HashSet< LinkedList<Integer> > combs = choose(n-1);
			HashSet< LinkedList<Integer> > newcombs = new HashSet<>();
			for (LinkedList<Integer> seq : combs) {
				int last = seq.get(seq.size()-1);
				if ( last < 9 ) {
					for (int i = last+1; i < 10; i++) {
						LinkedList<Integer> newseq = new LinkedList<>(seq);
						newseq.add(i);
						newcombs.add(newseq);
					}
				}
			}
			return newcombs;
		}

		return null;
	}
}

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

class ABC073C
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		HashSet<int> hash = new HashSet<int>();
		int A;
		for(int i=0; i < N; i++)
		{
			A = int.Parse(Console.ReadLine());
			if(hash.Contains(A))
			{
				hash.Remove(A);
			}
			else
			{
				hash.Add(A);
			}
		}
		Console.WriteLine(hash.Count);
	}
}


Measured memory_bytes: 19424
import bisect
A,B,Q =map(int,input().split())
INF = 10**18
S = [-INF] + [int(input()) for i in range(A)] + [INF]
T = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  i =bisect.bisect_right(S,x)
  j =bisect.bisect_right(T,x)
  d=INF
  for s in [S[i-1],S[i]]:
    for t in [T[j-1],T[j]]:
      d1 = abs(s-x) + abs(s-t)
      d2 = abs(t-x) + abs(s-t)
      d = min(d,d1,d2)
      
  print(d)




Measured memory_bytes: 12800
import numpy as np

def Count(n,divisor):
    print (divisor <= n).sum()

EightDivisors = np.array([3*5*7, 3*5*11, 3*5*13, 3*7*11, 3**3 *5, 3**3 * 7, 3**3 * 11])


n = int(raw_input())
Count(n, EightDivisors)


Measured memory_bytes: 19184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a,b;
	cin >> a >> b;
	if(a == b) {
		cout << 1 << '\n';
		return 0;
	}
	ll no = a^b;
	ll ls = -1;
	for(int i=0;i<61;i++) {
		if(no&(1LL<<i)) {
			ls = i;
		}
	}
	ls++;
	a = a&((1LL<<(ls))-1);
	b = b&((1LL<<(ls))-1);
	if(a < b) {swap(a,b);}
	ll mu = 1LL<<(ls-1);
	ll ma = a^(1LL<<(ls-1));
	ll ba = 1;
	while(ma) {
		ma >>= 1;
		ba <<= 1;
	}
	ba--;
	ba = min(ba,b-1);
	ll res = (mu-b)*2 + ba + 1;
	cout << res << '\n';
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s1 = scanner.next();
		String s2 = scanner.next();
		String s3 = scanner.next();

		System.out.println(s1.charAt(0)+""+ s2.charAt(1)+""+ s3.charAt(2));

	}
}


Measured memory_bytes: 21716
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}


template<typename T,typename Y,T(F_up)(T,T),Y(F_gt)(T,Y)>
struct BUPSegTree{
    int sz,ex;
    T ini_d;
    vector<T> dat;

    BUPSegTree(vector<T> init,T _ini_d) : ini_d(_ini_d){
        int n=(int)(init.size());
        ex=1;
        while((1<<ex) < n)ex++;
        sz=(1<<ex);
        dat=vector<T>(2*sz,ini_d);
        for (int i = 0; i < n; ++i) dat[sz + i] = init[i];
        for (int i = sz - 1; i > 0; --i) dat[i] = F_up(dat[2*i],dat[2*i+1]);
    }

    void up_q(int p,T x){
        for(dat[p+=sz]=x;p>1;p>>=1){
            dat[p>>1]=F_up(dat[p],dat[p^1]);
        }
    }

    T get_q(int l,int r){//[l,r)
        T res=ini_d;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1){
                res=F_gt(res,dat[l]);
                ++l;
            }
            if(r&1){
                --r;
                res=F_gt(res,dat[r]);
            }
        }
        return res;
    }
};
//0-indexedと思って渡してよい
int my_max(int a,int b){return max(a,b);}
int my_repl(int a,int b){return b;}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  V<char> s(n);
  rep(i,0,n)cin>>s[i];

  V<BUPSegTree<int,int,my_max,my_max>> v(26,BUPSegTree<int,int,my_max,my_max>(V<int>(n),0));

  rep(i,0,n){
    v[s[i]-'a'].up_q(i,1);
  }

  int q;cin>>q;
  while(q--){
    int t,x;cin>>t>>x;
    
    if(t==1){
      char y;cin>>y;
      x--;
      v[s[x]-'a'].up_q(x,0);
      v[y-'a'].up_q(x,1);      
      s[x]=y;
    }else{
      int y;cin>>y;
      x--;
      int ans=0;
      rep(j,0,26){
        ans+=v[j].get_q(x,y);
        //cerr<<j<<" "<<ans<<ENDL;
      }
      cout<<ans<<ENDL;
    }
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 113408
s = input()

n = 2 ** (len(s) - 1)
result = 0

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * ((len(s) - 1) - len(bin_n)) + bin_n
  current_address = 0
  for j in range(len(bin_n)):
    if bin_n[j] == '1':
      result += int(s[current_address:j+1])
      current_address = j+1

  result += int(s[current_address:])

print(result)

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

#pragma warning(disable:4996)
using namespace std;
using ld =long double;


int main() {
	int N,H,W;cin>>N>>H>>W;
	int ans=0;
	for (int i = 0; i < N/2; ++i) {
		int a,b;cin>>a>>b;
		int l=min(a+b,2*W-a-b);
		ans+=l;
	}
	cout<<ans*H<<endl;
 	return 0;
}


Measured memory_bytes: 3096
package main

import (
    "fmt"
)

func main() {
    var n, m int 
    fmt.Scan(&n, &m) 
    x := make([]int, n)
    y := make([]int, m)
    for i := 0; i < n; i++ {
        fmt.Scan(&x[i])
    }   
    for i := 0; i < m; i++ {
        fmt.Scan(&y[i])
    }   

    const mod = 1000000007
    var yoko, tate int 
    for i := 0; i < n; i++ { // 横辺の長さ
        yoko += (x[i] * i) % mod 
        yoko = (yoko + mod - (x[i] * (n - 1 - i))) % mod 
    }   
    for i := 0; i < m; i++ { // 縦辺の長さ
        tate += (y[i] * i) % mod 
        tate = (tate + mod - (y[i] * (m - 1 - i))) % mod 
    }   
    res := (yoko * tate) % mod 
    if res < 0 { 
        res += mod 
    }   
    fmt.Println(res)
}


Measured memory_bytes: 5504
import java.util.*;

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

        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();

        System.out.println((s1.substring(0, 1)).toUpperCase() + (s2.substring(0, 1)).toUpperCase() + (s3.substring(0, 1)).toUpperCase());
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   


  int main(){
 lint N;
 lint y=0;
 cin>>N;
 string s;
 cin>>s>>s;

 bool f;
 lint ans;
 if(N==1){
   cout<<3;
   return 0;
 }else if(s[0]==s[1]){ans=6;
    f=false;
    y++;
 }else {
   ans=3;
  f=true;
 }
  repp(i,y+1,N){
    if(s[i]=='1')break;
      if(s[i]==s[i+1]&&f==true){
        ans*=2;
        ans%=MOD;
        f=false;
        i++;
      }
      else if(s[i]==s[i+1]&&f==false){
        ans*=3;
        ans%=MOD;
        i++;
      }
 else  if(s[i]!=s[i+1]&&f==false){
       f=true;
      }
else if(s[i]!=s[i+1]&&f==true){
       ans*=2;
       ans%=MOD;
      }
  }
  cout<<ans;
}

Measured memory_bytes: 256