akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N,M;
int ab[10][10];

signed main(){
    cin>>N>>M;
    deque<int> ar(N-1);
    rep(i,N-1)ar.at(i)=i+1;//1~N-1
    rep(i,M){
        int a,b; cin>>a>>b;
        a--; b--;
        ab[a][b]++;
        ab[b][a]++;
    }
    int ans=0;
    do{
        ar.push_front(0);
        bool b=true;
        rep(i,N-1){
            if(ab[ar.at(i)][ar.at(i+1)]==0){
                b=false;
                break;
            }
        }
        ar.pop_front();
        if(b)ans++;
    }while(next_permutation(all(ar)));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int h, w;
    cin >> h >> w;
    int i;
    string str;
    for(i = 0; i < w+2; i++){
        cout << "#";
    }
    cout << endl;
    for(i = 0; i < h; i++){
        cout << "#";
        cin >> str;
        cout << str;
        cout << "#" << endl;
    }
    for(i = 0; i < w+2; i++){
        cout << "#";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,Y;
    cin >> N >> Y;
    ll x,y,z;
    for(x=0;x<=N;x++){
      for(y=0;y<=N-x;y++){
        z=N-x-y;
        if(10000*x+5000*y+1000*z==Y){
          cout << x <<" "<< y <<" "<< z;
          return 0;
        }
      }
    }
    cout << -1 <<" "<< -1 <<" "<< -1;

    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    H, W, M = map(int, input().split())
    row = [0] * (H)
    col = [0] * (W)
    bomb = set()
    for _ in range(M):
        h, w = map(int, input().split())
        bomb.add((h, w))
        row[h-1] += 1
        col[w-1] += 1
    row_max = max(row)
    row_index_list = [i for i, v in enumerate(row) if v == row_max]
    col_max = max(col)
    col_index_list = [i for i, v in enumerate(col) if v == col_max]
    ans = row_max + col_max - 1
    c = False
    for x in row_index_list:
        for y in col_index_list:
            if not (x + 1, y + 1) in bomb:
                c = True
                break
        if c:
            break
    if c:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 166432
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i128,
        b: i128,
        c: i128,
        d: i128,
    }

    let ac = a * c;
    let ad = a * d;
    let bc = b * c;
    let bd = b * d;

    let a1 = std::cmp::max(ac, ad);
    let b1 = std::cmp::max(bc, bd);

    println!("{}", std::cmp::max(a1, b1));


}


Measured memory_bytes: 2132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;

int n;
LL ans;
char s[N];
vector<int> vc;

LL cal() {
	LL res=0,c=0;
	for(int x: vc) {
		if(x==0) c++;
		else res+=c;
	}
	vc.clear();
	return res;
}

