akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main (void)
{
    int n,m,k,i,ans=0;
    long sum=0,asum=0;
    scanf("%d %d %d",&n,&m,&k);
    int a[n+1],b[m+1];
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        asum+=a[i];
    }
    for(i=1;i<=m;i++)
    {
        scanf("%d",&b[i]);
    }
    b[0]=0;
    int j=n;
    for(i=0;i<=m;i++)
    {
        sum+=b[i];
        if(sum>k)
        {
            break;
        }
        long ksum=sum+asum;
        while(ksum>k&&j>0)
        {
            ksum-=a[j];
            asum-=a[j];
            j--;
        }
        if(ans<i+j)
        {
            ans=i+j;
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
    int N; cin >> N;
    vector<int> a; a.resize(N + 10);
    for (int i = 1; i <= N; ++i){
        cin >> a[i];
    }

    int ans = 0;
    for (int i = 1; i <= N; ++i){
        if (a[a[i]] == i)
            ++ans;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll i, j, k;
int main(){
    scanf("%lld", &N);
    printf("%lld", (N + 1) / 2);
    return 0;
}

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

int main() {
  string a,b,c; cin>>a>>b>>c;
  if (a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		in.close();
		int ans = (b - a + 1) * (b - a) / 2 - b;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

long a[505];
long memo[505][505];
long acc[505][505];

long solve(int l, int r){
  if(memo[l][r] >= 0) return memo[l][r];
  if(l == r) return 0;
  if(l+1 == r) return 0;

  long ans = LLONG_MAX;
  rep(i,l,r-1){
    ans = min(ans, solve(l,i+1) + solve(i+1, r));
  }

  return memo[l][r] = ans + acc[l][r];
}

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

  fill(memo[0], memo[500], -1);

  rep(i,n){
    acc[i][i] = 0;
    rep(j,i,n) acc[i][j+1] = acc[i][j] + a[j];
  }

  cout << solve(0,n) << endl;

  return 0;
}


Measured memory_bytes: 3840
N = int(input())
ans = 1
A = list(map(int, input().split()))
flag = 0

for j in range(len(A)):
  if A[j] == 0:
    flag = 1
    ans = 0

if flag == 0:
  for i in range(N):
    ans = ans * A[i]
    if ans > 10 ** 18:
      break


if ans > 10 ** 18:
  print('-1')
else:
  print(ans)

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

int main(void) {
  int r,g,b;
  cin >> r >> g >> b;
  if(( (g*10) + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S,T;
  cin>>S>>T;
  
  string S_a=S;
  
  bool ans=false;
  
  for(int i=0;i<101;i++){
    if(S==T){
      ans=true;
    }
    S=S.back()+S.substr(0,S.size()-1);
  }
  
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main(void)
{
	int k,x;
	int min =-1000000,max = 1000000;
	cin >> k >> x;
	min = x - k+1;
	max = x + k -1;
	for(int i=min;i<=max;++i){
		cout << i << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n, t[100], a, b, c, d, x, i, j;
	scanf("%d", &n);
	for(i=1; i<=n; i++)
	{
		t[i]=0;
	}
	for(i=1; i<=n*(n-1)/2; i++)
	{
		scanf("%d %d %d %d", &a, &b, &c, &d);
		if(c>d)
		t[a]+=3;
		if(c<d)
		t[b]+=3;
		if(c==d)
		{
			t[a]++;
			t[b]++;
		}
	}
	for(i=1; i<=n; i++)
	{
		x=n;
		for(j=1; j<=n; j++)
		{
			if(t[i]>=t[j]&&i!=j)
			x--;
		}
		printf("%d\n", x);
	}
	
	return 0;
}


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

int main() {
  string s; cin>>s;
  vector<char>vecs(s.size());
  for(int i=0; i<s.size() ;i++){
    vecs[i]=s[i];
  }
  sort(vecs.begin(),vecs.end());
  vecs.erase(unique(vecs.begin(),vecs.end()),vecs.end());
  
  string alp="abcdefghijklmnopqrstuvwxyz";
  vector<char>vecalp(26);
  for(int i=0; i<alp.size();i++){
    vecalp[i]=alp[i];
  }
  
  vector<char>ans;
  for(int i=0;i<alp.size();i++){
    if(vecalp[i]!=vecs[i]){
      ans.push_back(vecalp[i]);
      break;
    }
  }
  if(ans.size()==0) cout<<"None"<<endl;
  else cout<<ans[0]<<endl;
}
    
    


Measured memory_bytes: 512
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))

for d in range(x + 2):
	if x - d not in p:
		print(x-d)
		exit()
	if x + d not in p:
		print(x+d)
		exit()

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<string,ll>a;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		a[s]++;
	}
	ll ans=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        ll now= itr->second ;
        if(now!=1){
        	ans+=now*(now-1)/2;
        }
    }	
    cout << ans;
	return 0;
}

Measured memory_bytes: 11136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0,nn=(intl)(n);i<nn;++i)
#define Rep1(i,n) for(intl i=1,nn=(intl)(n)+1;i<nn;++i)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);}
#define Input2(a,b) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);cin>>(b).at(ii);}
#define mp make_pair
#define mt make_tuple
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
using si = set<intl>;
using vsi = vec<si>;
using mii = map<intl,intl>;
using vmii = vec<mii>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;



int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  intl N;
  cin >>N;
  intl A;
  mii K;
  intl ans=0;
  Rep1(i,N){
    cin >>A;
    if(i-A >0){ans +=  K[i-A];}
    K[A+i] ++;
  }
  cout <<ans;
}
    

Measured memory_bytes: 17456
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vi ans(n);
    rep(i, n-1) {
        int st = i;
        int num = -1;
        while(s[i] != 'L' || s[i+1] != 'R') {
            if(num == -1 && s[i+1] == 'L') {
                num = i+1;
            }
            
            ++i;
            if(i == n-1) break;
        }
        if((i-num)&1) {
            ans[num-1] = (i-st+2)/2;
            ans[num] = (i-st+1)/2;
        } else {
            ans[num] = (i-st+2)/2;
            ans[num-1] = (i-st+1)/2;
        }
    }

    rep(i,n) {
        cout << ans[i] << (i != n-1 ? ' ' : '\n');
    }
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] ags) {
        Scanner s = new Scanner(System.in);
        long h = s.nextLong();
        double l = Math.log(h) / Math.log(2);
        int p = (int)Math.ceil(l) + (Math.floor(l) < l ? 0 : 1);
        System.out.println((long)Math.pow(2, p) - 1);
    }
}


