akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    int p=!x;
    cout<<p;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;



int main() {
  ll a,b,c,o=4;
  cin >> a >> b >> c;
  ll d=c-a-b;
  if (d>0 && d*d>4*a*b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int main()
{
	int k, a, b; 
	giii(k, a, b); ++k;
	int64 ans = k;
	if (k > a && b > a)
	{
		int l = k - a;
		ans = max(ans, a + 1LL * (l >> 1) * (b - a) + (l & 1));
	}
	cout<<ans<<endl;
}


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

int main(){
  int N, A;
  int X;
  
  cin >> N >> A;
  
  X = N / 500;

  
  if ( N - X * 500 <= A ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>k;

	if(n>k || n+m<k) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;



}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    int dp[N];
    dp[0] = 0;

    FOR(i, 1, N) {
        dp[i] = INF32;

        FOR(j, 1, K + 1) {
            if (i - j >= 0)
                chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
object Main extends App {
    type P = (Double, Double)
    def koch(p1: P, p2: P, n: Int): Unit = {
        if (n == 0) println(p1._1 + " " + p1._2)
        else {
            val s = ((p1._1*2+p2._1)/3, (p1._2*2+p2._2)/3)
            val t = ((p1._1+p2._1*2)/3, (p1._2+p2._2*2)/3)
            val x = math.Pi/3
            val (d1, d2) = (t._1-s._1, t._2-s._2)
            val u = (s._1+d1*math.cos(x)-d2*math.sin(x),s._2+d1*math.sin(x)+d2*math.cos(x))
            koch(p1, s, n-1)
            koch(s, u, n-1)
            koch(u, t, n-1)
            koch(t, p2, n-1)
        }
    }
    val in = io.StdIn.readInt
    val p1 = (0.0, 0.0)
    val p2 = (100.0, 0.0)
    koch(p1, p2, in)
    println(p2._1 + " " + p2._2)
}

Measured memory_bytes: 49652
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = s.size() - t.size(); i >= 0; --i) {
        bool canInsert = true;
        for (int j = 0; j < t.size(); ++j) {
            if (s[i + j] == t[j] || s[i + j] == '?')
                continue;
            canInsert = false;
        }

        if (canInsert) {
            for (int j = 0; j < t.size(); ++j) {
                s[i + j] = t[j];
            }

            for (int j = 0; j < s.size(); ++j) {
                if (s[j] == '?')
                    s[j] = 'a';
            }

            cout << s << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
    return 0;
}

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

static const int N = 100;

int main()
{
    int n, p[N + 1], m[N + 1][N + 1];  // pは行と列を入れる配列，mは行列の計算回数を入れる配列
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i - 1] >> p[i];  // 行と列を入れている
    }

    for (int i = 1; i <= n; i++) {
        m[i][i] = 0;  // 対角成分を初期化する(同じ行列同士をかける場所だから)
    }
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j - 1; k++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3136
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

#define nextInt nextpint
int main(void){
	int A = nextInt();
	int B = nextInt();
	int K = nextInt();
	int C;
	for(int i=0; i<K; i++){
		C = A/2;
		A = B + C;
		B = C;
	}
	if(K%2==1){
		C = A;
		A = B;
		B = C;
	}
	printf("%d %d\n", A, B);
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
using namespace std;

long long N;
long long C[200000];
long long pow2[200001];


long long mod_prod(long long a, long long b) {
	return (a*b) % 1000000007;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	pow2[0] = 1;
	for (int i = 1; i < 200002; i++) {
		pow2[i] = mod_prod(pow2[i - 1], 2) ;
	}

	sort(C, C + N);

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += mod_prod(C[N-i-1], (pow2[N-1] + mod_prod(i, pow2[N - 2])));
		ans = ans % 1000000007;
	}
	ans = mod_prod(ans, pow2[N]);
	cout << ans;
}

Measured memory_bytes: 3328
#include <stdio.h>
int INF = 1 << 20;

int dp[101][10001];
int N, W;
int value[100];
int weight[100];
int max(int x, int y) { if (x < y) return y; else return x; }

int main() {
	scanf("%d %d\n", &N, &W);
	for (int i = 0; i < N; i ++) {
		scanf("%d %d\n", &value[i], &weight[i]);
	}
	for (int i = 0; i <= 10000; i ++) {
		dp[0][i] = 0;
	}
	for (int i = 1; i <= N; i ++) {
		int v = value[i - 1];
		int w = weight[i - 1];
		for (int j = 0; j <= 10000; j ++) {
			if (j - w >= 0) {
				dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j]);
			} else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	printf("%d\n", dp[N][W]);
	return 0;
}

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

map<long, int> pf(long n) {
  map<long, int> ma;
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) ma[i]++, n /= i;
  }
  if (n != 1) ma[n]++;
  return ma;
}

int main() {
  int N, M = 1e9+7;
  cin >> N;
  vector<int> cnt(N + 1);
  for (int i = 1; i <= N; i++) {
    for (auto [a, b] : pf(i)) cnt.at(a) += b;
  }
  long ans = 1;
  for (auto c : cnt) {
    ans *= ++c;
    ans %= M;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3644
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		while(true){
			String[] line =sc.nextLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
		//break	
			if(n==0 && x==0){
				break;
			}
			System.out.println(sum(n,x));
		}					

	}
	public static int sum(int n,int x){
		int count=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<i;j++){
				for(int k=0;k<j;k++){
					if(x-3==i+j+k){
						count=count+1;
					}
				}
			}
		}
		return count;
	}
}

