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

using namespace std;
using ll = long long;

int main(void){
    ll ans = 0;
    ll left = 0; //次にWを持ってこれる位置
    string S;
    cin >> S;
    int lenS = S.length();
    for(int i=0; i<lenS; i++){
        if (S.at(i) == 'W'){
            ans += (i-left);
            left++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    int sum = 0;
    for (int i = 0; i < N; i++) sum += a[i];
    int ave = sum / N;
    int cost1 = 0;
    for (int i = 0; i < N; i++) cost1 += (a[i] - ave) * (a[i] - ave);
    int cost2 = 0; ave++;
    for (int i = 0; i < N; i++) cost2 += (a[i] - ave) * (a[i] - ave);
    cout << min(cost1, cost2) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    static char [] letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            int n = Integer.parseInt(sc.nextLine());
            for(int i=0;i<n;i++) {
                String str = sc.nextLine();
                ab(str);
            }
        }
    }
    
    static void ab(String str) {
        loop:for(int a=0;a<10000;a++) {
            for(int b=0;b<26;b++) {
            	if(a%2==0 || a%13==0 || a%26==0) continue loop;
                if(check(change(str,a,b))) {
                    return;
                }
            }
        }
    }
     
    static String change(String str,int a,int b) {
        StringBuffer ans = new StringBuffer();
        for(int j=0;j<str.length();j++) {
            if(str.charAt(j)==' ') {
                ans.append(" ");
            }else {
                int x = Arrays.binarySearch(letters, str.charAt(j));
                int f = (a*x+b)%26;
                ans.append(letters[f]);
            }
        }
        return ans.toString();
    }
     
    static boolean check(String ans) {
        for(int k=0;k<ans.length()-3;k++) {
            String key = ans.substring(k,k+4);
            if(key.equals("that") || key.equals("this")) {
                System.out.println(ans);
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 35332
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    string s;
    cin >> s;
    //処理
    int ans=0;
    REP(i,0,s.length()-1){
        if(s[i]!=s[i+1]) ans++;
    }
    //出力
    cout << ans << ENT;
    return 0;
}

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


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



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

    vi a(n);
    VIN(a);

    sort(ALL(a));

    int mx = a[n-1];

    int sa=IINF;
    int ans=mx;
    FORR(i,0,n-1){
        if(sa > abs(mx/2 - a[i])){
            sa = abs(mx/2 - a[i]);
            ans = a[i];

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

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define il inline
#define rg register
#define ldb double
#define lst long long
#define rgt register int
#define N 100050
using namespace std;
const int Inf=1e9;
il int MAX(rgt x,rgt y){return x>y?x:y;}
il int MIN(rgt x,rgt y){return x<y?x:y;}
il int read()
{
	int s=0,m=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')m=1;ch=getchar();}
	while( isdigit(ch))s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return m?-s:s;
}

int n,K;
vector<int> V[N];

int main()
{
	n=read();
	for(rgt k=1;k<=n+1;++k)
		if(k*(k-1)/2==n)K=k;
	if(!K)puts("No");
	else
	{
		rgt tot=1;
		for(rgt i=1;i<K;++i)
			for(rgt j=i+1;j<=K;++j)
			{
				V[i].push_back(tot);
				V[j].push_back(tot);
				++tot;
			}
		puts("Yes");
		printf("%d\n",K);
		for(rgt i=1;i<=K;++i)
		{
			rgt Sz=V[i].size();
			printf("%d ",Sz);
			for(rgt j=0;j<Sz-1;++j)
				printf("%d ",V[i][j]);
			printf("%d\n",V[i][Sz-1]);
		}
	}
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
using namespace std;
#include<stack>
int main(){
  stack<int> s;
  char a[20];
  int tmp=0;
  while(1){
    cin>>a;
    if (cin.eof())
      break;
    if(a[0]=='+'){
      int tmp1=s.top();
      s.pop();
      int tmp2=s.top();
      s.pop();
      s.push(tmp1+tmp2);
    }else if(a[0]=='-'){
      int tmp1=s.top();
      s.pop();
      int tmp2=s.top();
      s.pop();
      s.push(tmp2-tmp1);
    }else if(a[0]=='*'){
      int tmp1=s.top();
      s.pop();
      int tmp2=s.top();
      s.pop();
      s.push(tmp1*tmp2);
    }else{
      int i=0;
      while(1){
        tmp=tmp*10+static_cast<int>(a[i])-48;
        i++;
        if(a[i]=='\0')
          break;
      }
      s.push(tmp);
      tmp=0;
    }
  }
  cout<<s.top()<<endl;
  return 0;
}



Measured memory_bytes: 3100
n,m=map(int,input().split())
mod=10**9+7
def f(l):
  a=1
  for i in range(1,l+1):
    a=a*i
    a=a%mod
  return a%mod
d=abs(n-m)
if d>1:
  print(0)
elif d==1:
  print((f(m)*f(n))%mod)
else:
  print(((f(m)*f(n))*2)%mod)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);

using namespace std;

int masu[10000];


int main(){
	while(1){
		int n,m;
		sintt(n,m);
		
		if(n==0)break;
		
		rep(i,10000){
			masu[i]=0;
		}
		
		
		rep(i,n){
			rep(j,m){
				int a;
				sint(a);
				masu[j]+=a<<i;
			}
		}
		
		
		int maxi=0;
		
		rep(i,1<<n){
			int cont=0;
			rep(j,m){
				int cont2=0;
				//printf("%d-",masu[j]^i);
				rep(k,n){
					if(i>i<<k)break;
					//printf("%d",(masu[j]^i)&(1<<k));
					if(((masu[j]^i)&(1<<k))>0){
						cont2++;
					}
				}
				//printf("-%d ",cont2);
				cont+=max(cont2,n-cont2);
			}//puts("");
			maxi=max(maxi,cont);
		}
		
		
		printf("%d\n",maxi);
	}
}
/*
3 6
1 0 0 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1 

*/

Measured memory_bytes: 916
#include <iostream>
using namespace std;
int main(){
    char a[5];
    int ans=0;
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    if(a[0]=='1')ans++;
    if(a[1]=='1')ans++;
    if(a[2]=='1')ans++;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		long A[] = new long[N];
		long B[] = new long[M];
		int ans = 0;
		A[0] = sc.nextLong();
		for(int i = 1; i < N; i++) {
			A[i] = sc.nextLong() + A[i - 1];
		}
		if(A[N - 1] <= K) ans = N;
		B[0] = sc.nextLong();
		for(int i = 1; i < M; i++) {
			B[i] = sc.nextLong() + B[i - 1];
		}
		if(B[M - 1] <= K) ans = Math.max(ans, M);
		long time = 0;
		int cnt = M - 1;
		out : for(int i = 0; i <= N; i++) {
			if(i != 0) {
				time = A[i - 1];
				if(time > K) {
					continue;
				}
			}
			for(int j = cnt; j >= 0; j--) {
				if(time + B[j] <= K) {
					ans = Math.max(ans, i + j + 1);
					cnt = j;
					continue out;
				} else {
					cnt = j;
				}
			}
		}
		System.out.println(ans);
	}
}


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



//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define ek cout<<1<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
//const ll fx[]={0,1,0,-1};
//const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/

void oka()
{

        ll a,b;
        cin>>a>>b;
        string s1="",s2="";
        char x,y;
        x=a+'0';
        y=b+'0';
        while(a--)
            s1+=y;
        while(b--)
            s2+=x;
        if(s1>s2)
            cout<<s2<<endl;
        else
            cout<<s1<<endl;


}












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

    run
    ll t;
    t=1;
  //cin>>t;
    while(t--){

    oka();
    }



}



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

int main() {
  ll h, w;
  cin >> h >> w;
  vector <vector <ll>> v(10, vector <ll> (10));
  rep(i, 10) {
    rep(j, 10) {
      cin >> v.at(i).at(j);
    }
  }
  rep(k, 10) {
    rep(i, 10) {
      rep(j, 10) {
        v.at(i).at(j) = min(v.at(i).at(j), v.at(i).at(k)+v.at(k).at(j));
      }
    }
  }
  ll res = 0;
  rep(i, h) {
    rep(j, w) {
      ll a;
      cin >> a;
      if (a == -1) continue;
      else res += v.at(a).at(1);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

const int m = 10;
int dp[(1<<m)+1][100001];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=(1<<m);i++){
        if(i > n)break;
        int nx = i/2;
        for(int j=0;j<=100000;j++){
            chmax(dp[i][j],dp[nx][j]);
            if(j+b[i] <= 100000)chmax(dp[i][j+b[i]],dp[nx][j]+a[i]);
            if(j)chmax(dp[i][j],dp[i][j-1]);
        }
    }
    int q;
    cin>>q;
    while(q--){
        int v,l;
        cin>>v>>l;
        if(v <= (1<<m)){
            cout << dp[v][l] << "\n";
            continue;
        }
        // v,v/2,...
        int ans = 0;
        queue<array<int,3>> que;
        que.push({v,0,0});
        while(que.size()){
            array<int,3> now = que.front();
            que.pop();
            int w = now[1],val = now[2],p = now[0];
            if(p <= (1<<m)){
                chmax(ans,dp[p][l-w]+val);
            }
            else{
                if(w+b[p] <= l)que.push({p/2,w+b[p],val+a[p]});
                que.push({p/2,w,val});
            }
        }
        cout << ans << "\n";
    }
    
}


Measured memory_bytes: 405240
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 n;
string l;
vector<array<i64, 2>> dp;

i64 g(i64 i, bool f) {
  if (i < 0) return 1;
  if (dp[i][f] > 0) return dp[i][f];
  i64 y;
  if (f) {
    if (l[i] == '0') y = g(i - 1, true) % mod;
    else y = (2 * g(i - 1, true) + g(i - 1, false)) % mod;
  } else {
    y = 3 * g(i - 1, false) % mod;
  }
  return dp[i][f] = y;
}

int main() {
  cin >> l;
  n = l.size();
  reverse(begin(l), end(l));
  init_n(dp, n);

  cout << g(n - 1, true) << '\n';
  return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

void dfs(int pos, int per_color);

vector<int> tree[SIZE];
bool isvisit[SIZE];
map<P, int> mp;
int mx = 0;

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

    int N;
    cin >> N;
    vector<P> edge;
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        tree[a].pb(b);
        tree[b].pb(a);
        if(a > b) swap(a, b);
        edge.pb(MP(a, b));
    }

    dfs(1, -1);
    set<int> st;
    for(int i = 0; i < N - 1; ++i) {
        st.insert(mp[MP(edge[i].F, edge[i].S)]);
    }

    cout << st.size() << endl;
    for(int i = 0; i < N - 1; ++i) {
        cout << mp[MP(edge[i].F, edge[i].S)] << endl;
    }

    return 0;
}

void dfs(int pos, int per_color) {
    if(isvisit[pos]) return;
    isvisit[pos] = true;

    int c = 1;
    for(int i = 0; i < tree[pos].size(); ++i) {
        if(isvisit[tree[pos][i]]) continue;
        if(c == per_color) ++c;
        int a, b;
        a = pos, b = tree[pos][i];
        if(a > b) swap(a, b);
        mp[MP(a, b)] = c;
        dfs(tree[pos][i], c);
        ++c;

    }
    return;
}



Measured memory_bytes: 18300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl;
#define all(v) v.begin(), v.end()


int main() {
  int N;
  cin >> N;
  print((10000-N)%1000);
  return 0;
}

Measured memory_bytes: 3632
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (A, B): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = *vec![A + B, A - B, A * B].iter().max().unwrap();

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


Measured memory_bytes: 4352
x=input()
x=int(x)
if x>=400 and x<600:
  rank=8
elif 600<=x and x<800:
  rank=7
elif 800<=x and x<1000:
  rank=6
elif 1000<=x and x<1200:
  rank=5
elif 1200<=x and x<1400:
  rank=4
elif 1400<=x and x<1600:
  rank=3
elif 1600<=x and x<1800:
  rank=2
elif 1800<=x and x<2000:
  rank =1
print(rank)


Measured memory_bytes: 9180
#include <stdio.h>
int h,w,n,x,y,f[1005][1005],dp[1005][1005];
int main(){
	for(;;){
		scanf("%d%d%d",&h,&w,&n);if(!h) return 0;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)scanf("%d",&f[i][j]),dp[i][j]=0;
		dp[1][1]=n;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
			if(i>=2) dp[i][j]+=(dp[i-1][j]+!f[i-1][j])/2;
			if(j>=2) dp[i][j]+=(dp[i][j-1]+f[i][j-1])/2;
		}
		for(x=1,y=1;x<=h&&y<=w;){ if((f[x][y]^dp[x][y])&1) x++; else y++;}
		printf("%d %d\n",x,y);
	}
}

Measured memory_bytes: 8904
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const lim = 100
const lim2 = 50

func main() {
	sc.Split(bufio.ScanWords)
	A, B := getInt(), getInt()
	a := A - 1
	b := B - 1
	// white block
	fmt.Println(((a+lim2-1)/lim2+(b+lim2-1)/lim2)*2+2, lim)
	h := (a + lim2 - 1) / lim2

	for x := 0; x < lim; x++ {
		fmt.Print("#")
	}
	fmt.Println()
	for y := 0; y < h; y++ {
		for x := 0; x < lim; x += 2 {
			if a > 0 {
				fmt.Print(".#")
				a--
			} else {
				fmt.Print("##")
			}
		}
		fmt.Println()
		for x := 0; x < lim; x++ {
			fmt.Print("#")
		}
		fmt.Println()
	}
	// Black
	h = (b + lim2 - 1) / lim2
	for y := 0; y < h; y++ {
		for x := 0; x < lim; x++ {
			fmt.Print(".")
		}
		fmt.Println()
		for x := 0; x < lim; x += 2 {
			if b > 0 {
				fmt.Print("#.")
				b--
			} else {
				fmt.Print("..")
			}
		}
		fmt.Println()
	}
	for x := 0; x < lim; x++ {
		fmt.Print(".")
	}
	fmt.Println()
}


Measured memory_bytes: 1836
#include <stdio.h>

int leap_year(int y)
{
	if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)){
		return (1);
	}
	else {
		return (0);
	}
}

