akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] ary = new int[N-1];
		int sum = 0;
		for (int i = 0; i < N-1; i++) {
			if (S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
				sum++;
			}
			ary[i] = sum;
		}
		for (int i = 0; i < Q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int temp = 0;
			if (l != 1) {
				temp = ary[l-2];
			}
			System.out.println(ary[r-2]-temp);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 52192
#include<iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,res=0;
    string S;
    cin >> N >> S;

    for (int i = 1; i < N;i++){
           int a[26]={0};
            int b[26]={0};
        for (int j = 0; j < N; j++){
            if(j<i){
                a[S[j] - 'a']++;
            }else{
                b[S[j] - 'a']++;
            }
        }
        int cnt = 0;
        for (int j = 0; j < 26;j++){
            if(a[j]>0 && b[j]>0){
                cnt++;
            }
        }
        res = max(res, cnt);
    }
    cout << res << endl;
}

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

char nyuryoku[100][100];
int h,w;

void fun(int y,int x,char masume){
	if((x<0)||(w<=x)||(y<0)||(h<=y))
		return;
	if(masume==nyuryoku[y][x])
		nyuryoku[y][x]='x';
	else
		return;
	fun(y+1,x,masume);
	fun(y-1,x,masume);
	fun(y,x+1,masume);
	fun(y,x-1,masume);
}