Measured memory_bytes: 26424
#define _CRT_SECURE_NO_DEPRECATE
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define ll  long long

int main() {
	//freopen("test.txt", "r", stdin);
	int t; cin>>t;
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	for(int i=0;i<32;i++){
		if(t-1==i) {cout<<a[i]<<endl; break;}
	}
	return 0;
}

Measured memory_bytes: 256
s = gets.strip.split("")
a = z = ""

(1..s.length).each do |i|
    if s[i-1] == "A"
        a = i
        break
    end
end

(a..s.length).reverse_each do |i|
    if s[i-1]  == "Z"
        z = i 
        break
    end
end

puts (z - a + 1)


Measured memory_bytes: 17844
# 2019/05/18
# AtCoder Beginner Contest 109 - C

# For the Answer:
# 1. Xと各点の差を出す(絶対値)
# 2. 累積最小公約数を出す

import fractions

# Input
n, x = map(int, input().split())
xl = list(map(int, input().split()))


ldif = list()
# 1. 
for i in range(n):
    ldif.append(abs(xl[i]-x))


# 2.
ac_gcd = ldif[0]
for i in range(1, n):
    ac_gcd = fractions.gcd(ac_gcd, ldif[i])

print(ac_gcd)


Measured memory_bytes: 16284
#include<iostream>
using namespace std;
long N,H,D,mod=1e9+7;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	lazysegtree(int n_=0,T defvalue_=0,T lazydefvalue_=0):defvalue(defvalue_),lazydefvalue(lazydefvalue_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazy[i])
		{
			dat[i]=(dat[i]+lazy[i]*(r-l))%mod;
			if(r-l>1)
			{
				lazy[2*i+1]=(lazy[2*i+1]+lazy[i])%mod;
				lazy[2*i+2]=(lazy[2*i+2]+lazy[i])%mod;
			}
			lazy[i]=lazydefvalue;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=(lazy[k]+x)%mod;
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=(dat[2*k+1]+dat[2*k+2])%mod;
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return (query(a,b,2*k+1,l,(l+r)/2)+query(a,b,2*k+2,(l+r)/2,r))%mod;
	}
};
main()
{
	cin>>N>>H>>D;
	lazysegtree<long>P(H);
	long s=0,p=1;
	for(int i=1;i<=N;i++)
	{
		p=p*i%mod;
		s=(s+p)%mod;
	}
	P.update(0,D,p);
	for(int i=0;i<H;i++)
	{
		P.update(i+1,i+D+1,P.query(i,i+1)*s%mod);
	}
	cout<<P.query(H-1,H)<<endl;
}


Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <numeric>
using namespace std;


int main(){
    string s;cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++){
        if(i%2){
            if(s[i]=='1')a++;
            else b++;
        }
        else{
            if(s[i]=='0')a++;
            else b++;
        }
    }
    cout<<s.size()-max(a,b);
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
ll abs(ll a){return(a<0)?-a:a;}
ll gcd(ll a, ll b){
    if(b > a){
        ll tmp = b;
        b = a;
        a = tmp;
    }
    if(b == 0) return a;
    return gcd(b,a%b);
}

