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

using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int temp=b-a;
    int sum=0;
    for(int i=1; i<temp; i++){
       sum+=i;
    }
    cout << sum-a << endl;
    return 0;
}

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

int main() {
  int N,h,t,o;
  cin >>  N;
  h = N/100;
  t = (N-(h*100))/10;
  o = N-(h*100)-t*10;
  if(h == 7 || t == 7 || o == 7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int p = 1000000007;
int log2_p_MAX = 32;
long long felmer(long long a)
{
  // a^(2^i) mod p
  long long rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  long long res = 1;
  long long expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
int main()
{
  long long n,a,b,i,t,u,res=1;
  cin >> n >> a >> b;
  t=n;
  u=2;
  while(t>0){
    if(t%2==1){
      res*=u;
      res%=p;
    }
    t/=2;
    u*=u;
    u%=p;
  }
  res--;
  t=1;
  for(i=0;i<a;i++){
    t*=n-i;
    t%=p;
    t*=felmer(i+1);
    t%=p;
  }
  res-=t;
  if(res<0) res+=p;
  for(i=a;i<b;i++){
    t*=n-i;
    t%=p;
    t*=felmer(i+1);
    t%=p;
  }
  res-=t;
  if(res<0) res+=p;
  cout << res << endl;
  return 0;
}

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

int main(){
    string s; cin >> s;
    int ans = 700;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n;
  ll sum = 0, x = 0, ans = INFL;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 0; i < n; i++) {
    x += a[i];
    if (i + 1 < n) ans = min(ans, abs(sum - 2 * x));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<string> vec(N);
  for(ll i=0;i<N;i++) {
string S;
    cin>>S;
    sort(all(S));
    vec[i]=S;
  }
  sort(all(vec));
  
  ll ans=0;
  for(ll i=0;i<N-1;i++) {
  if(vec[i]==vec[i+1]) {
ll count=1;
    for(ll j=i+1;j<N;j++) {
      if(vec[i]==vec[j]) {
count++;
      }
      else {
i=j-1;
        break;
      }
      if(j==N-1) {
        i=j-1;
      }
    }
    ans+=count*(count-1)/2;
  }
  }
  
  
  cout<<ans<<endl;
}



  
    
    
    


Measured memory_bytes: 6436
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll w,d;
    while(cin>>w>>d){
        if(w==0){break;}
    vector<ll> a(w);
    for(auto &I:a){cin>>I;}
    vector<ll> b(d);
    for(auto &I:b){cin>>I;}
    vector<vector<ll>> dp(w+1,vector<ll>(1LL<<d,MOD));
    dp[0][0]=0;
    for(int i=0;i<w;i++){
        for(int k=0;k<d;k++){
            if(a[i]>b[k]){continue;}
            for(int h=0;h<(1LL<<d);h++){
                dp[i+1][h]=min(dp[i+1][h],dp[i][h]+a[i]);
                if(a[i]==b[k]){dp[i+1][h|(1<<k)]=min(dp[i+1][h|(1<<k)],dp[i][h]+a[i]);}
                int O=((1<<d)-1)^h;
                for(int key=O;key>0;key=(key-1)&O){
                    if(key>>k&1){continue;}
                    ll sum=0;
                    for(int p=0;p<d;p++){
                        if(key>>p&1){
                            if(b[p]>a[i]){sum+=MOD;}
                            sum+=b[p];
                        }
                    }
                    if(a[i]==b[k]){
                        dp[i+1][h|(1<<k)|key]=min(dp[i+1][h|(1<<k)|key],dp[i][h]+sum+a[i]);
                    }
                    else{
                        dp[i+1][h|key]=min(dp[i+1][h|key],dp[i][h]+sum+a[i]);
                    }
                }
            }
        }
    }
    cout<<dp[w][(1LL<<d)-1]<<endl;
    }
    
    
    

    return 0;
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi[maxii];
vector<int> vi2[maxii];
vector<int> vi3[maxii];
vector<int>:: iterator child;
vector<vector<pair<int, int> > > vii;
//vector<pii> vii;
vector<pll> vll;
//vii.clear();
//vii.resize(n + 1);


int arr[maxii];
int arr2[maxii];
int arr3[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m,store,county;
stack<int>st;
void dfs(int node)
{
    check[node]=true;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            dfs(vi[node][child]);
        }
    }
    st.push(node);
}

void dfs2(int node)
{
    check[node]=true;
    arr2[node]=store;
    county++;
    for(int child=0;child<vi2[node].size();child++)
    {
        if(check[vi2[node][child]]==false)
        {
            dfs2(vi2[node][child]);
        }
    }
}
void dag_count(int node)
{
    check[node]=true;
    arr[node]=1;
    //cout<<node<<" "<<arr[node]<<endl;

    for(int child=0;child<vi3[node].size();child++)
    {
        if(check[vi3[node][child]]==false)
        {

            dag_count(vi3[node][child]);
            //arr[node]+=arr[vi3[node][child]];
        }
        arr[node]=max(arr[node],1+arr[vi3[node][child]]);

    }
   // cout<<node<<" "<<arr[node]<<endl;
}
queue<int>que;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    sc(n)
    sc(m)
    int a,b;
    for(int i=0;i<m;i++)
    {
        sc(a)
        sc(b)
        vi3[a].pb(b)
    }
    for(int i=1;i<=n;i++)
    {
        if(check[i]==false)
        {
            dag_count(i);
        }
    }
    int maxi=0;
    for(int i=1;i<=n;i++)
    {
        //cout<<i<<" "<<arr[i]<<endl;
        maxi=max(maxi,arr[i]);
    }
    cout<<maxi-1<<endl;

}






Measured memory_bytes: 17008
#include <bits/stdc++.h>
using namespace std;
double sa(double a,double   b){
    return max(a,b)-min(a,b);
}
int main(void){
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    long double pi=2.0*asin(1.0);
    long double rad=pi/180.0*(sa((60.0*H+M)/2.0,M*6.0));
    long double len=sqrt(A*A+B*B-2*A*B*cosl(rad));
    printf("%.10Lf",len);
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
void fastscan(int &x)
 {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    } 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 100010;
const int mod1 = 998244353;
   

signed main()
 {
  string  s,t;
  cin>>s>>t;
  int m,n;
  m= s.size();
  n = t.size();
  int dp[n+1][m+1];
  loop(i,0,m+1)
   dp[0][i] = 0;
  loop(i,0,n+1)
   dp[i][0] = 0;
   int ma =-1;
  loop(i,1,n+1)
   {
    loop(j,1,m+1)
     {
      if(s[j-1] == t[i-1])
         dp[i][j] = dp[i-1][j-1] + 1;
      else 
         dp[i][j] = max(dp[i-1][j],dp[i][j-1]); 
     }
   }

  string ans ;
  int i = n,j=m;
  while(i>0 && j>0)
     {
      if(dp[i][j] > max(dp[i][j-1],dp[i-1][j]))
         {
          ans.pb(s[j-1]);
          i--;
          j--;
         }
      else if(dp[i-1][j] == dp[i][j])
        i--;
      else 
        j--;
        
     }
  reverse(ans.begin(),ans.end());  
  cout<<ans;
return 0;
}

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

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;

  int tmp;
  for(int i = 0;i < n;i++){
    cin >> tmp;
    x = max(x,tmp);
  }
  for(int j = 0;j < m;j++){
    cin >> tmp;
    y = min(y,tmp);
  }

  if(x < y){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }

  return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        StringBuilder op = new StringBuilder();
        int max = A[N-1];
        int min = A[0];
        for (int i = 1; i < N-1; i++) {

            if (max-A[i]-min >= max-(min-A[i])) {
                op.append(max+" "+A[i]+"\n");
                max -= A[i];
            } else {
                op.append(min+" "+A[i]+"\n");
                min -= A[i];
            }
        }
        op.append(max+" "+min+"\n");

        System.out.println(max-min);
        System.out.print(op.toString());
    }
}


