akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
char s[100009],st[100009],ss[100009];
int len;
int main()
{
	gets(s);
	len=strlen(s);
	for(int i=0;i<strlen(s);++i)
		st[len-i-1]=s[i];
	for(int i=0;i<strlen(st);++i)
	{
		if(st[i]=='b') ss[i]='d';
		if(st[i]=='d') ss[i]='b';
		if(st[i]=='p') ss[i]='q';
		if(st[i]=='q') ss[i]='p';
	}
	if(strcmp(s,ss)==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
int good[(int)1e5+1],n,m,h[(int)1e5+1];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",h+i);
    for(int i=1;i<=m;i++){
        int x,y;scanf("%d%d",&x,&y);if(h[x]==h[y]){n-=(good[x]==0)+(good[y]==0),good[x]=good[y]=1;continue;}
        good[h[x]<h[y]?x:y]=good[h[x]<h[y]?x:y]==0?(n--,1):1;
    }
    printf("%d\n",n);
}

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

ll N, M, Q;
vector<vector<ll>> LR(501, vector<ll>(501, 0));
vector<vector<ll>> v(501, vector<ll>(501, 0));

int main(void){
    
    cin >> N >> M >> Q;
    for(int i = 0; i < M; ++i){
        ll a, b; cin >> a >> b;
        ++LR[a][b];
    }
    
    for(int x = 1; x <= N; ++x){
        ll sum = 0;
        for(int y = 1; y <= N; ++y){
            sum += LR[x][y], v[x][y] = sum;
        }
    }
    
    for(int i = 0; i < Q; ++i){
        ll a, b; cin >> a >> b;
        ll sum = 0;
        for(int i = a; i <= b; ++i){
            sum += v[i][b] - v[i][a - 1];
        }
        cout << sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin>>str;
	int left = 0, right = str.size()-1;
	int rez = 0;
	while(left < right)
	{
		if(str[left] == str[right])
		{
			left++;
			right--;
			continue;
		}
		else
		{
			str[right] = str[left];
			right--;
			left++;
			rez++;
			continue;
		}
	}
	cout<<rez<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  for (int i=0;i<N;i++){
    cin >> S.at(i);
  }
 
  std::sort(S.begin(), S.end());
  int J=1;
  
  for (int i=1;i<N;i++){
    if(S.at(i) != S.at(i-1)){
      J++;
    }
  }
  
  cout << J << endl;
  
}



Measured memory_bytes: 9608
#include<iostream>
#include<math.h>
#include<iomanip>
#include <string>
#include <cstdio>
#include<stdio.h>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define INF 2147483647
#define N 100000
using namespace std;int stop;
int n,m,k;
int arr[N];

int main(){
    int i,j,x,y;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&arr[i]);
    }
    sort(arr+1,arr+1+n);
    ll sum = 0;
    int biaoji  = -1;
    if(arr[1] < 0 && arr[n] > 0){
        for(i=1;i<=n;i++){
            if(arr[i] <= 0){
                sum+=(-arr[i]);
                biaoji = i;
            }else{
                sum+=arr[i];
            }
        }
        printf("%lld\n",sum);
        int x = arr[1],y = arr[n];
        for(i=biaoji+1;i<n;i++){
            printf("%d %d\n",x,arr[i]);
            x -= arr[i];
        }
        printf("%d %d\n",y,x);y-=x;
        for(i=2;i<=biaoji;i++){
            printf("%d %d\n",y,arr[i]);
            y-=arr[i];
        }

    }else if(arr[1] >= 0){
        sum = -arr[1];
        for(i=2;i<=n;i++){
            sum+=arr[i];
        }
        printf("%lld\n",sum);
        x = arr[1];
        for(i=2;i<n;i++){
            printf("%d %d\n",x,arr[i]);
            x-=arr[i];
        }
        printf("%d %d\n",arr[n],x);
    }else if(arr[n] <= 0){
        sum = arr[n];
        for(i=1;i<=n-1;i++){
            sum-=arr[i];
        }
        printf("%lld\n",sum);

        int x = arr[n];
        for(i=1;i<n;i++){
            printf("%d %d\n",x,arr[i]);
            x-=arr[i];
        }
     }
    //else{
    //     for(i=1;i<=n;i++){
    //         sum+=arr[i];
    //     }
    //     printf("%lld\n",sum);
    //     int x = arr[1];
    //     for(i=2;i<n;i++){
    //         printf("%d %d\n",x,arr[i]);
    //         x-=arr[i];
    //     }
    //     printf("%d %d\n",arr[n],x);
    // }
    
    return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};
