akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var consoleReader = new ConsoleReader(Console.In);
            var N = consoleReader.Int;

            var count = consoleReader.Repeat(N).String
            .Select(x => new string(x.OrderBy(c => c).ToArray()))
            .GroupBy(x => x)
            .Select(g => (long)g.Count())
            .Where(l => l > 1)
            .Select(l => l * (l - 1) / 2)
            .Sum();

            Console.WriteLine(count);
        }
    }

    class ConsoleReader
    {
        private StringBuilder sb = new StringBuilder(4096);
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                sb.Clear();
                int current = textReader.Read();
                while (current > 0 && char.IsWhiteSpace((char)current)) { current = textReader.Read(); }
                while (current > 0 && !char.IsWhiteSpace((char)current)) { sb.Append((char)current); current = textReader.Read(); }
                return sb.ToString();
            }
        }


        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}


Measured memory_bytes: 33296
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s;
    map<ll, ll> mp;
    cin >> s;
    for(auto x:s){
        if(mp[x]) ANS("no");
        mp[x]++;
    }
    ANS("yes")
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<cctype>
#include<cstdio>
#include<vector>
const int N=100007,M=512,P=998244353,base=1000000000000000000%P;
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
int mul(int a,int b){return 1ll*a*b%P;}
int n;
struct graph
{
    int f[N],g[M],vis[M];std::vector<int>e[N];
    void input()
    {
	for(int m=read(),u,v;m;--m) u=read(),v=read(),e[std::min(u,v)].push_back(std::max(u,v));
	for(int u=n;u;--u)
	{
	    for(int v:e[u]) vis[f[v]]=1;
	    while(vis[f[u]]) ++f[u];
	    for(int v:e[u]) vis[f[v]]=0;
	}
	for(int i=1,x=1;i<=n;++i) x=mul(x,base),inc(g[f[i]],x);
    }
}a[3];
int main()
{
    n=read();int ans=0;
    for(int i=0;i<3;++i) a[i].input();
    for(int i=0;i<512;++i) for(int j=0;j<512;++j) inc(ans,1ll*a[0].g[i]*a[1].g[j]%P*a[2].g[i^j]%P);
    printf("%d",ans);
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<long long int> pq;
    for(int i = 0;i < n;i++)
    {
        long long int x;
        cin >> x;
        pq.push(x);
    }
    for(int i = 0;i < m;i++)
    {
        long long int tmp = pq.top() / 2;
        pq.pop();
        pq.push(tmp);
    }
    long long int sum = 0;
    while(!pq.empty())
    {
        sum += pq.top();
        pq.pop();
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()

using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<ll> a(3*N);
  REP(i, 3*N) cin >> a[i];
  sort(ALL(a), greater<ll>());
  ll ans = 0;
  for (int i = 1; i < 2*N; i += 2) ans += a[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<cstdio>

using namespace std;

int main()
{
	int n;
	while(~scanf("%d",&n),n){
		int cnt=0;
		for(int i=5;i<=n;i*=5){
			cnt+=n/i;
		}
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[110100];
ll diff[110100];
int main(){
    int N;
    cin >> N;
    ll asum = 0;
    ll ok = true;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        asum += a;
    }

    ll n = N*(N+1LL)/2;
    if(asum % n != 0) ok = false;
    ll K = asum / n;


    ll difsum = 0;
    REP(i,N-1){
        diff[i] = A[i+1] - A[i] - K;
        if(diff[i] > 0) ok = false;
        if(diff[i] % N != 0) ok = false;
        difsum += diff[i];
    }
    diff[N-1] = A[0] - A[N-1] - K;
    difsum += diff[N-1];

    if(difsum != -N*K) ok = false;

    //ll sum = 0;
    //for(int k = 0; k < N; k++){
    //    if(diff[k] == 0) continue;
    //    if(diff[k] > 0 || diff[k] % N != 0){
    //        ok = false;
    //        break;
    //    } 
    //    sum += -diff[k] / N;
    //}


    if(ok)
        cout << "YES" << endl;
    else{
        cout << "NO" << endl;
    }

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}
#define sea 0
#define rand 1

int W, H;
vector<vector<int> > c;
vector<vector<bool> > memo;

int dw[8] = {0,1,1,1,0,-1,-1,-1};
int dh[8] = {1,1,0,-1,-1,-1,0,1};
void dfs(int h, int w){
    memo[h][w] = true;
    for(int i = 0; i < 8; i++){
        int next_h = h + dh[i];
        int next_w = w + dw[i];
        //地図の範囲外でないかの確認
        if(next_w < 0 || next_h < 0 || W <= next_w || H <= next_h)continue;
        //行き先が見探索であるか確認
        if(memo[next_h][next_w])continue;
        dfs(next_h, next_w);
    }
}

main(void) {
    while (true) {
        cin >> W >> H;
        if(W + H == 0)break;
        memo.resize(H);
        rep(h,H){
            memo[h].resize(W);
            rep(w,W)memo[h][w] = false;
        }
        c.resize(H);
        for(int h = 0; h < H; h++){
            c[h].resize(W);
            for(int w = 0; w < W; w++){
                cin >> c[h][w];
                if(c[h][w] == sea)memo[h][w] = true;
            }
        }
        int ans = 0;
        rep(h,H){
            rep(w, W){
                if(!memo[h][w]){
                    dfs(h, w);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3248
N = int(input())
A = [int(i) for i in input().split()]
print(' '.join([str(A[i]) for i in range(0, N)]))
for i in range(1, N):
    v = int(A[i])
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(' '.join([str(A[i]) for i in range(0, N)]))

Measured memory_bytes: 7716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARatedForMe solver = new ARatedForMe();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARatedForMe {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int r = in.nextInt();
            out.println(r < 1200 ? "ABC" : r < 2800 ? "ARC" : "AGC");
        }

    }
}



Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
long GCD(long x, long y){                                                                         
  if(y == 0) return x;
  else return GCD(y, x % y);
}

int main(){
  int N, i;
  long X;
  scanf("%d %ld", &N, &X);

  long x[N];
  for(i = 0; i < N; i++){
    scanf("%ld", &x[i]);
    x[i] = labs(x[i] - X); 
  }

  long gcd = x[0];
  for(i = 1; i < N; i++){
    gcd = GCD(gcd, x[i]);
  }
  
  printf("%ld\n", gcd);

  return 0;
}

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


bool hasNumber(string s){
  for(size_t i = 0; i < s.size(); i++)
    if(0 <= (s[i] - '0') && (s[i] - '0') <= 9)
      return true;
  return false;
}


bool hasUpper(string s){
  for(size_t i = 0; i < s.size(); i++)
    if(0 <= (s[i] - 'A') && (s[i] - 'A') < 26)
      return true;
  return false;
}


bool hasLower(string s){
  for(size_t i = 0; i < s.size(); i++)
    if(0 <= (s[i] - 'a') && (s[i] - 'a') < 26)
      return true;
  return false;
}


int main(void){
  string s;
  cin >> s;
  if(s.size() >= 6 && hasNumber(s) && hasUpper(s) && hasLower(s)){ cout << "VALID" << endl; }
  else{ cout << "INVALID" << endl; }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N+1];
    int i;
    for(i=1; i<=N; i++){
        cin >> a[i];
    }
    int counta=0;
    for(i=1; i<=N; i++){
        if((i%2==1)&&(a[i]%2==1)){
            counta++;
        }
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3680
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    ans=10**12
    tmp=[]
    for a in range(1,10**6+1):
        if n%a==0 and n >=a:
            b=n//a
        elif n <a:
            break
        #a,bの最小値を記憶してくれてる？
        ans=min(ans,a+b-2)
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9208
#include <iostream>
#include <iomanip>

using namespace std;

int main(void){

	int a,b,r;
	int tmp;
	double g,l;
	double tmpa,tmpb;

	while(cin>>a>>b){
		tmpa=a;
		tmpb=b;
		r=1;
		while(r){
			if(a<b){
				tmp=a;
				a=b;
				b=tmp;
			} 
			r=a%b; a=b; b=r;	
		}
		g=a;
		l=tmpa*tmpb/g;
		//cout.unsetf(ios::scientific);
		cout << fixed << setprecision(0) << g << ' ' << l << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli mod = 998244353;


lli factorial(lli n){
  static lli dp[300001];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

lli pow(lli x,lli r,lli mod = 998244353){
  lli ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

lli inverse(lli x,lli mod = 998244353){
  return pow(x,mod-2,mod);
}


lli combination(lli n,lli m,lli mod = 998244353){
  if(n < m) return 0;
  return (((factorial(n)*inverse(factorial(m)))%mod)*inverse(factorial(n-m)))%mod;
}


lli n,a,b,k;
lli ans = 0;

int main(){
  cin >> n >> a >> b >> k;
  for(lli i = 0;i <= n;i++){
    if(k-a*i < 0) break;
    if((k-a*i)%b == 0){
      if((k-a*i)/b <= n){
        lli red = i;
        lli blue = (k-a*i)/b;
        ans += (combination(n,red)*combination(n,blue))%mod;
        ans %= mod;
      }

    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    int k,s;
    cin >> k >> s;
    ll ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int c = s - i - j;
            if(i + j + c == s && c <= k && c >= 0){
                ans++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  long long ans = 0, x, k = K % 2 ? K : K / 2;
  for (int i = k; i <= N; i += k) {
    ans++;
    x = (N - i) / K;
    ans += 3 * x * (x + 1);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3576
N=int(input())
X=list(map(int,input().split()))

dp=[0 for i in range(100)]
i=1
for j in range(N):
    dp[0]+=(X[j]-0)**2

while True:
    for j in range(N):
        dp[i]+=(X[j]-i)**2
    if dp[i]>=dp[i-1]:
        break
    i+=1

ans=dp[i-1]
print(ans)

Measured memory_bytes: 63556
n, k = map(int, input().split())
s = input() + "#"
group = 0
count = 0
for i in range(n):
  if s[i] == s[i+1]:
    count += 1
  else:
    group += 1
if k >= group//2:
  print(n-1)
else:
  print(count + 2*k)

Measured memory_bytes: 3316
//                             In The Name Of Allah                                           
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
const int N = 1e6 + 100, OO = 1e9 + 7, T = 22, M = 1e9 + 7, P = 6151, SQ = 1300, lg = 22;
typedef pair <int, int> pii;
string s, t = "";
int n, p;

bool check(int k) {
	string g = t;
	p = 9 * k;
	int st = 0;
	while(p) {
		if((int)g.size() <= st)
			g += '0';
		p += (int)(g[st] - '0');
		g[st] = (int)((p % 10) + '0');
		st++;
		p /= 10;
	}
	int cnt = 0;
	for(auto u : g) 
		cnt += (int)(u - '0');
	return (cnt <= 9 * k);
}

int32_t main() {
	use_fast;
	cin >> s;
	n = (int)s.size();
	for(int i = (int)s.size() - 1; i >= 0; i--) {
		p += (int)(s[i] - '0') * 9;
		t += (char)((p % 10) + '0');
		p /= 10;
	}
	while(p) {
		t += (char)((p % 10) + '0');
		p /= 10;
	}
	int l = 0, r = n + 1;
	while(l < r) {
		int mid = (l + r) >> 1;
		if(check(mid))
			r = mid;
		else
			l = mid + 1;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 5128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

public class Program
{	static public void Main(string[] args)
	{
		string str = Console.ReadLine();
		string[] input = str.Split(' ');
		string a = input[0];
		string b = input[1];

		string A = "";
		for (int i = 0; i < int.Parse(b); i++)
		{
			A += a;
		}
		string B = "";
		for (int i = 0; i < int.Parse(a); i++)
		{
			B += b;
		}


		if (A[0] < B[0])
		{
			Console.WriteLine(A);
		}
		else
		{
			Console.WriteLine(B);
		}
	}
}


Measured memory_bytes: 11092
import itertools
import math

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
all_pattern = math.factorial(N)
sum_length = 0
for i in itertools.permutations(range(N)):  # 0, 1, 2
    current_len = 0
    for x in range(len(i) - 1):
        sumlen = (xy[i[x + 1]][0] - xy[i[x]][0]) ** 2 + \
            (xy[i[x + 1]][1] - xy[i[x]][1]) ** 2
        current_len += math.sqrt(sumlen)
    sum_length += current_len
ave_length = sum_length / all_pattern
print(ave_length)


Measured memory_bytes: 40812
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
const string d="dream";
const string e="erase";

int main() {
  int n;
  cin>>n;
  vector<int> D(109);
  rep(i,n)
    cin>>D.at(i);
  sort(D.begin(),D.end(),greater<int>());
  
  int ans=1;
  rep(i,n-1){
    if(D[i]>D[i+1]) ans++;
  }
  
  cout<<ans<<endl;
}


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

int N, V, C, x[200009], dp[200009][20], rev[200009][20], s1[1 << 20][20], s2[1 << 20], t[200009];
int val[1 << 20];

int main() {
	cin >> N >> V;
	for (int i = 1; i <= N; i++) cin >> x[i];
	int s = V;
	for (int i = 0; i < 20; i++) {
		C = i + 1;
		vector<int>X;
		for (int j = 1; j <= N - 1; j++) {
			if (x[j + 1] - x[j] > V) X.push_back(j);
		}
		X.push_back(N);
		for (int j = 1; j <= N; j++) {
			int pos1 = lower_bound(X.begin(), X.end(), j) - X.begin();
			dp[j][i] = X[pos1] + 1;
		}
		X.push_back(0); sort(X.begin(), X.end());
		for (int j = N; j >= 1; j--) {
			int pos1 = lower_bound(X.begin(), X.end(), j) - X.begin(); pos1--;
			rev[j][i] = X[pos1];
		}
		if (V == 0) break;
		V /= 2;
	}
	for (int i = 0; i < (1 << C); i++) { for (int j = 0; j < C; j++) s1[i][j] = -1; s2[i] = (1 << 30); }
	s1[0][0] = 1;
	for (int i = 0; i < (1 << C); i++) {
		for (int k = 0; k < C; k++) {
			if (s1[i][k] == -1) continue;
			for (int j = 0; j < C; j++) {
				if ((i / (1 << j)) % 2 == 1) continue;
				s1[i + (1 << j)][j] = max(s1[i + (1 << j)][j], dp[s1[i][k]][j]);
			}
		}
	}
	s2[0] = N;
	for (int i = 0; i < (1 << C); i++) {
		if (s2[i] == (1 << 30)) continue;
		for (int j = 0; j < C; j++) {
			if ((i / (1 << j)) % 2 == 1) continue;
			s2[i + (1 << j)] = min(s2[i + (1 << j)], rev[s2[i]][j]);
		}
	}
	vector<pair<int, int>>X, Y;
	for (int i = 0; i < (1 << C); i++) {
		if (i % 2 == 1) X.push_back(make_pair(s1[i][0], i / 2));
		if (i % 2 == 0) Y.push_back(make_pair(s2[i], i / 2));
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	for (int i = 0; i < X.size(); i++) val[X[i].second]++;
	int cx = 0, cy = 0; vector<int>B;
	for (int i = 1; i <= N; i++) {
		while (cx < X.size() && X[cx].first <= i) { val[X[cx].second]--; cx++; }
		while (cy < Y.size() && Y[cy].first <= i) {
			val[Y[cy].second ^ ((1 << (C - 1)) - 1)]++;
			if (val[Y[cy].second ^ ((1 << (C - 1)) - 1)] == 2) B.push_back(Y[cy].second ^ ((1 << (C - 1)) - 1));
			cy++;
		}
		while (B.size() >= 1) {
			if (val[B[B.size() - 1]] < 2) B.pop_back();
			else break;
		}
		if (B.size() >= 1) {
			t[rev[i][0] + 1]++;
			t[dp[i][0]]--;
		}
	}
	for (int i = 1; i <= N; i++) t[i] += t[i - 1];
	for (int i = 1; i <= N; i++) {
		if (t[i] >= 1) cout << "Possible" << endl;
		else cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 88868
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

S = input()
S = S.translate(str.maketrans("?", "D"))
print(S)


Measured memory_bytes: 9864
#include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::max;

int main()
{
  int W, H, N, x, y, a;

  cin >> W >> H >> N;

  int left = 0, right = W, bottom = 0, top = H;

  for(int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    switch(a) {
      case 1: // kill left
        if(x > left) {
          left = x;
        }
        break;
      case 2: // kill right
        if(x < right) {
          right = x;
        }
        break;
      case 3: // kill below
        if(y > bottom) {
          bottom = y;
        }
        break;
      case 4: // kill above
        if(y < top) {
          top = y;
        }
        break;
      default:
        break;
    }
  }

  int width = max(right - left, 0);
  int height = max(top - bottom, 0);

  cout << width * height << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, W;
ll weight[100005];
ll value[100005];
ll dp[101][100005];
ll ans(ll index,ll v){
    if(v <= 0 ){
        return 0;
    }
    if(index > n){
        return 1e10;
    }
    if(dp[index][v] != -1){
        return dp[index][v];
    }
    ll left = 1e10;
    if(v - value[index] >= 0){
        left = weight[index] + ans(index+1,v-value[index]);
    }
    ll right = ans(index+1,v);
    return dp[index][v] = min(left,right);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>W;
    ll total = 0;
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n;i++){
        cin>>weight[i]>>value[i];
        total += value[i];
    }
    for(ll i=total;i>=0;i--){
        ll k = ans(1,i);
        if(k <= W){
            cout<<i<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 80128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int main(){
    char S[100001];
    cin >> S;
    int N = strlen(S);
    int maxp = N/2;
    int currentP = 0;
    REP1(i,N){
        if (S[i] == 'p') {
            currentP++;
        }
    }
    cout << maxp-currentP << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
#define ll long long int

int main(){
  ll n, m, ans;
  cin >> n >> m;
  if ( n > 2 && m > 2) ans = (n - 2) * (m - 2);
  else if ( n == 2 || m == 2 ) ans = 0;
  else if ( n == 1 && m == 1 ) ans = 1; 
  else if ( n == 1 || m == 1 ) ans = max ( n - 2, m - 2 );

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


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    ll sa = 0, wa = 0;

    REP(i, n) {
        if(a[i] < b[i]) {
            sa += (b[i] - a[i]) / 2 * 2;
        } else {
            wa += (a[i] - b[i]) * 2;
        }
    }

    if(sa >= wa) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string.h>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
#define int long long
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)cout << 0;
	else {
		int ans = a*b;
		ans = min(ans, b*c);
		ans = min(ans, a*c);
		cout << ans;
	}
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <math.h>//pow,powl,powf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>


using namespace std;
using Graph = vector<vector<int>>;

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; }

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> As(A);
    for (int i = 0; i < A; i++) cin >> As.at(i);
    vector<int> Bs(B);
    for (int i = 0; i < B; i++) cin >> Bs.at(i);
    vector<vector<int>> Cs(M, vector<int>(3));
    for (int i = 0; i < M ; i++) {
        for (int j = 0; j < 3 ; j++) {
            cin >> Cs.at(i).at(j);
        }
    }
    int ans = 1000000007;
    int count = 0;
    for (int i = 0; i < M; i++) {
        count = As.at(Cs.at(i).at(0)-1) + Bs.at(Cs.at(i).at(1)-1) - Cs.at(i).at(2);
        ans = min(ans, count);
    }
    sort(As.begin(), As.end());
    sort(Bs.begin(), Bs.end());
    ans = min(ans, As.at(0) + Bs.at(0));
    cout << ans << endl;
}


Measured memory_bytes: 6528
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();
		int c = sc.nextInt();
		int count = 0;
		for(int i = a; i <= b; i++){
			if(c % i == 0){
				count++;
			}
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 26360
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x,a;
  cin >> x >> a;
  cout << (x<a?0:10) << endl;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, t;
	cin >> x >> t;
	
	if (x < t) {
		cout << 0 << endl;
	} else {
		cout << x - t << endl;
	}
}

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

int main() {
  std::string str;
  std::cin >> str;
  std::vector<std::string> check = {"maerd", "remaerd","esare","resare"};
  std::reverse(str.begin(), str.end());
  int flag = 0;
  for (int i=0; i<str.size();) {
    int temp_flag = 1;
    for (int j=0; j < 4; j++) {
      if (str.substr(i,check.at(j).size()) == check.at(j)) {
        temp_flag = 0;
        i += check.at(j).size();
        break;
      }
    }
    if (temp_flag) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    std::cout << "NO" << std::endl;
  }
  else {
    std::cout << "YES" << std::endl;
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <limits>

using namespace std;

int main() {
  long long int n;
  cin >> n;
  
  long long int rmax = numeric_limits<long long int>::min(), rmin = numeric_limits<long long int>::max(), rsum = 0;
  for(long long int i=0; i<n; i++) {
      long long int temp;
      cin >> temp;
      if(temp > rmax) {
          rmax = temp;
      }
      if(temp < rmin) {
          rmin = temp;
      }
      rsum += temp;
  }
  
  cout << rmin << " " << rmax << " " << rsum << endl;

  return 0;
}



Measured memory_bytes: 3096
n, m, q = map(int, input().split())
a = [0 for i in range(q)]
b = [0 for i in range(q)]
c = [0 for i in range(q)]
d = [0 for i in range(q)]
v = [0 for i in range(n)]
for i in range(q):
	a[i],b[i],c[i],d[i]=map(int,input().split())
import itertools
maxcnt = 0
for pair in itertools.combinations_with_replacement(range(1,m+1), n):
	cnt = 0
	for i in range(q):
		if pair[b[i]-1]-pair[a[i]-1] == c[i]:
			cnt += d[i]
	if maxcnt < cnt:
		maxcnt = cnt
print(maxcnt)

Measured memory_bytes: 68156
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	b := y - 2*x
	if b >= 0 && b%2 == 0 && x >= b/2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n+1];
   int count=0;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i];
       if(i%2==1&&a[i]%2==1)
       count++;
   }
   cout<<count;
   
   return 0;
}

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

// B - Easy Linear Programming
int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int sum = 0;
    int count = K;
    if (A >= K) {
        cout << K;
        return 0;
    }
    count -= A;
    sum += A;
    if (B >= count) {
        cout << sum;
        return 0;
    }
    count -= B;

    cout << sum - count;
}


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

int main() {
  int n, ans = 1;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size() - 1; i++) ans += s[i] != s[i + 1];
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		long A = in.nextLong();
		long B = in.nextLong();
		long C = in.nextLong();
		long K = in.nextLong();

		if(A - K > 0) {
			System.out.println(K);
			return;
		}

		else if(A + B - K > 0) {
			System.out.println(A);
		}
		else {
			System.out.println(A - (K - A - B));
		}


	}


	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35688
package main

import(
  "fmt"
)

func main() {
  var N,M int
  fmt.Scan(&N,&M)

  A := make([]int, N)
  sum := 0
  for v := range A{
	fmt.Scan(&A[v])
	sum += A[v]
  }

  var border int
  if sum%(4*M) == 0 {
	border = sum/(4*M) -1
  } else {
	border = sum/(4*M)
  }

  count := 0
  for _,v:= range A {
	if v >border {
	  count++
	}
  }

  if count >= M {
	fmt.Println("Yes")
  } else {
	fmt.Println("No")
  }
}


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

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

using namespace std;

int main() {
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;

  int ans = 0;
  rep(i, a + 1) {
    rep(j, b + 1) {
      rep(k, c + 1) {
        if ((500 * i + 100 * j + 50 * k) == x) {
          ans++;
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3604
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    c =  input()
    a = "abcdefghijklmnopqrstuvwxyz"
    for i in range(25):
        if a[i] == c:
            print(a[i+1])
            return

main()



Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,k,ans;
vll a,b;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    cin >> n;
    a.resize(3*n);
    rep(i,3*n) cin >> a[i];

    sort(ALL(a),greater<ll>());
    // sort(ALL(a));
    // rep(i,3*n) cout << a[i] << " ";
    // cout << endl;
    ans = 0;
    rep(i,2*n) {
        if(i%2==0) continue;
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

class MakeGraph:
    
    # 隣接行列もしくは隣接リストの初期化
    # node_num：ノード数
    # isMat：隣接行列(True) / 隣接リスト(False)
    def __init__(self, node_num:int, isMat:bool) -> None:
        self.n = node_num
        self.isMat = isMat

        # 隣接行列の初期化
        if self.isMat:
            INF = float("inf")
            self.graph = [[INF for _ in range(self.n)] for _ in range(self.n)]
    
        # 隣接リストの初期化
        else:
            self.graph = [[] for _ in range(self.n)]

    # エッジの追加
    # frm, to：起点ノード, 終点ノード
    # dist：frm→toへのコスト
    def add_undr_edge_mat(self, frm:int, to:int, dist:int) -> None:
        self.graph[frm][to] = dist
        self.graph[to][frm] = dist
        
    def add_drct_edge_mat(self, frm:int, to:int, dist:int) -> None:
        self.graph[frm][to] = dist
        
    def add_undr_edge_lst(self, frm:int, to:int, dist:int) -> None:
        self.graph[frm].append((dist, to))
        self.graph[to].append((dist, frm))
        
    def add_drct_edge_lst(self, frm:int, to:int, dist:int) -> None:
        self.graph[frm].append((dist, to))

                
    # 完成したグラフを取り出す
    def get_graph(self) -> list:
        return self.graph

# 入力    
N,M = map(int, input().split())
ABC = []
for i in range(M):
    ABC.append(tuple(map(int, input().split())))
    
#file = open("sampleABC051D.txt", "r")
#
#N,M = map(int, file.readline().split())
#ABC = []
#for i in range(M):
#    ABC.append(tuple(map(int, file.readline().split())))
    
graphMaker = MakeGraph(N,False)
add_edge = graphMaker.add_undr_edge_lst

for a,b,c in ABC:
    add_edge(a-1, b-1, c)

graph = graphMaker.get_graph()

dist = []
for i in range(N):
    dist_temp = dijkstra(graph, N, i)
    dist.append(dist_temp)
    
ans = 0
for i in range(N):
    for cost, node in graph[i]:
        if dist[i][node] != cost:
            ans += 1
            
            
print(ans//2)



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

int main() {
  vector<string> grid;
  int h, w, count=0;
  cin >> h >> w;
  string extra(w+2,'.');
  string row, temp;
  grid.push_back(extra);
  for (int i=0; i<h; i++) {
    cin >> temp;
    row = "." + temp + ".";
    grid.push_back(row);
  }
  grid.push_back(extra);
  for (int i=1; i<=h; i++) {
    for (int j=1; j<=w; j++) {
      if (grid[i][j]=='#') cout << "#";
      else {
        count = 0;
        for (int k=-1; k<=1; k++) {
          for (int l=-1; l<=1; l++) {
            if (grid[i+k][j+l]=='#') count++;
          }
        }
        cout << count;
      }
    }
    cout << endl;
  }
  //for (auto i : grid) cout << i << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
 
int main(){
  int n,d;
  cin >> n >> d;
  int ans;
  ans =  (n+2*d)/(2*d+1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (int argc,char **argv)
{
	int n,a,b;
	int x = 0;

	scanf("%d %d %d",&n,&a,&b);

	x = a * n;

	if(x <= b)
	{
		printf("%d\n",x);
	}

	else 
	{
		printf("%d\n",b);
	}

}

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

int main() {
  int h,w;
  cin>>h>>w;
  char a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  int l[h][w],r[h][w],u[h][w],d[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#') l[i][j]=0;
      else if(j==0) l[i][j]=1;
      else l[i][j]=l[i][j-1]+1;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=w-1;j>=0;j--){
      if(a[i][j]=='#') r[i][j]=0;
      else if(j==w-1) r[i][j]=1;
      else r[i][j]=r[i][j+1]+1;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#') d[i][j]=0;
      else if(i==0) d[i][j]=1;
      else d[i][j]=d[i-1][j]+1;
    }
  }
  for(int i=h-1;i>=0;i--){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#') u[i][j]=0;
      else if(i==h-1) u[i][j]=1;
      else u[i][j]=u[i+1][j]+1;
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    }
  }
  cout<<ans<<endl;
  
  /*int b[h][w];
  int c[h][w];
  for(int i=0;i<h;i++){
    int d=-1;
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        for(int k=d+1;k<j;k++){
          b[i][k]=j-d-1;
        }
        b[i][j]=0;
        d=j;
      }
    }
    for(int j=d+1;j<w;j++){
      b[i][j]=w-d-1;
    }
  }
  
  for(int i=0;i<w;i++){
    int d=-1;
    for(int j=0;j<h;j++){
      if(a[j][i]=='#'){
        for(int k=d+1;k<j;k++){
          c[k][i]=j-d-1;
        }
        c[j][i]=0;
        d=j;
      }
    }
    for(int j=d+1;j<h;j++){
      c[j][i]=h-d-1;
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,b[i][j]+c[i][j]);
    }
  }
  cout<<ans-1<<endl;*/
}


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

#define PB emplace_back
#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1e6 + 100;

long long int inter(long long int l1, long long int r1, long long int l2, long long int r2) {
    long long int ret = r1 - l1 + 1 + r2 - l2 + 1;
    long long int l = max(l1, l2), r = min(r1, r2);
    return ret - max(0ll, r - l + 1);
}

int main () {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    long long int a, b;
    cin >> a >> b;
    for(long long int i = 60 ; i >= 0 ;  i--) {
        if((a & (1LL << i)) && (b & (1LL << i))) a -= (1LL << i), b -= (1LL << i);
        else if(b & (1LL << i)) break;
    }
    long long int bi = 0;
    if(a == b) return cout << 1,0;
    for(long long int i = 0 ; i <= 60 ; i++ ) {
        if((1LL << i) & b) bi = i;
    }
    long long int t = (1LL << bi);
    long long int ans = t - 1 - a + 1, bi2 = -1;
    for(long long int i = bi - 1 ; i >= 0 ; i-- ) {
        if((1LL << i) & b) {
            bi2 = i;
            break;
        }
    }
    cout << ans + inter(t, t + ((1LL << (bi2 + 1)) - 1), a + t, 2 * t - 1);
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[])
{
	char str1[11], str2[12];
	scanf("%s %s", &str1, &str2);
	str2[strlen(str2) - 1] = '\0';
	if(strcmp(str1, str2) == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
using namespace std;
int main(){
	int n,x,sum;
		for(;;){
		cin>>n>>x;
		if(n==0&&x==0)
			break;
		sum=0;
    for(int i=1;i<n+1;i++){
      for(int j=i+1;j<n+1;j++){
    for(int k=j+1;k<n+1;k++){
      if((i+k+j)==x)sum++;
    }
      }
    }
    cout<<sum<<endl;

		}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  double a, b, h;
  cin >> a >> b >> h;
  
  cout << (a + b) * h / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

vector<int> lcs(vector<int> a, vector<int> b) { // O(nm)
  int n = a.size();
  int m = b.size();
  int dp[n+1][m+1];
  int f[n+1][m+1];
  REP(i,n) {
    REP(j,m) {
      if (a[i] == b[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
        f[i+1][j+1] = 0;
      } else if (dp[i+1][j] > dp[i][j+1]) {
        dp[i+1][j+1] = dp[i+1][j];
        f[i+1][j+1] = 1;
      } else {
        dp[i+1][j+1] = dp[i][j+1];
        f[i+1][j+1] = -1;
      }
    }
  }
  vector<int> res;
  for (int i=n, j=m; i>0&&j>0;) {
    if (f[i][j]>0) --j;
    else if (f[i][j]<0) --i;
    else {--i;--j;res.push_back(a[i]);}
  }
  reverse(ALL(res));
  return res;
}
int dp[300][300];
int f[300][300];

int main() {
  string s;
  while(cin >> s, s != "#END") {
    int ma = 0;
    string ans;
    for (int i=1; i<s.size(); ++i) {
      string a = s.substr(0, i);
      string b = s.substr(i);
      int n = a.size(), m = b.size();
      REP(j,n+1) dp[j][0] = 0;
      REP(j,m+1) dp[0][j] = 0;
      REP(j,n) {
        REP(k,m) {
          if (a[j] == b[k]) {
            dp[j+1][k+1] = dp[j][k] + 1;
            f[j+1][k+1] = 0;
          } else if (dp[j+1][k] > dp[j][k+1]) {
            dp[j+1][k+1] = dp[j+1][k];
            f[j+1][k+1] = 1;
          } else {
            dp[j+1][k+1] = dp[j][k+1];
            f[j+1][k+1] = -1;
          }
        }
      }
      if (dp[n][m] > ma) {
        ma = dp[n][m];
        ans = "";
        for (int j=n, k=m; j>0&&k>0;) {
          if (f[j][k]>0) --k;
          else if (f[j][k]<0) --j;
          else {--j;--k; ans+=string(1,a[j]);}
        }
        reverse(ALL(ans));
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
    int H, W;
    cin >> H >> W;
    while(H!=0 && W!=0){
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
            cout << "#";
            }
        cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3096
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: SpeedForces #2
#pragma GCC optimize ("trapv")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

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

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
ll n,m;
int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n >> m;
	if (n == 1) {
		cout << m;
		return 0;
	}
	vector< ll > divs;
	for (ll i=1; i*i<=m; i++) {
		if (m % i == 0) {
			divs.pb(i);
			if (i != m/i) 
				divs.pb(m/i);
		}
	}
	
	ll mxv = 1;
	
	for (auto& e:divs) {
		if ((((m-(e*(n-1))) % e)+e)%e == 0 && (m-(e*(n-1))) > 0) {
			mxv = max(mxv, e);
		}
	}
	
	cout << mxv;
	
	return 0;
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
N, W = map(int, input().split())
H = []
H.append([0,0])
for _ in range(N) :
  S = str(input())
  H.append(list(map(int, S.split())))
#index
Hw = 0
Hv = 1
 
#print (H)
Vmax = (10**3) * N
#Vmax = (60) * N
 
#合計価値viのときの最小重量
dp = [[sys.maxsize for _ in range(Vmax+1)] for _ in range(N+1)]

for i in range(1, N+1) :
  #Niのvの反映
  dp[i][H[i][Hv]] = min(H[i][Hw], dp[i][H[i][Hv]])
  #VjのときにNiを選んだ場合/選ばない場合
  for j in range(Vmax+1) :
    if dp[i-1][j] != sys.maxsize :
      #Niを選ばないとき
      dp[i][j] = min(dp[i-1][j], dp[i][j])
      #Niを選ぶとき
      if (j + H[i][Hv]) <= Vmax+1 :
        dp[i][j + H[i][Hv]] = min(dp[i-1][j] + H[i][Hw], dp[i][j + H[i][Hv]])
        
  #print (dp[i][:])
  """
  out = copy.deepcopy(dp[i][:])
  line = ""
  for x in range(len(out)) :
      if out[x] == sys.maxsize :
        line += "_" + "\t"
      else :    
        line += str(out[x]) + "\t"
  print(line)
  """

for k in range(Vmax) :
  if dp[N][Vmax-k] <= W :
    print(Vmax-k)
    exit()
    

Measured memory_bytes: 171016