Measured memory_bytes: 67036
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int H, W, K, M = 1000000007;
        {int[] a = in.ii(); H = a[0]; W = a[1]; K = a[2];}
        int[][] dp = new int[H+1][W+1];
        dp[0][1] = 1;
        for(int i = 1;i <= H; i++)
            for(int k = 0; k < 1<<W-1; k++)
                if((k&k/2) == 0)
                    for(int m = k<<1, j = 1; j <=W ; j++)
                        dp[i][j] = (dp[i][j] + dp[i-1][(m>>j&1) > 0 ? j+1 : (m>>(j-1)&1) > 0 ? j-1 : j])%M;
        out.println(dp[H][K]);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
} ;

typedef struct node Node;

Node *root, *NIL;

void Insert(int);
void Inorder(Node *);
void Preorder(Node *);

int main()
{
  int n,i,a;
  char in[7],insert[7] = "insert";
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",in);
    if(strcmp(in, insert) == 0) {
      scanf("%d",&a);
      Insert(a);
    }
    else {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void Insert(int a) {
  Node *b = NIL;
  Node *c = root;
  Node *d;

  d = malloc(sizeof(Node));
  d -> key = a;
  d -> left = NIL;
  d -> right = NIL;
  while(c != NIL) {
    b = c;
    if(d -> key < c -> key) c = c -> left;
    else  c = c -> right;
  }

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

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

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



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

int main(){
    int H, W;
    
    while(true){
        cin >> H >> W;
    
        if (H == 0 && W == 0){
            break;
        } else {
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j ++){
                    cout << '#';
                }
                cout << endl;
            }
            cout << endl; 
        }
    }

    return 0;
}




Measured memory_bytes: 3080
import java.util.Scanner;


public class Main {

	static int k;
	static long n;
	static long[] stones;
	static long memo[];

	public static void main(String[] args) {

		String input1 = "";
		String input2 = "";
		Scanner scanner = new Scanner(System.in);
		input1 = scanner.nextLine();
		input2 = scanner.nextLine();
		String[] n2 = input1.split(" ");

		n = Long.parseLong(n2[0]);
		k = Integer.parseInt(n2[1]);
		String[] arr = input2.split(" ");
		stones = new long[(int) n];
		for (int i = 0; i < arr.length; i++) {
			stones[i] = Integer.parseInt(arr[i]);
		}

		memo = new long[(int) n];
		for (int i = 0; i < memo.length; i++) {
			memo[i] = -1;
		}
		System.out.println(getMinCostStone(0));
		scanner.close();
	}

	public static long getMinCostStone(int i) {
		if (i == stones.length - 1) {
			return 0;
		}
		long cost = memo[i];

		if (cost != -1) {
			return cost;
		}
		cost = (long) 1e18;
		memo[i] = cost;
		if (i != stones.length - k) {
			for (int j = 1; j <= k; j++) {
				if (i + j < stones.length) {
					cost = Long.min(cost, getMinCostStone(i + j) + Math.abs(stones[i] - stones[i + j]));
					memo[i] = cost;
				}
			}
		}
		return memo[i] = cost;
	}

}


Measured memory_bytes: 61784
from collections import deque

n,m = map(int,input().split())
a = deque(sorted(list(map(int,input().split()))))
bc = [list(map(int,input().split()))[::-1] for i in range(m)]
bc.sort(reverse=True)
def hoge(n,m,a,bc):
    cur_sum = sum(a)
    for x in bc:
        c = x[0]
        for i in range(x[1]):
            prv_sum = cur_sum
            cur_sum -= a.popleft()
            cur_sum += c
            a.append(c)
            if prv_sum >= cur_sum:
                print(prv_sum)
                return
    print(cur_sum)
    return
hoge(n,m,a,bc)

Measured memory_bytes: 24792
@$_=$_ for@p=1..<>;map{unshift@a,@p*$#p/2-$%;@$A>@$B&&($A^=$B^=$A^=$B),$%+=@$B*map$p[($$B[@$B]=$_)-1]=$B,@$A if($B=$p[$'-/ /])-($A=$p[$`-1])}reverse<>;print"@a"

Measured memory_bytes: 140672
H, W = map(int, input().split())
S = ['a' * (W+2)] + [list('a' + input() + 'a') for i in range(H)] + ['a' * (W+2)]
for i in range(H):
    for j in range(W):
        if S[i+1][j+1] == '#':
            if [S[i][j+1], S[i+1][j], S[i+1][j+2], S[i+2][j+1]].count('#') < 1:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
pair<long long, long long> a[N];
long long n, seg[4 * N], lazy[4 * N];
vector<long long> adj[N];
void prop(long long idx, long long start, long long end)
{
	if (start > end)
		return;
	seg[idx] += lazy[idx] * (end - start + 1);
	if (start != end)
	{
		lazy[2 * idx + 1] += lazy[idx];
		lazy[2 * idx + 2] += lazy[idx];
	}
	lazy[idx] = 0;
}
void upd(long long idx, long long start, long long end, long long l, long long r, long long val)
{
	prop(idx, start, end);
	if (start > end || start > r || end < l)
		return;
	else if (start >= l && end <= r)
	{
		seg[idx] += (end - start + 1) * val;
		if (start != end)
		{
			lazy[2 * idx + 1] += val;
			lazy[2 * idx + 2] += val;
		}
	}
	else
	{
		long long mid = (start + end) / 2;
		upd(2 * idx + 1, start, mid, l, r, val);
		upd(2 * idx + 2, mid + 1, end, l, r, val);
		seg[idx] = seg[2 * idx + 1] + seg[2 * idx + 2];
	}
}
long long query(long long idx, long long start, long long end, long long l, long long r)
{
	prop(idx, start, end);
	if (start > end || start > r || end < l)
		return 0;
	else if (start >= l && end <= r)
		return seg[idx];
	else
	{
		long long mid = (start + end) / 2;
		long long ls = query(2 * idx + 1, start, mid, l, r);
		long long rs = query(2 * idx + 2, mid + 1, end, l, r);
		return (ls + rs);
	}
}
bool cmp(pair<long long, long long> lhs, pair<long long, long long> rhs)
{
	return lhs.second < rhs.second;
}
int  main(int argc, char const *argv[])
{
	cin >> n;
	for (long long i = 0; i < n - 1; ++i)
	{
		long long u, v;
		cin >> u >> v;
		u --;
		v --;
		if (u > v)
			swap(u, v);
		adj[u].push_back(v);
		a[i] = make_pair(u, v);
	}
	sort(a, a + n - 1, cmp);
	long long j = 0;
	for (long long i = 0; i < n; ++i)
	{
		while (j < n - 1 && a[j].second <= i)
			j ++;
		upd(0, 0, n - 1, i, i, i + 1 - j);
	}
	long long ans = query(0, 0, n - 1, 0, n - 1);
	for (long long i = 1; i < n; ++i)
	{
		upd(0, 0, n - 1, 0, n - 1, -1);
		for (long long v: adj[i - 1])
			upd(0, 0, n - 1, v, n - 1, 1);
		ans = ans + 1LL * query(0, 0, n - 1, i, n - 1);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 25832
use std::io::*;

fn main(){
    let w : isize = input();
    let h : isize = input();
    let x : isize = input();
    let y : isize = input();
    let ans1 : f64 = (w * h) as f64 / 2.0;
    let ans2 = if (w  == x * 2) && (h == y * 2) {1} else {0};
    println!("{:.6} {}", ans1, ans2);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;

int main(){
    int a,b,c,res;

    cin >> a >> b >> c;

    res = abs(a-b) + abs(b-c);
    if( res > ( abs(b-a) + abs(a-c) ) ){
        res = abs(b-a) + abs(a-c);
    }
    if( res > ( abs(c-a) + abs(c-b) ) ){
        res = abs(c-a) + abs(c-b);
    }

        cout << res << "\n";
}

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

typedef long long ll;
using namespace std;

int main(){
	ll n,m,ans;
	cin>>n>>m;
	if(n==1 && m==1){
		ans=1;
	}
	else if(n==1){
		ans=m-2;
	}
	else if(m==1){
		ans=n-2;
	}
	else{
		ans=(n-2)*(m-2);
	}
	cout << ans<<endl;
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

bool issymmetric(string s, string t){
    if(s.size() != t.size()) return false;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != t[(int)s.size()-i-1]) return false;
    }
    return true;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for (auto &&i : v) cin >> i;
    vector<int> perm(h);
    for (int i = 0; i < h; ++i) perm[i] = i/2;
    int x = 0;
    do {
        bool ok = true;
        int p = 0;
        for (int i = 0; i < h; ++i) {
            if (h % 2 == 1 && perm[i] == h / 2) continue;
            if(perm[i] < p) continue;
            if(perm[i] == p) { ++p; continue;}
            ok = false;
            break;
        }
        if(!ok) continue;
        vector<int> u = perm, cnt((h+1)/2, 0);
        for (int i = 0; i < h; ++i) {
            if(cnt[u[i]] == 0) cnt[u[i]]++;
            else u[i] = h - u[i] - 1;
        }
        map<string, int> m;
        for (int i = 0; i < w; ++i) {
            string t(h, ' ');
            for (int j = 0; j < h; ++j) {
                t[u[j]] = v[j][i];
            }
            ++m[t];
        }
        int a = w%2;
        ok = true;
        for (auto &&k : m) {
            if(issymmetric(k.first, k.first)){
                if(k.second % 2 == 1) --a;
                continue;
            }
            string t = k.first;
            reverse(t.begin(), t.end());
            if(k.second != m[t]) {
                ok = false;
                break;
            }
        }
        if(!ok || a != 0) continue;
        puts("YES");
        return 0;
    }while(next_permutation(perm.begin(), perm.end()));
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline()[:-1].decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7


n, m = map(int, input().split())
data = [list(map(int, input().split())) for i in range(m)]





l, r = 0, 10**6
for i, j in data:
	l = max(l, i)
	r = min(r, j)
print(max(0, r-l+1))


Measured memory_bytes: 55772
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;















signed main(){
    string s;
    bool fl = 1;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (s[i] != s[n - 1 - i]) fl = 0;
    }
    for (int i = 0; i < (n)/2; i++){
        if (s[i] != s[(n)/2 - 1 - i]) fl = 0;
      //  cout << s[i];
    }
   // cout << endl;
    for (int i = n - 1; i >= (n+2)/2; i--){
        if (s[i] != s[(n + 2) / 2 + (n - 1 - i)]) fl = 0;
      //  cout << s[i];
    }

    if (fl == 0){
        cout << "No";
    }else cout << "Yes";
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  double s = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      s += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }
  cout << setprecision(7) << s * 2 / n << '\n';
  return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    H = [int(i) for i in input().split()]

    c = [0]
    tmp = H[0]
    count = 0
    for h in H[1:]:
        if tmp >= h:
            count += 1
        else:
            c.append(count)
            count = 0
        tmp = h

    c.append(count)
    # print(c)
    print(max(c))


if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n;
  int ans = 0;
  for (int i = 105; i <= n; i+=2) {
    int cont = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) cont++;
    }
    if (cont == 8) ans++;
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


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

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

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

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

inline int sq(int x) {
  return x * x;
}

signed main() {
  for (;;) {
    int N = rint();
    int M = rint();
    if (!N && !M)
      break;
    int C[M];
    dotimes(i, M)
      C[i] = rint();
    const int inf = 1LL << 61;
    int dp[2][256];
    dotimes(y, 256)
      dp[0][y] = inf;
    dp[0][128] = 0;
    dotimes(i, N) {
      int x = rint();
      dotimes(y, 256)
        dp[(i+1)%2][y] = inf;
      dotimes(y, 256) dotimes(j, M) {
        int z = max(0LL, min(255LL, y + C[j]));
        mins(dp[(i+1)%2][z], dp[i%2][y] + sq(z - x));
      }
    }
    int r = inf;
    dotimes(y, 256)
      mins(r, dp[N%2][y]);
    wint(r);
  }
  return 0;
}



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

using namespace std;

int N;

int main(){
    cin >> N;
    cin.ignore();

    vector<unsigned long long> a;
    unsigned long long tmp;
    unsigned long long x_sum = 0;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        x_sum ^= tmp;
        a.push_back(tmp);
    }

    for(int i = 0; i < N - 1; i++){
        unsigned long long numout = x_sum ^ a[i];
        cout << numout << " " << flush;
    }
    unsigned long long numout_end = x_sum ^ a[N - 1];
    cout << numout_end << endl;

    return 0;
}

Measured memory_bytes: 5296
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
mod = 10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, 10**5+5 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
    
    
ans = 0
for i in range(0, n-k+1):
  ans += a[i]*cmb(n-i-1, k-1, mod)
  ans %= mod

a.sort()
for i in range(0, n-k+1):
  ans -= a[i]*cmb(n-i-1, k-1, mod)
  ans %= mod
  
print(ans)


Measured memory_bytes: 20696
s = int(input())
import sys
p = 10**9+7
dp = [0]*2003
dp[2]=1
if s<=3:
    print(dp[s-1])
    sys.exit()
for i in range(3,s):
    dp[i] = (dp[i-1]%p+dp[i-3]%p)%p


print(dp[s-1])

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int h,a;
	cin>>h>>a;
	cout<<(h+(a-1))/a<<endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val line = readLine.split(" ").map(_.toInt)
  val H = line(0)
  val W = line(1)
  val board = Array.ofDim[Int](H*W)
  for(j <- 0 until H) {
    val l = readLine.toList
    for((b, i) <- l.zipWithIndex) {
      board(j*W+i) = if(b == '.') Int.MaxValue else -1
    }
  }
  val count = board.count(_ == Int.MaxValue)
  board(0) = 0
  val last = H*W - 1

  def nextStep(board: Array[Int], pos:(Int, Int)=(0,0), value:Int=0):Unit = {
    val direction = List((0,1), (0,-1), (1, 0), (-1,0))
    val myValue = value + 1
    var maximum = -1
    for(d <- direction) {
      val x = pos._1 + d._1
      val y = pos._2 + d._2
      if(x != -1 && x != W && y != -1 && y != H) {
        if(x+y*W == last) {
          board(last) = myValue
        } else if(board(x+y*W) > myValue) {
          board(x+y*W) = myValue
          nextStep(board, (x,y), myValue)
        }
      }
    }
  }
  nextStep(board)
  if(board(last) == Int.MaxValue) {
    println(-1)
  } else {
    println(count-(board(last)+1))
  }
}


Measured memory_bytes: 116496
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


def gcd(a,b):
	while b:
		a,b = b, a%b
	return a

def lcm(a,b):
	return a*b // gcd(a,b)


N = inp()
aa = inpl()
tmp = 1

for a in aa:
    tmp = lcm(a,tmp)

tmp %= mod
ans = 0
for a in aa:
    ans += tmp * pow(a,mod-2,mod)
    ans %= mod

print(ans)


Measured memory_bytes: 44120
S = list(input())
judge = 1 #1:OK , 0:NG
C_count = 0
C_index = 0

if(S[0] != 'A'):#先頭の文字判定
  print('WA')
  
else: #S{i] == 'A'
 for i in range(len(S)):
  if(i != 0):
   if(S[i] == 'C'):
     C_count += 1
     C_index = i
   else:
     if(S[i] != S[i].lower()):#小文字判定
       judge = 0
      
 if(C_count != 1):#'C':1個 , 'C'のインデックスの判定
   judge = 0
 else:
  if( (C_index < 2)or((len(S)-2) < C_index) ):
    judge = 0
 
 if(judge == 1):
    print('AC')
 else:
    print('WA')
    
    


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            for (var i = X; i <= 100003; i++)
            {
                if (IsPrime(i))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 11092
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ld long double
#define pas(v) cout << #v << ' ' << v << endl
using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout.precision(30);
    int n, m; cin >> n >> m;
    int s, t; cin >> s >> t; s--, t--;

    vector<vector<int>> g(n);
    vector<vector<ll>> y(n);
    vector<vector<ll>> sn(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        g[v].pb(u);
        g[u].pb(v);
        y[v].pb(a);
        y[u].pb(a);
        sn[v].pb(b);
        sn[u].pb(b);
    }

    vector<vector<ll>> costs = y;
    vector<ll> fpart, spart;
    int start = s;
    for (int z = 0; z < 2; z++, costs = sn, start = t) {
        set<pll> d;
        vector<ll> dists(n, 1e18);
        dists[start] = 0;
        d.insert({0, start});
        vector<int> used(n);
        while (!d.empty()) {
            auto x = *d.begin();
            d.erase(x);
            ll len, v;
            tie(len, v) = x;

            if (used[v]) continue;
            used[v] = 1;
            
            for (int i = 0; i < g[v].size(); i++) {
                int u = g[v][i];
                ll cst = costs[v][i];

                if (dists[u] > len + cst) {
                    dists[u] = len + cst;
                    d.insert({len + cst, u});
                }

            }
        }
        if (z == 0) fpart = dists;
        else spart = dists;
    }

    ll mn = 1e18;

    vector<ll> ans;

    for (int i = n - 1; i > -1; i--) {
        // cout << fpart[i] << ' ' << spart[i] << endl;
        mn = min(mn, fpart[i] + spart[i]);
        
        ans.pb(mn);
    }

    ll beg = 1e15;

    for (int i = n - 1; i > -1; i--) {
        cout << beg - ans[i] << '\n';

    }


    return 0;
}

Measured memory_bytes: 29056
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll N;
  cin >>N;
  vl a(N);
  rep(i,N) {
cin >>a.at(i);
  }

  ll dp[N];
  dp[0]=a.at(0);
  repl(i,1,N) {
    dp[i]=dp[i-1]+a.at(i);
  }
  
  ll sum=dp[N-1];
 
  vl vec(N-1);
  rep(i,N-1) {
    vec.at(i)=abs((sum-dp[i])-dp[i]);
  }
  sort(all(vec));
  cout<<vec.at(0)<<endl;
}