int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m,l,k,a,h;
  while(scanf("%d%d%d%d%d%d",&n,&m,&l,&k,&a,&h),n+m+l+k+a+h){
    vector<bool> blood(n,false);
    vector<vector<bool> > flag(n,vector<bool>(n,false));
    vector<vector<int> >  load(n, vector<int>(n, 0));

    REP(i,l){
      int tmp; scanf("%d",&tmp);
      blood[tmp] = true;
    }
    REP(i,k){
      int x,y,t;
      scanf("%d%d%d",&x,&y,&t);
      load[x][y] = load[y][x] = t;
    }

    typedef pair<int,pair<int,pair<int,int> > > data;
    priority_queue<data,vector<data>,greater<data> > pq;
    pq.push(mp(0,mp(a,mp(m,a))));
    while(pq.size()){
      data d = pq.top();
      int time = d.f;
      int now  = d.s.f;
      int b    = d.s.s.f;
      int last = d.s.s.s;

      if(now == h){
        int tt = time;
        if(time > m)
          tt += time - m;
        printf("%d\n",tt);
        break;
      }

      if(!flag[last][now]){
        flag[last][now] = true;
        if(blood[now]){
          b = m;
          last = now;
        }

        REP(i,n){
          if(load[now][i] != 0){
            int tt = time + load[now][i];
            int bb = b - load[now][i];
            if(bb < 0) continue;
            pq.push(mp(tt,mp(i,mp(bb,last))));
          }
        }
      }

      pq.pop();
      if(pq.empty()){
        puts("Help!");
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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 dx[2] = {0,1};
int dy[2] = {1,0};
int main()
{
    int N;
    cin >> N;

    string S;
    cin >> S;


    vector<vector<int>> c(2, vector<int>(N, 0));

    REP(i, N){
        if(i==0){
            if(S[i]=='E') c[0][i]=1;
            else c[1][i]=1;    
        }
        else{
            c[0][i]=c[0][i-1];
            c[1][i]=c[1][i-1];
            if(S[i]=='E') c[0][i]++;
            else c[1][i]++;
        }
    }
    /*
    REP(i, N){
        cout << c[0][i] <<" ";
    }
    cout << endl;  
    REP(i, N){
        cout << c[1][i] <<" ";
    }
    cout << endl;
    */
    int ans = 3*1E5;
    REP(i, N){
        int nw=0;
        int ne=0;
        if(i==0){
            nw=0;
            ne=c[0][N-1]-c[0][0];
        }
        else if(i==(N-1)){
            nw=c[1][N-2];
            ne=0;
        }
        else{
            nw=c[1][i-1];
            ne=c[0][N-1] - c[0][i];
        }
        ans = min(ans, nw+ne);
    }

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

Measured memory_bytes: 4228
#include <iostream>
using namespace std;
int main(void){
    int a=0;
    string s;
    while(cin >> s){
        if(a!=0){
            cout << " ";
        }
        a++;
        for(int i=0;i<s.size();i++){
            char c=s[i];
            if('A'<= c && c <= 'Z'){
                c=c+ 32;
            }
            else if('a'<= c && c <= 'z'){
                c=c- 32;
            }
            cout << c;
        }
          
    }
    cout << endl;
}


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

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  int kakutei = 0;
  int kaigai = 0;

  rep(i, n) {
    if (s[i] == 'a') {
      // 国内
      if (kakutei < (a + b)) {
        cout << "Yes" << endl;
        kakutei++;
      } else {
        cout << "No" << endl;
      }
    } else if (s[i] == 'b') {
      // 海外
      if (kakutei < (a + b) && kaigai < b) {
        cout << "Yes" << endl;
        kakutei++;
        kaigai++;
      } else {
        cout << "No" << endl;
      }
    } else {
      // どれでもない
      cout << "No" << endl;
    }
  }
}


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

string in[50000];
int linum, N;

struct object {
  vector<string> key;
  vector<string> property;
  vector<object *>child;
};

object *parse(int pindent = -1) {
  object *res = new object;
  
  while(linum<N) {
    int indent = 0;
    for(;in[linum][indent]==' ';) indent++;
    if( indent<=pindent ) break;
    
    int colon = in[linum].find(":");
    string key = in[linum].substr(indent, colon-indent);
    if(colon==in[linum].size()-1){
      res->key.push_back(key);
      res->property.push_back("__object");
      
      linum++;
      res->child.push_back(parse(indent));
    } else {
      res->key.push_back(key);
      res->property.push_back(in[linum].substr(colon+2));
      res->child.push_back(NULL);

      linum++;
    }
  }
  return res;
}

const string NG = "no such property";

string find(const object* root, const vector<string>v) {
  for(int i=0; i<v.size()-1; i++) {
    bool ok = 0;
    for(int j=0; j<root->key.size(); j++) {
      if(root->key[j]==v[i]) {
	if(root->property[j]!="__object") break;
	root=root->child[j];
	ok = 1;
	break;
      }
    }
    if(!ok) return NG;
  }
  
  for(int i=0; i<root->key.size(); i++) {
    if(root->key[i]==v.back()) {
      if(root->property[i]=="__object") return "object";
      else return "string \"" + root->property[i] + "\"";
    }
  }
  return NG;
}

int main() {
  
  vector<string> Query;
  string query;
  getline(cin, query);
  for(int i=0; i<query.size(); i++) if(query[i] == '.') query[i] = ' ';
  stringstream ss(query);
  while(ss>>query) Query.push_back(query);
  
  linum = 0;
  N = 0;
  while(getline(cin, in[N])) N++;
  object *yaml = parse();
  
  cout << find(yaml, Query) << endl;
  
  return 0;
}

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

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  
  vector<int> X(m), sub(m-1);
  for (int i = 0; i < m; i++) cin >> X.at(i);
  sort(X.begin(), X.end());
  for (int i = 0; i < m-1; i++) sub.at(i) = X.at(i+1) - X.at(i);
  sort(sub.begin(), sub.end());
  for (int i = 0; i < m-n; i++) ans += sub.at(i);
  cout << ans << endl;
}

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

int main()
{
    string s;
    cin>>s;
    int n = s.length();
    int cnt = 0;
    int mid = 0;
    if(!(n%2))
    {
        int mid = n/2 - 1;
        for(int i = 0 , j = n-1 ; i<=mid , j>mid ; i++ , j--)
            if(s[i]!=s[j])cnt++;
    }
    else
    {
        int mid = n/2;
        for(int i = 0 , j = n-1 ; i<=mid , j>=mid ; i++ , j--)
        if(s[i]!=s[j]) cnt++;
    }
    cout<<cnt;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <algorithm>

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

using std::max;

int
main()
{
  long a, b, x;
  cin >> a >> b >> x;
  cout << max(b / x - (a + x - 1) / x + 1, 0L) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, string > State;

const int v1[] = {1, 2, 3, 4, 5, 6, 7, 8, 0};
const int v2[] = {8, 0, 1, 2, 3, 4, 5, 6, 7};
const int v3[] = {6, 7, 8, 0, 1, 2, 3, 4, 5};
const int v4[] = {3, 4, 5, 6, 7, 8, 0, 1, 2};

int main()
{
  int Horizon, Vertical;
  while(cin >> Horizon >> Vertical, Horizon) {
    string D = "", E = "";
    for(int i = 0; i < 9; i++) {
      string K;
      cin >> K;
      D += K;
    }
    for(int i = 0; i < 9; i++) {
      string K;
      cin >> K;
      E += K;
    }

    priority_queue< State, vector< State >, greater< State > > que;
    que.push(State(0, D));
    unordered_map< string, int > used;
    used[D] = 0;
    while(!que.empty()) {
      string q = que.top().second;
      int cost = que.top().first;
      que.pop();
      if(q == E) {
        cout << cost << endl;
        break;
      }
      if(used.find(q) != used.end() && used[q] < cost) {
        continue;
      }
      int pos = q.find('0'), nextCost;
      
      nextCost = cost + Horizon;
      swap(q[pos], q[v1[pos]]);
      if(used.find(q) == used.end() || used[q] > nextCost) {
        used[q] = nextCost;
        que.push(State(nextCost, q));
      }
      swap(q[pos], q[v1[pos]]);
      swap(q[pos], q[v2[pos]]);
      if(used.find(q) == used.end() || used[q] > nextCost) {
        used[q] = nextCost;
        que.push(State(nextCost, q));
      }
      swap(q[pos], q[v2[pos]]);
      if(used.find(q) == used.end() || used[q] > nextCost) {
        used[q] = nextCost;
        que.push(State(nextCost, q));
      }
      nextCost = cost + Vertical;
      swap(q[pos], q[v3[pos]]);
      if(used.find(q) == used.end() || used[q] > nextCost) {
        used[q] = nextCost;
        que.push(State(nextCost, q));
      }
      swap(q[pos], q[v3[pos]]);
      swap(q[pos], q[v4[pos]]);
      if(used.find(q) == used.end() || used[q] > nextCost) {
        used[q] = nextCost;
        que.push(State(nextCost, q));
      }
      swap(q[pos], q[v4[pos]]);
    }
  }
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string a,b,c;
	cin>>a>>b>>c;
	cout<<(a.back()==b[0]&&b.back()==c[0]?"YES\n":"NO\n");
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int a, int b){ int S = 1; while(b--)S *= a; return S;}

int32_t main(){
	int k, n;
	cin >> k >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int S = k - a[n-1] + a[0];
	for(int i = 1; i < n; i++){
		S = max(S, a[i] - a[i-1]);
	}
	cout << k - S;

	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>

using namespace std;

struct vertex{
    int X;
    int Y;
};

int	gcd(int	a, int b){
    while( b ){
        int	m = a % b;
        a = b;
        b = m;
    }
    return a;
}

int	lcm(int a, int	b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //????????????

    int N;
    cin >> N;
    int a,d;
    cin >> a >> d;
    int M;
    cin >> M;
    int x[10],y[10],z[10];
    for(int i=0;i<M;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    int K;
    cin >> K;
    
    for(int i=1;i<=M;i++){
        if(x[M-i]==0){
            if(K==y[M-i]){
                K=z[M-i];
            }else if(K==z[M-i]){
                K=y[M-i];
            }
        }else{
            if(K==y[M-i]){
                K=z[M-i];
            }
        }
    }
    
    int ans=a;
    
    for(int i=0;i<K-1;i++){
        ans=ans+d;
    }
    
    cout << ans << endl;
    
    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.7f",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    static int[]w;
    static int[]v;
    static long[][]d;
    
    void solve() throws IOException {
        int n=ni(),W=ni();
        w=new int[n+1];
        v=new int[n+1];
        d=new long[W+1][n+1];
        for (int x=1;x<=n;x++) {w[x]=ni(); v[x]=ni(); for (int y=1;y<=W;y++) d[y][x]=-1;}
        System.out.println(solve(n,W));
    }
    
    long solve(int n, int W) {
        if (n==0 || W<1) return 0;
        if (d[W][n]==-1) {
            if (w[n]>W) d[W][n]=solve(n-1,W);
            else d[W][n]=Math.max(solve(n-1,W),solve(n-1,W-w[n])+v[n]);
        }
        return d[W][n];
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 129448
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int x[n];
    int y[n];
    int sum1 = 0;
    int sum2 = 0;
    long sum3 = 0;
    int max = 0;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    for (int i = 0; i < n; i++) {
        int d = abs(x[i] - y[i]);
        sum1 += d;
        sum2 += d * d;
        sum3 += d * d * d;
        if (d > max) max = d;
    }
    cout << fixed << setprecision(8);
    cout << sum1 << endl;
    cout << pow(sum2, 1 / 2.0) << endl;
    cout << pow(sum3, 1 / 3.0) << endl;
    cout << max << endl;
}

Measured memory_bytes: 3452
n, x, y = map(int, input().split())

cnt = [0] * n
cycle = y - x + 1

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i < x and j > y:
            cnt[j - y + x - i + 1] += 1
        elif i < x:
            d = min(j - x, y - j + 1)
            cnt[x - i + d] += 1
        elif j > y:
            d = min(y - i, i - x + 1)
            cnt[j - y + d] += 1
        else:
            d = min(j - i, y - j + 1 + i - x)
            cnt[d] += 1

print(*cnt[1:], sep="\n")


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

void dfs(string s, char x) {
    if (s.length() == n) {
        cout << s << endl;
    }
    else {
        for (char c = 'a'; c <= x; c++) {
            if (c == x) dfs(s + c, (char)(x + 1));
            else dfs(s + c, x);
        }
    }
}

int main() {
    cin >> n;
    dfs("", 'a');
}

Measured memory_bytes: 1536
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		fmt.Println("a > b")
	}
	if a == b {
		fmt.Println("a == b")
	}
	if a < b {
		fmt.Println("a < b")
	}
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int N;
    cin>>N;
    Vs S(N);
    REP(i,N) cin>>S[i];

    Vi C(4);
    REP(i,N){
        if(S[i] == "AC") C[0]++;
        else if(S[i] == "WA") C[1]++;
        else if(S[i] == "TLE") C[2]++;
        else C[3]++;
    }

    cout<<"AC x "<<C[0]<<endl;
    cout<<"WA x "<<C[1]<<endl;
    cout<<"TLE x "<<C[2]<<endl;
    cout<<"RE x "<<C[3]<<endl;
    return 0;
}

Measured memory_bytes: 6436
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		int S = sc.nextInt();

		int sum = 0;
		int[] A = new int[N+1];
		A[0] = 0;
		for(int i=1; i<=N; i++) {
			sum += sc.nextInt();
			A[i] = sum;
		}

		if(N == 1) {
			if(A[1] >= S) {
				System.out.println(1);
			} else {
				System.out.println(0);
			}
			return;
		}

		int min = Integer.MAX_VALUE;
		for(int i=1; i<=N; i++) {
			if(A[i] - A[0] < S) {
				continue;
			}

			int j = i - 1;
			boolean flag = false;
			while(j >= 0 && i - j < min) {
				if(A[i] - A[j] >= S) {
					flag = true;
					break;
				}
				j--;
			}

			if(flag) {
				min = i - j;
			}
		}

		if(min == Integer.MAX_VALUE) {
			System.out.println(0);
		} else {
			System.out.println(min);
		}

	}

	static 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;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); 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() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
    }
}

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

Measured memory_bytes: 64892
#include <iostream>
#include <string>

using namespace std;

void count_score(string taro_card, string hanako_card, int &taro_score, int &hanako_score)//?????????????????????????????????????????????
{
	int min_size = 1;
	if(taro_card.size() > hanako_card.size()){
		min_size = hanako_card.size();
	}
	else{
		min_size = taro_card.size();
	}
	
	for(int i = 0; i < min_size; i++){
		if(taro_card[i] > hanako_card[i]){
			taro_score += 3;
			return;
		}
		else if(taro_card[i] < hanako_card[i]){
			hanako_score += 3;
			return;
		}
	}
	if(taro_card.size() > hanako_card.size()){
		taro_score += 3;
	}
	else if(taro_card.size() < hanako_card.size()){
		hanako_score += 3;
	}
	else{
		taro_score += 1;
		hanako_score += 1;
	}
}
int main(void)
{
	int n;//n?????????
	cin >> n;
	
	int taro_score = 0;
	int hanako_score = 0;
	for(int i = 0; i < n; i++){
		
		string taro_card;
		string hanako_card;
		cin >> taro_card;
		cin >> hanako_card;
		
		count_score(taro_card, hanako_card, taro_score, hanako_score);
	}
	cout << taro_score << ' ' << hanako_score << endl;
	return 0;
}

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

int main(){
  int n;
  int sum = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=2e5+5;
int n,p[N],pos[N],b[N];
bool vis[N];
struct data{
	int l,r,x,y;
	inline bool operator<(const data&rhs)const{return x>rhs.x;}
};
priority_queue<data>q;
struct sgt_{
	int d[N<<2];
	void build(int l,int r,int o){
		if(l==r)d[o]=b[l];else{
			const int mid=l+r>>1;
			build(l,mid,o<<1),build(mid+1,r,o<<1|1);
			d[o]=min(d[o<<1],d[o<<1|1]);
		}
	}
	void modify(int l,int r,int o,const int&pos,const int&x){
		if(l==r)d[o]=x;else{
			const int mid=l+r>>1;
			if(pos<=mid)modify(l,mid,o<<1,pos,x);else modify(mid+1,r,o<<1|1,pos,x);
			d[o]=min(d[o<<1],d[o<<1|1]);
		}
	}
	int query(int l,int r,int o,const int&L,const int&R){
		if(L<=l&&r<=R)return d[o];
		const int mid=l+r>>1;
		if(L<=mid&&mid<R)return min(query(l,mid,o<<1,L,R),query(mid+1,r,o<<1|1,L,R));
		if(L<=mid)return query(l,mid,o<<1,L,R);
		return query(mid+1,r,o<<1|1,L,R);
	}
}t[2];
void add(int l,int r){
	if(l>r)return;
	int x=t[l&1].query(1,n,1,l,r),y=t[l&1^1].query(1,n,1,pos[x]+1,r);
	q.push((data){l,r,x,y});
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",p+i),pos[p[i]]=i;
	memset(b,0x3f,sizeof b);
	for(int i=1;i<=n;i+=2)b[i]=p[i];
	t[1].build(1,n,1);
	memset(b,0x3f,sizeof b);
	for(int i=2;i<=n;i+=2)b[i]=p[i];
	t[0].build(1,n,1);
	add(1,n);
	while(!q.empty()){
		data u=q.top();q.pop();
		printf("%d %d ",u.x,u.y);
		add(u.l,pos[u.x]-1),add(pos[u.x]+1,pos[u.y]-1),add(pos[u.y]+1,u.r);
	}
	return 0;
}

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

#define NIL -1

struct Node { int parent, right, left; };
int D[100000];
Node T[100000];

void rec(int u, int d) {
    D[u] = d;
    if (T[u].right != NIL) { rec(T[u].right, d); }
    if (T[u].left != NIL) { rec(T[u].left, d + 1); }
}

void print(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] <<", ";

    if (T[u].parent == NIL) { cout << "root, "; }
    else if (T[u].left != NIL) { cout << "internal node, "; }
    else { cout << "leaf, "; }

    cout << "[";
    int i = u;
    if (T[i].left != NIL) {
        cout << T[i].left; i = T[i].left;
        if (T[i].right != NIL) { cout << ", ";}
        while (T[i].right != NIL) {
            cout << T[i].right;
            i = T[i].right;
            if (T[i].right != NIL) { cout << ", "; }
        }
    }
    cout << "]" << endl;
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        T[i].parent = T[i].right = T[i].left = NIL;
        D[i] = NIL;
    }
    for (int i = 0; i < n; ++i) {
        int id ,k, d; cin >> id >> k; d = id;
        for (int j = 0; j < k; ++j) {
            int c; cin >> c;
            if (j == 0) { T[id].left = c; }
            else { T[d].right = c; }
            d = c;
            T[c].parent = id;
        }
    }
    int u = 0;
    for (int i = 0; i < n; ++i) {
        if (T[i].parent == NIL) u = i;
    }
    rec(u, 0);
    for (int i = 0; i < n; ++i) {
        print(i);
    }
}