int main(void)
{
	int m_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int ny, nm, nd, ty, tm, td, cnt;
	
	while (1){
		cnt = 0;
		
		scanf("%d %d %d %d %d %d", &ny, &nm, &nd, &ty, &tm, &td);
		
		if (ny == -1 || nm == -1 || nd == -1 || ty == -1 || tm == -1 || td == -1){
			break;
		}
		
		while (ny != ty || nm != tm || nd != td){
			if (leap_year(ny)){
				m_days[2 - 1] = 29;
			}
			else {
				m_days[2 - 1] = 28;
			}
			
			nd++;
			
			if (nd > m_days[nm - 1]){
				nd = 1;
				nm++;
			}
			
			if (nm > 12){
				nm = 1;
				ny++;
			}
			
			cnt++;
		}
		
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

using lint = long long;

int main() {

    int N;
    std::cin >> N;
    std::vector<lint> A(N);
    std::vector<std::vector<int>> graph(N);
    rep (i, N) std::cin >> A[i];
    rep (i, N - 1) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    if (N == 2) {
        std::cout << (A[0] == A[1] ? "YES" : "NO") << '\n';
        return 0;
    }

    bool answer = true;
    std::function<lint(int, int)> dfs = [&] (const int& v, const int& prev) {
        if (graph[v].size() == 1) return A[v];
        lint max = 0, sum = 0;
        for (const int& u : graph[v]) {
            if (u == prev) continue;
            lint tmp = dfs(u, v);
            chmax(max, tmp);
            sum += tmp;
        }
        chmax(max, (sum + 1) / 2);
        if (A[v] < max || A[v] > sum) {
            answer = false;
        }
        return sum - (sum - A[v]) * 2;
    };

    rep (i, N) {
        if (graph[i].size() > 1) {
            if (dfs(i, -1) != 0) answer = false;
            break;
        }
    }
    std::cout << (answer ? "YES" : "NO") << '\n';
    return 0;

}


Measured memory_bytes: 14464
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
B = [0]*(N+1)

for i in range(N//2+1,N+1):
    B[i] = A[i]

for i in range(N//2):
    Li = B[N//2-i::N//2-i]
    B[N//2-i] = [1,0][sum(Li)%2==A[N//2-i]]

B.pop(0)

print(sum(B))
ans=[]
for i in range(len(B)):
    if B[i]==1:
        ans.append(i+1)

print(*ans)

Measured memory_bytes: 16056
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long N;
    cin >> N;
    
    auto max = static_cast<long>(sqrt(N));
    for( long A = max; A > 0; --A ){
        if( N%A == 0 ){
            long B = N/A;
            cout << A+B-2 << endl;
            break;
        }
    }
    
    
    return 0;
}

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

using namespace std;

int main() {
    unordered_set<char> vowel;
    vowel.insert('a');
    vowel.insert('e');
    vowel.insert('i');
    vowel.insert('o');
    vowel.insert('u');
    char c;
    cin >> c;
    if (vowel.find(c) != vowel.end()) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc154/tasks/abc154_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    unordered_set<int> st;
    REP(i, N) {
        int t;
        cin >> t;
        st.insert(t);
    }
    if (st.size() == N) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<string>vec(a);
  vector<ll>veco(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i)>>veco.at(i);
  }
  vector<ll>new1(a);
  for(ll i=0;i<a;i++){
    ll b=0;
    for(ll j=0;j<a;j++){
      if(vec.at(j)<vec.at(i)){
        b+=1;
        
      }
      else if(vec.at(i)==vec.at(j)){
        if(veco.at(j)>veco.at(i)){
          b+=1;
        }
      }
    }
    new1.at(b)=i+1;
  }
  for(ll i=0;i<a;i++){
    cout<<new1.at(i)<<endl;
  }
  
  return 0;
    
  
      
  
  
    
}

Measured memory_bytes: 3632
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ct = 0
for i in range(1, n+1):
    head = i%10
    if head == 0:
        continue
    k = i
    tail = 0
    while k > 0:
        tail = k%10
        k //= 10
    if head == tail:
        if head <= n:
            ct += 1
    # (head)...(tail)
    d = 10
    while d <= n:
        # head*d + tail
        if n >= (head+1)*d:
            ct += d//10
        elif n < head*d:
            pass
        else:
            ct += (n-head*d-tail+10)//10
        d *= 10
print(ct)


Measured memory_bytes: 42476
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = int(raw_input())
s = raw_input()
con = {'R':0,'B':1,'G':2}
r_dict = [[0, 0, 0] for i in range(n)]
r_dict[n - 1][con[s[n - 1]]] = 1
for i in range(n - 2,-1,-1):
    for j in range(3):
        r_dict[i][j] = r_dict[i + 1][j]
    r_dict[i][con[s[i]]] += 1
ans = 0
for i in range(n):
    f = s[i]
    for j in range(i + 1,n):
        if s[j] != s[i]:
            se = s[j]
            gap = j - i
            if 'R' != f and 'R' !=se:
                th= 'R'
            elif 'B' != f and 'B' != se:
                th = 'B'
            else:
                th = 'G'
            #print(f,se,th,i,j)
            ans += r_dict[j][con[th]]
            if j + gap < n and s[j + gap] == th:
                ans -= 1
        
print ans
#print('No')
#print()


Measured memory_bytes: 73668
n,m=map(int,input().split())
if(m>n):
    c=m-n
    print(min(c,n))
else:
    if(n%m==0):
        print('0')
    else:
        c=n%m
        print(min(c,m-c))
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

ll ans;

int main(void) {
    ll a, b, n;
    cin >> a >> b >> n;
    ll t = 0;
    if (n<=b-1) t = n;
    else t = b-1;
    
    ans = ((t*a)/b) - a * (t/b);

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3568
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        int stop = -1;

        PrintWriter out = new PrintWriter(System.out);

        if (X == 2) {
            out.println(2);
            sc.close();
            out.flush();
            return;
        }

        while (true) {
            stop = -1;

            for (int i = 2; i < X; i++) {
                if (X % i == 0) {
                    stop = 0;
                    break;
                }
            }

            if (stop == 0) {
                X++;
            } else {
                break;
            }
        }

        out.println(X);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int T = 0;
  for( int i = 0; i < N; i++ ){
    cin >> A[i];
    if( i == 0 ) T = A[0];
    else T = T^A[i];
  }
  for( int i = 0; i < N; i++ ){
    int ans = T^A[i];
    cout << ans << " ";
  }
}


Measured memory_bytes: 4732
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R = INT()
G = INT()
print(2*G-R)

Measured memory_bytes: 5704
n = int(input())
B = list(map(int, input().split()))
A = [0]*n

MX = 100001

for i in range(n-1):
	A[i] = B[i]
A[n-1] = MX
for i in range(n-1):
	A[i+1] = min(A[i+1], B[i])
print(sum(A))

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

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

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

int main() {
  int L,R, A,B,C,D;
  cin >> A >> B >> C >> D;
 L = A+B;
R =  C+D;
 
if(L > R){
     cout << "Left" <<endl;
}else if(L<R){
     cout << "Right" <<endl;
  }else{
     cout << "Balanced" <<endl;
}

}

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

const int maxn = (int)1e5 + 3;
int n, a[maxn];

LL solve() {
	static LL b[maxn];
	b[n] = 0;
	for(int i = n; i > 0; --i)
		b[i - 1] = b[i] + a[i];
	LL ret = 0, cur = 1;
	for(int i = 0; i <= n; ++i) {
		if(cur < a[i])
			return -1;
		ret += cur;
		cur -= a[i];
		if(cur > b[i])
			return -1;
		cur = min(cur << 1, b[i]);
	}
	return !cur ? ret : -1;
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i <= n; ++i)
		scanf("%d", a + i);
	printf("%lld\n", solve());
	return 0;
}

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

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxN = 5005, mod = 1e9 + 7;

int dp[maxN][maxN][2], sz[maxN], las[maxN][2];
int f[maxN], g[maxN];
vector <int> adj[maxN];

int power(int a, int b)
{
	if(b == 0) return 1;
	ll res = power(a, b/2);
	res *= res, res %= mod;
	if(b & 1) res *= a, res %= mod;
	return res;
}

void DFS(int v, int par = -1)
{
	dp[v][1][0] = 1;
	sz[v] = 1;

	for (auto u : adj[v])
	{
		if(u == par) continue ;
		DFS(u, v);
		

		for (int i=1; i<=sz[v]; i++) las[i][0] = dp[v][i][0], las[i][1] = dp[v][i][1], dp[v][i][0] = dp[v][i][1] = 0;

		for (int i=1; i<=sz[v]; i++)
			for (int j=1; j<=sz[u]; j++)
			{
				for (int k=0; k<2; k++)
					for (int kk=0; kk<2; kk++)
					{
						ll w = 1LL * las[i][k] * (1LL * dp[u][j][kk] % mod) % mod;
						dp[v][i + j][k ^ kk] += w, dp[v][i + j][k ^ kk] %= mod;
					
						if(j & 1) continue; 
						w = 1LL * las[i][k] * (1LL * dp[u][j][kk] * f[j] % mod) % mod;
						dp[v][i][k ^ kk ^ 1] += w, dp[v][i][k ^ kk ^ 1] %= mod;
						

					}
			}

		sz[v] += sz[u];

	}

	/*cout << v << endl;
	for (int i=1; i<=sz[v]; i++)
		cout << i << " :: " << dp[v][i][0] << ',' << dp[v][i][1] << endl;
	*/

	return ;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int i=0; i<n-1; i++)
	{
		int u, v; cin >> u >> v;
		u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	for (int i=0; i<maxN; i++) f[i] = g[i] = 1;
	
	f[2] = 1;
	for (int i=4; i<maxN; i += 2) f[i] = 1LL * (i - 1) * f[i - 2] % mod;
	
	for (int i=2; i<maxN; i += 2) g[i] = power(f[i], mod - 2);
	
	DFS(0);

	ll ans = 0;

	for (int i=1; i<=n; i++) {
		dp[0][i][0] = 1LL * dp[0][i][0] * f[i] % mod;
		dp[0][i][1] = 1LL * dp[0][i][1] * f[i] % mod;
		
		//cout << i << endl;
		//cout << dp[0][i][0] << ',' << dp[0][i][1] << endl;

		if(i & 1) continue;
		
		ans += dp[0][i][0], ans %= mod;
		ans += mod - dp[0][i][1], ans %= mod;

	}

	cout << ans << endl;

}

Measured memory_bytes: 195456
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	if (itr == s.end())return;
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

vector<ll> enum_div(ll n) {//約数列挙
	vector<ll> ans;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ans.push_back(i);
			if (i != 1 && i * i != n) {
				ans.push_back(n / i);
			}
		}
	}
	return ans;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> st = enum_div(n);
	sort(all(st));
	ll Min = 0;
	ll Max = st.size();
	while (st.size() > 0) {
		Min++;
		ll a = st.back();
		st.erase(st.end() - 1);
		vector<ll> ay = enum_div(a);
		for (auto it = ay.begin(); it != ay.end(); ++it) {
			auto ity = equal_range(all(st), *it);
			st.erase(ity.first, ity.second);
		}
	}
	cout << Min << " " << Max << endl;
}


Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_SMTB2019
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            double m = s[0] + 0.999999999;
            int ans = (int)(m / 1.08);
            int tmp = (int)(ans * 1.08);
            //WriteLine(ans);
            //WriteLine(tmp);
            if (tmp == s[0])
            {
                WriteLine(ans);
            }
            else
            {
                WriteLine(":(");
            }/*
            WriteLine(ans);
            if (m % 108 == 0)
            {
                WriteLine(m / 108);
            }
            else
            {
                WriteLine(":(");
                WriteLine(m % 108);
                WriteLine(m / 108);
            }
            */
        }
    }
}