Measured memory_bytes: 25684
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long n,m;
	cin>>n>>m;
	if(n==1||m==1)return !printf("1\n");
	if((n*m)%2==0)cout<<n*m/2<<endl;
	else cout<<(n*m)/2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> sum(n + 1, vector<int>(n + 1, 0));
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    ++sum[l][r];
  }
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= n; ++j){
      sum[i][j] += sum[i - 1][j];
      sum[i][j] += sum[i][j - 1];
      sum[i][j] -= sum[i - 1][j - 1];
    }
  }

  rep(i, q) {
    int l, r;
    cin >> l >> r;
    int ans = sum[r][r] - sum[l - 1][r] - sum[r][l - 1] + sum[l - 1][l - 1];
    cout << ans << endl;
  }
}

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

using namespace std;

int main()
{
    int n, g=0, I=0;
    cin >> n;
    int a[n], b[n], B[n];
    vector <pair<int,int>> V, AB;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        B[i] = 1;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        AB.push_back({b[i],a[i]});
    }
    sort(AB.begin(),AB.end());
    for (int i = 0; i < n; i++)
    {
        b[i] = AB[i].first;
        a[i] = AB[i].second;
        V.push_back({a[i],i});
    }
    sort(V.begin(),V.end());
    while (B[I] == 1)
    {
        B[I] = 0;
        I = V[I].second;
    }
    for (int i = 0; i < n; i++)
    {
        if (B[i] == 1)
        {
            g = 1;
        }
        if (V[i].first > b[i])
        {
            cout << "No";
            return 0;
        }
    }
    if (g == 0)
    {
        for (int i = 1; i < n; i++)
        {
            if (V[i].first <= b[i-1] && V[i-1].first <= b[i])
            {
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	static int w,h;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w=sc.nextInt();
			h=sc.nextInt();
			if(w==0&&h==0) break;
			int[][] map = new int[h][w];
			int[][] flag = new int[h][w];
			for(int j=0;j<h;++j){
				for(int i=0;i<w;++i){
					map[j][i]=sc.nextInt();
				}
			}
			int count=0;
			for(int j=0;j<h;++j){
				for(int i=0;i<w;++i){
					if(map[j][i]==1&&flag[j][i]==0){
						flag[j][i]=1;
						mapping(map,flag,i,j);
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void mapping(int[][]map,int[][]flag,int i,int j){
		if(i!=0){
			if(map[j][i-1]==1&&flag[j][i-1]==0){
				flag[j][i-1]=1;
				mapping(map,flag,i-1,j);
			}
		}
		if(j!=0){
			if(map[j-1][i]==1&&flag[j-1][i]==0){
				flag[j-1][i]=1;
				mapping(map,flag,i,j-1);
			}
		}
		if(i!=w-1){
			if(map[j][i+1]==1&&flag[j][i+1]==0){
				flag[j][i+1]=1;
				mapping(map,flag,i+1,j);
			}
		}
		if(j!=h-1){
			if(map[j+1][i]==1&&flag[j+1][i]==0){
				flag[j+1][i]=1;
				mapping(map,flag,i,j+1);
			}
		}
		if(i!=0&&j!=0){
			if(map[j-1][i-1]==1&&flag[j-1][i-1]==0){
				flag[j-1][i-1]=1;
				mapping(map,flag,i-1,j-1);
			}
		}
		if(i!=0&&j!=h-1){
			if(map[j+1][i-1]==1&&flag[j+1][i-1]==0){
				flag[j+1][i-1]=1;
				mapping(map,flag,i-1,j+1);
			}
		}
		if(i!=w-1&&j!=0){
			if(map[j-1][i+1]==1&&flag[j-1][i+1]==0){
				flag[j-1][i+1]=1;
				mapping(map,flag,i+1,j-1);
			}
		}
		if(i!=w-1&&j!=h-1){
			if(map[j+1][i+1]==1&&flag[j+1][i+1]==0){
				flag[j+1][i+1]=1;
				mapping(map,flag,i+1,j+1);
			}
		}
	}
}


Measured memory_bytes: 44856
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <vector>
#include <sstream>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
int main()
{
    long long a, b;
    cin >> a >> b;
    long long c = a+b;
    if (c%2==0){
    	cout << c/2;
	}
	else{
		cout << "IMPOSSIBLE";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	bool ok = 0;
	rep(i, 9) rep(j, 9) ok |= (i + 1) * (j + 1) == n;
	
	cout << (ok ? "Yes" : "No") << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    string s;
    cin >> s;
    int ans = 1e9;
    for(int i=0;i<s.size()-2;++i){
        int x = stoi(s.substr(i,3));
        ans = min(ans,abs(753-x));
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

ll n,a,b;
ll fast_pow(ll a, ll b){
	ll ret = 1;
	for(;b;b>>=1){
		if(b&1) ret = ret * a % mod;
		a = a * a % mod;
	}
	return ret;
}

int main(){
	cin >> n >> a >> b;
	ll s=fast_pow(2,n)-1;
	ll mns=1;
	for (int i=1;i<=max(a,b);i++){
		mns *= (n+1-i);
		mns %= mod;
		mns *= fast_pow(i,mod-2);
		mns %= mod;	
		if (i==min(a,b)) s-=mns;
	}
	s -= mns;
	s %= mod;
//	cout << s<< endl;
	while (s<0) s += mod; 
	cout << s;
	return 0;
}


Measured memory_bytes: 256
import math


def main():
    N = int(input())
    W = [input() for _ in range(N)]

    if len(set(W)) != len(W):
        print("No")
        return
    W = [list(a) for a in W]

    for i in range(len(W) - 1):
        if W[i][-1] != W[i + 1][0]:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()


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

int main(int argc, const char * argv[]) {
    int round;
    int houses;
    
    cin >> round;
    cin >> houses;
    int array[houses];
    vector<int> meters(houses);
    for (int i = 0; i < houses; i++) {
        cin >> array[i];
    }
    
    for (int j = 0; j < houses; j++) {
        if (j == (houses-1)) {
            meters.at(j) = (array[0] - 0) + (round - array[j]);
        }else{
            meters.at(j) = array[j+1] - array[j];
        }
    }
    int max = meters[0];
    for (int k: meters) {
        if (k > max) {
            max = k;
        }
    }
    cout << round - max <<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	vector<string> s;
	string ss, tt;
	cin >> ss >> tt;
	s.push_back(ss);
	s.push_back(tt);

	reverse(s[1].begin(), s[1].end());
	if (s[0] == s[1]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long int M = 1e9 + 7;
int main() {
    long long int n , k , i , j;
    cin >> n >> k;
    long long int a[n+1];
    for(i = 0 ; i < n ; i++) {
        cin >> a[i];
    }
    long long int ans = 0;
    for(i = 0 ; i < n ; i++) {
        long long int c = 0 , d = 0;
        for(j = 0 ; j < i ; j++) {
            if(a[j] > a[i]) {
                c++;
            }
        }
        for(j = 0 ; j < n ; j++) {
            if(a[j] > a[i]) {
                d++;
            }
        }
        ans += (((c%M) * (k%M))%M +((((k%M)*((k-1)%M)/2)%M)*(d%M))%M)%M;
        ans = ans%M;
    }
    cout << ans << "\n";
}

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

#define rep2(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) rep2(i,0,n)
#define all(a) a.begin(),a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    
    int a, b;
    cin >> a >> b;
    rep(i, 100001) {
        if(i * 8 / 100 == a && i / 10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
  int A=0, B=0, C=0;
  int X=0;

  std::cin >> A >> B >> C >> X;

  int res = 0;

  for (int i=0; i<A+1; ++i){
    for (int j=0; j<B+1; ++j){
      for (int k=0; k<C+1; ++k){
        if (500*i+100*j+50*k==X){
          ++res;
        }
      }
    }
  }

  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
struct edge {int to, cost;};
typedef pair<int, int> P;

signed main(){
	int n, a, b;
	cin >> n >> a >> b;
	if ((a - b) & 1)puts("Borys");
	else puts("Alice");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


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

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

using namespace std;

int main() {
    int n, m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) {
            break;
        }
        int nums[n];
        for(int i = 0; i < n; i++) {
            cin >> nums[i];
            if(i != 0) {
                nums[i] += nums[i - 1];
            }
        }

        int max = nums[m - 1];
        for(int i = 1; i < n - m; i++) {
            if(nums[m - 1 + i] - nums[i - 1] > max) {
                max = nums[m - 1 + i] - nums[i - 1];
            }
        }
        cout << max << endl;
    }
}



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

int main()
{
    int a, b;
    string s, t, u;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        a--;
    if (u == t)
        b--;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	while (cin >> n, n){
		int left = 1;
		int right = 1;
		int sum = 1;
		int ans = 0;
		while (right < n){
			if (sum < n){
				right++;
				sum += right;
			}
			else if (sum > n){
				sum -= left;
				left++;
			}
			else{
				ans++;
				sum -= left;
				left++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3092
import java.util.*;
public class Main {
	

	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		int mod = (int)1e9+7;
		
		int cnt[] = new int[N+1];
		
		for(int i=2;i<=N;i++) {
			int tmp = i;
			for(int j=2;j*j<=tmp;j++) {
				while(tmp%j==0) {
					tmp /= j;
					cnt[j]++;
				}
			}
			if(tmp!=1)cnt[tmp]++;
		}
		
		long ans = 1;
		for(int t:cnt) {
			ans *= (t+1);
			ans %= mod;
		}
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;

  ui N{}, M{}; cin >> N >> M;
  vector<ui> L(M), R(M);
  rep(0, M) cin >> L[i] >> R[i];

  auto Lmax = boost::max_element(L);
  auto Rmin = boost::min_element(R);

  auto ans = (*Lmax > *Rmin) ? 0 : (*Rmin - *Lmax + 1);

  using std::cout;
  cout << ans << '\n';
  
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll n,m,max,min,s,c;
cin>>n>>m;
ll ans=-1;
vector<pair<ll,ll>>a(m);

max=rep_jijo(10,n);
if(n!=1){
    min=rep_jijo(10,n-1);
}
else{
    min=0;
}


rep(i,m){
    cin>>s>>c;
    a[i]=make_pair(s,c);}
for(ll j=max-1;j>=min;j--){
    ll cnt=0;
    for(auto p:a){
        auto k=p.first;
        auto v=p.second;
        if(k==n-2 && j/100==v){
         cnt++;
         }
        else if(k==n-1 && j%100/10==v){
            cnt++;
        }
        else if(k==n && j%10==v){
            cnt++;
        }
            
    }
    if(cnt==m)ans=j;
   
}
   cout<<ans<<endl;
   return 0;
}



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

using namespace std;

int main(){
  int n,k; cin>>n>>k;
  int cnt = 0;
  for(int i = 0; i < n; i++){
     int x; cin>>x;
     if(x >= k) cnt++;
  }
  cout<<cnt<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
const int maxt=(1<<16)+10;
int n,ans;
int val[maxn],cnt[20],pos[20];
int dp[2][maxt];
vector<int> all;
inline void update(int &a,int b)
{
	if(b>a)a=b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v,a;
		scanf("%d%d%d",&u,&v,&a);
		val[u]^=a;
		val[v]^=a;
	}
	for(int i=0;i<n;i++)
	{
		if(val[i]==0)continue;
		cnt[val[i]]^=1;
		if(!cnt[val[i]])ans++;
	}
	memset(pos,-1,sizeof(pos));
	for(int i=1;i<16;i++)
	{
		if(cnt[i])
		{
			ans++;
			pos[i]=all.size();
			all.push_back(i);
		//	cout<<i<<endl;
		}
	}
	memset(dp,-1,sizeof(dp));
	int p=0,q=1;
	dp[p][0]=0;
	for(int i=0;i<all.size();i++)
	{
		memset(dp[q],-1,sizeof(dp[q]));
		for(int msk=0;msk<(1<<i);msk++)
		{
			if(dp[p][msk]==-1)continue;
			update(dp[q][msk|(1<<i)],dp[p][msk]);
			for(int a=0;a<i;a++)if(msk>>a&1)
			for(int b=a+1;b<i;b++)if(msk>>b&1)
			{
				if(all[a]^all[b]^all[i]==0)
				{
					update(dp[q][msk^(1<<a)^(1<<b)],dp[p][msk]+1);
				//	cout<<"2 "<<a<<" "<<b<<" "<<i<<endl;
				}
				for(int c=b+1;c<i;c++)if(msk>>c&1)
				{
					int t=all[a]^all[b]^all[c]^all[i];
					if(t==0)
					{
						update(dp[q][msk^(1<<a)^(1<<b)^(1<<c)],dp[p][msk]+1);
					//	cout<<"3 "<<a<<" "<<b<<" "<<c<<" "<<i<<endl;
					}
					else
					{
						int d=pos[t];
						if(d!=-1&&d!=a&&d!=b&&d!=c&&(msk>>d&1))
						{
						//	cout<<"4 "<<a<<' '<<b<<" "<<c<<" "<<d<<" "<<i<<endl;
							update(dp[q][msk^(1<<a)^(1<<b)^(1<<c)^(1<<d)],dp[p][msk]+1);
						}
					}
				}
			}
		}
		swap(p,q);
	}
	int res=0;
	for(int i=0;i<(1<<16);i++)update(res,dp[p][i]);
//	cout<<res<<" "<<ans<<endl;
	printf("%d\n",ans-res);
	return 0;
}

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

using namespace std;

void hawawa()
{
	int n;
	string str;
	cin >> n;
	cin >> str;
	int ans = n;
	vector<int> left_w(n + 1), right_e(n + 1);
	for (int i = 1; i <= n; i++) {
		left_w[i] = left_w[i - 1] + (str[i - 1] == 'W');
	}
	string sub = str.substr(1);
	right_e[0] = count(begin(sub), end(sub), 'E');
	for (int i = 1; i < n; i++) {
		right_e[i] = right_e[i - 1] - (str[i] == 'E');
	}
	for (int i = 0; i < n; i++) {
		ans = min(ans, left_w[i] + right_e[i]);
	}
	cout << ans << "\n";
}

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


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

int N;
int x[10];
int y[10];

    
int fact(int i){
    if(i == 0) return 1;
    return i * fact(i-1);
}


double dist(int i, int j){
    return(sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])));
}

/*
double sumation (int n, x[], y[]){
    double sum = 0.0;
    if (n == 0) return sum;
    else {
        
        factn--;
    }
}
*/

int main(void){
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    
    //cout << x[0] << y[0] << endl;
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    /* 
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++){
            if (j != i) {
                sum += dist(x[i], x[j], y[i], y[j]);
                cout << sum << endl;
            }
            for(int k = 0; k < N; k++){
                if (j != i && k != i && k != j) {
                    sum += dist(x[j], x[k], y[j], y[k]);
                    cout << sum << "hoge" << endl;
                }
            }
        }
    }
    */
    do {
        for(int i = 0; i < N-1; i++) sum += dist(v[i], v[i+1]);
        
    } while (next_permutation(v.begin(), v.end()));
    
    double ans = sum / fact(N);
    
    cout << setprecision(10)<< ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;
ll w[1000];
ll m = 100000000000000;
int main() {
	ll n,a, sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += a;
		w[i + 1] = w[i] + a;
	}
	for (int i = 1; i <= n; i++) {
		m = min(m, abs(sum - w[i]-w[i]));
	}
	cout << m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
 
#define fir first
#define sec second
 
typedef pair <int, int> P;
vector <P> v(1028);
 
int dp[1028][2048];
 
int main(void)
{
    int cnt = 1;
    while (1){
        int w, n;
        cin >> w; if (w == 0) break;
        cin >> n;
        char a;
        for (int i = 0; i < n; i++){
            scanf("%d,%d", &v[i].fir, &v[i].sec);
        }
        for (int i = 0; i < n; i++){
            for (int j = 0; j <= w; j++){
                if (j < v[i].sec) dp[i+1][j] = dp[i][j];
                else dp[i+1][j] = max(dp[i][j], dp[i][j-v[i].sec]+v[i].fir);
            }
        }
        int res1 = 0, res2 = 0;
        for (int i = 1; i <= w; i++){
            if (res1 < dp[n][i]){
                res1 = dp[n][i];
                res2 = i;
            }
        }
        cout << "Case " << cnt << ":" << endl << res1 << endl << res2 << endl;
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 9436
n = int(input())
s = input()
list1 = []
for counter in range(n + 1):
    d = s.count("D", 0, counter)
    i = s.count("I", 0, counter)
    number = i - d
    list1.append(number)

if max(list1) <= 0:
    print(0)
else:
    print(max(list1))

Measured memory_bytes: 38384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] array=new int[3];
    int[] copy=new int[3];
    for(int i=0; i<3; i++){
      array[i]=sc.nextInt();
      copy[i]=array[i];
    }
    int min =100000;
    for(int i=0; i<3;i++){
      for(int j=0; j<3;j++){
        if(i!=j){
          if((array[i]+copy[j])<min){
            min=array[i]+copy[j];
          }
        }
      }
    }
    System.out.println(min);
  }
}

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

int main(){
	int a,b,n;
	while(cin>>a>>b>>n){
		int s=0;
		a %= b;
		for(int i=0;i<n;i++){
			a = (a*10);
			s += a/b;
			a %= b;
		}
		cout<<s<<endl;	
	}
	return 0;
}

Measured memory_bytes: 1160
miu = input()

sella = miu[0:2]
miu = miu[2:4]

delphine = [0,0]

if 1 <= int(sella) and int(sella) <= 12:
	delphine[0] += 1


if 1 <= int(miu) and int(miu) <= 12:
	delphine[1] += 1

if sum(delphine) == 0:
	print("NA")
elif sum(delphine) == 2:
	print("AMBIGUOUS")

elif delphine[0] == 1:
	print("MMYY")
else:
	print("YYMM")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <numeric>
#include <vector>

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

using namespace std;

typedef enum TE
{
  R,S,P,TE_NUM
}TE;
const char te[] = {'r', 's', 'p'};
int id(char c)
{
  if(c == 'r') return R;
  if(c == 's') return S;
  return P;
}
string win(string& t)
{
  string w = t;
  rep(i, t.length())
  {
    w[i] = te[(id(t[i]) + 2) % TE_NUM];
  }
  return w;
}
char change(char now, char next)
{
  if(next == now)
    return te[(id(now) + 1) % TE_NUM];
  else
  {
    int sum = id(now) + id(next);
    return te[TE_NUM - sum];
  }
}

int main()
{
  int n, k;
  int score[TE_NUM];
  string t;
  cin >> n >> k;
  rep(i, TE_NUM)
    cin >> score[i];
  cin >> t;
  string w = win(t);

  int sum = 0;
  for(int i = 0; i < n; ++i)
  {
    if(i < k)
    {
      sum += score[id(w[i])];
    }
    else
    {
      if(w[i] == w[i-k])
      {
        int x = (i + k < n) ? k : 0;
        w[i] = change(w[i], w[i+x]);
      }
      else
      {
      sum += score[id(w[i])];
      }
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 3005;

int dp[N][N][2];
int n, a[N];

int solve(int i, int j, int cur) {
	if (i > j) return 0;
	int &ans = dp[i][j][cur];
	if (ans != -1) return ans;
	if (cur == 0) ans = max(solve(i + 1, j, 1) + a[i], solve(i, j - 1, 1) + a[j]);
	else ans = min(solve(i + 1, j, 0) - a[i], solve(i, j - 1, 0) - a[j]);
	return ans;
}
				
int32_t main() {
	fast_cin();  

	cin >> n; 
	for (int i = 0; i < n; i++)
		cin >> a[i];
	memset(dp, -1, sizeof dp);
	int ans = solve(0, n - 1, 0);
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 100016

int main()
{
    canhazfast();

    int n, m, ans;
    int b = 0, e = MX;

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        b = max(b, l);
        e = min(e, r);
    }
    ans = max(e-b+1, 0);
    cout << ans << '\n';

    return 0;
}


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

#define ll long long
#define MAX 3000

void In_Out() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

void display_arr(std::vector<int> v) {
	for (auto ele : v) {
		cout << ele << " ";
	}
	cout << endl;
}

int dp[MAX + 1][MAX + 1];

// Top down DP approach
int LCS_length(string &s, string &t, int i, int j) {
	// if iteration on any string is completed, then there will be no character to compare hence return 0
	if (i >= s.length() or j >= t.length())
		return 0;
	// look up case
	if (dp[i][j] != -1)
		return dp[i][j];
	// Recursive solution
	if (s[i] == t[j]) {
		return dp[i][j] = 1 + LCS_length(s, t, i + 1, j + 1);
	}
	return dp[i][j] = max(LCS_length(s, t, i + 1, j), LCS_length(s, t, i, j + 1));
}

string get_LCS_string(string &s, string &t, int len) {
	int i = 0, j = 0;
	string out = "";
	while (len) {
		if (s[i] == t[j]) {
			out.push_back(s[i]);
			i++;
			j++;
			len--;
		}
		else {
			if (dp[i][j + 1] > dp[i + 1][j]) j++;
			else i++;
		}
	}
	return out;
}

int main() {
	// In_Out();
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	memset(dp, -1, sizeof(dp));
	string s, t, out;
	cin >> s >> t;
	int len = LCS_length(s, t, 0, 0);
	cout << get_LCS_string(s, t, len);
}

// input -
// abracadabra
// avadakedavra

// output -
// aaadara


Measured memory_bytes: 39212
N = int(input())
S = input()

dp = [0 for i in range(N + 1)]
for i in range(N):
    dp[i + 1] = dp[i] + (S[i] == '#')
ans = min(dp[i] + (N - i - (dp[N] - dp[i])) for i in range(N + 1))
print(ans)


Measured memory_bytes: 11400
import java.util.Scanner;

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

    public static void main(String[] args) {

        String  s = sc.next();
        char[] c = s.toCharArray();
        
        long ans = 0;
        
        for(int i =0; i<s.length(); i++)
        ans += c[i]-'0';
        
   System.out.println(ans%9==0?"Yes":"No");
        
       



    }
















    static int max(int a, int b)
    {
        return Math.max(a,b);
    }
    static int max(int a, int b, int c)
    {
        return Math.max(max(a,b), c);
    }
    static int max(int a, int b, int c, int d)
    {
        return Math.max(max(a,b), max(c,d));
    }

    static int min(int a, int b)
    {
        return Math.min(a, b);
    }

    static int min(int a, int b, int c )
    {
        return Math.min(a, min(b,c));
    }

    static int min(int a, int b, int c, int d )
    {
        return Math.min(min(a,d), min(b,c));
    }

    static boolean isPower(int a, int b)
    {
        double temp = Math.log(a)/Math.log(b);
        return temp == (int) temp;
    }
    static boolean isPrime(int n)
    {
        if(n==1) return false;
        if(n==2) return true;
        if(n%2==0) return false;

        if(n<9)return true;
        if(n%3==0) return false;

        int r = (int)Math.sqrt(n);

        for(int i = 5; i<=r; i +=6)
        {
            if(n%i==0) return false;
            if(n%(i+2)==0) return false;
        }
        return true;



    }
}


Measured memory_bytes: 40628
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    grid_wid, grid_hei, t, p = map(int, input().split())
    if grid_wid == 0:
        exit()
    grid = [[1]*grid_wid for _ in range(grid_hei)]

    fold = [list(map(int, input().split())) for _ in range(t)]
    pin = [list(map(int, input().split())) for _ in range(p)]

    # 区間の左端と右端[L,R)
    L = 0
    R = grid_wid
    # 区間の下端と上端[B,H)
    B = 0
    H = grid_hei

    for ope, axis in fold:
        if ope == 1:
            # 横におる
            current_width = R-L
            if axis > current_width/2:  # kaiten
                alter_axis = current_width-axis
                for i in range(alter_axis):
                    for j in range(grid_hei):
                        grid[j][axis-i-1+L] += grid[j][axis+i+L]
                        grid[j][axis+i+L] = 0

                # 回転させる
                for j in range(grid_hei):
                    grid[j] = list(reversed(grid[j]))
                # 区間の更新
                L, R = grid_wid-R+alter_axis, grid_wid-L

            else:
                for i in range(axis):
                    for j in range(grid_hei):
                        grid[j][axis+i+L] += grid[j][axis-i-1+L]
                        grid[j][axis-i-1+L] = 0
                L += axis

        if ope == 2:
            # 縦におる
            current_hei = H-B
            if axis > current_hei/2:  # kaiten
                alter_axis = current_hei-axis
                for i in range(alter_axis):
                    for j in range(grid_wid):
                        grid[axis-i-1+B][j] += grid[axis+B+i][j]
                        grid[axis+i+B][j] = 0

                # 回転させる
                grid = list(reversed(grid))
                # 区間の更新
                B, H = grid_hei-H+alter_axis, grid_hei-B
            else:
                for i in range(axis):
                    for j in range(grid_wid):
                        grid[axis+i+B][j] += grid[axis-i-1+B][j]
                        grid[axis-i-1+B][j] = 0
                B += axis
    for px, py in pin:
        ans = grid[B+py][L+px]
        print(ans)


while True:
    solve()



Measured memory_bytes: 5888
awk '$0=NR%2FS$NF' RS=\ |sort|uniq -c|sort -n|awk 's+=$1{$2?b=a:e=d;$2?a=$1:d=$1;$2?c=$3:f=$3}END{print s-(c~f?a+e<b+d?b+d:a+e:a+d)}'

Measured memory_bytes: 11720
#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	int a = 0, b = 0;
	char op = ' ';

	while (1){
		cin >> a >> op >> b;	
		if (op == '?'){ break; }
		switch (op)
		{
		case '+':
			a = a + b;
			break;
		case '-':
				a = a - b;
				break;
		case '*':
			a = a * b;
			break;
		case '/':
			a = a / b;
			break;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll Q;
std::vector<P> qrys;
ll bS;
std::multiset<ll> L, R;
ll N;
ll mi;

int main()
{
  std::cin >> Q;

  rep( q, Q )
  {
    ll t;
    std::cin >> t;

    if( t == 1 )
    {
      ll a, b;
      std::cin >> a >> b;

      bS += b;

      if( !L.empty() )
      {
        ll l = *L.rbegin(), r = *R.begin();

        if( !(l <= a && a <= r) )
          mi += std::min( llabs(l-a), llabs(r-a) );
      }

      ++N;

      if( !L.empty() && *L.rbegin() < a )
      {
        R.emplace( a );
        R.emplace( a );

        while( R.size() > N )
        {
          auto it = R.begin();
          ll x = *it;
          R.erase( it );
          L.emplace( x );
        }
      }
      else
      {
        L.emplace( a );
        L.emplace( a );

        while( L.size() > N )
        {
          auto it = L.end();
          --it;
          ll x = *it;
          L.erase( it );
          R.emplace( x );
        }
      }

      /*for( auto v : L )
        printf( "L: %lld\n", v );
      for( auto v : R )
        printf( "R: %lld\n", v );*/
    }
    else
    {
      std::cout << *L.rbegin() << ' ' << mi+bS << std::endl;
    }
  }

  return 0;
}

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

int a[2][101];
int sm[2][101];

int main() {
  int n;cin>>n;
  for(int i=0;i<2;++i) {
    for(int j=0;j<n;++j){
      cin>>a[i][j];
      if (j>0) sm[i][j] += sm[i][j-1] + a[i][j];
      else sm[i][j] = a[i][j];
    }
  }
  
  int ans = sm[0][0] + sm[1][n-1];
  for(int i=1;i<n;++i){
    ans = max(ans, sm[0][i] + sm[1][n-1] - sm[1][i-1]);
  }
  cout<<ans<<endl;
  
  return 0;
}

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

int main(){
int A,B;
cin >> A >> B;

if(A >= 13){
    cout << B <<endl;  
}
else if( 6 <= A && A <= 12){
    B = B/2;
    cout << B << endl;
}
else if(A <= 5){
    cout << 0 << endl;
}

}

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

using namespace std;

long long x, f[4005], fi[4005], res;
const long long mod = 1e9 + 7;

long long powermod(long long a, long long b) {
	long long ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}

long long divi(long long q, long long d) {
	long long temp = 1;
	temp = (q * powermod(d, mod - 2)) % mod;
	return temp;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x;
    f[0] = 1; fi[0] = 1;
    for (int i = 1; i < 4005; i++) {
    	f[i] = (f[i - 1] * i) % mod;
    	fi[i] = divi(fi[i - 1], i);
	}
	if (x >= 3) res = 1;
	else res = 0;
	for (int i = 6; i <= x; i += 3) {
		res += ((f[x - i + (i / 3 - 1)] * fi[i / 3 - 1]) % mod * fi[x - i]) % mod;
		res %= mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 3708