int N,X;
int x[100000];
int main(void){
    // Your code here!
    scanf("%d %d",&N,&X);
    for(int i = 0; i < N; i++) scanf("%d",x+i);
    
    if(N == 1){
        printf("%lld\n",abs(X-x[0]));
        return 0;
    }
    
    ll ans = gcd(abs(X-x[0]),abs(X-x[1]));
    for(int i = 2; i < N; i++){
        ans = gcd(ans, abs(X-x[i]));
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 640
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    map<char,ll> res;
    vector<char> C = {'M','A','R','C','H'};
    REP(i,5) res[C[i]] = 0;

    REP(i,N) {
        string S;
        cin >> S;
        char c = S[0];
        bool ok = false;
        REP(j,5) if(c == C[j]) ok = true;
        if(!ok) continue;
        res[c]++;
    }
    ll ans = 0;
    REP(i,3) {
        for(int j = i+1; j < 4; j++) {
            for(int k = j+1; k < 5; k++) {
                ans += res[C[i]]*res[C[j]]*res[C[k]];
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N; cin >> N;
	int a[100];
	int maxV = 0;
	int minV = 10000;
	rep(i, 0, N) {
		cin >> a[i];
		if (maxV < a[i]) maxV = a[i];
		if (minV > a[i]) minV = a[i];
	}

	cout << maxV - minV << endl;
}

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

int f(int x) {
  int res = 0;
  while (x > 0) {
    res += x % 10;
    x /= 10;
  }
  return res;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,l; cin >> n >> l;
    if(l>=0)cout << n*(n+1)/2+(l-1)*n-l << endl;
    else if(l+n-1 < 0)cout << n*(n+1)/2+(l-1)*n-l-n+1<< endl;
    else cout << n*(n+1)/2+(l-1)*n << endl;
}

Measured memory_bytes: 256
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, d]: number[] = tmp[0].split(" ").map(int => parseInt(int));
    const dd: number = 2 * d + 1;
    return `${Math.floor(n / dd) + (n % dd == 0 ? 0 : 1)}`;
  }
}
 console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
if __name__ == '__main__':
    n, w = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(n)]

    dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

    for i in range(n):
        for j in range(w + 1):
            if j >= wv[i][0]:
                dp[i + 1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])
            else:
                dp[i + 1][j] = dp[i][j]

    print(dp[n][w])


Measured memory_bytes: 171656
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
q=int(input())

inf = set()
num_min =2**(n-1).bit_length()
dat=[inf]*(2*num_min-1)

#初期化
for i in range(n):
    dat[i+num_min-1]=set(s[i])
for i in range(num_min-2,-1,-1):
    dat[i]=dat[2*i+1].union(dat[2*i+2])

#親のノード(n-1)//2
#子のノード2n+1,2n+2

def segfunc(x,y):
    return x.union(y)

def update(i,x):
    i+=num_min-1
    dat[i]=x
    while i>0:
        i=(i-1)//2
        dat[i]=segfunc(dat[2*i+1],dat[2*i+2])
def query(a,b): #半開区間、[a,b)の最小値
    if b<=a:
        return inf
    res=inf
    a += num_min-1
    b += num_min-2
    while b-a>1:
        if a&1==0:
            res = segfunc(res,dat[a])
        if b&1==1:
            res = segfunc(res,dat[b])
            b-=1
        a=a//2
        b=(b-1)//2
    if a==b:
        res = segfunc(res,dat[a])
    else:
        res=segfunc(segfunc(res,dat[a]),dat[b])
    return res

for i in range(q):
  t,l,r=input().split()
  if t=="1":
    update(int(l)-1,set(r))
  else:
    ans=query(int(l)-1,int(r))
    print(len(ans))