Measured memory_bytes: 7764
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int count = 0;
    for(int i = 1; i <= N; i++){
      int n = Integer.parseInt(sc.next());
      if(n != i){
        count++;
      }
    }
    String ans = "NO";
    if(count == 0 || count == 2){
      ans = "YES";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
/*
 * Author: Anmol Choudhary
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    multiset<int>s1,s2;
    vector<int>v1,v2;
    rep0(i,a){
        int x;
        cin>>x;
        v1.pb(x);
    }
    rep0(i,b){
        int x;
        cin>>x;
        v2.pb(x);
    }
    sort(v1.beg,v1.en);
    reverse(v1.beg,v1.en);
    sort(v2.beg,v2.en);
    reverse(v2.beg,v2.en);
    rep0(i,x){
        s1.in(v1[i]);
    }
    rep0(i,y){
        s1.in(v2[i]);
    }
    rep0(i,c){
        int x;
        cin>>x;
        s2.in(x);
    }
    //deb(s1,s2);
    while(s2.si){
        auto it=s1.begin();
        int x=*it;
        auto it2=s2.end();
        --it2;
        if(x<*it2){
            s1.erase(it);
            s1.in(*it2);
            s2.erase(it2);
        }
        else break;
    }
    int ans=0;
    for(auto x:s1) ans+=x;
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


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

int main() {
	int h,w;
	cin>>h>>w;
	char a;
long long 	int arr[h][w]={0},brr[h][w]={0};
	
	int i=0,j=0;
		for(i=0;i<h;i++)
	{
	    for(j=0;j<w;j++)
	    {
	      brr[i][j]=0;
	    }
	    
	}
	for(i=0;i<h;i++)
	for(j=0;j<w;j++)
	{
	    cin>>a;
	    if(a=='#')
	    arr[i][j]=1;
	}
	brr[0][0]=0;
	for(i=1;i<h;i++)
	{
	   if(arr[i][0]==1)
	   {
	       break;
	   }
	   brr[i][0]=1;
	}
	
		for(i=1;i<w;i++)
	{
	   if(arr[0][i]==1)
	   {
	       break;
	   }
	   brr[0][i]=1;
	}
	
	for(i=1;i<h;i++)
	{
	    for(j=1;j<w;j++)
	    {
	      if(arr[i][j]==0)
	      brr[i][j]=(brr[i-1][j]+brr[i][j-1])%1000000007;
	    }
	}
	
	cout<<(brr[h-1][w-1])%1000000007;
	return 0;
}


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

typedef long long ll;
const int N = 1e5 + 100, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int n, cnt[N], power_2[N], power_3[N];
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	power_2[0] = power_3[0] = 1;
	for (int i = 1; i < N; i++)
		power_2[i] = mul(power_2[i - 1], 2), power_3[i] = mul(power_3[i - 1], 3);
	
	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++)
		cnt[i] = (i? cnt[i - 1]: 0) + (s[i] == '1');
	
	int ans = power_2[cnt[n - 1]];
	for (int i = 0; i < n; i++)
		if(s[i] == '1')
			ans = sum(ans, mul(power_2[cnt[i] - 1], power_3[n - i - 1]));
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 1616
s = [input() for i in range(3)]
turn = 0
while True:
    if len(s[turn]) == 0:
        if turn == 0:
            print("A")
            break
        elif turn == 1:
            print("B")
            break
        else: 
            print("C")
            break            
    elif s[turn][0] =="a":
        s[turn]=s[turn][1:]
        turn = 0
    elif s[turn][0] =="b":
        s[turn]=s[turn][1:]
        turn = 1
    elif s[turn][0] =="c": 
        s[turn]=s[turn][1:]
        turn = 2

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()

const ll Mod = 998244353;

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

    ll n,m; cin>>n>>m;
    ll ans = n*(n-1)/2 + m*(m-1)/2;
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long m = scan.nextLong();
		long n = scan.nextLong();
		long MOD = 1000000007L;
		long ans = 1;
		while(n>0) {
			if(n%2==1) {
				ans = (ans*m)%MOD;
			}
			m = (m*m)%MOD;
			n>>=1;
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 26136
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[] = {-1,0,1,0,-1,-1,1,1};
const int dy[] = {0,-1,0,1,1,-1,1,-1};
ll dp[110][110];
ll m[2][110];

ll solve(int x,int y){
  if(dp[x][y]!=l_INF) return dp[x][y];
  ll ans=l_INF;
  for(int i=x+1;i<=y;i++){
    ans=min(ans,solve(x,i-1)+solve(i,y)+m[0][x]*m[1][i-1]*m[1][y]);
  }
  //cout<<ans<<endl;
  return dp[x][y]=ans;
}
int main(){
  int n; cin>>n;
  rep(i,n) cin>>m[0][i]>>m[1][i];
  rep(i,n)rep(j,n) dp[i][j]=l_INF;
  rep(i,n) dp[i][i]=0;
  rep(i,n-1) dp[i][i+1]=m[0][i]*m[0][i+1]*m[1][i+1];
  cout<<solve(0,n-1)<<endl;
}



Measured memory_bytes: 3168
N, Q = map(int, input().split())
graph = [[] for i in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1

    ans[p] += x

seen = [False for i in range(N)]

stack = [0]

# dfs
while stack != []:
    v = stack.pop()
    seen[v] = True

    for i in graph[v]:
        if seen[i] == True:
            continue
        ans[i] += ans[v]
        stack.append(i)

print(*ans)


Measured memory_bytes: 106272
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include<iostream>
using namespace std;

int main(void)
{
    int x,a;
    cin >> x >> a;
    if(x >= a)
    {
        cout << 10<<endl;
    }else{
        cout << 0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,N;
  cin >> N >> A ;
  int a;
  a = N % 500;
  if(a < A || a == A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  } 
}


Measured memory_bytes: 256
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	var (
		n          = nextInt()
		c          = nextInt()
		k          = nextInt()
		t          = make([]int, n)
		ans        = 0
		waitStart  = 0
		waitPeople = 0
	)

	for i := range t {
		t[i] = nextInt()
	}
	sort.Ints(t)

	for _, ti := range t {
		if ti-waitStart > k || waitPeople == c {
			waitPeople = 0
		}
		waitPeople++

		if waitPeople == 1 {
			waitStart = ti
			ans++
		}
	}
	fmt.Println(ans)
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define M 200010
#define LL long long
#define rep(i, x, y) for(int i = (x); i <= (y); ++ i)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int a[M], b[M];
int A[M], B[M];
int main() {
	//freopen("in.txt", "r", stdin);
	int n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) b[i] = read();
	int res = 0;
	for(int T = 1; T <= (1 << 29); T <<= 1) {
		rep(i, 1, n) A[i] = a[i] % (2 * T);
		rep(i, 1, n) B[i] = b[i] % (2 * T);
		sort(A + 1, A + n + 1);
		sort(B + 1, B + n + 1);
		int T1 = n, T2 = n, T3 = n, T4 = n;
		LL wt = 0;
		rep(i, 1, n) {
			while(A[i] + B[T1] >= T && T1) T1 --;
			while(A[i] + B[T2] >= 2 * T && T2) T2 --;
			while(A[i] + B[T3] >= 3 * T && T3) T3 --;
			while(A[i] + B[T4] >= 4ll * T && T4) T4 --;
			wt += T2 - T1; wt += T4 - T3;
		}
		if(wt & 1) res += T;
	}
	printf("%d\n", res); 
	return 0;
}


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

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

    int n, m;
    cin >> n >> m;

    vector<int> s[m];
    int mx = 0;
    rep(i, m){
        int k;
        cin >> k;
        mx = max(mx, k);
        rep(j, k){
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp);
        }
    }

    vector<int> p(m);
    rep(i, m){
        cin >> p[i];
    }

    int ans = 0;
    for(int i = 0; i < (1<<n); ++i){
        int cnt = 0;
        for(int j = 0; j < m; ++j){//denkyu
            int tmp = 0;
            for(int jj = 0; jj < s[j].size(); ++jj){
                if(i & (1<<(s[j][jj]-1)) ){
                    ++tmp;
                }
            }
            if(tmp%2 == p[j]){
                ++cnt;
            }
        }
        if(cnt == m) ++ans;
    }

    ppp(ans);

    // int cnt = 0;
    // for(int j = 0; j < m; ++j){ //denkyu
        //     for(int jj = 0; jj < s[i].size(); ++jj){
            //         if(i & (1<<j) and s[i][jj] == j+1){
                //             ++cnt;
                //             cnt %= 2;
                //         }
                //     }
                // }
                // if(cnt != p[j]){
                    //     breakl
                    // }


    return 0;
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    if((a+b)%2==0)
        cout << (a+b)/2 << endl;
    else
        cout << (a+b)/2+1 << endl;       
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int candy, a;
	
	while(scanf("%d", &candy) != EOF){
		
		a = candy % 39;
		if(a != 0){
			printf("3C%02d\n", a);
		}
		else{
			puts("3C39");
		}
	}
	
	return 0;
}

Measured memory_bytes: 616
#include<stdio.h>
void trace(int A[],int N){
  int i;
 
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void swap(int *x,int *y)
{
  int a;
  a=*x;
  *x=*y;
  *y=a;
}

int main(){
  int A[100];
  int i,j,n,N;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  for(i=0,N=0;i<n-1;i++){
    for(j=n-1;j>=1;j--){
      if(A[j]<A[j-1]){
	swap(&A[j],&A[j-1]);
	N++;
      }
    }
  }
  trace(A,n);
  printf("%d\n",N);
  return 0;
}

Measured memory_bytes: 2716
#include <iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a)-abs(x-b)>0){
        cout << "B" << "\n";
    }
    else{
        cout << "A" << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n;
	cin>>n;
	map<int,int> g;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
	cin>>v[i];
	g[v[i]]++;
	g[v[i]-1]++;
	g[v[i]+1]++;
	}

	int ans=0;
	for(auto x:g)
	{
	  ans=max(ans,x.second);
	}

	cout<<ans<<"\n";
}

Measured memory_bytes: 5120
A = [3,5]
Q = []

def a(x,y,z)
 Q << [?+,x,y,z]*" "
 A[z] = (A[x]||=0) + (A[y]||=0)
end

def c(x,y,z)
 Q << [?<,x,y,z]*" "
 A[z] = (A[x]||=0) < (A[y]||=0) ? 1 : 0
end

c(3,0,3) # a[3] = !!a[0]
63.times{|i|
 a(3+i,3+i,4+i) # a[3+i] = 2**i
}

def to_b(x,s)
 a(x,3,x) # A[x] += 1
 63.downto(0){|i|
  a(3+i,s+64+i+1,s+64+i)
  c(s+64+i,x,s+i)
  a(s+i,2,s+64+i)
  i.times{a(s+64+i,s+64+i,s+64+i)}
  a(s+64+i,s+64+i+1,s+64+i)
 }
end

to_b(0,67)
to_b(1,195)

#324

def and(x,y,z,t)
 a(x,y,t)
 c(t,3,z)
end

32.times{|i|
 32.times{|j|
  x=67+i
  y=195+j
  a(x,y,324)
  c(3,324,325)
  a(326+i+j,325,326+i+j)
 }
}

64.times{|i|
 i.times{a(326+i,326+i,326+i)}
 a(2,326+i,2)
}

# STDERR.puts "Q = #{Q.size}"
# STDERR.puts A.map.with_index{|x,i|x||=0;"#{i}:#{x}"}*" "

puts Q.size
puts Q

Measured memory_bytes: 15784
# Problem https://atcoder.jp/contests/abc081/tasks/abc081_a
# Ruby 1st Try

one,two,three = gets.chomp('\n').split('')
answer = 0
if one == '1'
    answer = answer + 1
end
if two == '1'
    answer = answer + 1
end
if three == '1'
    answer = answer + 1
end
puts(answer)

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

bool comp( const tuple<int,int,int> &lhs, const tuple<int,int,int> &rhs ) {
    return std::get<1>(lhs) < std::get<1>(rhs);
}

int main(void) {
    int N;
    cin >> N;
    vector< tuple<int,int,int> > X(N);
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        X[i] = make_tuple(x, i, 0);
    }

    sort(X.begin(), X.end());
    for(int i=0; i<N; i++) {
        if(i < N/2) {
            get<2>(X[i]) = get<0>(X[N/2]);
        } else {
            get<2>(X[i]) = get<0>(X[N/2-1]);
        }
    }
    sort(X.begin(), X.end(), comp);

    for(int i=0; i<N; i++) {
        cout << get<2>(X[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <unordered_map>

using namespace std;

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

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

long long lcom(long long a, long long b){
    long long x = a * b, c, r;
    if(a < b){
        c = a;
        a = b;
        b = c;
    }
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return x / b;
}

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << B - A + 1 - ((B / C + B / D - B / lcom(C, D)) - ((A - 1) / C + (A - 1) / D - (A - 1) / lcom(C, D))) << endl;
    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}


map<pair<ll,ll>,ll> memo;
ll mod = 1e9 + 7;


ll f(ll s, ll x){
  pair<ll,ll> P = make_pair(s,x);
  if(memo.count(P)) return memo[P];
  if(s<=3 && x <=3){
    ll ans = 0;
    REP(a,4)REP(b,4){
      if((a&b) != b) continue;
      if(a+b<=s && (a^b) <= x) ans++;
    }
    return memo[P] = ans;
  }else{
    ll ans = (f(s/2,x/2) + f((s-1)/2,(x-1)/2) + f((s-2)/2,x/2)) % mod;
    return memo[P] = ans;
  }
}

ll n;

int main(){
  cin >> n;
  cout << f(n,n) << endl;
}


Measured memory_bytes: 256
// Problem : B - Two Switches
// Contest : AtCoder - AtCoder Beginner Contest 070
// URL : https://atcoder.jp/contests/abc070/tasks/abc070_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int l1,r1,l2,r2;cin>>l1>>r1>>l2>>r2;
if(l1>r2 or r1<l2)
cout<<0;
else
{
	cout<<min2(r1,r2)-max2(l1,l2);
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3580