akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[111111];
vector<int> ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=1,e=0,f=0,g=0,h,j;
  cin >>i[0]>>i[1]>>i[2];
  sort(i,i+3);
  cout <<i[0]+i[1]<<'\n';
  return (0);
}


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

string str;
char ch;

int px,py;
int main()
{
    cin>>str; px=py=-1;
    int lg=str.length();
    if(str[0]==str[1])
    {
        cout<<1<<' '<<min(lg,3)<<'\n';
        return 0;
    }
    for(int i=2; i<lg; ++i)
        if(str[i-1]==str[i] || str[i-2]==str[i])
        {
            cout<<i-1<<' '<<i+1<<'\n';
            return 0;
        }
    cout<<-1<<' '<<-1<<'\n';
    return 0;
}


//https://atcoder.jp/contests/abc043/tasks/arc059_b?fbclid=IwAR1nkTmf1WOQJX8LHpmmf4YPIp15x5tlxq8pYPD7dTbjBD4Bz1CuFYpV3nU


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int n, L, m;
int a[100010];
int block, num;
int b[100010];
int to[100010];
int val[100010];
int nxt[100010];

int find(int x)
{
	int l = x + 1;
	int r = n;
	int ans;
	while(l <= r)
	{
		int mid = (l+r)/2;
		if(a[mid] - a[x] <= L)
		{
			ans = mid ;
			l = mid + 1;
		}
		else
		{
			r = mid - 1;
		}
	}
	return ans;
}

void build(void)
{
	block = sqrt(n);
	num = ceil(1.0*n / block);
	for(int i=1; i<=n; i++)
	{
		b[i] = (i-1) / block + 1;
	}
	for(int i=1; i<n; i++)
	{
		int t = i;
		int sp = 0;
		while(b[i] == b[t])
		{
			t = to[t];
			sp++;
		}
		val[i] = sp;
		nxt[i] = t;
	}
}

int query(int x, int y)
{
	int ans = 0;
	while(b[x] < b[y])
	{
		ans += val[x];
		x = nxt[x];
	}
	while(x < y)
	{
		x = to[x];
		ans++;
	}
	return ans;
}

int main(void)
{
	cin >> n; 
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
	}
	cin >> L >> m;
	for(int i=1; i<n; i++)
	{
		to[i] = find(i);
	}
	to[n] = n+1;
	build();
	while(m--)
	{
		int x, y;
		cin >> x >> y;
		if(x > y)
		{
			swap(x, y);
		}
		cout << query(x, y) << endl;
	}
	return 0;
}





















Measured memory_bytes: 2816
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

x = INT()
a = (x//500)*1000 + ((x-(x//500)*500)//5)*5
print(a)

Measured memory_bytes: 66028
N, K = [int(i) for i in input().split(' ')]
    
#p = list(range(K, N+1,K))
p = N//K

cnt = 0

if K%2:
    print(p ** 3)
else:
    for a in range(1,N+1):
        if a%K == K//2:
            cnt = cnt + 1
    print(p ** 3 + cnt**3)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[4] = {};
    string s;
    cin >> n;
    while (n--) {
        cin >> s;
        if (s == "AC") a[0]++;
        else if (s == "WA") a[1]++;
        else if (s == "TLE") a[2]++;
        else a[3]++;
    }
    cout << "AC x " << a[0] << '\n';
    cout << "WA x " << a[1] << '\n';
    cout << "TLE x " << a[2] << '\n';
    cout << "RE x " << a[3] << '\n';
}


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

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B, T;
	cin >> A >> B >> T;

	cout << T / A * B;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N,M,K;
vector<int>Ex[101010],Ey[101010];
ll dist[1000000];
map<vector<int>,int>mp;
vector<pair<int, int>>Enew[1000000];

