akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

vector<string> a;
vector<VL> memo;
int ans(int y, int x) {
    if (memo[y][x] != -1)return memo[y][x];
    ll ret = 0;
    if (0 < y && a[y - 1][x] != '#')(ret += ans(y - 1, x)) %= mod;
    if (0 < x && a[y][x - 1] != '#')(ret += ans(y, x - 1)) %= mod;
    return memo[y][x] = ret;
}

int main() {
    init();

    int h, w; cin >> h >> w;
    a.resize(h); cin >> a;
    memo = defvec<ll>(-1, h, w);
    memo[0][0] = 1;
    cout << ans(h - 1, w - 1) << "\n";
}


Measured memory_bytes: 9344
#include<stdio.h>
 
int h,H[251];
int right(int);
int left(int);
int parent(int);
 
main(){
  int i;
  scanf("%d",&h);
   
  for(i=1;i<=h;i++){
    scanf("%d",&H[i]);
  }
  for(i = 1;i<=h;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(parent(i)>=1) printf("parent key = %d, ",H[parent(i)]);
    if(left(i)<=h) printf("left key = %d, ",H[left(i)]); 
    if(right(i)<=h) printf("right key = %d, ",H[right(i)]);
    printf("\n");   
  }
  return 0;
}
 
 
int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i+1;
}

Measured memory_bytes: 600
import fractions

N,M = map(int,input().split())

A = list(map(int,input().split()))

def lcm(X):
    ret = X[0]
    for i in range(1,len(X)):
        ret = ret * X[i] //fractions.gcd(ret,X[i])
        if ret > M:
            ret = M+1
            break
    return ret




count = 0
a = A[0]
while a % 2 == 0:
    a //= 2
    count += 1

det = 0
for i in range(1,N):
    x = A[i] / (2**count)
    if x % 2 == 0 or int(x) != x:
        det = -1
        break
#print(det)
if det == -1:
    print(0)