Measured memory_bytes: 4992
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    if((a+b)>=x && a<=x){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define dbg(x...) do { cout << "\033[32;1m" << #x <<" -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<class T, class... Ts> void err(const T& arg,const Ts&... args) { cout << arg << " "; err(args...); }
const int N = 100000 + 5;
vector<int> xall, yall;
int n;
struct Seg{
    int x1, x2, y1, y2;
}l[N];
vector<pair<int,int>> line[2*N], q[2*N];
ll c[2*N];
int getxid(int x){
    return lower_bound(xall.begin(),xall.end(), x) - xall.begin() + 1;
}
int getyid(int x){
    return lower_bound(yall.begin(),yall.end(), x) - yall.begin() + 1;
}
void add(int x, int y){
    for(;x<2*N;x+=x&-x) c[x]+=y;
}
ll ask(int x){
    ll res = 0;
    for(;x;x-=x&-x) res += c[x];
    return res;
}
int main(){
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        int x, y, x2, y2;
        scanf("%d%d%d%d", &x, &y, &x2, &y2);
        xall.push_back(x);
        xall.push_back(x2);
        yall.push_back(y);
        yall.push_back(y2);
        l[i] = Seg{x, x2, y, y2};
    }
    sort(xall.begin(),xall.end());xall.erase(unique(xall.begin(),xall.end()),xall.end());
    sort(yall.begin(),yall.end());yall.erase(unique(yall.begin(),yall.end()),yall.end());
    for(int i=1;i<=n;i++){
        if(l[i].x1 == l[i].x2){
            int xid = getxid(l[i].x1);
            if(l[i].y1 > l[i].y2) swap(l[i].y1, l[i].y2);
            q[xid].push_back(make_pair(getyid(l[i].y1), getyid(l[i].y2)));
        } else {
            if(l[i].x1 > l[i].x2) swap(l[i].x1, l[i].x2);
            line[getxid(l[i].x1)].push_back(make_pair(1, getyid(l[i].y1))); //  1表示添加
            line[getxid(l[i].x2)].push_back(make_pair(2, getyid(l[i].y1))); //  2表示删除
        }
    }
    ll res = 0;
    for(int i=1;i<=xall.size();i++){
        for(auto t : line[i]){
            int type = t.first, y = t.second;
            if(type == 1){
               //dbg(xall[i-1], type, yall[y-1]);
                add(y, 1);
            }
        }
        for(auto t : q[i]){
            int x1 = t.first, x2 = t.second;
            // dbg(x1, x2, ask(x2)-ask(x1-1));
            res += ask(x2) - ask(x1-1);
        }
        for(auto t : line[i]){
            int type = t.first, y = t.second;
            if(type == 2){
                //dbg(xall[i-1], type, yall[y-1]);
                add(y, -1);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 18072
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

bool r[100001] = {};
ll b[100001] = {};

int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		b[i] = 1;
	}
	r[1] = true;

	ll m; cin >> m;

	rep(i, 0, m) {
		ll x, y; cin >> x >> y;
		b[x]--;
		b[y]++;
		if (r[x]) {
			r[y] = true;
		}
		if (b[x] == 0) {
			r[x] = false;
		}
	}

	ll ans = 0;
	repe(i, 1, n) {
		if (r[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

void rotate_S(int minase_inori[6]) {
	int hayami_saori = minase_inori[0];
	minase_inori[0] = minase_inori[4];
	minase_inori[4] = minase_inori[5];
	minase_inori[5] = minase_inori[1];
	minase_inori[1] = hayami_saori;
}

void rotate_NES(int kugimiya_rie[6]) {
	int kitamura_eri = kugimiya_rie[1];
	kugimiya_rie[1] = kugimiya_rie[3];
	kugimiya_rie[3] = kugimiya_rie[4];
	kugimiya_rie[4] = kugimiya_rie[2];
	kugimiya_rie[2] = kitamura_eri;
}

int check(const int asumi_kana[6], const int iguti_yuka[6]) {
	int sakura_ayane;
	int satou_satomi[6];
	for (sakura_ayane = 0; sakura_ayane < 6; sakura_ayane++) {
		satou_satomi[sakura_ayane] = iguti_yuka[sakura_ayane];
	}
	for (sakura_ayane = 0; sakura_ayane < 4; sakura_ayane++) {
		int tateno_kanako;
		for (tateno_kanako = 0; tateno_kanako < 6; tateno_kanako++) {
			if (asumi_kana[tateno_kanako] != satou_satomi[tateno_kanako]) break;
		}
		if (tateno_kanako >= 6) {
			return 1;
		}
		rotate_NES(satou_satomi);
	}
	return 0;
}

int tokui_sora(const int utida_maaya[6], const int taneda_risa[6]) {
	int igarasi_hiromi[6];
	int horie_yui;
	for (horie_yui = 0; horie_yui < 6; horie_yui++) {
		igarasi_hiromi[horie_yui] = taneda_risa[horie_yui];
	}
	if (check(utida_maaya, igarasi_hiromi)) return 1;
	for (horie_yui = 0; horie_yui < 4; horie_yui++) {
		rotate_NES(igarasi_hiromi);
		rotate_S(igarasi_hiromi);
		if (check(utida_maaya, igarasi_hiromi)) return 1;
		rotate_S(igarasi_hiromi);
		rotate_S(igarasi_hiromi);
		rotate_S(igarasi_hiromi);
	}
	rotate_S(igarasi_hiromi);
	rotate_S(igarasi_hiromi);
	return check(utida_maaya, igarasi_hiromi);
}

int main(void) {
	int mizuhasi_kaori;
	int ootani_ikue[100][6];
	int uesaka_sumire, suzaki_aya;
	if (scanf("%d", &mizuhasi_kaori) != 1) return 1;
	for (uesaka_sumire = 0; uesaka_sumire < mizuhasi_kaori; uesaka_sumire++) {
		for (suzaki_aya = 0; suzaki_aya < 6; suzaki_aya++) {
			if (scanf("%d", &ootani_ikue[uesaka_sumire][suzaki_aya]) != 1) return 1;
		}
	}
	for (uesaka_sumire = 0; uesaka_sumire < mizuhasi_kaori; uesaka_sumire++) {
		for (suzaki_aya = uesaka_sumire + 1; suzaki_aya < mizuhasi_kaori; suzaki_aya++) {
			if (tokui_sora(ootani_ikue[uesaka_sumire], ootani_ikue[suzaki_aya])) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}




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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll a, b;

vector<ll> store;

ll ans = 0;

ll count_one(ll k, ll x) {
  ll band = (ll) powl(2, k + 1);

  ll dude = (ll) powl(2, k);

  ll part = (x + 1) / band;

  ll num = dude * part;

  ll cut = (x + 1) % band;

  if (cut == 0) {
    return num;
  }
  else {
    if (cut >= (band / 2) + 1) {
      return num + cut - ((band / 2) + 1) + 1;
    }
    else {
      return num;
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%lld %lld", &a, &b);

  int size = log2(b) + 1;

  for (int i = 0; i <= size; ++i) {
    ll bottom = count_one(i, a - 1);
    ll top = count_one(i, b);

    ll num_one = top - bottom;

    if (num_one % 2 == 0) {
      store.push_back(0);
    }
    else {
      store.push_back(1);
    }
  }

  for (int i = 0; i < store.size(); ++i) {
    ll tmp = (ll) powl(2, i);
    ll diff = tmp * store[i];
    ans += diff;
  }

  printf("%lld\n", ans);

  return 0;
}


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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

vector<int> v(256);

int solve(string s) {
	vector<int> x;
	rep(i, s.size()) {
		x.push_back(v[s[i]]);
	}
	int res = 0;
	reps(i, 1, s.size()) {
		res += x[i-1] != x[i];
	}
	return res;
}

signed main() {
	v['y'] = 1;
	v['u'] = 1;
	v['i'] = 1;
	v['o'] = 1;
	v['p'] = 1;
	v['h'] = 1;
	v['j'] = 1;
	v['k'] = 1;
	v['l'] = 1;
	v['n'] = 1;
	v['m'] = 1;
	string s;
	while (cin >> s, s != "#") cout << solve(s) << endl;
}




Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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=100010;
const ll mod=1e9+7;


int main(){
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        a[i]*=n;
    }
    int ret=inf;
    int ans=0;
    rep(i,n){
        if(ret>abs(sum-a[i])){
            ret=abs(sum-a[i]);
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = "";
    int n = 0;
    for (int i = 0; i < s.length(); i++) {
      String t = s.substring(i, i+1);
      if (t.equals("B") && a.length() == 0) continue;
      if (t.equals("B") && a.length() != 0) {
        a = a.substring(0, n-1);
        n--;
      } else {
        a += t;
        n++;
      }
    }
    
    System.out.println(a);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>


using namespace std;


string S, T;



int main()
{

	cin >> S;
	cin >> T;

	int ans = 0;

	for (int i = 0; i < 3; i++) {
		if (S.at(i) == T.at(i)) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
#define ll long long


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    const int mod = 1e9 + 7;
    int n;
    cin >> n;
    int sum = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans = (ans + (a * 1LL * sum) % mod) % mod;
        sum = (sum + a) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld n,k;
  cin>>n>>k;
  lld p[n];
  lld i;
  for(i=0;i<n;i++)
  {
    cin>>p[i];
  }
  sort(p,p+n);
  lld sum = 0;
  for(i=0;i<k;i++)
  {
    sum+=p[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include <vector>
#include<string>
#include<map>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620