void dijkstra() {
	for (int i = 0; i < 1000000;i++)dist[i] = inf;
	min_priority_queue<pair<ll,int>>q;
	int idx = mp[{0, 0, 0}];
	q.push({0,idx});
	while (q.size()) {
		auto p = q.top();
		q.pop();
		ll d = p.first;
		int v = p.second;
		fore(x, Enew[v]) {
			int to = x.first;
			ll cost = x.second;

			if (dist[to] > d + cost) {
				q.push({d+cost,to});
				dist[to] = d + cost;
			}
		}
	}
}

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

	cin >> M >> N >> K;
	int fl0 = 0;
	int fl1 = 0;
	for (int i = 0; i < K; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		Ex[x].pb(y);
		Ey[y].pb(x);
		if (x == 0 && y == 0)fl0 = 1;
		if (x == M - 1 && y == N - 1)fl1 = 1;
	}
	if (!fl0) { Ex[0].pb(0); }
	if (!fl1) { 
		Ex[M - 1].pb(N - 1); 
		Ey[N - 1].pb(M - 1);
	}

	for (int i = 0; i < 101010; i++)sort(all(Ex[i]));
	for (int i = 0; i < 101010; i++)sort(all(Ey[i]));

	int cnt = 0;
	for (int i = 0; i < 101010; i++) {
		fore(x, Ex[i]) {
			if (fl0 == 0 && i == 0 && x == 0) {
				mp[{0,0,0}] = cnt;
				cnt++;
			}
			else {
				mp[{i,x,0}] = cnt;
				cnt++;
				mp[{i,x,1}] = cnt;
				cnt++;
			}
		}
	}

	for (int i = 0; i < 101010; i++) {
		for (int j = 0; j + 1 < Ex[i].size(); j++) {
			int num1 = mp[{i,Ex[i][j],0}];
			int num2 = mp[{i,Ex[i][j+1],0}];
			int diff = Ex[i][j + 1] - Ex[i][j];
			Enew[num1].pb({num2,diff});
			Enew[num2].pb({num1,diff});
		}
	}
	for (int i = 0; i < 101010; i++) {
		for (int j = 0; j + 1 < Ey[i].size(); j++) {
			int num1 = mp[{Ey[i][j],i, 1}];
			int num2 = mp[{Ey[i][j+1], i, 1}];
			int diff = Ey[i][j + 1] - Ey[i][j];
			Enew[num1].pb({ num2,diff });
			Enew[num2].pb({ num1,diff });
		}
	}

	for (int i = 0; i < 101010; i++) {
		fore(x, Ex[i]) {
			if (fl0 == 0 && i == 0 && x == 0)continue;
			if (fl1 == 0 && i == M - 1 && x == N - 1)continue;
			int num1 = mp[{i, x, 0}];
			int num2 = mp[{i, x, 1}];
			Enew[num1].pb({ num2,1 });
			Enew[num2].pb({ num1,1 });
		}
	}
	dijkstra();

	ll ans = min(dist[mp[{M - 1, N - 1, 0}]], dist[mp[{M - 1, N - 1, 1}]]);
	if (ans > 1e16)puts(-1);
	else puts(ans);

	return 0;
}


Measured memory_bytes: 105676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N, K, d;
    cin >> N >> K;
    vector<int> snuke(N, 0);
    rep(i, K)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            a--;
            snuke[a]++;
        }
    }
    int cnt = 0;
    for (int s : snuke)
    {
        if (s == 0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3600
/***************************************************

@author: vichitr
Compiled On: 19th Mar 2020

*****************************************************/
#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define ip pair<int, int>
#define F first
#define S second

#define loop(i,n) for(int i=0;i<n;i++)
#define loops(i,s,n) for(int i=s;i<=n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 998244353;
const ll SZ = 107;
const ll N = 2e5+7;
// const ll M = 2e5+7;

ll pwr(ll x, ll y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r;
}

int inv(int x)
{
    return pwr(x, MOD-2ll);
}

// int fact[N];

// int nCr(int x, int y){
//     int ans= fact[x];
//     ans *= inv(fact[y]);
//     ans %= MOD;
//     ans *= inv(fact[x-y]);
//     ans %= MOD;
//     return ans;
// }

// bool prim(int n){
//     for(int i=2;i*i<=n;i++){
//         if(n%i==0)
//             return 0;
//     }
//     return 1;
// }
bool ispal(string s){
    int n = s.size();
    for(int i=0;i<n/2;i++)
        if(s[i]!=s[n-1-i])
            return 0;
    return 1;
}

int dp[3005][3005], a[3005], n, S;

int solve(int idx, int s){
    if(s == 0)
        return (n-idx+1);
    if(idx >= n or s < 0)
        return 0;
    int &ans = dp[idx][s];
    if(ans != -1)
        return ans;
    ans = 0;
    if(s == S){
        ans += solve(idx+1, s);
        // if(idx==0) cout<<ans<<" ";
        ans %= MOD;
        ans += (idx+1)*solve(idx+1, s-a[idx]);
        ans %= MOD;
        // if(idx==0)cout<<ans<<endl;
    }
    else{
        ans += solve(idx+1, s);
        ans %= MOD;
        ans += solve(idx+1, s-a[idx]);
        ans %= MOD;
    }
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    return ans;
}

void solve()
{ 
    // int s;
    cin>>n>>S;
    loop(i, n) cin>>a[i];
    int ans =0;
    memset(dp, -1, sizeof dp);
    ans = solve(0, S);
    cout<<ans;
}

signed main()
{
    fast;
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
// #endif
    int t=1;
    // cin >>t;

    // fact[0] =1;
    // for(int i=1;i<N;i++){
    //     fact[i] = fact[i-1]*i;
    //     fact[i] %= MOD;
    // }
    // int i  =1;
    while(t--){
        // int n = i++;
        solve();
        
    }
    return 0;
}

/*****************************

1
10 3
1 5 1
3 6 1
6 9 1


**************************/

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

int main() {
	string s, t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

long long walk(long long x, vector<long long> &s, vector<long long> &t){
    auto its = lower_bound(s.begin(), s.end(), x);
    int si=its-s.begin();
    auto itt = lower_bound(t.begin(), t.end(), x);
    int ti=itt-t.begin();

    vector<long long> lrst(0);
    lrst.push_back(s[si]-x);
    lrst.push_back(x-s[si-1]);
    lrst.push_back(t[ti]-x);
    lrst.push_back(x-t[ti-1]);

    //cout << x  << "_" << si << ' ' << ti << endl;

    long long ans = MOD*MOD;
    ans=min(ans, max(lrst[0],lrst[2]));
    ans=min(ans, max(lrst[1], lrst[3]));
    ans=min(ans, 2*min(lrst[0],lrst[1])+min(lrst[2],lrst[3]));
    ans=min(ans, min(lrst[0],lrst[1])+2*min(lrst[2],lrst[3]));
    return ans;
}

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

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

    vector<long long> s(A+2,0);
    vector<long long> t(B+2,0);
    s[A]=-100000000000;
    t[B]=-100000000000;
    s[A+1]=100000000000;
    t[B+1]=100000000000;
    for(int i=0; i<A; i++){
        cin >> s[i];
    }
    for(int i=0; i<B; i++){
        cin >> t[i];
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    //cout_vec(s);
    //cout_vec(t);

    for(int i=0; i<Q; i++){
        long long x;
        cin >> x;
        cout << walk(x, s, t) << endl;
    }
}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int mod = 1000000007;
inline int mul(int x,int y){return 1ll*x*y%mod;}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int sq(int x){return 1ll*x*x%mod;}
int mpow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(mpow(a,b/2))) : sq(mpow(a,b/2)));}