Measured memory_bytes: 372712
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
    string s;
    cin>>s;
    int cnt1,cnt2;
    cnt1=0,cnt2=0;
    for(auto it:s){
	  if(it=='0')cnt1++;
	  else cnt2++;	
	}
	cout<<(cnt1<cnt2?to_string(2*cnt1):to_string(2*cnt2))<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    ll ans;

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
        ans = sz_*(sz_-1)/2;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）

        // 回答更新
        ll p=siz[x], q=siz[y];
        ans = ans + (p*(p-1))/2 + (q*(q-1))/2 - ((p+q)*(p+q-1))/2;

        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    vector<pair<ll,ll>> ab(m);
    rep(i,m){
        cin>>ab[i].first;
        cin>>ab[i].second;
    }
    reverse(all(ab));
    UnionFind tree(n);

    vector<ll> ans;
    ans.push_back(n*(n-1)/2);
    for(auto t : ab){
        tree.merge(t.first-1, t.second-1);
        ans.push_back(tree.ans);
    }

    reverse(all(ans));
    for(int i=1; i<=m; i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5364
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<string> vs(N);
  FOR(i,0,N) cin >> vs[i];
  int ans = 2e9;
  // i-j行が青の時
  FOR(i,1,N-1){
    FOR(j,i,N-1){
      int cnt = 0;
      FOR(y,0,N){
        FOR(x,0,M){
          // 白
          if(y < i){
            if(vs[y][x] != 'W') cnt++;
          }
          // 赤
          else if(y > j){
            if(vs[y][x] != 'R') cnt++;
          }
          // 青
          else {
            if(vs[y][x] != 'B') cnt++;
          }
        }
      }
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3228
def solve():
    N = int(input())

    now_t, now_a = 1,1
    for _ in range(N):
        t, a = map(int,input().split())
        n = max(-(-now_t//t), -(-now_a//a))
        now_t = t * n
        now_a = a * n
    
    print(now_t + now_a)
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 67760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename V> typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V> typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N >> S;
	int r = 0;
	REP(i, N) {
		if (S[i] == 'R')r++;
	}
	if (r > (N - r))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define PI 3.14159265358979323846
ll power(ll a, ll b){ll res=1;a=a%mod; while(b){if(b&1)res=(res*a)%mod; a=(a*a)%mod;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}

int main(void)
{
	FIO	
	double r;
	cin>>r;
	cout<<2*PI*r<<"\n";
	return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    unsigned long long int ans,i,j,k,n;
    vector<unsigned long long int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
    }
    ans=v[0];
    for(i=1;i<n;i++)
    {
        ans=(ans/__gcd(ans,v[i]))*v[i];
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
rn,gn,bn,n=map(int,input().split())
nn=sorted([rn,gn,bn]) 
c=0
for r in range(1+n//nn[0]):
    rt=n-nn[0]*r
    for g in range(1+rt//nn[1]):
        gt=rt-nn[1]*g
        if gt%nn[2]==0:
            c+=1
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN = 20;

int rev(int n)
{
	int res = 0;

	while (n)
	{
		res = res * 10 + n % 10;
		n /= 10;
	}

	return res;
}

int mask[MAXN + 1];
int d[MAXN + 1];
int cond[MAXN + 1];
map <int, int> prec;
map <int, int> prec2;

ll sol(ll len)
{
	ll ans = 0; 

	for (int m = 0; m < (1 << (len - 1)); m++)
	{
		for (int i = 0; i < len - 1; i++)
		{
			mask[i] = (bool)(m & (1 << i));
		}

	
		ll cur = 1;
		for (int i = 0; i < len; i++)
		{
			int bi = len - i - 1;
			int sm = i;
			int res = d[i];
			if (mask[i])
			{
				res -= 10;
			}
			if (i && mask[i - 1])
			{
				res++;
			}

			if (bi == sm)
			{
				if (res == 0)
				{
					cur *= 10;
				}
				else
				{
					cur = 0;
				}
			}
			else if (bi < sm)
			{
				swap(bi, sm);
				res = -res;
				if (cond[bi] != res)
				{
					cur = 0;
				}
			}
			else
			{
				cond[bi] = res;
				if (sm == 0)
					cur *= prec2[res];
				else
					cur *= prec[res];
			}
		}

		ans += cur;
	}

	return ans;
}

int main()
{
	for (int d1 = 0; d1 < 10; d1++)
		for (int d2 = 0; d2 < 10; d2++)
			prec[d1 - d2]++;


	for (int d1 = 1; d1 < 10; d1++)
		for (int d2 = 0; d2 < 10; d2++)
			prec2[d1 - d2]++;

	int v;
	cin >> v;

	int sz = 0;

	for (int i = 0; i < MAXN; i++)
	{
		d[i] = v % 10;
		v /= 10;
		if (d[i])
			sz = i + 1;
	}

	ll res = 0;

	for (int i = sz; i < MAXN; i++)
		res += sol(i);

	cout << res << '\n';


	return 0;	
}


Measured memory_bytes: 384
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    for i in 0..h {
        for j in 0..w {
            let s = iterator.next().unwrap();
            if s == "snuke" {
                return format!("{}{}", ('A' as u8 + j as u8) as char, i + 1);
            }
        }
    }

    return String::new();
}


Measured memory_bytes: 2104
n,a,b = map(int,input().split())

if a == 0:
  print(0)
elif b == 0:
  print(n)
elif a >= n:
  print(n)
elif a+b >= n:
  print(a)

else:
  c = a*int(n//(a+b)) + min(n%(a+b),a)
  print(c)

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


const int L=2e5+9;
LL c[L];
vector<int> es[L];
LL ps[L];
LL w[L];
LL cnt[L];
LL ret[L];
LL N;
LL dfs(int r, int p)
{
	int pcnt=cnt[c[r]];
	int pps=ps[c[r]];
	ps[c[r]]=r;
	LL s=1;
	ret[c[r]]+=s;
	LL sum=1;
	for(auto i:es[r]){
		if(i==p){
			continue;
		}
		w[r]=0;
		auto v=dfs(i,r);
		auto t=w[r]+v;
		ret[c[r]]+=t*s;
		s+=t;
		sum+=v;
	}
	{
		auto t=N-sum-pcnt;
		ret[c[r]]+=t*s;
	}
	cnt[c[r]]+=s;
	w[pps]-=sum;
	ps[c[r]]=pps;
	return sum;
}

int main(){
    scanf("%lld",&N);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&c[i]);
    }
    for(int i = 0 ; i < N-1 ; i++){
		LL a,b;
        scanf("%lld",&a);
        scanf("%lld",&b);
		es[a].push_back(b);
		es[b].push_back(a);
    }
	dfs(1,0);
	for(int i=1;i<=N;i++){
		cout << ret[i] << endl;
	}
    return 0;
}


Measured memory_bytes: 37540
#include <stdio.h>
#include <stdlib.h>
#define MAX 100005

struct process {
	char name[10];
	int time;
} P[1000000];

int head, end;

void enqueue(struct process x) {
	P[end] = x;
	end = (end + 1) % MAX;
}

struct process dequeue() {
	struct process x = P[head];
	head = (head + 1) % MAX;
	return x;
}

int min( a, b) {
	return a < b ? a : b;
}

int main() {
	int n, q;
	int i;
	int plus = 0;
	struct process p;
	scanf("%d%d", &n, &q);
	head = 1;
	end = n + 1;
	for (i = 1; i <= n; i++) {
		scanf("%s%d", P[i].name, &P[i].time);
	}
	while (head != end) {
		p = dequeue();
		int m = min(q, p.time);
		p.time -= m;
		plus += m;
		if (p.time > 0)
			enqueue(p);
		else
			printf("%s %d\n", p.name, plus);
	}
	return 0;
}



Measured memory_bytes: 3292
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#from itertools import groupby as gb
#from itertools import permutations as perm
#from itertools import combinations as comb
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
x,y,z = map(int, stdin.readline().rstrip().split())
#AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]
print(z,x,y)


Measured memory_bytes: 2940
n,m = map(int,input().split())
l = []
for i in range(m):
    p,s = input().split()
    p = int(p)
    l.append([p,s])
pl = [0 for i in range(n+1)]
b = 0
key = 0
count = 0
ans = 0
penalty = 0
for i in range(m):
    if l[i][1] == "AC":
        if pl[l[i][0]] >= 0:
            ans += 1
            penalty += pl[l[i][0]]
            pl[l[i][0]] = -1
    else:
        if pl[l[i][0]] >= 0:
            pl[l[i][0]] += 1
        else:
            continue   
print(ans,penalty)

Measured memory_bytes: 24800
#include <iostream>
#include <vector>
#include <queue>
#define INF (int)1e9

int common_part(int m, int p, int q, std::vector<std::vector<std::pair<int, int> > > v); 
int bellman_ford(std::vector<std::vector<std::pair<int, int> > > v, std::vector<int> rvec); 

int main(void) {
    int n;
    int m;

    int a;
    int b;
    int cost;
    int time;

    int k;

    int p;
    int q;
    int r;

    int res;

    while (true) {
        std::cin >> n >> m;
        if (n == 0 && m == 0) {
            break; 
        }

        std::vector<std::vector<std::pair<int, int> > > vcost(m);
        std::vector<std::vector<std::pair<int, int> > > vtime(m);

        for (int i = 0; i < n; i++) {
            std::cin >> a >> b >> cost >> time;
            --a;
            --b;
            vcost[a].push_back(std::make_pair(cost, b));
            vcost[b].push_back(std::make_pair(cost, a));
            vtime[a].push_back(std::make_pair(time, b));
            vtime[b].push_back(std::make_pair(time, a));
        }

        std::cin >> k;

        for (int i = 0; i < k; i++) {
            std::cin >> p >> q >> r;
            --p;
            --q;

            // Bellman Ford or Dijkstra
            if (r == 0) {
                res = common_part(m, p, q, vcost);
            } else {
                res = common_part(m, p, q, vtime);
            }
            std::cout << res << std::endl;
        }
    }
    return 0;
}

void bellman_ford(int m, std::vector<std::vector<std::pair<int, int> > > &v, std::vector<int> &rvec, bool &flag) {
    int value;
    int target;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < v[i].size(); j++) {
            value = v[i][j].first;
            target = v[i][j].second;
            if (rvec[target] > rvec[i] + value) {
                rvec[target] = rvec[i] + value;
                flag = true;
            }
        }
    }
    return;
} 

int common_part(int m, int p, int q, std::vector<std::vector<std::pair<int, int> > > v) {
    std::vector<int> rvec(m, INF);
    bool flag;
    rvec[p] = 0;

    do{
        flag = false;
        bellman_ford(m, v, rvec, flag);

    } while(flag);

    return rvec[q];
} 

Measured memory_bytes: 3180
#include <cstdio>
bool isprime(int x)
{
    for(int i=2;i*i<=x;i++)
        if(x%i==0)
            return false;
    return true;
}
int main()
{
    int N,cnt;
    scanf("%d",&N);
    cnt=0;
    for(int i=6;cnt<N;i+=5)
        if(isprime(i))
        {
            if(cnt!=N-1)
                printf("%d ",i);
            else printf("%d\n",i);
            cnt++;
        }
    return 0;
}


Measured memory_bytes: 128
import sys

H, W, A, B = map(int, sys.stdin.readline().split())

for i in range(H):
    for j in range(W):
        if i < B:
            if j < A:
                print(0, end="")
            else:
                print(1, end="")
        else:
            if j < A:
                print(1, end="")
            else:
                print(0, end="")
    print("")

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

int main() {
  int N;
  int l,r;
  int ans = 0;
  
  cin >> N;
  for (int i=0; i<N; i++){
  	cin >> l >> r;
  
  	for (int j=l; j<=r; j++){
		ans++;
    }
  
  }
  cout << ans;
}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val M = sc.nextInt()
    if (N >= M) {
        println(0)
        return
    }

    val X = IntArray(M){0}
    for (i in 0 until M) {//MをN個に区切る
        val x = sc.nextInt()
        X[i] = x
    }
    X.sort()

    val sub = IntArray(M-1){0}
    for (i in 0 until M-1) {
        sub[i] = X[i+1] - X[i]
    }
    sub.sort()
    println(sub.dropLast(N-1).sum())//ギャップが大きいところをなくすように区切る

    // 0 1 2 3 4 5
    //  1 1 1 1 1
    // 1 2 10 12 14
    //  1 8  2  2
}

Measured memory_bytes: 53528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

lint invmod(lint n, lint m) {
	//nの逆元を返す
	lint ret = 0;
	ret = power(n, m - 2, m);
	return ret;
}

lint comb(lint n, lint k, lint m) {
	//nCk%MODを返す
	//O(k)
	lint ans = 1;
	rep(i, k) {
		ans *= n - i;
		ans %= m;
		ans *= invmod(k - i, m);
		ans %= m;
	}
	return ans;
}

int main() {
	lint MOD = pow(10, 9) + 7;
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint sum = 0;
	lint sig = 0;
	rep(i, N) {
		sum += A[i];
		sum %= MOD;
	}
	rep(i, N) {
		sig += A[i] * A[i];
		sig %= MOD;
	}
	lint ans = sum * sum - sig + MOD;
	ans %= MOD;
	ans *= invmod(2, MOD);
	ans %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 4788
def eat(a, b):
    e = A[a] + A[b] - X
    if 0 < e <= A[b]:
        A[b] -= e
    elif e > A[b]:
        e -= A[b]
        A[b] = 0
        A[a] -= e

N, X = map(int, input().split())
A = list(map(int, input().split()))
before_eat = sum(A)
eat(-1, -2)
for i in range(N - 1):
    eat(i, i + 1)
print(before_eat - sum(A))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	int n;
	cin >> n;
	vll h(n);
	ll ma = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (ma <= h[i])
			ans++;
		ma = max(ma, h[i]);
	}
	
	cout << ans;
}

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

int v[12];
int H, W;

void func(int x) {
    for (int i = 0; i < H + W; i++) {
        v[i] = x % int(pow(2, i + 1)) / int(pow(2, i));
    }
}

int main() {
    int K, num, ans = 0, count;
    cin >> H >> W >> K;
    vector<vector<char>>c(H, vector<char>(W)), d(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> c.at(i).at(j);
        }
    }
    num = pow(2, H + W);
    for (int i = 0; i < num; i++) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                d.at(i).at(j) = c.at(i).at(j);
            }
        }
        func(i);
        for (int j = 0; j < H+W; j++) {
            if (v[j] == 1) {
                if (j < H) {
                    for (int k = 0; k < W; k++) {
                        if (d.at(j).at(k) != 'r') {
                            d.at(j).at(k) = 'r';
                        }
                    }
                }
                else {
                    for (int k = 0; k < H; k++) {
                        if (d.at(k).at(j-H) != 'r') {
                            d.at(k).at(j-H) = 'r';
                        }
                    }
                }
            }
        }
        count = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (d.at(i).at(j) == '#') {
                    count++;
                }
            }
        }
        if (count == K) {
            ans++;
        }
    }
    cout << ans;
}

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