int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	int p=1;
	while(p<=n) {
		if(s[p]=='A') {
			vc.push_back(0);
			p++;
		}
		else if(p<n && s[p]=='B' && s[p+1]=='C') {
			vc.push_back(1);
			p+=2;
		}
		else {
			ans+=cal();
			p++;
		}
	}
	ans+=cal();
	printf("%lld\n",ans);
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int h, w;
    cin >> h >> w;

    rep(x, w + 2) {
        cout << '#';
    }
    cout << endl;
    rep(y, h) {
        cout << '#';
        rep(x, w) {
            char c;
            cin >> c;
            cout << c;
        }
        cout << '#' << endl;
    }
    rep(x, w + 2) {
        cout << '#';
    }
    cout << endl;
}



Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, K;
    cin >> N >> K;
    int ret = 0;
    while (N > 0) {
        N /= K;
        ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void) {

	int n;	cin >> n;
	vector<int> L(n);
	for(int i = 0 ; i < n ; i++)    cin >> L[i];
	
	sort(L.begin(),L.end() , greater<int>());
	int ans = 0;
  	for(int i = 0 ; i < n - 2; i++){
		int longest = L[i];
      
      	for(int j = i + 1 ; j < n - 1; j++){
			for(int k = j + 1 ; k < n ; k++){
              
				int other_sum = L[j] + L[k];
              	if(longest < other_sum){
                  	ans += 1;
                }else{
                  	break;
                }
              
            }
        }
    }

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int W,H;
int x[4]={0,0,1,-1};
int y[4]={1,-1,0,0};
int i,j;
int count=0;
char room[100][100];

int dfs(int, int);

int main(){
  while(1){
    int sy,sx;
    cin >> W >> H;
    if(W==0&&H==0)break;
    for(i = 0 ; i < H ; i++){
      for(j = 0 ; j < W ; j++){
	cin >> room[i][j];
	if(room[i][j] == '@'){
	  sy = i;
	  sx = j; 
	}
      }
    }
    cout << dfs(sx,sy) << endl;
  }
  return 0;
}

int dfs(int ax,int ay){
  if(ax<0||ay<0)return 0;
  if(ax>=W||ay>=H)return 0;
  if(room[ay][ax]=='#')return 0;
  room[ay][ax]='#';
  int cnt=1;
  int i;
  for(i=0;i<4;i++){
    int nx=ax+x[i];
    int ny=ay+y[i];
    cnt+=dfs(nx,ny);
  }
  return cnt;
}

Measured memory_bytes: 1172
fun main(args: Array<String>) {
    var (N, D, A) = listOfInt()
    var XH = Array(N) {
        var (x, h)= listOfLong()
        x to h
    }.sortedBy { it.first }
    val d = 2L * D
    val q = Queue<Pair<Long, Long>>()
    var ans = 0L
    var total = 0L
    repeat (N) {
        var (x, h) = XH[it]
        while (q.count() > 0 && q.first().first < x) {
            total -= q.dequeue()!!.second
        }
        h -= total
        if (h > 0) {
            val num = (h + A - 1) / A
            ans += num
            val dmg = num * A
            total += dmg
            q.enqueue(x + d to dmg)
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt() = listOfString().map(String::toInt)
class Queue<T> {
    val elements = mutableListOf<T>()
    fun count() = elements.size
    fun isEmpty() = elements.isEmpty()
    fun first() = elements[0]
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
}

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

typedef long long LL;

const int N=100000,INF=(1<<30)-1;

int n,mn;
struct seg{
  int l,r;
  seg(int L=0,int R=0){l=L;r=R;}
}a[N+9];

bool cmp(const seg &a,const seg &b){return a.l<b.l;}

int ans;

void into(){
  scanf("%d",&n);
  mn=INF;
  int l=1,r=INF;
  for (int i=1;i<=n;++i){
	scanf("%d%d",&a[i].l,&a[i].r);
	mn=min(mn,a[i].r);
	ans=max(ans,a[i].r-a[i].l+1);
	l=max(l,a[i].l);
	r=min(r,a[i].r);
  }
  ans+=max(r-l+1,0);
}

void Get_ans(){
  sort(a+1,a+n+1,cmp);
  int l=1,r=INF;
  for (int i=n;i>1;--i){
	if (a[i].r==mn) return;
	l=max(l,a[i].l);
	r=min(r,a[i].r);
	ans=max(ans,max(r-l+1,0)+max(mn-a[i-1].l+1,0));
  }
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4560
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define power ios_base :: sync_with_stdio(false)cin.tie(NULL
#define ll long long
void solve(int t)
{
    string s;
    cin>>s;
    s+="0";
    string ans="";
    int pre = 0;
    for(int i=0; i<s.size()-1; i++)
    {
        while(pre<s[i]-'0')
        {
            ans+="(";
            pre++;
        }
        ans+=s.at(i);
        while(pre>s[i+1]-'0')
        {
            ans+=")";
            pre--;
        }

    }
    cout<<"Case #"<<t<<": ";
    cout<<ans<<endl;
//    cout<<ans.size()<<endl;
}

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   swap(a,b);
   swap(a,c);
   cout<<a<<" "<<b<<" "<<c<<endl;

}



Measured memory_bytes: 256
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)

  if op == '+':
    print(a + b)
  elif op == '-':
    print(a - b)
  elif op == '*':
    print(a * b)
  elif op == '/':
    print(a // b)
  else:
    break



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

#define fi first
#define se second

const int N = 55;
const double EPS = 1e-9;

pair<double, double> ar[N];
int n;
double h, k, r;

double dist(pair<double, double> a, pair<double, double> b) {
    double ret = pow(a.fi - b.fi, 2) + pow(a.se - b.se, 2);
    ret = sqrt(ret);
    return ret;

}

// kontol
void findCircle(int x1, int y1, int x2, int y2, int x3, int y3) 
{ 
    double x12 = x1 - x2; 
    double x13 = x1 - x3; 
  
    double y12 = y1 - y2; 
    double y13 = y1 - y3; 
  
    double y31 = y3 - y1; 
    double y21 = y2 - y1; 
  
    double x31 = x3 - x1; 
    double x21 = x2 - x1; 
  
    // x1^2 - x3^2 
    double sx13 = pow(x1, 2) - pow(x3, 2); 
  
    // y1^2 - y3^2 
    double sy13 = pow(y1, 2) - pow(y3, 2); 
  
    double sx21 = pow(x2, 2) - pow(x1, 2); 
    double sy21 = pow(y2, 2) - pow(y1, 2); 
  
    double f = ((sx13) * (x12) 
             + (sy13) * (x12) 
             + (sx21) * (x13) 
             + (sy21) * (x13)) 
            / (2 * ((y31) * (x12) - (y21) * (x13))); 
    double g = ((sx13) * (y12) 
             + (sy13) * (y12) 
             + (sx21) * (y13) 
             + (sy21) * (y13)) 
            / (2 * ((x31) * (y12) - (x21) * (y13))); 
  
    double c = -pow(x1, 2) - pow(y1, 2) - 2 * g * x1 - 2 * f * y1; 
  
    // eqn of circle be x^2 + y^2 + 2*g*x + 2*f*y + c = 0 
    // where centre is (h = -g, k = -f) and radius r 
    // as r^2 = h^2 + k^2 - c 
    h = -g; 
    k = -f; 
    double sqr_of_r = h * h + k * k - c; 
  
    // r is the radius 
    r = sqrt(sqr_of_r); 
} 

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> ar[i].fi >> ar[i].se;
    }    
    double ans = 10000;
    if (n == 2) {
        ans = dist(ar[0], ar[1]) / 2;
        cout << fixed << setprecision(9) << ans << '\n';
        exit(0);
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int kon = j + 1; kon < n; kon++) {
                findCircle(ar[i].fi, ar[i].se, ar[j].fi, ar[j].se, ar[kon].fi, ar[kon].se);
                bool can = true;
                for (int l = 0; l < n; l++) {
                    if (l != i && l != j && l != kon) {
                        if (dist({h, k}, ar[l]) > r) {
                            can = false;
                            break;
                        }
                    }
                }
                if (can) ans = min(ans, r);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            pair<double, double> cntr = {(ar[i].fi + ar[j].fi) / 2, (ar[i].se + ar[j].se) / 2};
            r = dist(cntr, ar[i]);
            bool can = true;
            for (int l = 0; l < n; l++) {
                if (l != i && l != j) {
                    if (dist(cntr, ar[l]) > r) {
                        can = false;
                        break;
                    }
                }
            }
            if (can) ans = min(ans, r);
        }

    }
    cout << fixed << setprecision(9) << ans << '\n';
    return 0;
}

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

int L;
string s, t;

int main() {
	cin >> L >> s >> t;
	
	if (s + t > t + s)
		swap(s, t);
	
	int N = s.size(), M = t.size();
	int mx = 0;
	for (int i = 0; i <= L / N; i++)
		if (!((L - i * N) % M))
			mx = i;
	
	string sol = "";
	for (int i = 0; i < mx; i++)
		sol += s;
	for (int i = 0; i < (L - mx * N) / M; i++)
		sol += t;
	
	cout << sol << endl;
	
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};

class UnionFind{

  private:
  vector<int> par;
  public:
  UnionFind(int size) : par(size,-1){}
  bool unite(int x,int y){
    x = root(x),y = root(y);
    if(x == y)return false;
    if(par[y] < par[x])swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool find(int x,int y){
    return root(x) == root(y);
  }
  int root(int x){
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
  int size(int x){
    return -par[root(x)];
  }

};


int main(){

  int n,m,k;
  cin >> n >> m >> k;
  UnionFind fre(n);
  vector<vector<int>> v(n);
  vector<vector<int>> blo(n);
  REP(i,m){
    int x,y;cin >> x >> y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
    fre.unite(x,y);
  }
  REP(i,k){
    int x,y;cin >> x >> y;
    x--,y--;
    blo[x].push_back(y);
    blo[y].push_back(x);
  }
  REP(i,n){
    int res = fre.size(i);
    res -= ((int)v[i].size() + 1);
    for(auto nv : blo[i]){
      if(fre.find(nv,i))res--;
    }
    cout << res << " ";
  }


  return 0;
}

Measured memory_bytes: 12152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define pb push_back
#define mx 100;

int main()
{
    int n,m,a,b;
    cin>>n>>m;
    vector<int> st[n+1];
    for(int i=1; i<=m; i++){
        cin>>a>>b;
        st[a].pb(b);
        st[b].pb(a);
    }
    for(int i=1; i<=n; i++)
        cout<<st[i].size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,total=0;
	scanf("%d%d",&n,&m);
	char queue[n+1];
	for(int i=1;i<=n;i++){
		cin>>queue[i];
		if(queue[i]!=queue[i-1]){
			total++;
//			cout<<i<<' ';
		}
	}
	m*=2;
	if(m<=total){
		total-=m;
	}
	else{
		total=0;
	}
	if(total==0){
		total++;
	}
	printf("%d",n-total);
	return 0;
}

Measured memory_bytes: 384
import sys
S = str(input())

if len(S) < 2 or len(S) > 200:
    sys.exit()
if not S.islower():
    sys.exit()

result = 0
for I in range(len(S)):
    length = len(S) - I
    if (not I == 0) and length % 2 == 0 and S[0:int(length / 2)] == S[int(length / 2):length]:
        print(length)
        sys.exit()

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y;
int main() {
  cin>>m>>n;
  string s[n];
  for(int i=0;i<n;i++) {
    cin>>s[i];
    for(int j=0;j<m;j++)if(s[i][j]=='W')y++;
  }
  int a=0,b=1,M=y;
  for(int j=0;j<m;j++) {
    for(int i=0;i<n;i++)s[i][j]=='W'?y--:x++;
    if(x+y<M)M=x+y,a=j+1,b=j+2;
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 4612
import sys

n = int(input())
a = [int(input()) for i in range(n)]

a.sort()

number = {}

for item in a:
    if item in number.keys():
        number[item] += 1
    else:
        number[item] = 1
    
cnt = 0
for i in number.values():
    if i % 2 != 0:
        cnt += 1

print("{}".format(cnt))

Measured memory_bytes: 16300
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let l: Vec<usize> = (0..N).map(|_| read()).collect();
    use std::collections::HashMap;
    let mut map: HashMap<usize, usize> = HashMap::new();
    for v in l {
        let entry = map.entry(v).or_insert(0);
        *entry += 1;
    }
    let mut ans = 0;
    for &i in map.keys() {
        for &j in map.keys() {
            if i >= j {
                continue;
            }
            for &k in map.keys() {
                if j >= k {
                    continue;
                }
                // i < j < k
                if i + j > k {
                    ans += map.get(&i).unwrap() * map.get(&j).unwrap() * map.get(&k).unwrap()
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
#104_B
S=input()
S_upper=S.upper()
flg= S[0]=='A' and S[2:-1].count('C')==1 and S.count('A')==1 and S.count('C')==1 and set(S)&set(S_upper)=={'A','C'}
print('AC' if flg else 'WA')

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
int main()
{
    char blue1[100][10],red1[100][10],blue2[100][10],red2[100][10];
    int bl,re,max,i,j,t1=1,t2=1,b[100],r[100],jg[100];
    scanf("%d",&bl);
    for(i=0;i<bl;i++)
        scanf("%s",blue1[i]);
    scanf("%d",&re);
    for(j=0;j<re;j++)
        scanf("%s",red1[j]);
    for(i=0;i<bl;i++)
        b[i]=0;
    for(i=0;i<re;i++)
        r[i]=0;
    strcpy(blue2[0],blue1[0]);
    strcpy(red2[0],red1[0]);
    for(i=0;i<bl;i++)
    {
        for(j=0;j<t1;j++)
        {
            if((strcmp(blue1[i],blue2[j])==0))
            {
                b[j]=b[j]+1;break;
            }
        }
        if(j==t1)
            {
                strcpy(blue2[t1],blue1[i]);
                b[t1]=b[t1]+1;
                t1++;
            }
    }
    for(i=0;i<re;i++)
    {
        for(j=0;j<t2;j++)
        {
            if((strcmp(red1[i],red2[j])==0))
            {
                r[j]=r[j]+1;break;
            }
        }
        if(j==t2)
            {
                strcpy(red2[t2],red1[i]);
                r[t2]=r[t2]+1;
                t2++;
            }
    }
    for(i=0;i<t1;i++)
    {
           for(j=0;j<t2;j++)
    {
        if(strcmp(blue2[i],red2[j])==0)
        {
            jg[i]=b[i]-r[j];
            break;
        }

    }
    if(j==t2)
            jg[i]=b[i];
    }
    max=jg[0];
    for(i=0;i<t1;i++)
        if(max<jg[i])
        max=jg[i];
    if(max<=0)
        printf("0\n");
    else
        printf("%d\n",max);
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class AHaiku {
public:
void solve(std::istream& cin, std::ostream& cout) {
    string s;
    cin >> s;
    cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
}
};


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


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int A = in.nextInt();
		int B = in.nextInt();

		if (A+B == 3) {
			System.out.println(3);
		} else if (A+B == 4) {
			System.out.println(2);
		} else if (A+B == 5) {
			System.out.println(1);
		}
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

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

int main()
{
	int n,a,b;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	int cnta = 0,cntb = 0;
	for(auto c:s)
	{
		if(c=='a')
		{
			if(cnta+cntb<a+b)
			{
				cnta++;
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
			
		}
		else if(c=='b')
		{
			
			if(cnta+cntb<a+b&&cntb<b)
			{
				cntb++;
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
			
		}
		else
		{
			cout<<"No"<<endl;
		}
		
		
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{

  i64 K, A, B;
  cin >> K >> A >> B;
  for (i64 i = A; i <= B; i++)
    if (i % K == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < n; i++) {
      sb.append(s.charAt(i));
      sb.append(t.charAt(i));
    }
    System.out.println(sb);
  }

}


Measured memory_bytes: 23764
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n, d, x, a[150] = { 0 };

	cin >> n;
	cin >> d >> x;

	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	int ko[105] = { 0 };
	int cnt = 0;

	for (j = 0; j < n; j++) {
		for (i = 1; i <= d; i=i+a[j] ) {
			cnt++;



		}
	}

	cout << cnt + x << endl;








	getchar();
	getchar();
	return 0;
}

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

using namespace std;

bool used[100000];

int main(){
    int N;
    long L[100000], R[100000];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> L[i] >> R[i];
    }
    sort(L, L+N, greater<int>());
    sort(R, R+N);
    long ans = 0;
    long tmp = 0;
    for(int i = 0; i < N; i++){
        int cur = i/2;
        if(i%2 == 0) tmp += 2*L[cur];
        else tmp -= 2*R[cur];
        ans = max(tmp, ans);
    }
    tmp = 0;
    for(int i = 0; i < N; i++){
        int cur = i/2;
        if(i%2 == 0) tmp -= 2*R[cur];
        else tmp += 2*L[cur];
        ans = max(tmp, ans);
        cur++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    char S[10000];
    int i=0,N;
    scanf("%d",&N);
    scanf("%s",&S);
    while(S[i]!=0){
        S[i]+=N;
        if(S[i]>0x5A)
        S[i]-=26;
        i++;
    }
    printf("%s",S);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#define LL long long
#define N 100100
#define M 1010
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
int mp[M][M];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int n;
	scanf("%d",&n);
	int x = 1,y = 1;
	FOR(i,1,n){
		int num;
		scanf("%d",&num);
		for (int j = 1; j <= num; j ++){
			mp[x][y] = i;
			if (x & 1){
				y ++;
				if (y > w){
					y = w;
					x ++;
				}
			}
			else{
				y --;
				if (y < 1) y = 1,x ++;
			}
		}
	}
	FOR(i,1,h){
		printf("%d",mp[i][1]);
		FOR(j,2,w) printf(" %d",mp[i][j]);
		printf("\n");
	}
}

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

int N;
vector<int> P;

bool solve() {
    vector<int> maxLeftP(N+1, 0), minRightP(N+1, N-1);
    for (int i = 0; i < N; ++i) maxLeftP[i+1] = max(maxLeftP[i], P[i]);
    for (int i = N; i >= 1; --i) minRightP[i-1] = min(minRightP[i], P[i-1]);
    
    for (int i = 0; i < N-1; ++i) {
        if (P[i] == i && P[i+1] == i+1) { if (maxLeftP[i+1] != i) return false; }
        
        if (P[i] != i && P[i+1] != i+1) { if (maxLeftP[i+1] != i) return false; }
    }
    
    for (int i = 1; i+1 < N; ++i) {
        if (P[i] > i) { if (maxLeftP[i] > P[i]) return false; }
        else if (P[i] < i) { if (minRightP[i] < P[i]) return false; }
    }

    return true;
}

int main() {
    cin >> N;
    P.resize(N);
    for (int i = 0; i < N; ++i) cin >> P[i], --P[i];
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3840
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

w,h,x,y=MI()
print(w*h/2,end=" ")
if 2*x==w and 2*y==h:
    print(1)
else:
    print(0)


Measured memory_bytes: 2940
n, k = gets.split.map(&:to_i)
a    = gets.split.map(&:to_i)

h = Hash.new(0)
a.each do |num|
  h[num] += 1
end

sum = 0
if h.size > k
  h.sort_by{|k,v|-v}.to_a[k..-1].each do |a,b|
    sum += b
  end
end

p sum

Measured memory_bytes: 42112
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

ll MOD = 1000000007;

int main(void){
  double x,y; cin >> x >> y;
  double a = (4*x-y)/2;
  double b = x - a;
  if(floor(a) == a && a >= 0){
    if(floor(b) == b && b >= 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    int n, d;
    cin >> n >> d;
    int ans = n / (2 * d + 1);
    if (n % (2 * d + 1)) ans++;
    cout << ans << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		static int[] ls;
		static void Main(string[] args)
		{
			var nabc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nabc[0];
			int a = nabc[1];
			int b = nabc[2];
			int c = nabc[3];

			ls = new int[n];
			for (int i = 0; i < n; i++) {
				ls[i] = int.Parse(Console.ReadLine());
			}

			int ans = int.MaxValue;
			var pattern = new int[][]{
					new []{a, b, c },
					new []{a, c, b },
					new []{b, a, c },
					new []{b, c, a },
					new []{c, a, b },
					new []{c, b, a },
				};
			foreach (var p in pattern) {
				int temp = Calc(n, p[0], p[1], p[2]);
				ans = Math.Min(ans, temp);
			}

			Console.WriteLine(ans);
		}

		static int Calc(int n, int k1, int k2, int k3)
		{
			int used = 0;
			int ret1 = CalcCore(n, k1, ref used);
			int ret2 = CalcCore(n, k2, ref used);
			int ret3 = CalcCore(n, k3, ref used);

			return ret1 + ret2 + ret3;
		}

		static int CalcCore(int n, int target, ref int used)
		{
			int max = 1001;
			var dp = new Tuple<int, int>[max];
			for (int i = 0; i < max; i++) {
				dp[i] = new Tuple<int, int>(100000, 0);
			}

			for (int i = 0; i < 1 << n; i++) {
				if ((i & used) != 0) {
					continue;
				}

				int length = 0;
				int count = 0;
				for (int j = 0; j < n; j++) {
					if ((i & (1 << j)) != 0) {
						++count;
						length += ls[j];
					}
				}

				if (length == 0) {
					continue;
				}

				int cost = (count - 1) * 10;
				if (length >= max) {
					cost += (length - max  + 1);
					length = max - 1;
				}

				if (cost < dp[length].Item1) {
					dp[length] = new Tuple<int, int>(cost, i);
				}
			}

			for (int i = 1; i < max; i++) {
				if (dp[i - 1].Item1 < dp[i].Item1) {
					dp[i] = new Tuple<int, int>(dp[i - 1].Item1 + 1, dp[i - 1].Item2);
				}
			}

			for (int i = max - 2; i >= 0; i--) {
				if (dp[i + 1].Item1 < dp[i].Item1) {
					dp[i] = new Tuple<int, int>(dp[i + 1].Item1 + 1, dp[i + 1].Item2);
				}
			}

			used |= dp[target].Item2;
			return dp[target].Item1;
		}
	}
}


Measured memory_bytes: 13500
h, w = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(h)]
B = []
count = 0

for i in range(h):
    for j in range(w-1):
        if A[i][j] % 2 == 1:
            count += 1
            A[i][j+1] += 1
            B.append([i+1, j+1, i+1, j+2])
            
for i in range(h-1):
    if A[i][-1] % 2 == 1:
        count += 1
        A[i+1][-1] += 1
        B.append([i+1, w, i+2, w])
        
print(count)
for b in B:
    print(b[0], b[1], b[2], b[3])

Measured memory_bytes: 30136
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: usize,
      aa: [usize; n],
    }
    let mut a0 = vec![0; n];
    let mut a1 = vec![0; n];
    for i in 0..n {
        for j in 0..i {
            if aa[j] > aa[i] {
                a0[i] += 1;
            }
        }
    }
    for i in 0..n {
        for j in 0..n {
            if aa[j] > aa[i] {
                a1[i] += 1;
            }
        }
    }

    const MOD: usize = 1e9 as usize + 7;
    let mut ans = 0usize;
    for i in 0..n {
        let v0 = a0[i];
        let vn = ((a1[i] * (k-1)) % MOD + v0) % MOD;
        let temp = (k/2 * (v0 + vn)) % MOD;
        if k % 2 == 1 {
            let rem: usize = k/2 + 1;
            ans += ((a1[i] * (rem-1)) % MOD + v0) % MOD;
            ans %= MOD;
        }
        ans += temp;
        ans %= MOD;
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
//package AtCoder.Nekkei;

import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        char[][] arr = new char[3][n];
        for (int i = 0; i < 3; i++) {
            String str = s.next();
            arr[i] = str.toCharArray();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
//            TreeSet<pair> set = new TreeSet<>();
//            if(set.)
//            set.add(new pair())
            HashSet<Character> set = new HashSet<>();
            set.add(arr[0][i]);
            set.add(arr[1][i]);
            set.add(arr[2][i]);

            sum += set.size() - 1;
        }
        System.out.println(sum);


    }


}

Measured memory_bytes: 23892
A = int(input())
B = int(input())
C = int(input())
X = int(input())

n = int(X/50)
num = 0

if n >= 10:
  if X%2 != 0 and C == 0:
    num == 0
  else:
    if A == 0 and B != 0:
      for c in range(C+1):
        for b in range(B+1):
          if c*50 + b*100 == X:
            num += 1
    elif A != 0 and B == 0:
      for c in range(C+1):
        for a in range(A+1):
          if c*50 + a*500 == X:
            num += 1
    else:
      for c in range(C+1):
        for b in range(B+1):
          for a in range(A+1):
            if c*50 + b*100 + a*500 == X:
              num += 1
  
elif 10 > n >= 2:
  if X%2 != 0 and C == 0:
    num == 0
  else:
    for c in range(C+1):
      for b in range(B+1):
        if c*50 + b*100 == X:
          num += 1
      
else:
  if C != 0:
    num = 1
  else:
    num = 0

print(num)

Measured memory_bytes: 3064
from collections import deque
N, K = map(int, input().split())
towns = list(map(int, input().split()))

# 閉路を求める問題。閉路が見つかれば、あとはそれを掛け算するだけ

seen_points = set([])
indexes = [-1 for _ in range(N)]
now_town = 1
index = 0
while K > 0:
    # print(f'now_town={now_town}', K, seen_points)
    # すでに見つかっているところに戻ってきたなら閉路が見つかっているはず。
    if now_town in seen_points:
        # 閉路でかかるコストはroop_count
        roop_count = index - indexes[now_town - 1]
        # なので、省略する
        if K > roop_count:
            # print(K, roop_count)
            K = K % roop_count
        seen_points = set([])
        continue
    seen_points.add(now_town)
    indexes[now_town - 1] = index
    now_town = towns[now_town - 1]
    index += 1
    K -= 1

print(now_town)


Measured memory_bytes: 126600
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
int tt[100005],tlen;
LL s[500005];
int a[100005],b[100005],n;
int lowbit(int x){return x&-x;}
void change(int x){while(x<=400000)s[x]++,x+=lowbit(x);}
LL findsum(int x){LL ret=0;while(x>=1)ret+=s[x],x-=lowbit(x);return ret;}
bool check(int x)
{
	int p=tt[x];
	LL sum=0;memset(s,0,sizeof(s));
	for(int i=1;i<=n;i++)
	{
		if(a[i]>p)b[i]=b[i-1];
		else b[i]=b[i-1]+1;
	}
	change(200000);
	for(int i=1;i<=n;i++)
	{
		int op=2*b[i]-i+200000;
		sum+=findsum(op-1);
		change(op);
	}
	if(sum>=(LL)n*(n+1)/4+1)return true;
	return false;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),tt[++tlen]=a[i];
	sort(tt+1,tt+1+tlen);
	tlen=unique(tt+1,tt+1+tlen)-(tt+1);
	int l=1,r=tlen,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",tt[ans]);
	return 0;
}

Measured memory_bytes: 5376
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		out.println((a<=c&&c<=b)?"Yes":"No");
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {

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

    while (sc.hasNextInt()) {
      h[counter] = sc.nextInt();
      counter++;
    }

    int[] dp = new int[N];

    for (int i = 0; i < N; i++) {
      dp[i] = Integer.MAX_VALUE;
    }

    dp[0] = 0;

    for (int i = 1; i < N; i++) {
      dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
      if (i > 1) {
        dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
      }
    }

    System.out.println(dp[N - 1]);

  }
}

Measured memory_bytes: 55124
S = input()
C = {"a": 0, "b": 0, "c": 0}
for s in S:
    C[s] += 1
if abs(C["a"] - C["b"]) <= 1 and abs(C["b"] - C["c"]) <= 1 and abs(C["c"] - C["a"]) <= 1:
    print("YES")
else:
    print("NO")


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

P = [0] * (n + 1)
P[0] = 1
A = [0] * (n + 1)
A[0] = 1
for i in range(1, n + 1):
    P[i] = P[i - 1] * 2 + 1
    A[i] = A[i - 1] * 2 + 3

#print(P)
#print(A)

def dfs(n, x):
    if n == 0:
        if x <= 0:
            return 0
        else:
            return 1
    elif x <= 1 + A[n - 1]:
        return dfs(n - 1, x - 1)
    else:
        return P[n - 1] + 1 + dfs(n - 1, x - 1 - A[n - 1] - 1)

print(dfs(n, x))

Measured memory_bytes: 3064
n = int(input())
if n<=3000:
  for a in range(1,3501):
    for b in range(1,3501):
      s = n*a*b
      #s=4
      t = 4*a*b-n*b-n*a
      #t=8-4-2
      if s<=t*3500:
        if t!=0 and s%t==0 and t>0:
          c = s//t
          print(a,b,c)
          exit()
else:
  for a in range(3501,1,-1):
    for b in range(3501,1,-1):
      s = n*a*b
      #s=4
      t = 4*a*b-n*b-n*a
      #t=8-4-2
      if s<=t*3500:
        if t!=0 and s%t==0 and t>0:
          c = s//t
          print(a,b,c)
          exit()
  

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

using namespace std;


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int counter = 0;
    while(b <= a) {
        b *= 2;
        counter++;
    }
    while(c <= b) {
        c *= 2;
        counter++;
    }
    if(counter <= k) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

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

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

  cout << max({A + B, A - B, A * B}) << endl;
  return 0;
}

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

#define N 10
int main(){
	int height[N];
	
	for(int i=0;i<N;i++){
		cin >> height[i];
	}
	
	sort(height,height+N);
	
	for(int j=N-1;j>N-4;j--){
		cout << height[j] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  string S;
  cin >> S;
  int N;
  N = S.size();
  vector<int> ans(N);

  // Rグループについて
  int cnt = 0;
  int evenNum = 0, oddNum = 0;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == 'R')
      cnt++;
    else
    {
      evenNum = cnt / 2;
      oddNum = cnt - evenNum;
      ans[i] += evenNum;
      ans[i - 1] += oddNum;
      cnt = 0, evenNum = 0, oddNum = 0;
    }
  }

  // Lグループについて
  cnt = 0;
  evenNum = 0, oddNum = 0;
  for (int i = N - 1; i >= 0; i--)
  {
    if (S[i] == 'L')
      cnt++;
    else
    {
      evenNum = cnt / 2;
      oddNum = cnt - evenNum;
      ans[i] += evenNum;
      ans[i + 1] += oddNum;
      cnt = 0, evenNum = 0, oddNum = 0;
    }
  }

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

// 偶数回数後 R->L L->R 各マスの偶奇に着目する 折り返し地点　(Rから見たらL，Lから見たらR)までの距離が偶数か奇数かで場合を分けることができる．偶数回後の移動では偶数距離離れたもの折り返し地点に収束し，奇数距離離れたものは折り返し地点の一つ前に収束する．折り返し地点までの距離が偶数の人はevenNum = cnt / 2(切り捨て), 奇数の人はoddNum = (cnt + 1)/2で求められる．（切り上げ）（図を書けばわかる．）


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll sum = 0;
    ll A[N];
    F0R(i, N) {
        cin >> A[i]; sum ^= A[i];
    }

    sum ^= A[0] ^ A[1];
    ll total = A[0] + A[1];

    ll dp[2]; dp[0] = -1e15; dp[1] = 0;
 //   cout << sum << nl;
    F0Rd(bit, 45) {
        if (sum & (1ll << bit)) {

            if (A[0] & (1ll << bit)) {
                dp[0] += (1ll << bit);
                ckmax(dp[0], dp[1]);
                dp[1] += (1ll << bit);
            } else {
                dp[0] += (1ll << bit);
            }
            total -= (1ll << bit);
        } else {
            if (total >= (1ll << (bit+1))) {
                if (!(A[0] & (1ll << bit))) {
                    dp[1] = -1e15;
                }
                dp[0] += (1ll << bit);
                dp[1] += (1ll << bit);
                total -= 1ll << (bit+1);
            } else {
                if (A[0] & (1ll << bit)) {
                  // dp[0] += (1ll << bit);
                ckmax(dp[0], dp[1]);
               // dp[1] += (1ll << bit);
                }
            }
        }
//        cout << bit << " " << dp[0] << " " << dp[1] << nl;
    }

    if (total == 0 && (dp[0] > 0 || dp[1] > 0)) {
        cout << A[0]-max(dp[0], dp[1]) << nl;
    } else {
        cout << -1 << nl;
    }


	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3668