const int N = 1000000;
int fac[N+10],invfac[N+10],n,k;

int C(int n,int m){
	return mul(fac[n],mul(invfac[m],invfac[n-m]));
}

int main() {
	fac[0] = 1;
	for(int i=1;i<=N;i++)fac[i] = mul(fac[i-1],i);
	invfac[N] = mpow(fac[N],mod-2);
	for(int i=N-1;i>=0;i--) invfac[i] = mul(invfac[i+1],i+1);
	read(n);
	int ans = fac[n];
	for(int i=1;i<=n-1;i++){
		if(i*2<n)continue;
		int b0 = i*2-n,d0 = i-b0;
		assert(d0!=0);
		ans = sub(ans,mul(C(i-1,d0-1),mul(fac[i],fac[n-1-i])));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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;

int N;
ll a[100010];

int main() {
    cin >> N;
    a[0] = 0;
    for (int i = 1; i <= N; i++) cin >> a[i];
    a[N+1] = 0;
    ll S = 0;
    for (int i = 1; i <= N+1; i++) {
        S += abs(a[i] - a[i-1]);
    }

    for (int i = 1; i <= N; i++) {
        cout << S - abs(a[i] - a[i-1])
                  - abs(a[i+1] - a[i])
                  + abs(a[i+1] - a[i-1]) << endl;
    }
}


Measured memory_bytes: 2048
def main():
    N, K = map(int, input().split())
    max_K = (N - 1) * (N - 2) // 2
    if K > max_K:
        print(-1)
        exit()

    ans = []
    for i in range(2, N+1):
        ans.append((1,i))

    cand = []
    for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
    for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

    print(len(ans))
    for u, v in ans:
        print(u,v)



if __name__ == "__main__":
    main()

Measured memory_bytes: 43120
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/


int main(){
  ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> v(n+1),w(n+1);
  rep(i,n){
    cin >> v[i+1] >> w[i+1];
  }
  vector<vector<P>> data((1<<10)+5); //d9 made hanbun-zenrekkyo
  REP(i,1,min(n+1,1<<10)){
    vector<int> ls;
    if(i==1){
      data[i].emplace_back(w[i],v[i]);
      data[i].emplace_back(0,0);
    } else {
      for(auto it:data[i/2]){
        data[i].emplace_back(it.F,it.S);
        data[i].emplace_back(it.F+w[i],it.S+v[i]);
      }
    }

    sort(data[i].begin(),data[i].end());
    REP(j,1,data[i].size()){
      data[i][j].S = max(data[i][j].S, data[i][j-1].S);
    }
  }

  int q;
  cin >> q;
  while(q--){
    int x,L; cin >> x >> L;
    if(x<min(n+1,1<<10)){
      int pos = lower_bound(data[x].begin(),data[x].end(),P(L+1,0)) - data[x].begin();
      int ans = data[x][pos-1].S;
      cout << ans << ln;
    } else {
      vector<int> ls;
      int tmp = x;
      while(tmp>=(1<<10)){ ls.emplace_back(tmp); tmp/=2; }
//      sort(ls.rbegin(),ls.rend());
      int sz = ls.size();
      int ans = 0;
      rep(b,1<<sz){
        int vsum = 0, wsum = 0;
        rep(j,sz)if(bit(b,j)){
          vsum += v[ls[j]];
          wsum += w[ls[j]];
        }
        if(wsum>L) continue;
        int pos = lower_bound(data[tmp].begin(),data[tmp].end(),P(L-wsum+1,0)) - data[tmp].begin();
        ans = max(ans, vsum+data[tmp][pos-1].S);
      }
      cout << ans << ln;
    }
  }

  return 0;
}

Measured memory_bytes: 10832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};

int dist[21][21];
int H, W;
char S[21][21];
int res;

void clean(){
  rep(i,H){
    rep(j,W){
      dist[i][j]=INF;
    }
  }
  return;
}

int bfs(int xs,int ys, int xg, int yg){
  queue<P> que;
  clean();
  que.push(P(ys,xs));
  dist[ys][xs]=0;

  while(que.size()){
    P p = que.front(); que.pop();
    int x0 = p.second; int y0 = p.first;
    if(y0==yg && x0==xg) break;

    rep(i,4){
      int x = x0 + dx[i]; int y = y0 + dy[i];
      if(0<=x && x <= W-1 && 0<=y && y<=H-1){
        if(S[y][x]=='.' && dist[y][x]==INF) {
          que.push(P(y,x));
          dist[y][x] = dist[y0][x0]+1;
        }
      }
    }
  }
  return dist[yg][xg];
}

int main()
{
  cin >> H >> W;

  rep(i,H) cin >> S[i];

  res=0;
  rep(sy,H){
    rep(sx,W){
      if(S[sy][sx] == '#') continue;
      rep(gy, H){
        rep(gx, W){
          if(S[gy][gx] == '#') continue;
          clean();
          int num = bfs(sx,sy,gx,gy);
          if(num < INF) res = max(res, num);
          //printf("s(%d, %d) g(%d, %d): %d\n", sx, sy, gx, gy, num);           
          //print();                                                            
        }
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

int main() {
    string S;
    cin >> S;

    int left = 0;
    int right = S.size() - 1;
    int ans = 0;

    while (right - left > 0) {
        if (S[left] != S[right]) ans++;
        left++;
        right--;
    }
    cout << ans << endl;

    return 0;
}


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

int n,m,q;
int grid[501][501];
int ans[501][501];

int main(){
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		int l,r;
		cin>>l>>r;
		grid[l][r]++;
	}
	for(int i=n;i>=1;i--){
		for(int j=1;j<=n;j++){
			ans[i][j]=grid[i][j]+ans[i][j-1]+ans[i+1][j]-ans[i+1][j-1];
		}
	}
	
	for(int i=1;i<=q;i++){
		int l,r;
		cin>>l>>r;
		cout<<ans[l][r]<<endl;
	}
}

Measured memory_bytes: 2944
import std.stdio;
import std.string;
import std.array;
import std.range;
import std.algorithm;
import std.conv;
import std.typecons;

long solve(long d, long n){
    if(n != 100){
        return 100 ^^ d * n;
    }else{
        return 100 ^^ (d+1) + 100 ^^ d;
    }
}

void main(){
    auto dn = readln().chomp().split().map!(to!long).array();
    auto d = dn[0];
    auto n = dn[1];
    solve(d, n).writeln();
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

template < typename T > 
inline string toString( const T &a ) 
{ ostringstream oss; oss << a; return oss.str(); };

long long dp[105][2][5];
int K;

long long solve(const string &s){

    const int L=s.size();

    fill((long long *)dp,(long long*)dp+sizeof(dp)/sizeof(long long ),0);
    //dp[決定した桁数][N以下確定][j個の非0を用いて]:=総数
    dp[0][0][0]=1;

    for(int i=0;i<L;i++)
    {
        const int D=s[i]-'0';

        for(int j=0;j<2;j++)
        //N以下確定か否か
        {
            for(int k=0;k<=K;k++)
            {
            //使用した非0の個数
                for(int d=0;d<=(j ? 9:D);d++)
                {
                    if(d==0)dp[i+1][j||(d<D)][k]+=dp[i][j][k];

                    else{
                        dp[i+1][j||(d<D)][k+1]+=dp[i][j][k];
                    }
                }
            }
        }
    }


    return dp[L][1][K]+dp[L][0][K];
}

int main(){

    //桁DP

    string s;
    cin>>s;
    cin>>K;
    
    
    cout<<solve(s)<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m; cin >> n >> m;
  vector<pair<ll,ll>> e(n);
  ll ans=0;
  rep(i,n){ 
    cin >> e[i].F >> e[i].S; 
  }
  sort(e.begin(),e.end());
  
  ll cnt=0;
  while(m>0){
    if(m<=e[cnt].S){ ans += e[cnt].F*m; break;}
    m -= e[cnt].S;
    ans += e[cnt].F*e[cnt].S;
    cnt++;
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repm(i,m,n) for(int i=m; i<(n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int x = 0, xmax = 0;
    rep(i,n)
    {
        if(s[i] == 'I') x++;
        else if(s[i] == 'D') x--;
        xmax = max(xmax, x);
    }

    cout << xmax << endl;

    return 0;
}

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

int main(void) {
	int a = 0, b = 0;
	int count = 0;
	cin >> count;
	while ( count != 0) {
		int sumA = 0, sumB = 0;
		for (int i = 0; i < count; i++) {
			cin >> a >> b;
			if (a > b) sumA += a + b;
			else if (a < b) sumB += a + b;
			else {
				sumA += a;
				sumB += b;
			}
		}
		cout << sumA << " " << sumB << endl;
		cin >> count;
	}
	return 0;
}

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

int card2i(string c)
{
    if (c[1] >= '0' && c[1] <= '9')
    {
        return c[1] - '0';
    }
    return -1;
}

void bubbleSort(string A[], int N)
{
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int j = N - 1; j >= 1; j--)
        {
            if (card2i(A[j]) < card2i(A[j - 1]))
            {
                swap(A[j], A[j - 1]);
                flag = true;
            }
        }
    }
    for (int i = 0; i < N - 1; i++)
    {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
}

void selectionSort(string A[], int N)
{
    for (int i = 0; i <= N - 1; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (card2i(A[j]) < card2i(A[minj]))
            {
                minj = j;
            }
        }
        if (i != minj)
        {
            swap(A[i], A[minj]);
        }
    }

    for (int i = 0; i < N - 1; i++)
    {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
}

void isStablePrint(string orig[], string sorted[], int N)
{
    char suitsOrg[36], suitsStd[36];
    for (int i = 1; i <= 9; i++)
    {
        int idxOrg = 0, idxStd = 0;
        bool isSame = true;
        for (int j = 0; j < N; j++)
        {
            if (card2i(orig[j]) == i)
            {
                suitsOrg[idxOrg++] = orig[j][0];
            }
            if (card2i(sorted[j]) == i)
            {
                suitsStd[idxStd++] = sorted[j][0];
            }
        }
        for (int j = 0; j < idxOrg; j++)
        {
            if (suitsOrg[j] != suitsStd[j])
            {
                isSame = false;
                break;
            }
        }
        if (!isSame)
        {
            cout << "Not stable" << endl;
            return;
        }
    }
    cout << "Stable" << endl;
    return;
}

int main()
{
    int N;
    string C[36], C1[36], C2[36];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
        C1[i] = C2[i] = C[i];
    }
    bubbleSort(C1, N);
    isStablePrint(C, C1, N);
    selectionSort(C2, N);
    isStablePrint(C, C2, N);

    return 0;
}


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

int main()
{
   int n, m;
   cin >> n >> m;
   P p[m];
   rep(i,m)
   {
      int a, b;
      cin >> a >> b;
      p[i] =P(b,a);
   }
   sort(p,p+m);
   reverse(p, p+m);
   vector<int> cut;
   int prev = -1;
   rep(i,m)
   {
      int start = p[i].second;
      int end = p[i].first;
     // cout << start << " " << end << " " << prev << endl;
      if(prev!= -1)
      {
         if(end > prev)
         {
            if(prev < start) prev = start;
         } 
         else {
            prev = start;
            cut.push_back(start);
         }
      }
      else
      {
         prev = start;
         cut.push_back(start);
      }

   }
   cout << cut.size() << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll pl(ll x, ll k, ll d)
{
	k -= x / d;
	x -= x / d * d;

	if (k < 0)
	{
		x += -1 * k * d;
		k = 0;
	}

	if (k == 0)
		return abs(x);
	if (abs(x - d) < x) {
		x -= d, k--;
		if (k % 2 == 0)
			return abs(x);
		return abs(x + d);
	}
	else {
		if (k % 2 == 0)
			return abs(x);
		return abs(x - d);
	}
}


ll mi(ll x, ll k, ll d)
{
	return pl(-1 * x, k, d);
}

int main(void)
{
	ll x, k, d;

	scanf("%lld %lld %lld", &x, &k, &d);

	if (x <= 0)
		printf("%lld", mi(x, k, d));
	else printf("%lld", pl(x, k, d));

	return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, x, m, sum=0, mi=10000;
    cin >> n >> x;
    REP(i,n){
        cin >> m;
        sum += m;
        mi = min(mi, m);
    }
    cout << n + (x-sum)/mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  vi a(3);
  rep(i, 3) cin >> a[i];
  ll ans = 0;
  sort(all(a));
  ll sub = a[2] - a[1] + a[2] - a[0];
  if(sub%2==0)ans = sub / 2;
  else{
    ans=(sub + 3) / 2;
  }
  print(ans);
}

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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int main()
{
    int r;
    cin >> r;
    double ans = 2.0 * PI * static_cast<double>(r);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Pair[] pairs = new Pair[n];
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				pairs[i] = new Pair(a, b);
			}
			Arrays.sort(pairs);
			String ans = "Yes";
			int sum = 0;
			for (int i = 0; i < n; i++) {
				sum += pairs[i].a;
				if (sum > pairs[i].b) {
					ans = "No";
					break;
				}
			}
			System.out.println(ans);
		}
	}

	class Pair implements Comparable<Pair> {
		int a, b;

		public Pair(int a, int b) {
			super();
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Pair o) {
			return b - o.b;
		}

	}
}

Measured memory_bytes: 24300
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> v(n), c(n);
    for (Int i = 0; i < n; i++) cin >> v[i];
    for (Int i = 0; i < n; i++) cin >> c[i];
    vector<Int> y(n);
    for (Int i = 0; i < n; i++) y[i] = v[i] - c[i];
    sort(y.begin(), y.end(), greater<Int>());
    Int res = 0;
    Int i = 0;
    while (i < n && y[i] > 0) {
        res += y[i];
        i++;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){
    cout<<"Left"<<"\n";
    return(0);
  }
  if(a+b<c+d){
    cout<<"Right"<<"\n";
    return(0);
  }
  cout<<"Balanced"<<"\n";
  return(0);
}


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

struct C{
	double r,x,y;
	C(double r,double x,double y) : r(r) , x(x) , y(y) {}
};

bool cmp_x(const C &a,const C &b){ return a.x == b.x ? a.y < b.y : a.x < b.x ; }
bool cmp_y(const C &a,const C &b){ return a.y == b.y ? a.x < b.x : a.y < b.y ; }

double dist(const C &a,const C &b){
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt( x * x + y * y );
}
int main(){
	int n;
	while(cin >> n && n){
		vector<C> a,b;
		for(int i = 0 ; i < n ; i++){
			double r,x,y;
			cin >> r >> x >> y;
			a.push_back(C(r,x,y));
			b.push_back(C(r,x,y));
		}
		double ans = 1e15;
		sort(a.begin(),a.end(),cmp_x);
		sort(b.begin(),b.end(),cmp_y);
		for(int i = 0 ; i < n ; i++){
			for(int j = i+1 ; j < min(i+6,n) ; j++){
				ans = min(ans,dist(a[i],a[j])-a[i].r-a[j].r);
			}
			for(int j = i+1 ; j < min(i+6,n) ; j++){
				ans = min(ans,dist(b[i],b[j])-b[i].r-b[j].r);
			}
		}
		printf("%.7f%c",ans,10);
	}
}

Measured memory_bytes: 0
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static int n;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int m=sc.nextInt();
		int s=sc.nextInt()-1;
		int t=sc.nextInt()-1;
		ArrayList<Node>[] aedge=new ArrayList[n];
		ArrayList<Node>[] bedge=new ArrayList[n];
		for(int i=0; i<n; i++){
			aedge[i]=new ArrayList<>();
			bedge[i]=new ArrayList<>();
		}
		for(int i=0; i<m; i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			int a=sc.nextInt();
			int b=sc.nextInt();
			aedge[u].add(new Node(v,a));
			aedge[v].add(new Node(u,a));
			bedge[u].add(new Node(v,b));
			bedge[v].add(new Node(u,b));
		}
		long[] sfor=Dijkstra(aedge,s);
		long[] tfor=Dijkstra(bedge,t);
		
		long[] ans=new long[n];
		long hand=1000000000000000L;
		ans[n-1]=sfor[n-1]+tfor[n-1];
		for(int i=n-2; i>=0; i--){
			ans[i]=Math.min(ans[i+1],sfor[i]+tfor[i]);
		}
		PrintWriter pw=new PrintWriter(System.out);
		for(int i=0; i<n; i++){
			pw.println(hand-ans[i]);
		}
		pw.flush();
	}
	static long[] Dijkstra(ArrayList<Node>[] edge,int start){
		long[] re=new long[n];
		Arrays.fill(re,-1);
		PriorityQueue<Node> q=new PriorityQueue<>((x,y)->((x.dis-y.dis)<0?-1:1));
		q.add(new Node(start,0));
		while(!q.isEmpty()){
			Node node=q.poll();
			if(re[node.goal]!=-1) continue;
			re[node.goal]=node.dis;
			for(Node tmp:edge[node.goal]){
				if(re[tmp.goal]!=-1) continue;
				q.add(new Node(tmp.goal,node.dis+tmp.dis));
			}
		}
		return re;
	}
	static class Node{
		int goal;
		long dis;
		Node(int goal,long dis){
			this.goal=goal;
			this.dis=dis;
		}
	}
}


Measured memory_bytes: 167144
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	long long ans = 0;
	long long k;
	for (auto & p : mp) {
		k = p.second;
		ans += k * (k - 1) / 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

struct Dice{
  int n[6];
  void roll(char c){
    int nn;
    if(c == 'E'){
      nn = n[0];
      n[0] = n[3];
      n[3] = n[5];
      n[5] = n[2];
      n[2] = nn;
    }else if(c == 'W'){
      nn = n[0];
      n[0] = n[2];
      n[2] = n[5];
      n[5] = n[3];
      n[3] = nn;
    }else if(c == 'N'){
      nn = n[0];
      n[0] = n[1];
      n[1] = n[5];
      n[5] = n[4];
      n[4] = nn;
    }else if(c == 'S'){
      nn = n[0];
      n[0] = n[4];
      n[4] = n[5];
      n[5] = n[1];
      n[1] = nn;
    }else if(c == '!'){
      nn = n[1];
      n[1] = n[3];
      n[3] = n[4];
      n[4] = n[2];
      n[2] = nn;
    }

  }
  int top(){
    //cout << n[0] << endl;
    return n[0];
  }
  int right(){
    //cout << n[2] << endl;
    return n[2];
  }
  int left(){
    //cout << n[3] << endl;
    return n[3];
  }
  int front(){
    return n[1];
  }
  int back(){
    return n[4];
  }
  int under(){
    return n[5];
  }
};


int main(){
  Dice d;
  for(int i = 0; i < 6; i++) cin >> d.n[i];
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int a,b; cin >> a >> b;
    if(d.right() == a) d.roll('W');
    if(d.left() == a) d.roll('E');
    if(d.front() == a) d.roll('N');
    if(d.back() == a) d.roll('S');
    if(d.under() == a){
      d.roll('E');
      d.roll('E');
    }
    while(d.front() != b) d.roll('!');
    cout << d.right() << endl;
  }
  return 0;
}



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

int main() {
	int n,k;cin >> n>>k;
	vector<int> v(n);
	for (int i=0;i<n;++i){
		cin >>v[i];
	}
	sort(v.begin(),v.end());
	int out =0;
	for (int j=0;j<k;++j){
		out +=v[j];
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Queue;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void BFS() {
		//complete the following
		int[] distance = new int[totalVertex];
		boolean[] visited = new boolean[totalVertex];
		for(int i = 1; i < totalVertex; i++) {
			distance[i] = -1;
		}
		
		Queue<Integer> q1 = new LinkedList<Integer>();
		q1.add(0);
		while(!q1.isEmpty()) {
			int n = q1.poll();
			visited[n] = true;
			LinkedList<Integer> q2 = adjList.get(n);
			for(Integer neighbor:q2) {
				if(!visited[neighbor]) {
					q1.add(neighbor);
					int n1 = distance[n] + 1;
					distance[neighbor] = distance[neighbor] == -1 ? n1 : Math.min(distance[neighbor], n1);
				}
			}
		}
		for(int i = 0; i < totalVertex; i++) {
			System.out.println((i+1) + " " + distance[i]);
		}
	}
	
	
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.BFS();
	}
}



Measured memory_bytes: 38760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class ACoffee {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s;
	    in >> s;
	    bool flg = false;
	    if(s[2] == s[3] && s[4] == s[5]) flg = true;
	    ans(flg, out);
	}
};