ll k, n, a[50];

int main() {
  cin >> k;

  ll alpha = k / 50; // もう一周分
  ll beta = k % 50;

  for (int i = 0; i < 50; i++) {
    a[i] = 49 + alpha;
  }
  for (int i = 0; i < beta; i++) {
    for (int j = 0; j < 50; j++) {
      if (j == i) {
        a[j] += 50;
      } else {
        a[j]--;
      }
    }
  }
  cout << 50 << endl;
  for (int i = 0; i < 50; i++) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long[] a = in.nextLongArray(3);
			Arrays.sort(a);

			out.println(a[0] * a[1] * (2*((a[2]+1)/2)-a[2]));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 24660
def pertition(A, p, r):
	x = A[r]
	i = p - 1
	for j in range(p, r):
		if A[j] <= x:
			i += 1
			A[i], A[j] = A[j], A[i]
	A[i + 1], A[r] = A[r], A[i + 1]
	return i + 1

n = int(raw_input())
a = raw_input()
l = []
l = a.split(" ")
for i in range(len(l)):
	l[i] = int(l[i])
i = pertition(l, 0, n - 1)
l[i] = "[" + str(l[i]) + "]"
print " ".join(map(str, l)) 

Measured memory_bytes: 18108
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  int ans = m;
  for(int i = 0; i < n - m + 1; i++) {
    int num = 0;
    for(int j = 0; j < m; j++) {
      if(s[i + j] != t[j]) {
        num++;
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
def therefore(n):
  a = [2, 4, 5, 7, 9]
  b = [0, 1, 6, 8]
  c = [3]
  z = int(str(n)[-1])
  if(z in a):
    return "hon"
  elif(z in b):
    return "pon"
  else:
    return "bon"

n = int(input())
print(therefore(n))


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    cout << ((a + b >= c)?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
#include <complex>
using namespace std;

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

int main() {
    int num[5];
    cin >> num[0] >> num[1] >> num[2];

    int cou = 0;
    while (true) {
        sort(num, num + 3);
        if (num[0] == num[1] && num[1] == num[2])break;
        if (num[0] == num[1]) {
            if (num[1] < num[2]) {
                num[0]++;
                num[1]++;
            }
            else {
                num[2] += 2;
            }
        }

        else if (num[0] < num[1]) {
            num[0] += 2;
        }
        else if (num[0] > num[1]) {
            if (num[1] == num[2]) {
                num[1]++;
                num[2]++;
            }
            else {
                num[0] += 2;
            }
        }
        cou++;
    }
    cout << cou << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[11000];

const string MINUSINF = "-";

void chmax_str(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A[i];

    rep(i, 11000) dp[i] = MINUSINF;
    dp[0] = "";

    rep(i, N) {
        if (dp[i] == MINUSINF) continue;
        for (auto a: A) {
            chmax_str(dp[i + match[a - 1]], dp[i] + (char) ('0' + a));
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 43776