Measured memory_bytes: 13268
N, L = map(int, input().split())
a = list(map(int, input().split()))

#最後に切るものを決める
i = 0
flag = False
while i < N - 1:
    if a[i] + a[i + 1] >= L:
        flag = True
        break
    i += 1

if not flag:
    print ('Impossible')
else:
    print ('Possible')
    if i > 0:
        for j in range(i):
            print (j + 1)
    for j in range(N - 1, i, -1):
        print (j)

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

int main() {
  int N;
  cin >> N;
  vector<tuple<int, int, int>> V;
  for (int i = 0; i < N; i++) {
    int x, y, h;
    cin >> x >> y >> h;
    if (h == 0) continue;
    V.push_back(make_tuple(x, y, h));
  }
  if (V.size() == 1) {
    return cout << get<0>(V.at(0)) << " " << get<1>(V.at(0)) << " " << get<2>(V.at(0)) << "\n", 0;
  }
  for (int x = 0; x <= 100; x++) {
    for (int y = 0; y <= 100; y++) {
      int diff = -1, h;
      for (auto v : V) {
        int tmp = 2e9 - abs(get<0>(v) - x) - abs(get<1>(v) - y) - get<2>(v);
        if (diff == -1) diff = tmp;
        if (tmp != diff) goto NG;
      }
      h = get<2>(V.at(0)) + abs(get<0>(V.at(0)) - x) + abs(get<1>(V.at(0)) - y);
      cout << x << " " << y << " " << h << "\n";
      NG:;
    }
  }
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	N *= 2;

	int A[N];
	long sum = 0;

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

	sort(A, A+N);

	for (int i = 0; i < N; i += 2)
	{
		sum += A[i];
	}

	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//const int N = (int)2e5+5;
int d[3000];
const int inf = 1 << 30;
int N , X , Y;
vector< pair< int, int > > g[3000];
int ans[3000];

void dijkstra(int src){
    for(int i = 0; i <= N; i++){ d[i] = inf ;}
    priority_queue< pair< int, int > , vector< pair< int, int > > , greater< pair< int, int > > >pq;
    pq.push({src,0});
    d[src] = 0;
    while(!pq.empty()){
        pair< int, int > t = pq.top();
        pq.pop();
        int u = t.first;
        for(auto &x : g[t.first]){
            int v = x.first;
            int w = x.second;
            if( d[v] > d[u] + w){
                d[v] = d[u] + w;
                pq.push({v,d[v]});
            }
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    cin >> N >> X >> Y;
    for(int i = 1; i < N; i++){
        g[i].push_back({i+1,1});
        g[i+1].push_back({i,1});
    }
    g[X].push_back({Y,1});
    g[Y].push_back({X,1});
    for(int i = 1; i <= N; i++){
        dijkstra(i);
        for(int i = 1; i <= N; i++){
            ans[ d[i] ]++;
        }
    }
    for(int i = 1; i < N; i++){
        cout << ans[i] / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
n, a, b = map(int, input().split())
s = list(input())
pass_all = 0
pass_abroad = 0
for c in s:
    if pass_all < a + b:
        if c == 'a':
            print('Yes')
            pass_all += 1
        elif c == 'b' and pass_abroad < b:
            print('Yes')
            pass_all += 1
            pass_abroad += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4708
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1360",problemID = "F",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n,a,b,c,d = invr()
    memo = {}
    def qw(n):
        if n == 0:
            return 0
 
        if n == 1:
            return d
 
        if n in memo:
            return memo[n]
 
        ret = n * d
 
        if (n % 2 == 0):
            ret = min(ret, a + qw(n // 2))
        else:
            ret = min(ret, (n%2)*d + a + qw(n // 2), (2-n%2)*d + a + qw((n+(2-n%2))//2))
 
        if (n % 3 == 0):
            ret = min(ret, b + qw(n // 3))
        else:
            ret = min(ret, (n%3)*d + b + qw(n // 3), (3-n%3)*d + b + qw((n+(3-n%3))//3))
 
        if (n % 5 == 0):
            ret = min(ret, c + qw(n // 5))
        else:
            ret = min(ret, (n%5)*d + c + qw(n // 5), (5-n%5)*d + c + qw((n+(5-n%5))//5))
        memo[n] = ret
        return ret
    print(qw(n))
        
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################

def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    t = inp()
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Measured memory_bytes: 88348
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

using namespace std;

const double pi=4*atan(1.0);

int mod=1000000007;

int dfs(int index,int time,vector<vector<int>>& dp,const vector<pair<int,int>>& Works){
	if(index>dp.size()-1)return 0;
	if(dp[index][time]>=0)return dp[index][time];

	int tmp1=dfs(index+1,time,dp,Works);
	int tmp2;
	if(time>=Works[index].second)tmp2=dfs(index+1,time-Works[index].second,dp,Works)+Works[index].first;
	dp[index][time]=max(tmp1,tmp2);
	return dp[index][time];
}

int get_ans(int W,int n,vector<vector<int>>& dp,const vector<pair<int,int>>& items){
	for(int j = 0; j <= W; j++) {
		dp[n][j] = 0;
	}
	for(int i = n - 1; i >= 0; i--) {
		for(int j = 0; j <= W; j++) {
			if(j < items[i].second)
				dp[i][j] = dp[i + 1][j];
			else
				dp[i][j] = max(dp[i + 1][j],dp[i + 1][j - items[i].second] + items[i].first);
		}
	}
	return dp[0][W];
}

int main() {
	//while(1){
		int N,M;
		cin>>N>>M;
		vector<pair<int,int>> Works(N);
		for(auto& val:Works){
			cin>>val.first>>val.second;
		}

		vector<vector<int>> dp(N+1,vector<int>(M+1,-1));

		//cout<<dfs(0,M,dp,Works)<<endl;
		cout<<get_ans(M,N,dp,Works)<<endl;

	//}
	//system("pause");
	return 0;
}

Measured memory_bytes: 6776
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
s1 = list(set(s))
for i in s1:
    x = s.count(i) - t.count(i)
    if ans < x:
        ans = x
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final long n = sc.nextLong();
		
		
		final long times = n / 11;
		final long rem = n % 11;
			
			
		System.out.println((rem == 0 ? 0 : rem <= 6 ? 1 : 2) + (2 *  times));

	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8148
import heapq

N, M = map(int, input().split())
A = list(map(lambda o: -int(o), input().split()))
heapq.heapify(A)

for i in range(0, M, 1):
	heapq.heappush(A, -(-heapq.heappop(A) >> 1))

print(-sum(A))

Measured memory_bytes: 14180