int main() {
	ACoffee solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int[] kushi = new int[2*num];
		for(int i=0; i<2*num; i++){
			kushi[i] = sc.nextInt();
		}

		Arrays.sort(kushi);

		int sum=0;
		for(int i=0; i<2*num; i+=2){
			sum += kushi[i];
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 9936
n = gets().chomp.to_i

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

puts list[n - 1]

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

int main(){
    string s;
    cin >> s;

    int counter_ary[26] = {0};

    for (int i = 0; s[i] != '\0'; i++) {
        counter_ary[s[i] - 'a']++;
    }
    
    int first_idx = -99;
    for (int i = 0; i < 26; i++) {
        if (counter_ary[i] == 0){
            first_idx = i;
            break;
        }
    }
    
    if (first_idx == -99)
        cout << "None" << endl;
    else
        cout << char('a' + first_idx ) << endl;
    
    return 0;
}

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

int main(){
  int N;
  string u, input;
  double sum=0.;
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> input >> u;
    if (u == "JPY") {
      sum += stoll(input) * 1.;
    } else {
      sum += stod(input) * 380000.0;
    }
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    string s;cin>>s;
    bool key=true;
    rep(i,0,s.size()-2){
        if(s[i]!=s[i+2]){
            key=false;
        }
    }
    if(key){
        cout<<"Second"<<endl;
        return 0;
    }
    else {
        if(s[s.size()-1]==s[0])cout<<(s.size()%2?"Second":"First")<<endl;
        else cout<<(s.size()%2?"First":"Second")<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#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 rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sd(x) scanf("%d",&x) 
#define sld(x) scanf("%lld",&x) 
#define pld(x) printf("%lld\n",x) 
#define pd(x) printf("%d\n",x) 
const int MOD = 1e9+7, N = 1e7 + 10; 

int main(){
    int a,b,c;
    sd(a); sd(b); sd(c);
    int countf = 0, counts = 0;
    if(a==5) countf++;
    if(a==7) counts++;
    if(b==5) countf++;
    if(b==7) counts++;
    if(c==5) countf++;
    if(c==7) counts++;
    if(countf==2 &&counts==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
r,g,b,n = map(int,input().split())

res=0
tmp=n
tmp1=0
re=n//r+1
ge=n//g+1

for i in range(re):
	tmp = tmp - i*r
	tmp1 = tmp
	for j in range(ge):
		tmp1 = tmp - j*g
		if tmp1 < 0:
			break
		elif tmp1%b==0:
			res = res + 1
		tmp1 = tmp
	tmp=n

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll bestsat = -1;

    srand(time(NULL));
    vector<ll> best(d,0);
    ll times = 100000;
    while(times--){
        ll sat = 0;
        vector<ll> ans(d,0);
        rep(i,d){
            ans.at(i) = (rand() % 26) + 1;
        }
            for(int i=1;i<=d;i++){
                ll t = ans.at(i-1);
                t--;
                last.at(t) = i;
                sat += s.at(i-1).at(t);
                for(int j=0;j<26;j++){
                    sat -= c.at(j) * (i - last.at(j));
                }
                //cout << sat << endl;
                if(sat>bestsat){
                    bestsat = sat;
                    best = ans;
                }
            }
    }

    rep(i,d){
        cout << best.at(i);
        if(i<d-1) cout << endl;
    }
  
    //cout << bestsat << endl;

    /*
    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    */
    return 0;
}


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

int main()
{
    ll a, b;
    cin >> a >> b;
    ll k;
    cin >> k;
    if(a <= k)
    {
        k -= a;
        a = 0;
    }
    else
    {
        a -= k;
        k = 0;
    }
    if(b <= k)
    {
        k -= b;
        b = 0;
    }
    else
    {
        b -= k;
        k = 0;
    }
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll cal(ll n, ll c, ll d) {
	return n - n / c - n / d + n / lcm(c, d);
}
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << cal(b, c, d) - cal(a - 1, c, d);
	return(0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
int A[N],B[N],n;
int pa[N],pb[N],pos[N];
int vis[N],val[N];
bool cmpa(int x,int y) { return A[x]<A[y]; }
bool cmpb(int x,int y) { return B[x]<B[y]; }
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(A[i]),pa[i]=i;
	for(int i=1;i<=n;++i) rd(B[i]),pb[i]=i,val[i]=B[i];
	{
		sort(val+1,val+n+1);
		int m=unique(val+1,val+n+1)-val-1;
		for(int i=1;i<=n;++i) {
			B[i]=lower_bound(val+1,val+m+1,B[i])-val;
			A[i]=lower_bound(val+1,val+m+1,A[i])-val;
		}
	}
	sort(pa+1,pa+n+1,cmpa);
	sort(pb+1,pb+n+1,cmpb);
	for(int i=1;i<=n;++i) pos[pb[i]]=i;
	for(int i=1;i<=n;++i)
		if(A[pa[i]]>B[pb[i]]) {
			printf("No\n");
			return 0;
		}
	int cur=1;
	while(!vis[cur]) vis[cur]=1,cur=pa[pos[cur]];
	for(int i=1;i<=n;++i) if(!vis[i]) {
		printf("Yes\n");
		return 0;
	}
	sort(A+1,A+n+1);
	int m=unique(A+1,A+n+1)-A-1;
	if(m==n) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2944