else:
    for i in range(N):
        A[i] //= 2**count
    min_l = lcm(A) * (2**(count-1))
    #print(min_l)
    t = M // min_l
    if t % 2 == 0:
        print(t//2)
    else:
        print((t+1)//2)

Measured memory_bytes: 16316
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] xy = scanner.nextLine().split(" ", 2);
        int x = Integer.parseInt(xy[0]);
        int y = Integer.parseInt(xy[1]);
        System.out.println(x + y / 2);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[32][32];
ll b[3][32];
int main() {
	ll n,c;
	cin>>n>>c;
	for(int i=0;i<c;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll m;
			cin>>m;
			m--;
			ll now=i+1+j+1;
			if(now%3==0){
				b[0][m]++;
			}
			else if(now%3==1){
				b[1][m]++;
			}
			else{
				b[2][m]++;
			}
		}
	}
	ll ans=INF;
	for(int i=0;i<c;i++){
		for(int j=0;j<c;j++){
			for(int k=0;k<c;k++){
				ll sum=0;
				if(i==j||j==k||k==i){
					continue;
				}
				for(int l=0;l<c;l++){
					sum+=a[l][i]*b[0][l]+a[l][j]*b[1][l]+a[l][k]*b[2][l];
				}
				ans=min(ans,sum);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=get_nsp
ans=0
S.each do|c|
    case c
    when "+" then
        ans+=1
    when "-" then
        ans-=1
    end
end
puts ans

Measured memory_bytes: 1788
N = int(input())
h = list(map(int, input().split()))
ans = 0
count = 0
h.append(0)
f = set(h)
for i in range(max(h)):
    if i in f:
        count = 0
        for k in range(N):
            if h[k] != 0 and h[k + 1] == 0:
                count += 1
    ans += count
    h = list(map(lambda x: (x - 1, 0)[x == 0], h))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <bitset>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
int C[4][4];
vector<pi>Stamp;
int dist[1<<16];

int f(int h, int w, int sx, int sy, int c, int S){
  //  cout << h << " " << w << " " << sx << " " << sy << " " << c << " " << S << endl;
  for(int i=max(sx, 0);i<min(sx+h, 4);i++){
    for(int j=max(sy, 0);j<min(sy+w, 4);j++){
      int pos = i*4+j;
      if(C[i][j] == c){
	S |= 1<<pos;
      }else{
	S &= ((1<<16)-1) - (1<<pos);
      }
    }
  }
  //  cout << h << " " << w << " " << sx << " " << sy << " " << c << " " << S << endl;  
  return S;
}

int main()
{
  cin >> N;
  Stamp.resize(N);
  for(auto &stamp: Stamp) cin >> stamp.first >> stamp.second;
  rep(i, 4){
    string s;
    cin >> s;
    rep(j, 4){
      if(s[j] == 'R')
	C[i][j] = 0;
      if(s[j] == 'G')
	C[i][j] = 1;
      if(s[j] == 'B')
	C[i][j] = 2;
    }
  }
  fill(dist, dist+(1<<16), INF);
  queue<pi>Q;
  Q.push(pi(0, 0));
  dist[0] = 0;
  while(!Q.empty()){
    pi p = Q.front(); Q.pop();
    int state = p.second;
    int cost = p.first;
    //    cout << static_cast<bitset<16> >(state) << " " << cost << endl;
    if(state == (1<<16) - 1){
      cout << cost << endl;
      break;
    }    
    if(dist[state] < cost) continue;
    for(auto &stamp: Stamp){
      int H = stamp.first, W = stamp.second;
      for(int sx = -H+1; sx < 4; sx++){
	for(int sy = -W+1; sy < 4; sy++){
	  for(int color=0;color<3;color++){
	    int next_state = f(H, W, sx, sy, color, state);
	    if(cost + 1 < dist[next_state]){
	      dist[next_state] = cost + 1;
	      Q.push(pi(dist[next_state], next_state));
	    }
	  }
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
ba = []
for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    ba.append((b,a))
ba.sort()
count = 0
prev_b = -1
for b, a in ba:
    if a < prev_b:
        continue
    prev_b = b
    count += 1
print(count)


Measured memory_bytes: 22812
#include <bits/stdc++.h>
using namespace std;
#define c 1000000000000000000
#define ll long long int
int main()
{
    ll n,i,count=1,flag=0;
    cin>>n;
    ll a[n+1];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            flag=1;
    }
    ll sum=a[0];
    if(flag==0) {
        for (i = 1; i < n; i++) {
            if (a[i] <= c / sum) {
                sum=sum*a[i];
                count++;
            } else
            {
                cout<<"-1"<<endl;
                break;
            }
        }
        if(count==n)
            cout<<sum<<endl;
    }
    else
        cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 4428
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  
  cout << (m<=4 ? "Heisei" : "TBD") << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
S = list(input())
K = int(input())

for i,s in enumerate(S):
    if s != S[K-1]:
        S[i] = '*'

print (''.join(S))


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


public class Test
{	
    public static void Main()
	{
	    string[] s = Console.ReadLine().Split(' ');
	    string s1 = s[0];
	    string s2 = s[1];
	    string s3 = s[2];
	    
	    if(s1[s1.Length-1] == s2[0] && s2[s2.Length-1] == s3[0])
	    {
	        Console.WriteLine("YES");
	    }
	    else
	    {
	        Console.WriteLine("NO");
	    }
	    
	} 
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int N, M;
	cin >> N >> M;
	int a[M];
	for(int i=0;i<M;i++){
		cin >> a[i];
	}
	int j = 0;
	ll dp[N+1];
	dp[0] = 1;
	dp[1] = 1;
	if(a[j] == 1){
		dp[1] = 0;
		j++;
	}
	for(int i = 2;i<=N;i++){
		if(j < M && a[j] == i){
			dp[i] = 0;
			j++;
		}
		else{
			dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>

using namespace std;

// Returns 1 if the i-th bit of x is set, 0 otherwise.
#define BIT_SET(x, i) (((x) & (1<<(i))) != 0)
// Sets the i-th bit of x to 1
#define SET_BIT(x, i) ((x) | (1<<(i)))
// Sets the i-th bit of x to 0
#define UNSET_BIT(x, i) ((x) & ~(1<<(i)))

class Task {
    public:
        void solve(istream& in, ostream& out) {
        	double r1, r2;
        	in >> r1 >> r2;
        	printf("%.10f\n", 1/(1/r1 + 1/r2));
        }
} task;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    task.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;
vector<int> num;
string a;
int dp[10005][180][3],k;
int cal(int pos,int du,int f)
{
    if(pos==num.size())
    {
        if(du==0)
            return 1;
        return 0;
    }
    if(dp[pos][du][f]!=-1)
        return dp[pos][du][f]%MOD;
    int res=0,Limit;
    if(f==0)
        Limit=num[pos];
    else
        Limit=9;
    for(int i=0; i<=Limit; i++)
    {
        int nf=f;
        int temp=(du+i)%k;
        if(f==0&&i<Limit)
            nf=1;
        res+=cal(pos+1,temp,nf);
    }
    dp[pos][du][f]=res%MOD;
    return res;
}
int chuyen(string x)
{
    num.clear();
    for(int i=0; i<x.size(); i++)
        num.push_back(x[i]-'0');
    memset(dp,-1,sizeof(dp));
    int res=cal(0,0,0);
    return res;
}
main()
{
    cin>>a;
    cin>>k;
    int temp1=chuyen(a);
    cout<<(temp1-1+MOD)%MOD<<endl;

}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#pragma GCC                   target ("avx2")
#pragma GCC                   optimize("Ofast")
#pragma GCC                   optimization ("O3")
#pragma GCC                   optimization ("unroll-loops")
#pragma GCC                   target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod                   1000000007
#define INF                   1000000000000000000
#define int                   long long
#define PI                    3.141592653
#define Author                std::ios_base::sync_with_stdio(0);
#define ABHISHEK_SHARMA       cout.tie(0);
#define IIIT_ALLAHABAD        cin.tie(0);
#define all(v)                v.begin(),v.end()
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()

clock_t time_p=clock();

void abhishhh1(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(double)(time_p)/(1.0*CLOCKS_PER_SEC)<<"\n";
}

void solve() {
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    int ans=0;
    if(k>=a){
        ans+=a;
        k-=a;
    }
    else{
        ans+=k;
        cout<<ans<<"\n";
        return;
    }
    if(k>=b){
        k-=b;
    }
    else{
        cout<<ans<<"\n";
        return;
    }
    ans-=k;
    cout<<ans<<"\n";
}

signed main(){
    //file reader-writer

    //Booster
    Author
    ABHISHEK_SHARMA
    IIIT_ALLAHABAD
    //Driver Code here
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    abhishhh1();
}

Measured memory_bytes: 3808
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <time.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    int maxa = -2000000000;
    int minv;
    cin>>minv;
    int temp;

    for(int i = 1;i<n;i++){
        cin>>temp;
        maxa = max(maxa,temp-minv);
        minv = min(minv,temp);
    }
    cout<<maxa<<endl;




    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC146();
}

void ABC146(){
    string s;
    cin>>n;
    cin>>s;
    for(i=0;i<s.length();i++){
        s[i]+=n;
        if(s[i]>'Z')s[i]+='A'-'Z'-1;
    }
    cout<<s<<endl;
}

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

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;


string s;
stack<int>st;
signed main() {
	cin>>s;
	rep(i,s.size()){
		if(st.empty())st.push(s[i]);
		else if(st.top()=='S'&&s[i]=='T'){
			st.pop();
		}else {
			st.push(s[i]);
		}
	}
	cout<<st.size()<<endl;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=100010;
ll a,b,d,c,e,x,y,z,k,m,n,l,q,ans=0;
double aa,bb;
vl v1,v2,v3;
vp vp1,vp2;
string s1,s2;
ll solve(void){
    a=0;
}
int main(){
    cin>>n>>k;
    

    cout<<n-k+1<<endl;
}

Measured memory_bytes: 256
N, M, Q = gets.split.map(&:to_i)
sum = Array.new(N+2){Array.new(N+2, 0)}
M.times do
    l, r = gets.split.map(&:to_i)
    sum[l][r] += 1
end
p=[],q=[]
Q.times do |i|
    p[i], q[i] = gets.split.map(&:to_i) 
end
 
1.upto(N) do |l|
    1.upto(N) do |r|
        sum[l][r] += sum[l][r-1]
        sum[l][r] += sum[l-1][r]
        sum[l][r] -= sum[l-1][r-1]
    end
    
end

 

Q.times do |i|
    puts sum[q[i]][q[i]] - sum[q[i]][p[i]-1] - sum[p[i]-1][q[i]] + sum[p[i]-1][p[i]-1]
end



Measured memory_bytes: 6424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
                p[i] = in.nextInt();
            int ans = 0;
            for (int i = 1; i < n - 1; i++) {
                int min = Math.min(p[i - 1], p[i + 1]);
                int max = Math.max(p[i - 1], p[i + 1]);
                if (min < p[i] && p[i] < max)
                    ans++;
            }
            out.print(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}

if c >= (a - b).abs
  for i in a..b do
    puts i
  end
else

  result = []
  n = c - 1
  for i in 0..n do
    result.push a + i
    result.push b - i
  end
  result.uniq!
  result.sort!
  for hoge in result do
    puts hoge
  end
end


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

using Graph = vector<vector<pair<int, int>>>;

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

	Graph G(N + 1);
	FOR(i, 1, N - 1) {
		ll u, v, w;
		cin >> u >> v >> w;
		w %= 2;
		G[u].push_back(MP(v, w));
		G[v].push_back(MP(u, w));
	}

	// BFS のためのデータ構造
	vector<int> iseven(N + 1, -1); // 全頂点を「未訪問」に初期化
	queue<int> que;

	// 初期条件 (頂点 1 を初期ノードとする)
	iseven[1] = 0;
	que.push(1); // 1 を橙色頂点にする

				 // BFS 開始 (キューが空になるまで探索を行う)
	while (!que.empty()) {
		int v = que.front(); // キューから先頭頂点を取り出す
		que.pop();

		// v から辿れる頂点をすべて調べる
		for (pair<int, int> nv : G[v]) {
			if (iseven[nv.first] != -1) continue; // すでに発見済みの頂点は探索しない

			// 新たな白色頂点 nv について距離情報を更新してキューに追加する
			iseven[nv.F] = (iseven[v] + nv.S) % 2;
			que.push(nv.F);
		}
	}

	// 結果出力 (各頂点の頂点 1 からの距離を見る)
	FOR(i, 1, N) {
		pv(iseven[i])
	}
}

Measured memory_bytes: 6784
n = int(input())
c = input()

w = [0]*(n+1)
r = [0]*(n+1)
for i in range(0,n):
  w[i+1] = w[i]
  r[n-i-1] = r[n-i]
  if c[i]=='W':
    w[i+1] += 1
  if c[n-i-1]=='R':
    r[n-i-1] += 1

ans = 1e10
for i in range(0,n+1):
  ans = min(ans,w[i]+r[i]-min(w[i],r[i]))
print(ans)

Measured memory_bytes: 18532
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int m,h,x,y,r;
	cin>>m>>h>>x>>y>>r;
	if (x>=m || x<=0 || y>=h || y<=0) cout<<"No"<<endl;
	else if(x+r>m || y+r>h) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
import math
import heapq
import collections

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)

Measured memory_bytes: 3856
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int ans = 0;
  int first_b = 0;
  int last_a = 0;
  int first_b_and_last_a = 0;
 
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int pos = s.find("AB");
    while (pos != std::string::npos) {
      ans++;
      pos = s.find("AB", pos + 1);
    }
    if (s.front() == 'B' && s.back() == 'A') first_b_and_last_a++;
    else if (s.front() == 'B') first_b++;
    else if (s.back() == 'A') last_a++;
  }
  if (first_b == 0 && last_a == 0) ans += max(0, first_b_and_last_a - 1);
  else ans += (first_b_and_last_a + min(first_b, last_a));
  cout << ans << endl;
  return 0;
}

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

int getGCD(int a, int b)
{
  /* a??¨b????????§??¬?´???°???????????? */
  int larger = a;
  int smaller = b;
  
  if (larger < smaller) {
    std::swap(larger, smaller);
  }
  
  int sub = larger - smaller;
  
  int ret = larger;
  while (sub > 0) {
    ret = sub;
    larger = sub;
    if (larger < smaller) {
      std::swap(larger, smaller);
    }
    sub = larger - smaller;
  }
  
  return ret;
}

int getLCM(int a, int b)
{
  /* a??¨b???????°???¬?????°???????????? */
  return a / getGCD(a, b) * b;
}

int main(void)
{
  int a, b;
  
  while (std::cin >> a >> b) {
    std::cout << getGCD(a, b) << " " << getLCM(a, b) << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
	char c;
	scanf("%c",&c);
	if(c=='a') puts("vowel");
	else if(c=='e') puts("vowel");
	else if(c=='i') puts("vowel");
	else if(c=='o') puts("vowel");
	else if(c=='u') puts("vowel");
	else puts("consonant");
	return 0;
}

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

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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);

	int y=-1,cnt=0,ans=0;
	rep(i,n){
		int h; scanf("%d",&h);
		if(y>=h) cnt++;
		else     cnt=0;
		y=h;
		ans=max(ans,cnt);
	}
	printf("%d\n",ans);

	return 0;
}


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

int main() {
	int n;
	cin>>n;
	
	vector<int> d(n);
	ll ans=0;
	
	rep(i,n)cin>>d[i];
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			ans+=d[i]*d[j];
		}
	}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


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


#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define mod 1000000007
#define maxn 1000003
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(){
	
	fastio;
	
	ll n,ans=0;
	cin>>n;
	
	for(int i=1;i  < n ;i++){
	 ans += (n-1)/i;
	}
	cout<<ans;
	
	}


	
	
	
	



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

int cnt[105];
int dp[105][80];

int main(){
    int n;
    cin>>n;
    rep(i,105)cnt[i]=1;
    for(int i=1; i<=n; ++i){
        int x=i;
        for(int j=2; j*j<=x; ++j){
            while(x%j==0){
                x/=j;
                cnt[j]++;
            }
        }
        if(x!=1)cnt[x]++;
    }
    dp[0][1]=1;
    for(int i=0; i<n; ++i){
        for(int j=1; j<=75; ++j){
            for(int k=1; k<=cnt[i]; ++k){
                if(j*k>75)continue;
                dp[i+1][j*k]+=dp[i][j];
            }
        }
    }
    cout<<dp[n][75]<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n; cin >> n;
	VI a(n); REP(i,n) cin >> a[i];
	ll ans=a[0]-1, p=2;
	for(int i=1;i<n;i++){
		if(a[i]==p)
			p++;
		ans+=(a[i]-1)/p;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  
  int N;cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  
  vector<int> left(N);
  left[0] = 0;
  for(int i=0;i<N;i++) left[i] = max(left[i-1],A[i]);
  vector<int> right(N+1);
  right[N] = 0;
  for(int i=N-1;i>=0;i--) right[i] = max(right[i+1],A[i]);
  
  for(int i=0;i<N;i++){
    cout << max(left[i-1],right[i+1]) << endl;
  }
  
}

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

#define ump unordered_map
#define int long long int
#define ps push_back
#define fi first
#define so second


signed main()
{
    int n,k,i;
    cin>>n>>k;
    int a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    int vis[n+1]={0};
    i=1;
    while(vis[i]==0)
    {
        vis[i]=1;
        i=a[i];
    }
    int st=i;
    int cs=0,cc=1;
    i=1;
    while(i!=st) {i=a[i];cs++;}
    i=a[i];
    while(i!=st) {i=a[i];cc++;}
    if(k<cs+cc)
    {
        i=1;
        while(k--) i=a[i];
        cout<<i;
    }
    else
    {
        int t=cs;
        k-=cs;
        k%=cc;
        t+=k;
        i=1;
        while(t--) i=a[i];
        cout<<i;
    }

}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  --a[0];
  bool found = false;
  for (int i = 1; i < n; ++i) {
    if (a[i] < a[i - 1]) {
      found = true;
      break;
    } else if (a[i] > a[i - 1]) {
      --a[i];
    }
  }
  puts(found ? "No" : "Yes");
  return 0;
}

Measured memory_bytes: 640
N = int( input() )
A = list( map( int, input().split() ) )

seekfor = 1
crack = 0

for i in range(N) :
    if A[i] == seekfor :
       seekfor += 1
    else : 
       crack += 1
    
if crack == N: 
    print( -1 )
else:    
    print(crack)

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

#define DIFF 'a'-'A'

int main(void){
    char str[1200];
    int i=0;

    gets(str);

    while(str[i]!='\0'){
        if(str[i]>='A'&&str[i]<='Z') str[i]+=DIFF;
        else if(str[i]>='a'&&str[i]<='z') str[i]-=DIFF;
        i++;
    }

    printf("%s\n",str);

    return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
string color[] = {"black", "blue", "lime", "aqua",
    "red", "fuchsia", "yellow", "white"};
int nums[][3] = {{0,0,0}, {0,0,255}, {0,255,0}, {0,255,255},
    {255,0,0}, {255,0,255}, {255,255,0}, {255,255,255}};

int convert(string str) {
    int res = 0;
    if ('0'<=str[0]&&str[0]<='9') {
        res += (str[0]-'0') * 16;
    } else if ('a'<=str[0]&&str[0]<='f') {
        res += (str[0]-'a'+10) * 16;
    }
    if ('0'<=str[1]&&str[1]<='9') {
        res += (str[1]-'0');
    } else if ('a'<=str[1]&&str[1]<='f') {
        res += (str[1]-'a'+10);
    }
    return res;
}

int main() {
    string str;
    while (cin >> str) {
        if (str == "0") break;
        double d = 10000000.0;
        string res;
        int r = convert(str.substr(1,2)), g = convert(str.substr(3,2)), b = convert(str.substr(5,2));
        for (int i=0; i<8; i++) {
            double tmp = sqrt(pow(r-nums[i][0], 2)+pow(g-nums[i][1], 2)+pow(b-nums[i][2], 2));
            if (tmp < d) {
                d = tmp;
                res = color[i];
            }
        }
        cout << res << endl;
    }
}

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

int main() {
    int n, k;
    while(cin >> n >> k) {
        int a = n / k;
        long long int ans = 1ll * a * a * a;
        if (!(k & 1)) {
            if (n - k / 2 >= 0) {
                int a = 1 + (n - k / 2) / k;
                ans += 1ll * a * a * a;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 20+5;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int N;
int v[maxn];
int c[maxn];
int max_ans = EPS;

void dfs(int i, int ans){
    if(i >= N){
        max_ans = max(ans, max_ans);
    }else{
        dfs(i+1, ans + v[i] - c[i]);
        dfs(i+1, ans);
    }
}

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    cin>> N;
    for(int i = 0; i < N; ++i)
        cin>>v[i];
    for(int i = 0; i < N; ++i)
        cin >> c[i];

    dfs(0, 0);
    cout<< max_ans<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
struct Node{
    int p;
    int l;
    int r;
};
struct Node np[MAX];
int depth = 0;
int hileft = 0;
int hiright = 0;
 
 
int get_depth(int u){
 
    if(np[u].p == NIL) return 0;
    if(np[u].p != NIL){
        depth++;
        get_depth(np[u].p);
    }
    return depth;
}
 
int degree(int u){
    if (np[u].l == NIL && np[u].r == NIL) return 0;
    else if(np[u].l != NIL && np[u].r != NIL)  return 2;
    else  return 1;
}
 
int sibling(int u){
 
    if(np[u].p == NIL) {
        return NIL;
    }
    else if(np[np[u].p].l == u) {
        return np[np[u].p].r;
    }
    else {
        return np[np[u].p].l;
    }
}
 
int hight(int u){
 
    int hileft = 0;
    int hiright = 0;
 
    if(np[u].l != -1) {
        hileft = hight(np[u].l) + 1;
    }
    if(np[u].r != -1){
        hiright = hight(np[u].r) + 1;
    }
    if(hileft < hiright){
        return hiright;
    }
    else {
        return hileft;
    }
}
 
void print(int u){
 
    printf("node %d: ",u);
    printf("parent = %d, ",np[u].p);
    printf("sibling = %d, ",sibling(u));
    printf("degree = %d, ",degree(u));
 
    depth = 0;
 
    printf("depth = %d, ",get_depth(u));
    printf("height = %d, ",hight(u));
 
    if(np[u].p == NIL)printf("root\n");
    else if(np[u].l == NIL && np[u].r == NIL) {
        printf("leaf\n");
    }
    else {
        printf("internal node\n");
    }
}
 
 
int main(){
    int i, j;
    int d, v, c, l;
    int n,tmp;
 
    scanf("%d", &n);
 
    for (i = 0; i < n; i++) {
        np[i].p = np[i].l = np[i].r = NIL;      // 初期化
    }
    for (i = 0; i <n ; i++){
        scanf("%d %d %d", &v, &d, &c);
        np[d].p = np[c].p = v;
        np[v].l = d;
        np[v].r = c;
    }
 
    for (i = 0; i < n; i++ ) {
        print(i);
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t Lucas(vector<int64_t> &vec,int i){
    int64_t L;
    if(i==0){
        L=2;
    }
    else if(i==1){
        L=1;
    }
    else if(vec[i]!=0){
        L=vec[i];
    }
    else{
        L = Lucas(vec,i-1) + Lucas(vec,i-2);
    }
    vec[i]=L;
    return L;

}

int main() {
int N;
cin >>N;
int64_t answer;
vector<int64_t> vec(N+1,0);
cout<<Lucas(vec,N)<<endl;




}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N;
    cin >> N;
    vi a(N);
    rep(i, 0, N) cin >> a[i];

    map<int, int> mp1, mp2;
    rep(i, 0, N) {
        mp1[a[i] + i]++;
        mp2[i - a[i]]++;
    }

    int ans = 0;
    rep(i, 0, N) {
        ans += mp1[i - a[i]];
        ans += mp2[a[i] + i];
    }

    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 50188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  vector<vector<ll>> B(M,vector<ll>(2));
  REP(i, M){
      cin >> B.at(i).at(1) >> B.at(i).at(0);
  }
  sort(ALL(B));
  ll j = M-1;
  REP(i,N){
    if(j>=0&&B.at(j).at(0)>A.at(i)&&B.at(j).at(1)>0){
      A.at(i)=B.at(j).at(0);
      B.at(j).at(1)--;
      if(B.at(j).at(1)==0){
        j--;
      }
    }else if(j<0||B.at(j).at(0)<=A.at(i)){
      break;
    }
  }

  ll sum = 0;
  REP(i,N){
    sum+=A[i];
  }

  cout << sum << endl;
}

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

using namespace std;

const int N=200005;
vector<int> v[N];
vector<int> col(N,0);
vector<int> x[2];

void dfs(int a,int p=0)
{
    col[a]=1-col[p];
    x[col[a]].push_back(a);
    for(int to:v[a])
    {
        if(to==p) continue;
        dfs(to,a);
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(1);
    int one=(n+2)/3;
    int two=(n+1)/3;
    vector<int> p(n+1,0);
    if(x[0].size()<x[1].size()) swap(x[0],x[1]);
    for(int i=0;i<one;i++) p[x[0][i]]=1;
    if((int)x[1].size()>=two) for(int i=0;i<two;i++) p[x[1][i]]=2;
    else for(int i=one;i<one+two;i++) p[x[0][i]]=2;
    vector<int> t={0,-2,-1};
    for(int i=1;i<=n;i++)
    {
        printf("%d%c",t[p[i]]+=3," \n"[i==n]);
    }
    /*cout << "one=" << one << endl;
    cout << "two=" << two << endl;
    cout << "white: " << endl;
    for(int y:x[0]) cout << y << " ";
    cout << endl;
    cout << "black: " << endl;
    for(int y:x[1]) cout << y << " ";
    cout << endl;*/
    return 0;
}


Measured memory_bytes: 19956
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<string> S(N);
	rep(i, N) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		S.at(i) = s;
	}
	sort(S.begin(), S.end());
	ll k = 1;
	ll an = 0;
	rep(i, N-1) {
		if (S.at(i + 1) == S.at(i)) {
			k++;
		}
		else {
			an += k * (k - 1) / 2;
			k = 1;
		}
	}
	an += k * (k - 1) / 2;
	cout << an << endl;

}

Measured memory_bytes: 5760
n = gets.to_i
a = gets.split.map(&:to_i)

array = []
(1..n).each do |i|
  if i.odd?
    array << i - 1
  end
end

result = []

array.each do |j|
  if a[j].odd?
    result << j
  end
end

puts result.size

Measured memory_bytes: 14264
#include<bits/stdc++.h>
using namespace std;
long long a[20000001],s[20000001],i,n;
bool pd(long long h)
{
	if (a[n]<=h&&(a[n-1]<=h||a[n+1]<=h)) return true;
	if (a[n]>h&&(a[n-1]>h||a[n+1]>h)) return false;
	for (long long i=1;i<n-1;i++)
	{
		if (a[n+i]<=h&&a[n+i+1]<=h||a[n-i-1]<=h&&a[n-i]<=h) return true;
		if (a[n+i]>h&&a[n+i+1]>h||a[n-i-1]>h&&a[n-i]>h) return false;
	}
	return a[1]<=h;
}
long long erfen(long long l,long long r)
{
	if (l==r) return l;
	long long mid=(l+r)/2;
	if (pd(mid)) return erfen(l,mid);
	else return erfen(mid+1,r);
}
int main()
{
	scanf("%lld",&n);
	for (i=1;i<n*2;i++)
	{
		scanf("%lld",&a[i]);
		s[i]=a[i];
	}
	sort(s+1,s+n+1);
	printf("%lld",erfen(1,n*2-1));
	return 0;
}

Measured memory_bytes: 5888
<?php 
  fscanf(STDIN, "%d %d %d", $N, $A, $B);

	$towns = array_map("intval", explode(" ", trim(fgets(STDIN))));

	$min = 0;
	for($j=1; $j < $N;$j++){
      $gap = $towns[$j] - $towns[$j - 1];
      $min += min(($gap * $A), $B);
    }

	echo $min;  
  ?>

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int sosu = scan.nextInt();

		while(!hantei(sosu)) {
			sosu++;
		}
			System.out.println(sosu);
		scan.close();

	}

	public static boolean hantei(int s) {


		if(s >= 2) {
		for(int i=2;i*i<=s;i++) {

			if(s%i == 0) {
				return false;
					}

			}
		}


		return true;

		}

}


Measured memory_bytes: 21844
#include<cmath>
#include<iostream>
using namespace std;
int n,m,o;
int N,M;
double Sn[500],Sm[500],sumN,sumM,sum;
double pi = acos(-1.0);

double d2r(int d){
  return 2.0*pi*((double)d/360.0);
}

int main(){
  //cout<<d2r(270)/pi<<endl;
  while(1){
    cin>>n;
    if(n==0)break;
    sumM=sumN=0.0;

    o=0;
    for(int i=0;i<n-1;i++){
      cin>>N;
      o+=N;
      if(N>=180)continue;
      sumN += 1.0 * 1.0 * sin( d2r(N)  ) * 0.5;
    }
    sumN += 1.0 * 1.0 * sin( d2r(360-o)  ) * 0.5;
    
    o=0;
    cin>>m;
    for(int i=0;i<m-1;i++){
      cin>>M;
      o+=M;
      if(M>=180)continue;
      sumM += 1.0 * 1.0 * sin( d2r(M)  ) * 0.5;
    }
    sumM += 1.0 * 1.0 * sin( d2r(360-o)  ) * 0.5;

    sum=sumM-sumN;
    if(sum<0.0)sum*=-1.0;
    if(sum<0.0000001){
      cout<<0<<endl;
    }else if(sumM<sumN){
      cout<<1<<endl;
    }else{
      cout<<2<<endl;
    }
  }
  return 0;
}

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

int main() {
  int A, B, C;
  cin >>A >>B >>C;
  if((A<B&&A<C&&C<B)||(A>B&&B<C&&C<A)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
from itertools import combinations

inputs = []
n,x = map(int,input().split())
while n != 0 or x != 0:
     inputs.append((n,x))
     n,x = map(int,input().split())

for n,x in inputs:
    print(len([0 for c in combinations(range(1,n+1),3) if sum(c) == x]))


Measured memory_bytes: 5656
#include <stdio.h>

int main(void) {
  int n,m,l,A[100][100],B[100][100],i,j,k;
  long int c[100][100];
  scanf(" %d %d %d",&n,&m,&l);
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i = 0; i < m; i++){
    for(j = 0; j < l; j++){
      scanf("%d",&B[i][j]);
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      c[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      for(k = 0; k < m; k++){
        c[i][j] += A[i][k] * B[k][j];
      }
      printf("%ld",c[i][j]);
      if(j != l - 1){
        printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
 
// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ---------------------------------------------------------------------------
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  ll sum_A=0,sum_B=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum_A += A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
    sum_B += B[i];
  }
  if(sum_A < sum_B){
    cout << -1 << endl;
    return 0;
  }
  int cnt = 0;
  priority_queue<int> que;
  ll sum = 0;
  for(int i=0; i<N; i++){
    if(A[i] < B[i]){
      cnt++;
      sum += B[i]-A[i];
    }else if(B[i] < A[i]){
      que.push(A[i]-B[i]);
    }
  }
  while(que.size()){
    if(sum<=0){
      cout << cnt << endl;
      return 0;
    }
    int d = que.top();
    que.pop();
    sum -= d;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=3e5+1e1;

struct Node{
	int p,w;
}h[MAXN],s[MAXN];
int n,m,k,c,ans=1;

map <lint,int> Map;

bool Cmp(Node A,Node B){
	return A.w>B.w;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d%d%d",&n,&m,&k),c=max(n,m)+1;
	for(int i=1;i<=n;i++) h[i].p=i;
	for(int i=1;i<=m;i++) s[i].p=i;
	for(int i=1;i<=k;i++){
		lint l=readlint,r=readlint;
		++Map[l*(lint)(c)+r];
		++h[l].w,++s[r].w;
		// printf("%lld ",l*(lint)(c)+r);
	}
	// printf("\n");
	sort(h+1,h+n+1,Cmp),sort(s+1,s+m+1,Cmp);
	// for(int i=1;i<=n;i++) printf("(%d %d) ",h[i].p,h[i].w);printf("\n");
	// for(int i=1;i<=m;i++) printf("(%d %d) ",s[i].p,s[i].w);
	int maxn=h[1].w,maxm=s[1].w;
	for(int i=1;i<=n;i++){
		if(h[i].w!=maxn || (!ans)) break;
		for(int j=1;j<=m;j++){
			if(s[j].w!=maxm || (!ans)) break;
			// printf("%lld ",(lint)(h[i].p)*(lint)(c)+(lint)(s[j].p));
			if(!Map[(lint)(h[i].p)*(lint)(c)+(lint)(s[j].p)]) ans=0;
		}
	}
	printf("%d\n",maxn+maxm-ans);

	return 0;
}

Measured memory_bytes: 27268
import java.util.*;

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

	for(int i=0;i<3;i++){
	    max[i]=0;
	}

	for(int i=0;i<10;i++){
	    in=s.nextInt();

	    if(max[0]<in){
		max[2]=max[1];
		max[1]=max[0];
		max[0]=in;
	    }
	    else if(max[0]==in){
		max[2]=max[1];
		max[1]=in;
	    }
	    else if(max[1]<in){
		max[2]=max[1];
		max[1]=in;
	    }
	    else if(max[1]==in){
		max[2]=max[1];
		max[1]=in;
	    }
	    else if(max[2]<in){
		max[2]=in;
	    }
	}

	for(int i=0;i<3;i++){
	    System.out.println(max[i]);
	}

    }
}

Measured memory_bytes: 17184
n = int(input())
d = []
t = [0] * n

for i in range(n):
    d.append(input().split())
    d[i].append(str(i + 1))

a = sorted(d, key=lambda x: (x[0], -int(x[1])))

for i in range(n):
    print(a[i][2])


Measured memory_bytes: 3060