int main(){
	while(cin >> h >> w,h){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >>nyuryoku[i][j];
			}
		}
		int count=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(nyuryoku[i][j]!='x'){
					fun(i,j,nyuryoku[i][j]);
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

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

int main(){
  int M,D;
  cin >> M >> D;
  
  int count=0;
  for(int m=1; m<=M; m++){
    for(int d=1; d<=D; d++){
      if(d>=10&&d/10>=2&&d%10>=2&&(d/10)*(d%10)==m) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    vector<int> N(3);
    cin >> N[0] >> N[1] >> N[2];
    sort(all(N));
    reverse(all(N));
    int ans = N[0] - N[1];
    N[2] += ans;
    N[1] = N[0];
    if ((N[0] - N[2]) % 2 == 1)
    {

        ans++;
        N[1]++;
        N[0]++;
    }
    ans += (N[0] - N[2]) / 2;
    cout << ans << endl;
}


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

using namespace std;

const int MAX_N=1e5;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

const ll INF=1e15;

int n;
int x[MAX_N];

ll seg[MAX_N*4];
int s;

void init(){
	s=1;
	while (s<MAX_N){
		s<<=1;
	}
}

void update(int i,ll x){
	i+=s-1;
	do{
		seg[i]=max(seg[i],x);
		i/=2;
	}while (i);
}

ll query(int a,int b,int k=1,int l=1,int r=s){
	if (a<=l && r<=b){
		return seg[k];
	}
	if (b<l || r<a){
		return 0;
	}
	int mid=(l+r)/2;
	return max(query(a,b,k*2,l,mid),query(a,b,k*2+1,mid+1,r));
}

int main(){
	scanf("%d",&n);
	ll sum=0;
	REP(i,n){
		scanf("%d",&x[i]);
		sum+=x[i];
	}
	init();
	REP(i,n){
		update(x[i],query(1,x[i])+x[i]);
	}
	printf("%lld\n",sum-seg[1]);
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long Xor(long long a) {
    if(a%4==0)return a;
    if(a%4==1)return 1;
    if(a%4==2)return a+1;
    return 0;
}
int main(){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",Xor(a-1)^Xor(b));
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i, a, b+1){
        string s = to_string(i);
        string t = s;
        reverse(s.begin(), s.end());
        if(s == t) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3676
while 1:
    n,r=map(int,input().split())
    if n==0: break
    c=list(range(n,0,-1))
    for _ in range(r):
        a,b=map(int,input().split())
        c=c[a-1:a+b-1]+c[:a-1]+c[a+b-1:]
    print(c[0])

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

int main(){
    long long H;
    std::cin >> H;
    long long at_num_p2 = 0;
    
    while(H != 0){
        H /= 2;
        at_num_p2++;
    }
    
    long long ans = 1;
    long long at_num_tmp = 1;
    for(int i=1; i<at_num_p2; i++){
        at_num_tmp *= 2;
        ans += at_num_tmp;
    }
    std::cout << ans << std::endl;
    return 0;
    
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    
    int cnta=0,cntb=0,i;
    for(i=0;i<s.length();i++)
    {
        if(s[i]=='A')
            cnta++;
        else
            cntb++;
    }
    
    if(cnta>0 && cntb>0)
        cout<<"Yes";
    else
         cout<<"No";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 998244353
int main()
{
    int n,i,u,v;
    scanf("%d",&n);
    long long temp,ans=n+2;
    ans=ans*(n+1);
    ans=ans*n/6;
    for(i=1;i<n;i++)
    {
        scanf("%d %d",&u,&v);
        if(u>v) swap(u,v);
        temp=n+1-v;
        temp=temp*u;
        ans=ans-temp;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v{ a, b, c };
	sort(v.begin(), v.end());
	cout << v[2] - v[0];

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
  int n,i;
  cin>>n;
  long a[n];
  for(i=0;i<n;i++)
      cin>>a[i];
  long result=a[0],count=0;
  for(i=1;i<n;i++)
      result=gcd(a[i],result);
  while(result%2==0)
  {
      result/=2;
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    double a, b, x, ans;
    cin >> a >> b >> x;
    double c = a * a * b / 2;
    if (c >= x){
        ans = atan(a * pow(b, 2) / (2 * x)) * 360 / (2 * PI);
    }
    else{
        ans = atan(2 * ((pow(a, 2) * b - x) / pow(a, 3))) * 360 / (2 * PI);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 512
S = input()
result = [0] * len(S)

for i in range(len(S)-1, 0, -1):
    s = len(S) - i - 1
    # 右方向
    if S[s] == 'R':
        if S[s] == S[s+1]:
            result[s+2] += result[s] + 1
            result[s] = 0
        else:
            result[s] += 1

    # 左方向
    if S[i] == 'L':
        if S[i] == S[i-1]:
            result[i-2] += result[i] + 1
            result[i] = 0
        else:
            result[i] += 1

print(' '.join([str(x) for x in result]))


Measured memory_bytes: 17076
<?php

$nums = explode(' ',trim(fgets(STDIN)));

for($i=0; $i<$nums[0]; $i++){
  $words[$i] = trim(fgets(STDIN));
}

sort($words);
                    
for($i=0; $i<$nums[0]; $i++){
  echo $words[$i];
}                    

?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 200010
#define endl '\n'
#define mp make_pair
#define INF 10000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)
#define coutyes cout<<"YES"
#define coutno cout<<"NO"

using namespace std;


int main() {
/*	ll n,m,x;
	cin>>n>>m>>x;
	ll c[n],a[n][m];
	forn(i,n){
		cin>>c[i];
		forn(j,m){
			cin>>a[i][j];
		}
	}
	bool flag=1;
	forn(i,m){
		ll sum=0;
		forn(j,n){
			sum+=a[j][i];
		}
		if(sum<x){
			flag=0;
			break;
		}
	}
	if(!flag){
		cout<<-1;
		return;
	}
	ll ans=0;
	*/
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	ll i=1;
	set<ll> se;
	vector<ll> v;
	v.pb(1);
	se.insert(1);
	ll j;
	int flag=1;
	ll x;
	for(j=1;j<=k;j++){
		if(se.find(a[i])==se.end()){
			i=a[i];
			se.insert(i);
			v.pb(i);
		//	flag=1;
		}
		else{
			x=a[i];
			flag=0;
			break;
		}
	}
	//cout<<j;
	set<ll>::iterator it;
	//forn(q,v.size())	cout<<v[q]<<' ';
	if(flag==1){
		cout<<i;
	}
	else{
		if(j==k){
			cout<<a[i];
		}
		else{
			i=a[i];
			k-=j;
			ll n=v.size();
			ll pos=-1;
			forn(q,n){
				if(v[q]==i){
					pos=q+1;
					break;
				}
			}
			ll m=n-pos+1;
			k%=m;
			cout<<v[pos-1+k];
		}
	}
}
 

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

bool positive(vector<int> &value, int x){
    int n = (int)value.size();
    int m = n / 2;
    int a = m - 1, b = m + 1;

    while (b < n && (value[b] >= x) != (value[b-1]>=x))
        b++;
    while (a >= 0 && (value[a] >= x) != (value[a+1]>=x))
        a--;
    a++;
    b--;

    if ((value[b]>=x)==(value[a]>=x))
        return value[b]>=x;

    if (b - m < m - a)
        return value[b] >= x;
    else
        return value[a] >= x;
}

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

    int n;
    cin >> n;
    n = 2 * n - 1;

    vector<int> value(n);

    for (int i = 0; i < n; ++i)
        cin >> value[i];

    int lo = 0, hi = n + 1;

    while (lo + 1 < hi){
        int mid = (lo + hi) / 2;

        if (positive(value, mid))
            lo = mid;
        else
            hi = mid;
    }

    cout << lo << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

// m > n >= 0
template <class T>
T gcd(T m, T n)
{
    if (n == 0)
        return m;
    return gcd(n, m % n);
}

// m > n >= 0
template <class T>
T lcm(T m, T n)
{
    return m * n / gcd(m, n);
}

int main()
{
    i64 a, b;
    cin >> a >> b;

    if (a < b)
        swap(a, b);

    i64 ans;
    ans = lcm(a, b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
v=0
s=0
ans=0
l.append(0)
for i in range(max(l)):
    v=0
    s=0
    while v<len(l):
        while l[v]!=0:
            v+=1
        if l[s]!=0:
            for y in range(v-s):
                l[s+y]-=1
            ans+=1
        s=v+1
        v+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()

struct edge{
    int to, cost;
    edge(int t, int c) { to = t; cost = c;}
};
struct vertex{
    int number, cost;
    vertex(int n, int c) { number = n; cost = c;}
    bool operator> (const vertex &a) const{
        return cost > a.cost;
    }
};
vector<vector<edge>> graph;
const int INF = INT_MAX;
vector<int> dist;
vector<int> prv;

//If a graph has a closed path, it returns true.
bool bellmanford(int n, int start){
    dist = vector<int>(n,INF);
    prv  = vector<int>(n,-1);
    dist[start] = 0;
    for(int i=0; i<n+1; i++){
        for(int v=0; v<n; v++){
            for(edge e : graph[v]){
                if(dist[v]==INF || dist[v] + e.cost >= dist[e.to]) continue;
                dist[e.to] = dist[v] + e.cost;
                prv[e.to] = v;
                if(i == n) return true;
            }
        }
    }
    return false;
}

int main() {
    int V, E;
    cin >> V >> E;
    graph = vector<vector<edge>>(V);
    rep(i,E){
        int s, t, d;
        cin >> s >> t >> d;
        graph.at(s).push_back(edge(t,d));
    }
    vector<vector<int>> cost_table(V);
    for(int v=0; v<V; v++){
        if(bellmanford(V, v)){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }else{
            rep(i,V) cost_table[v].push_back(dist[i]);
        }
    }
    rep(j,V){
        rep(i,V){
            if(cost_table[j][i]!=INF){
                cout << cost_table[j][i];
            }else{
                cout << "INF";
            }
            if(i!=V-1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int n, m, total = 0;
    scan2Int(n, m);
    int as[n];
    rep(i, n) {
        cin >> as[i];
        total += as[i];
    }
    double border = (double) total / (4 * m);
    rep(i, n) {
        if (as[i] >= border)
            m -= 1;
        if (m <= 0) break;
    }
    if (m <= 0)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3672
n = int(input())

if n == 19 or n == 29 or n == 39 or n == 49 or n == 59 or n == 69 or n == 79 or n == 89 or n == 91 or n == 92 or n == 93 or n == 94 or n == 95 or n == 96 or n == 97 or n == 98 or n == 99 :
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
N, K = list(map(int, list(input().split())))
h = list(map(int, list(input().split())))
h = [0] + h

dp = [0x3f3f3f3f for _ in range(N+1)]
dp[1] = 0
for i in range(1, N+1):
    for j in range(1, K+1):
        if j > i:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
print(dp[N])

Measured memory_bytes: 58080
N = input()
n = []
for i in N:
  n.append(int(i))
if n[0] == n[1] == n[2] == n[3]:
  print('Yes')
elif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9152
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn=1, Kr=1, Knr=1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N;
	long int x[50], y[50];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i];
	}

	int p, q;
	int ans = N;

	for (int i = 0; i < N-1; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			p = x[i] - x[j];
			q = y[i] - y[j];

			int cost = N;

			for (int k = 0; k < N-1; k++)
			{
				for (int l = k+1; l < N; l++)
				{
					bool A = (x[k] - x[l] == p && y[k] - y[l] == q);
					bool B = (x[k] - x[l] == -p && y[k] - y[l] == -q);
					if (A || B) cost--;
				}
			}

			ans = min(ans, cost);
		}
	}

	cout << ans;

	return 0;
}

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

using namespace std;

int n, m, two, four;
char s[110];
int num[26];

int main(){
	int t, i, j;
	scanf("%d %d", &n, &m);
	for(i = 1; i <= n; ++i){
		scanf("%s", s + 1);
		for(j = 1; j <= m; ++j)
			++num[s[j]-'a'];
	}
	
	two = (n & 1) * (m / 2) + (m & 1) * (n / 2);
	four = (n / 2) * (m / 2);
	
	for(i = 0; i < 26; ++i){
		t = min(num[i] / 4, four);
		num[i] -= t * 4; four -= t;
	}
	
	for(i = 0; i < 26; ++i){
		t = min(num[i] / 2, two);
		num[i] -= t * 2; two -= t;
	}
	
	if(!four && !two) puts("Yes"); else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
const int  d_MAX=1e9;

int N,M;
int d[300001];
vector<vector<int>> G;

void bfs(int s,int t){
    FOR(i,0,G.size())d[i]=d_MAX;
    d[s]=0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
      if (v==t)return;
        for(auto w:G[v]){
            if(d[w]==d_MAX){
                d[w]=d[v]+1;
                que.push(w);
            }
        }
    }
}

int main(){
    cin>>N>>M;
    G.resize(3*N);
    int u,v;
    FOR(i,0,M){
        cin>>u>>v;
        u--;v--;
        int u0,u1,u2,v0,v1,v2;
        u0=3*u;u1=3*u+1;u2=3*u+2;
        v0=3*v;v1=3*v+1;v2=3*v+2;
        G[u0].push_back(v1);
        G[u1].push_back(v2);
        G[u2].push_back(v0);
    }
    cin>>u>>v;
    u--;v--;
    bfs(3*u,3*v);
    if(d[3*v]==d_MAX)cout<<-1<<endl;
  else cout<<d[3*v]/3<<endl;
    return 0;
}

Measured memory_bytes: 17792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




vector <vector <long long>> prime_factorize(long long N) {
    vector <vector <long long>> res;
    long long upper = N;
    for (long long i = 2; i * i <= upper; ++i) {
        vector <long long> inp = {0, 0};
        while(1) {
            if (N % i == 0) {
                inp[0] = i;
                N /= i;
                ++inp[1];
            }
            else break;
        }
        if (inp[0] > 0) {
            res.push_back(inp);
        }
    }

    if (N != 1) res.push_back({N, 1});

    return res;
}





int main(void) {

    
    ll N; cin >> N;
    vector<vector<ll>> v = prime_factorize(N);

    ll ans = 0;
    rep(i,v.size()) {
        int k;
        for (int j = 0; ; ++j) {
            if (j * (j + 1) <= 2 * v[i][1] && 2 * v[i][1] < (j + 1) * (j + 2)) {
                k = j;
                break;
            }
        }
        ans += k;
    }

    
    out(ans);

    return 0;
}









Measured memory_bytes: 3628
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_8_C
//p222.cpp

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
	while( x->left != NIL ) x = x->left;
	return x;
}

Node * treeSuccessor(Node *x){
	if ( x->right != NIL ) return treeMinimum(x->right);
	Node *y = x->parent;
	while( y != NIL && x == y->right ){
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node *z){
	Node *y; //$B:o=|$9$kBP>](B
	Node *x; // y $B$N;R(B

	//$B:o=|$9$k@aE@$r7h$a$k(B
	if ( z->left == NIL || z->right == NIL ) y = z;
	else y = treeSuccessor(z);

	// y $B$N;R(B x $B$r7h$a$k(B
	if ( y->left != NIL ){
		x = y->left;
	}else{
		x = y->right;
	}

	if ( x != NIL ){
		x->parent = y->parent;
	}

	if ( y->parent == NIL ){
		root = x;
	}else{
		if ( y == y->parent->left){
			y->parent->left = x;
		}else{
			y->parent->right = x;
		}
	}

	if ( y != z ){
		z->key = y->key ;
	}

	free(y);
}


Node * find(Node *u, int k){
	while ( u != NIL && k != u->key ){
		if ( k < u->key ) u = u->left ;
		else u = u->right;
	}
	return u;
}


void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while ( x != NIL ){
		y = x;
		if ( z->key < x->key ){
			x = x->left;
		}else{
			x = x->right;
		}
	}

	z->parent = y;
	if ( y == NIL ){
		root = z;
	}else{
		if ( z->key < y->key ) {
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void inorder(Node *u){
	if ( u == NIL ) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u){
	if ( u == NIL ) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	string com;

	scanf("%d", &n);

	for ( i = 0; i < n; i++ ) {
		cin >> com;
		if ( com[0] == 'f' ){
			scanf("%d", &x);
			Node *t = find(root, x);
			if ( t != NIL )printf("yes\n");
			else printf("no\n");
		} else if ( com == "insert" ) {
			scanf("%d", &x);
			insert(x);
		} else if ( com == "print" ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if ( com == "delete" ){
			scanf("%d", &x);
			treeDelete(find(root, x));
		}
	}

	return 0;
}




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

int calcGcd(int, int);

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<int> a(n);
	for (auto& e: a) scanf("%d", &e);
	std::sort(a.begin(), a.end());
	int gcd{a.front()};
	for (auto& e: a)
	{
		gcd = calcGcd(e, gcd);
	}
	printf("%d\n", gcd);

	return 0;
}

int calcGcd(int a, int b)
{
	while (a)
	{
		b %= a;
		std::swap(a, b);
	}
	return b;
}

Measured memory_bytes: 640
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
using graph = vector<vector<int>>;
typedef long long ll;

int main() {
	ll n, m;
	cin >> n >> m;
	ll sum=0,mem;
	for (ll i = 0; i < m; i++) {
		cin >> mem;
		sum = sum + mem;
	}
	if (n  < sum) {
		cout << "-1" << endl;
	}
	else {
		cout << n - sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
# ABC102B - Maximum Difference
n = int(input())
lst = list(map(int, input().rstrip().split()))
max_dif = 0

for i in range(n):
    for j in range(n):
        max_dif = max(max_dif, abs(lst[i] - lst[j]))
    
print(max_dif)

Measured memory_bytes: 3060
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;


	clock_t startTime=clock();

	ll n;
	cin>>n;
	ll ar[n];
	rep(i,0,n)
	{
		cin>>ar[i];
	}

	sort(ar,ar+n);

	cout<<ar[n-1]-ar[0];

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

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

	if (b>c) {
		swap(b,c);
	}

	if (a>b) {
		swap(a,b);
	}

	if (b > c) {
		swap(b, c);
	}

	cout << a << ' ' << b << ' ' << c << '\n';
	return 0;
}

Measured memory_bytes: 3040
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int i[3][110000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d=0,e=0;
  string s;
  cin >>a>>b;
  c=a;
  if(b>0) b=0;
  if(a>0) cout <<"Positive\n";
  if(a<=0&&b>=0) cout <<"Zero\n";
  else{
    if(a<0){
      if(abs(a-b)%2!=0) cout <<"Positive\n";
      else cout <<"Negative\n";
    }
  }
  return (0);
}


Measured memory_bytes: 256
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line;
while((line=br.readLine())!=null){
String[] value=line.split(",");
double xa=Double.parseDouble(value[0]);
double ya=Double.parseDouble(value[1]);
double xb=Double.parseDouble(value[2]);
double yb=Double.parseDouble(value[3]);
double xc=Double.parseDouble(value[4]);
double yc=Double.parseDouble(value[5]);
double xd=Double.parseDouble(value[6]);
double yd=Double.parseDouble(value[7]);
double area1=area(xb-xa,yb-ya,xd-xa,yd-ya)+area(xb-xc,yb-yc,xd-xc,yd-yc);
double area2=area(xa-xb,ya-yb,xc-xb,yc-yb)+area(xa-xd,ya-yd,xc-xd,yc-yd);
if(area1==area2){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
static double area(double a,double b,double c,double d){
return Math.abs(a*d-b*c)/2;
}
}

Measured memory_bytes: 16924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  int N; cin >> N;
  double total = 0;
  for (int i = 0; i < N; i++) {
    double xi;
    string ui;
    cin >> xi >> ui;
    if (ui == "JPY") {
      total += xi;
    } else {
      total += 380000.0 * xi;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  int n, x, result;
 
  while(1) {
    cin >> n >> x;
    if(n == 0 && x == 0) break;
 
    result=0;
    for(int i=1; i <= n-2; i++) {
      for(int j=i+1; j <= n-1; j++) {
        for(int k=j+1; k <= n; k++) {
          // cout << k << endl;
          if(i+j+k == x) result++;
        }
      }
    }
    cout << result << endl;
  }
 
  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define F first
#define S second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lld I64d
#define ii  pair<int,int>
int main()
{
    ios
    ll n,m,i,j,k,num,test=1,pdt=1,sum=0;
    ll a, b, c;
    cin>>n>>a>>b;
    cout<<min(n*a, b);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4");
            WillReturn.Add("2 10 8 40");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("5 13 8 1000000000");
            //1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("3");
            WillReturn.Add("1000000000 1000000000 1000000000");
            //1000000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        int GCD = wkArr[0];
        for (int I = 1; I <= wkArr.GetUpperBound(0); I++) {
            GCD = DeriveGCD(GCD, wkArr[I]);
        }
        Console.WriteLine(GCD);
    }

    //ユークリッドの互除法で2数の最大公約数を求める
    static private int DeriveGCD(int pVal1, int pVal2)
    {
        pVal1 = Math.Abs(pVal1);
        pVal2 = Math.Abs(pVal2);

        int WarareruKazu = Math.Max(pVal1, pVal2);
        int WaruKazu = Math.Min(pVal1, pVal2);

        while (true) {
            int Amari = WarareruKazu % WaruKazu;
            if (Amari == 0) return WaruKazu;
            WarareruKazu = WaruKazu;
            WaruKazu = Amari;
        }
    }
}


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

typedef long long LL;

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

const int SZ = 200005;
int n, m;
int x[SZ], y[SZ];

int main() {
    setIO();
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>x[i]>>y[i];
    }
    vector<int> sums(n);
    for (int i = 0; i < n; i++) {
        sums[i] = x[i]+y[i];
    }
    int r1 = *max_element(sums.begin(), sums.end())
    - *min_element(sums.begin(), sums.end());

    for (int i = 0; i < n; i++) {
        sums[i] = x[i]-y[i];
    }
    int r2 = *max_element(sums.begin(), sums.end())
    - *min_element(sums.begin(), sums.end());

    cout<<max(r1, r2)<<endl;
    
    return 0;
}

Measured memory_bytes: 5576
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
// #define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'
ll Pow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a);
		a=(a*a);
		b>>=1;
	}
	return res;
}
struct pii
{
	ll val;
	ll cnt;
	ll vv;
	pii(ll _a,ll _b){
		val=_a;
		cnt=_b;
		vv=0;
		if(cnt<=30){
			vv=val/(1LL<<cnt);
			// vv=round(val*1.0/(1LL<<cnt));
		}
	}
	bool operator<(const pii &a)const{
		// ll p=eval();
		// ll q=a.eval();
		ll p=vv-pii(val,cnt+1).vv;
		ll q=a.vv-pii(a.val,a.cnt+1).vv;
		if(p==q)return val<a.val;
		return p<q;
	}
};

int main()
{
	priority_queue<pii> q;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		q.push(pii(a,0LL));
	}
	while(m--){
		pii x=q.top();
		q.pop();
		// cout<<x.val<<' '<<x.cnt+1<<' '<<x.vv<<endl;
		q.push(pii(x.val,x.cnt+1));
	}
	ll an=0;
	while(!q.empty()){
		pii x=q.top();
		q.pop();
		// ll vv=0;
		// if(x.cnt<=30){
		// 	vv=round(x.val*1.0/(1LL<<x.cnt));
		// }
		// cout<<x.val<<' '<<x.cnt<<endl;
		an+=x.vv;
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 6388
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc167B
    {
        public static void Main()
        {
            var abck = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var k = abck[3];
            long max = 0;
            if (abck[0] >= k)
            {
                Console.WriteLine(k);
                return;
            }
            max = abck[0];
            if (abck[0] + abck[1] < k)
                max -= (k - abck[0] - abck[1]);
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 28096
#include <bits/stdc++.h>
#define fo(i, a, b) for (ll i = a; i < ll(b); i++)
#define fr(i, a, b) for (ll i = b - 1; i >= ll(a); i--)
#define al(x) begin(x), end(x)
#define ral(x) rbegin(x), rend(x)
#define I(x) ll x; cin >> x;
#define this (*this)
#define ar array
#define vc vector
#define pb push_back
#define rs resize
#define is insert
#define vl vc<ll>
#define popcnt __builtin_popcountll
#define sp <<" "<<
using namespace std;
using namespace std::placeholders;
using ll = long long;
using ld = long double;
using pa = array<ll, 2>;
using ve = ar<ll,3000>;
using mt = ar<ve,3000>;
using pr = pair<ll, ll>;
using bt = bitset<64>;
#ifdef DEBUG
#include "../debug.h"
#else
#define dbg(x)
#define cerr if(false) cerr
#endif
const ll M = 998244353, inf = 1e18;
istream& operator>>(auto& is, auto &v) {
  for (auto &x : v) {
    cin >> x;
  }
}
int main() {
	ios::sync_with_stdio(false);
	cin.exceptions(ios::badbit | ios::failbit);
	I(h);I(w);I(n);
	I(sr);I(sc);
	string s,t;
	cin>>s>>t;
	bool ok=1;
	{
	ll x=sr, y=sc;
	fo(i,0,n){
		if(s[i]=='U'){--x;}
		ok&=(1<=x && x<=h);
		if(t[i]=='D' && x < h){++x;}
		
		if(s[i]=='L'){--y;}
		ok&=(1<=y && y<=w);
		if(t[i]=='R' && y < w){++y;}
	}
	}
	{
	ll x=sr, y=sc;
	fo(i,0,n){
		if(s[i]=='D'){++x;}
		ok&=(1<=x && x<=h);
		if(t[i]=='U' && x > 1){--x;}
		
		if(s[i]=='R'){++y;}
		ok&=(1<=y && y<=w);
		if(t[i]=='L' && y > 1){--y;}
	}
	}
	/*fo(i,0,n){
		#define up ok&=(x1>=1 && y1>=1 && x2<=h && y2<=w);
		y1-=(s[i]=='L');
		x1-=(s[i]=='U');
		up;
		if(y1<h){y1+=(t[i]=='R');}
		if(x1<w){x1+=(t[i]=='D');}
		up;
		y2+=(s[i]=='R');
		x2+=(s[i]=='D');
		up;
		if(x2>1){x2-=(t[i]=='U');}
		if(y2>1){y2-=(t[i]=='L');}
		up;
		dbg(x2);dbg(y2);
	}*/
	cout<<(ok?"YES":"NO")<<endl;
}

Measured memory_bytes: 920
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

temps = []

for i, v in enumerate(h):
    h[i] = t - h[i] * 0.006
    temps.append(abs(a - h[i]))

print(temps.index(min(temps)) + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

    ll X,Y; cin >> X >> Y;
    vector<ll> vec{};
    
    ll index = X;
    while(1){
        vec.push_back(index);
        index *= 2;
        if(index > Y) break;
    }
    
    cout << vec.size() << endl;
}

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

int sum (int l, int r) {
  return (r*(r+1)-l*(l-1)) / 2;
}

int main() {
  int n;
  while (cin >> n, n) {
    int l, r;
    int ans = 0;
    for (int l=1; l<=n; l++) {
      for (int r=l+1; r<=n; r++) {
        int ret = sum(l, r);
        /* if (ret == n) cout << l << ", " << r << "= " << ret << endl; */
        if (ret == n) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2996
# coding: utf-8
# Your code here!
N=int(input())
S,T=(input().split(" "))
S=list(S)
T=list(T)

#print(S,T)

ans=[]
for _ in range(N):
    ans.append(S.pop(0))
    ans.append(T.pop(0))
    
print("".join(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int A, B; cin >> A >> B;
  if(A>=13) cout << B << endl;
  else if(A>=6) cout << B/2 << endl;
  else cout << 0 << endl;
  return 0;
}


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

int main() {
    string n;
  	cin >> n;
  
  	for (int i = 0; i < n.size(); i++) {
     	if (n.at(i) == '1') n.at(i) = '9';
      	else if (n.at(i) == '9') n.at(i) = '1';
    }
  
  	cout << n << endl;
}

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

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

  return 0;
}

Measured memory_bytes: 256
type Card = (String, Int)
type Deck = [(Card, Bool)]

setupDeck :: Deck
setupDeck = [((m, n), False) | m <- ["S", "H", "C", "D"], n <- [1..13]]

updateDeck :: Card -> Deck -> Deck
updateDeck _ [] = []
updateDeck card@(m, n) (x@((m', n'), _):xs)
  | m == m' && n == n' = ((m, n), True):xs
  | otherwise          = x:(updateDeck card xs)

readCards :: Int -> Deck -> IO Deck
readCards 0 deck = return deck
readCards n deck = getLine >>= return.words >>= \[m, i] -> readCards (n - 1) $ updateDeck (m, read i :: Int) deck

printLackCards :: Deck -> IO ()
printLackCards [] = return ()
printLackCards (((m, n), r):xs)
  | not r     = putStrLn (m ++ " " ++ show n) >> printLackCards xs
  | otherwise = printLackCards xs

main :: IO ()
main = do
    n <- getLine >>= \n -> return (read n :: Int)
    readCards n setupDeck >>= printLackCards



Measured memory_bytes: 4080
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66020
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n, k, q; cin >> n >> k >> q;
	vector<int> a(n);
	rep(i, q){
		int aa; cin >> aa;
		aa--;
		a[aa]++;
	}
	rep(i, n){
		if(k-q+a[i] <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import fractions

A, B, C, D = map(int, input().split())

countAB = B - A + 1
ansC = B // C - (A - 1) // C
ansD = B // D - (A - 1) // D
lcmCD = (C * D) // fractions.gcd(C,D)
ansCD = B // (lcmCD) - (A - 1) // (lcmCD)

print(countAB - (ansC + ansD - ansCD))

Measured memory_bytes: 5048
N = int(input())
xyh = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        xyh.append([x, y, h])

if len(xyh) == 1:
    Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]

elif len(xyh) == 2:
    if xyh[0][2] > xyh[1][2]:
        Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]
    else:
        Cx, Cy, H = xyh[1][0], xyh[1][1], xyh[1][2]

else:
    flag = False
    for i in range(101):
        for j in range(101):
            sampleH = xyh[0][2] + abs(i-xyh[0][0]) + abs(j-xyh[0][1])
            for k in range(1, len(xyh)):
                flag = True
                if xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1]) != sampleH:
                    flag = False
                    break
            if flag:
                Cx, Cy, H = i, j, sampleH
                break
        if flag:
            break

print(Cx, Cy, H)


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

int main()
{
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	cout << max(0, min(B, D) - max(A, C)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char s[4];
	scanf("%s", s);

	for (int bit = 0; bit < (1 << 3); bit++) {
		char ope[3] = {'-', '-', '-'};
		for (int i = 0; i < 3; i++) {
			if (bit & (1 << i)) {
				ope[i] = '+';
			}
		}
		int ans = s[0] - '0';
		for (int i = 0; i < 3; i++) {
			int n = s[i + 1] - '0';
			if (ope[i] == '-') {
				ans -= n;
			}
			else {
				ans += n;
			}
		}

		if (ans == 7) {
			printf("%c", s[0]);
			for (int i = 0; i < 3; i++) {
				if (ope[i] == '-')
					printf("-");
				else
					printf("+");
				printf("%c", s[i + 1]);
			}
			printf("=%d\n", ans);
			break;
		}
	}

	return 0;
}

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

int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n / 1000;
  b = n % 1000 / 100;
  c = n % 100 / 10;
  d = n % 10;
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    cin >>str;
    int a;
    int b,c;
    while(str!="-"){
        cin >>b;
        for(a=0;a<b;a++){
            cin >>c;
            str=str.substr(c,str.size()-c)+str.substr(0,c);
        }
        cout << str << endl;
        cin >>str;
    }
    return 0;
}


Measured memory_bytes: 3144
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
vector<int>g[26];
vector<int>ans;
bool used[26];
void dfs(int pos){
    if(used[pos])return;
    used[pos]=true;
    for(int i=0;i<g[pos].size();i++){
        dfs(g[pos][i]);
    }
    ans.push_back(pos);
}
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        fill_n(g,26,vector<int>(0));
        fill_n(used,26,false);
        ans.clear();
        char str[1025];
        scanf("%s",str);
        if(strlen(str)==1){
            printf("%c\n",str[0]);
            continue;
        }
        for(int i=1;str[i];i+=3){
            int v1=str[i-1]-'a';
            int v2=str[i+2]-'a';
            if(str[i]=='-'){
                g[v1].push_back(v2);
            }
            else{
                g[v2].push_back(v1);
            }
        }
        for(int i=0;i<26;i++){
            sort(g[i].begin(),g[i].end());
            g[i].erase(unique(g[i].begin(),g[i].end()),g[i].end());
        }
        for(int i=0;i<26;i++)if(g[i].size())dfs(i);
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            printf("%c",ans[i]+'a');
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 1080