akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

struct UnionFind
{
    vector< int > data;
    
    UnionFind(int sz){
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    
    int root(int k){
        if(data[k] < 0) return(k);
        return (data[k] = root(data[k]));
    }
    
    int size(int k){
        return -data[root(k)];
    }
};

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


    int N, M;
    cin >> N >> M;

    UnionFind u(N+1);

    vector<int> p(N);
    REP(i, N) cin >> p[i];
    vector<int> x(M), y(M);
    REP(i, M){
        cin >> x[i] >> y[i];
        u.unite(x[i], y[i]);
    }

    int ans = 0;
    REP(i, N){
        if(u.root(p[i]) == u.root(i+1)) ans++;
    }
    cout << ans << "\n";

    

    return 0;
}

Measured memory_bytes: 3456
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

int n,m;
cin>>n>>m;
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];

sort(a,a+n);
queue<ll> q;
for(int i=0;i<n;i++)
q.push(a[i]);

vpll v;
for(int i=0;i<m;i++)
{
	ll a,b;
	cin>>a>>b;
	v.pb(mp(-b,a));
}

sort(all(v));

ll s=0;

for(int i=0;i<v.size();i++)
{if(q.empty())
break;
	for(int k=0;k<v[i].se;k++)
	{
	if(q.empty())
	break;
	ll h=q.front();
	q.pop();
		if(-v[i].fi>h)
		{
			h=-v[i].fi;
		}
		s+=h;
	}
}

while(!q.empty())
{
	s+=q.front();
	q.pop();
}

cout<<s;





}return 0;}

Measured memory_bytes: 4088
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
vector<ll> snuke; 
struct frac
{
	ll x, y;
	bool operator<(const frac &X) const
	{
		return x*X.y<X.x*y;
	}
};
frac stf[111];

ll next_val(ll x)
{
	ll tt=ndig(x,10), cc=1, i;
	stf[0].x=x; stf[0].y=bsum(x,10);
	for(i=1 ; i<=tt ; i++)
	{
		cc*=10;
		stf[i].x=(x/cc+1)*cc-1;
		stf[i].y=bsum(x/cc,10)+9*i;
	}
	sort(stf,stf+tt+1);
	return stf[0].x;
}

void gen(void)
{
	ll val=1;
	snuke.push_back(val);
	while(val<=(1e15))
	{
		val=next_val(val+1);
		snuke.push_back(val);
	}
}

int main(void)
{
	ll i, k; gen(); cin>>k; 
	for(i=0 ; i<k ; i++) cout<<snuke[i]<<"\n";
	return 0;
}


// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int N;
	string s;
	cin >> N;
	cin >> s;
	LOOP(i,s.length()){
		if(s[i]+N > 'Z'){
			s[i] = s[i]+N-26;
		}else{
			s[i] = s[i]+N;
		}
	}
	cout << s << endl;
}

// 2WPDX-JHP9X-JTM2T-3HWY4-RTMHZ


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

using static Input;
using static Util;
class Program
{
    static int N;

    static void INPUT()
    {
        N = NextInt();
    }

    static void OUT()
    {
        var c = new int[10, 10];
        for (int i = 1; i <= N; i++)
        {
            c[i.ToString().First() - '0', i % 10]++;
        }

        var a = 0L;
        for (int i = 0; i <= 9; i++)
        {
            for (int j = 0; j <= 9; j++)
            {
                a += c[i, j] * c[j, i];
            }
        }
        Console.WriteLine(a);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 15432
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <sstream>
#include <vector>

using namespace std;
int main() {
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string s;
  getline(cin, s);
  istringstream is{s};
  istream_iterator<int> ii{is}, eol;
  vector<int> v{ii, eol};

  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  getline(cin, s);
  istringstream iss{s};
  istream_iterator<int> iii{iss};
  vector<int> v2{iii, eol};

  cout << lexicographical_compare(v.begin(), v.end(), v2.begin(), v2.end())
       << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
//long long b[200005],c[200005];

int main ()
{

    long long int a,b, c,d,e,f,g,h,i,j,k,t,n,sum=0,x,y,z;

    cin >> a>>b>>c;

     if (a==c  && b!=c)
    {
        cout << "Yes"<<"\n";
    }

    else  if (b==c  && a!=c)
    {
        cout << "Yes"<<"\n";
    }


    else  if (b==a  && a!=c)
    {
        cout << "Yes"<<"\n";
    }



     else
    {
        cout << "No"<<"\n";
    }



}


Measured memory_bytes: 256
import java.util.*;


class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("");
        HashMap<String, Integer> a = new HashMap<>();
        for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        }

        String result = "Yes";
        if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;

int main() {
    int N, K;
    cin >> N >> K;
    int A[200001] = {0};
    int temp;
    rep (i, N) {
        cin >> temp;
        ++A[temp];
    }
    vector<int> ans;
    rep(i, 200000) {
        if (A[i] != 0) ans.push_back(A[i]);
    }

    sort(ans.begin(), ans.end());
    int answer = 0;
    if(ans.size() > K)
    rep(i, ans.size() - K) {
        answer += ans[i];
    }

    output(answer);
}

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

int main()
{
  int H, N, input;
  cin >> H >> N;
  for(int i = 0; i < N; i++){
    cin >> input;
    H -= input;
  }
  if(H <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
const int M = 100000;

template<typename T> inline T sqr(T x){return x * x;}

void sieve(vector<int>& v, int n){
    v.assign(n, 0); iota(all(v), 2);
    for(auto div=v.begin(); sqr(*div)<=v.back(); ++div){
        v.erase(remove_if(div+1, v.end(), [&](int x){return x % *div == 0;}), v.end());
    }
}

ostream& operator<<(ostream& os, const pair<int, int>& p){
    return os << p.first << " " << p.second;
}

vector<int> ps;

pair<int, int> solve(int m, int a, int b){
    int p = 2, q = 2, prod = 4;
    for(int& w: ps){
        if(m < w*w)break;
        int h = *(upper_bound(all(ps), min(m/w, w*b/a)) - 1);
        if(w*h < prod)continue;
        p = w; q = h; prod = w * h;
    }
    return {p, q};
}

int main(){
    sieve(ps, M/2);
    for(int m, a, b; cin >> m >> a >> b, m|a|b; cout << solve(m, a, b) << '\n');
    return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((g*10+b)%4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String S = sc.next();
		char[] c = S.toCharArray();

		if (c[0] == c[1] && c[1] == c[2] && c[2] == c[3])
			System.out.println("No");
		else if ((c[0] == c[1] && c[2] == c[3]) || (c[0] == c[2] && c[1] == c[3]) || (c[0] == c[3] && c[1] == c[2]))
			System.out.println("Yes");
		else
			System.out.println("No");

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

//A Simple Offline Text Editor
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();sc.nextLine();
		while(T--!=0){
			String s = sc.nextLine();
//			System.out.println("S:" + s);
			int cur = 0;
			int M = sc.nextInt();
			while(M--!=0){
				String cmd = sc.next();
//				System.out.println("CMD:" + cmd);
				if("forward".equals(cmd)){
					cmd = sc.next();sc.nextLine();
//					System.out.println("OPPE:" + cmd);
					if("char".equals(cmd)){
						cur = Math.min(s.length(), cur+1);
					}
					else{
						if(cur==s.length())continue;
						char ch = s.charAt(cur);
						if(ch==' '){
							while(cur<s.length()&&s.charAt(cur)==' ')cur++;
						}
						while(cur<s.length()&&s.charAt(cur)!=' ')cur++;
					}
				}
				else if("backward".equals(cmd)){
					cmd = sc.next();sc.nextLine();
//					System.out.println("OPPE:" + cmd);
					if("char".equals(cmd)){
						cur = Math.max(0, cur-1);
					}
					else{
						if(cur==0)continue;
						char ch = s.charAt(cur-1);
						if(ch==' '){
							while(cur>0&&s.charAt(cur-1)==' ')cur--;
						}
						while(cur>0&&s.charAt(cur-1)!=' ')cur--;
					}
				}
				else if("delete".equals(cmd)){
					cmd = sc.next();sc.nextLine();
//					System.out.println("OPPE:" + cmd);
					if("char".equals(cmd)){
						if(cur==s.length())continue;
						s = s.substring(0, cur) + s.substring(cur+1, s.length());
					}
					else{
						int p = cur;
						while(p<s.length()&&s.charAt(p)==' ')p++;
						if(p==s.length())continue;
						while(p<s.length()&&s.charAt(p)!=' ')p++;
						s = s.substring(0, cur) + s.substring(p, s.length());
					}
				}
				else{
					String t = sc.nextLine();
//					System.out.println("OPPE:" + t);
					int i=0;
					while(t.charAt(i)!='\"')i++;
					int j=t.length()-1;
					while(t.charAt(j)!='\"')j--;
					t = t.substring(i+1, j);
					s = s.substring(0, cur) + t + s.substring(cur, s.length());
					cur += t.length();
				}
//				sc.nextLine();
			}
			StringBuilder sb = new StringBuilder();
			for(int i=0;i<=s.length();i++){
				if(cur==i)sb.append('^');
				if(i<s.length())sb.append(s.charAt(i));
			}
			System.out.println(sb);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#include <cassert>

int const K = 20;
int const N = 1234567;

int pp[K][N];
int x[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", x + i);
  }
  int L;
  scanf("%d", &L);
  x[n] = x[n - 1];
  for (int i = 0, j = 0; i < n; i++) {
    while (j + 1 <= n && x[j + 1] - x[i] <= L) {
      ++j;
    }
    pp[0][i] = j;
    assert(i < j);
  }
  pp[0][n] = n;
  for (int i = 1; i < K; i++) {
    for (int v = 0; v <= n; v++) {
      pp[i][v] = pp[i - 1][pp[i - 1][v]];
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int left, right;
    scanf("%d%d", &left, &right);
    --left;
    --right;
    if (left > right) std::swap(left, right);
    int ans = 0;
    for (int j = K - 1; j >= 0; j--) {
      if (pp[j][left] < right) {
        left = pp[j][left];
        ans += 1 << j;
      }
    }
    assert(left < right);
    printf("%d\n", ans + 1);
  }
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		//int n=sc.I;
		int[] s=sc.Ia;
		//var a=sc.Arr(n,()=>sc.Ia);
		Console.WriteLine("{0}",Min(Min(s[0]+s[1],s[0]+s[2]),s[2]+s[1]));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

char change(int a,int b, char c){
  if(c == ' ')return c;
  return 'a' + (a * (c - 'a') + b) % 26;
}
int main(void){
  int a[] = {1,3,5,7,9,11,15,17,19,21,23,25,0};
  int n; cin>>n; cin.ignore();
  string str,str_cp,sp = " ";
  
  while(getline(cin,str)){
    str = str_cp = sp + str + sp;
    bool f = false;
    for(int i = 0 ; !f && a[i] ; i ++){
      for(int b = 0 ; !f && b < 26 ; b ++){
	for(int j = 0 ; j < str.length() ; j ++){
	  str[j] = change(a[i],b,str[j]);
	}
	if(str.find(" that ") != string::npos
	   || str.find(" this ") != string::npos){
	  f = true;
	  break;
	}

	str = str_cp;
      }
    }
    cout<<str.substr(1,str.length() - 2)<<endl;
  }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll mod=1e9+7;
const int maxn=2e5+10;
int n;
char s[maxn];
int pre[maxn],las[maxn];
int main(){
    ios::sync_with_stdio(false);
    //cout<<(1ll<<62)<<endl;
    cin>>n;
    cin>>s+1;
    int c1=0,c2=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='#') s[i]=1;
        else s[i]=0;
    }
    for(int i=1;i<=n;i++){
        pre[i]=pre[i-1];
        if(!s[i]) pre[i]++;
    }
    for(int i=n;i>=1;i--){
        las[i]=las[i+1];
        if(s[i]) las[i]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,pre[i]+las[i]);
    }
    cout<<n-ans<<endl;
	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(void) {
	int h[5];
	int i;

	for (i = 0; i < 5; i++) {
		scanf("%d", &h[i]);
	}
	int cnt = 0, ans = 0, temp, max = -1, maxi;
	while (cnt < 5) {
		max = -1;
		for (i = 0; i < 5; i++) {
			temp = ans;
			if (h[i] == -1) {
				continue;
			}
			else {
				temp += h[i];
				if (temp % 10 == 0) {
					maxi = i;
					break;
				}
				else if (temp % 10 > max) {
					max = temp % 10;
					maxi = i;
				}
			}
		}
		ans += h[maxi];
		h[maxi] = -1;
		while (cnt != 4 && ans % 10 != 0) {
			
			ans++;
		}
		cnt++;
	}
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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;}

int main() {

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

    int h, w;
    cin >> h >> w;
    vector<string> vs(h);
    rep(i, h) cin >> vs[i];

    int c1 = 0, c2 = 0, c4 = 0;
    if (h % 2 == 0 and w % 2 == 0) {
        c4 = h * w / 4;
    } else if (h % 2 == 0) {
        c2 = h / 2;
        c4 = h * (w - 1) / 4;
    } else if (w % 2 == 0) {
        c2 = w / 2;
        c4 = (h - 1) * w / 4;
    } else {
        c1 = 1;
        c2 = (h - 1) / 2 + (w - 1) / 2;
        c4 = (h - 1) * (w - 1) / 4;
    }

    map<char, int> mp;
    rep(y, h) rep(x, w) mp[vs[y][x]]++;

    for(auto p: mp) {
        if (p.second % 2 == 1) {
            c1--;
            p.second--;
        }
        if(p.second % 4 == 2) {
            c2--;
            p.second -= 2;
        }
        if(p.second %4 == 0) {
            c4 -= p.second / 4;
        }
    }

    if (c4 < 0 and c2 > 0 and c4 * 2 + c2 == 0) {
        c2 = c4 = 0;
    }
    // cout << c1 << " " << c2 << " " << c4 << endl;

    if (c1 == 0 and c2 == 0 and c4 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <sstream>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  int n, k;
  cin >> n >> k;
  unordered_set<int> set;
  for (int i = 1; i <= n; ++i) {
    set.insert(i);
  }

  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      cin >> a;
      if (set.count(a) > 0) {
        set.erase(a);
      }
    }
  }

  cout << set.size() << endl;

  return 0;
}


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



int32_t main() {
  ios_base::sync_with_stdio(0);

  int d, g;
  cin >> d >> g;

  vector<int> p(d);
  vector<int> c(d);

  int best = 0;
  for (int i = 0; i < d; ++i) {
    cin >> p[i] >> c[i];
    best += p[i];
  }

  for (int i = 0; i < (1<<d); ++i) {
    int sum = 0;
    int res = 0;

    for (int j = 0; j < i; ++j) if ((i >> j) & 1) sum += p[j] * 100 * (j + 1) + c[j], res += p[j];

    if (sum >= g) {
      best = min(best, res);
      continue;
    }

    for (int j = d-1; j >= 0; j--) {
      if ((i>>j) & 1) continue;
      int z = min(p[j] - 1, (g - sum + (100 * (j+1)) - 1) / (100 * (j+1)));
      res += z;
      sum += z * (100 * (j + 1));
      if (sum >= g) {
        best = min(best, res);
        break;
      }
    }
  }

  cout << best << "\n";

  return 0;
}


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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a+b) {
        if(k>=a)
        cout<<a<<endl;
        else cout<<k<<endl;
        return 0;
    }
    if(k>a+b) {
        cout<<a - (k - a - b)<<endl;
        return 0;
    }
	return 0;
}

Measured memory_bytes: 3612
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
a1=0
a2=0
tmp=x
while tmp<n:
    if tmp+1 in a:
        a1+=1
    tmp+=1
tmp=x
while tmp>0:
    if tmp-1 in a:
        a2+=1
    tmp-=1
print(min(a1,a2))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int h[100005];
long long f[100005];
int main() 
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	for (int i = 2; i <= n + 5; i++)f[i] = 1e11;
	f[1] = 0;
	for (int i = 1; i < n; i++)
	{
		f[i + 1] = min(f[i + 1], f[i] + abs(h[i + 1] - h[i]));
		f[i + 2] = min(f[i + 2], f[i] + abs(h[i + 2] - h[i]));
	}
	cout << f[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define OO pow(10, 5)+1
using namespace std;

int dp[3001][30001];
string x, y;

signed main()
{
    cin >> x >> y;
    
    for (int i=0;i<=x.length();++i)
    {
        for (int j=0;j<=y.length();++j)
        {
            if (i==0 ||j == 0)
                dp[i][j] = 0;
            else
            {
                if (x[i-1] == y[j-1])
                    dp[i][j] = dp[i-1][j-1] + 1;
                dp[i][j] = max(dp[i][j], max(dp[i-1][j], dp[i][j-1]));
            }
        }
    }
    int id = 0, xi = dp[x.length()][y.length()];
  //  cout << x << endl << y << endl;
    string tot = "";
    for (int i = x.length();i>0 && xi;--i)
    {
        for (int j = y.length();j>0 && xi; --j)
        {
          //  cout << dp[i][j]<< " ";
            if (dp[i][j] == xi && x[i-1] == y[j-1])
            {
                tot += x[i-1];
            //    cout << 42 << endl;
                xi--;
                break;
            }
        }
    //    cout << endl;
    }
    reverse(tot.begin(), tot.end());
    cout << tot << endl;
    return 0;
}

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

using namespace std;

int main(){
  string s;
  cin>> s;
  
  if(s=="Sunny") cout<< "Cloudy" <<endl;
  if(s=="Cloudy") cout<< "Rainy" <<endl;
  if(s=="Rainy") cout<< "Sunny" <<endl;

}

Measured memory_bytes: 256
while 1:
  n=input()
  if n==0:break
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int,raw_input().split(' '))
    if a in D: D[a]+=b*c
    else:
      D[a]=b*c
      A.append(a)
  f=1
  for i in A:
    if D[i]>=1e6: print i; f=0
  if f: print "NA"

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,y; cin>>x>>y;
    ll a = x;
    ll c =0;
    while(a <= y){
        a*=2;
        c++;
    }
    cout<<c<<endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] R = new int[n];
		for (int i=0; i < n; i++) {
			R[i] = sc.nextInt();
		}
//
//		int max = R[1] - R[0];
//		for (int i =0; i < n-1; i++) {
//			for (int j=i+1; j < n; j++) {
//				if (max < R[j] - R[i])
//				max = R[j] - R[i];
//			}
//		}
//
//		System.out.println(max);

		int max = R[1] - R[0];
		int i = 0;
		for ( int j=1; j < n; j++) {
			if ( R[j] - R[i] > max ) {
				max = R[j] - R[i];
			}
			if ( R[i] > R[j] ) {
				R[i] = R[j];
			}
		}

		System.out.println(max);

	}

}

Measured memory_bytes: 100112
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, l, r;
	cin >> n;

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


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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
const int INF = 0x3f3f3f3f;
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    lli n;
    lint1(n);
    lli arr[n];
    fors(i,n){
        lint1(arr[i]);
    }
    
    sort(arr,arr+n);
    vector<lli> eq;
    fors(i,n-1){
        if(arr[i]==arr[i+1]) {eq.pb(arr[i]); i++;}
    }
    if(eq.size()<2){
        pint(0);
    }
    else{
        lli temp = eq[eq.size()-1]*eq[eq.size()-2];
        printf("%lld",temp);
    }
    return 0;
}



Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,w;
    cin>>n>>w;
    long long v[n],r[n],dp[n+1][w+1];
    for(int i=0;i<n;i++){
        cin>>r[i]>>v[i];
    }
    //for(int i=1;i<=n;i++){
       /* for(int j=1;j<=w;j++){
            dp[i][j]=INT_MIN;
        }
    }*/
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
	    if(i==0||j==0)
		dp[i][j]=0;
           else if(r[i-1]<=j){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-r[i-1]]+v[i-1]);
            }
	    else
		dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int r, d, x;
  cin >> r >> d >> x;

  rep(i, 10){
    x = r*x - d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ans=[0]*n
    a=LIST()
    for i in a:
        ans[i-1]+=1
    
    for i in ans:
        print(i)
if __name__ == '__main__':
    do()

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int main() {
	int N;
	cin >> N;
	int d = N%10;
	if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9)
		cout << "hon" << endl;
	else if(d == 0 || d == 1 || d == 6 || d == 8)
		cout << "pon" << endl;
	else 
		cout << "bon" << endl;
	return 0;
}


Measured memory_bytes: 3624
n=int(input())
#n,p=map(int,input().split())
pl=list(map(int,input().split()))
ql=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import itertools
l=[i for i in range(1,n+1)]

p = list(itertools.permutations(l))
p.sort()
a=p.index(tuple(pl))
b=p.index(tuple(ql))

print(abs(a-b))

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll D,G;
  cin>>D>>G;
  vector<ll>p(D),c(D);
  for(int i=0;i<D;i++)cin>>p[i]>>c[i];
  ll bit=pow(2,D);
  ll ans=INF;
  for(int i=0;i<bit;i++){
    ll memo=0;
    ll sum=0;
    for(int j=0;j<D;j++){
      if((i>>j)&1){
        memo+=p[j];
        sum+=p[j]*(j+1)*100+c[j];
      }
    }

    for(int j=D-1;j>=0;j--){
      if(sum>=G)break;
      if(!((i>>j)&1)){
        for(int k=0;k<p[j]-1;k++){
          if(sum>=G)break;
          memo++;
          sum+=(j+1)*100;
        }
      }
    }
    if(sum>=G)ans=min(ans,memo);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
# 累積和を使わないバージョン。時間が多分間に合わずにTLEしそう

n, k = list(map(int, input().split() ))
values = a = list(map(int, input().split() ))
ans = 0

left_pop_max = min(k, n)
for left in range(left_pop_max+1):
	picked_l = values[:left]

	# right_pop_max = min(k-left, n-left)
	right_pop_max = left_pop_max - left
	for right in range(right_pop_max+1):
		# rightが0だとvalues[0:]が配列全体になってしまうので
		if (right > 0):
			picked = picked_l + values[-right:]
		else:
			picked = picked_l

		picked.sort()
		push_max = min(k - left - right, left + right)
		push_val_sum = 0
		for i in range(push_max):
			if picked[i] >= 0:
				break
			push_val_sum += picked[i]

		new_ans = sum(picked) - push_val_sum
		ans = max(ans, new_ans)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
  #define trcc(v) do { cerr << "name : " << #v << "\n"; int cnt = 0; each(x , v){cerr << (cnt++) << " : "; trc(x); } } while(0)
#else
  #define trc(...)
  #define trca(...)
  #define trcc(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(s,t)   rep(i,sz(s)){in(s[i] , t[i]);}
#define in3(s,t,u) rep(i,sz(s)){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ins(S);
  int ans = 0;
  int l = 0 , r = sz(S) - 1;
  while(l < r){
    if(S[l] == S[r]){
      l++ , r--;
    }
    else if(S[l] == 'x'){
      l++; ans++;
    }
    else if(S[r] == 'x'){
      r--; ans++;
    }
    else die("-1");
  }
  out(ans);
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int n,m,ans=0;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m) cin >> p[i].second >> p[i].first;
    sort(p.begin(),p.end());
    int now=0;
    for(int i=0;i<m;i++){
        if(now<=p[i].second){
            ans++;
            now=p[i].first;
        }
    }
    
    cout << ans << endl;

    return 0;
}







Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String s = sc.next();

        String t = sc.next();

        {
            String tmp = s;
            s = t;

            t = tmp;
        }
        System.out.println(s + t);
    }
}

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

int main(){
  int X,Y,Z,K;cin>>X>>Y>>Z>>K;
  vll A(X), B(Y), C(Z);
  for (int i=0;i<X;++i){
    ll a;cin>>a;A[i]=a;
  }
  for (int i=0;i<Y;++i){
    ll b;cin>>b;B[i]=b;
  }
  for (int i=0;i<Z;++i){
    ll c;cin>>c;C[i]=c;
  }

  vll partial_sum;
  for (int i=0;i<X;++i){
    for (int j=0;j<Y;++j){
      ll s=A[i]+B[j];
      partial_sum.push_back(s);
    }
  }

  sort(partial_sum.begin(), partial_sum.end(), greater<ll>());
  vll ans;

  int K_=min(K, X*Y);
  for (int i=0;i<K_;++i){
    for (int j=0;j<Z;++j){
      ll t=partial_sum[i]+C[j];
      ans.push_back(t);
    }
  }

  sort(ans.begin(), ans.end(), greater<ll>());

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

  return 0;
}

Measured memory_bytes: 42984
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

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

	vector<int> A;

	int ans = 0;
	rep(i, N-1) {
		int tmp;
		cin >> tmp;
		A.pb(tmp);
		if (i == 0) {
			ans += A[i];
		} else {
			ans += min(A[i], A[i-1]);
		}
	}

	ans += A[N-2];

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

        int t[] = new int[5];

        for (int i = 0; i < 5; i++) {
            t[i] = scan.nextInt();
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4 - i; j++) {
                if (t[j] < t[j + 1]) {
                    int x = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = x;
                }
            }
        }

        for (int i = 0; i < 5; i++) {
            if (i < 4) {
                System.out.print(t[i] + " ");
            } else {
                System.out.println(t[i]);
            }
        }
    }
}



Measured memory_bytes: 26168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

static const int INF=1<<29;
static const int di[]={-1, 0, 1, 0};
static const int dj[]={0, -1, 0, 1};
 
int main() {
    int R, C;
    cin >> R >> C;

    vector<string> c(R);
    rep(i,R) cin >> c.at(i);

    vector<string> d(R);
    rep(i,R) d.at(i) = c.at(i);


    ll ans = 0;
    for(int sx = 0; sx<C; sx++){
        //for(int gx = 0; gx<C; gx++){
            for(int sy = 0; sy<R; sy++){
                //for(int gy = 0; gy<R; gy++){
                    rep(i,R) c.at(i) = d.at(i);
                    ll now = 0;
                    vector<vector<int>> dp(R, vector<int>(C, INF)); dp[sy][sx]=0;

                    queue<pair<int, int>> q; 
                    q.emplace(sy, sx);
                    while (!q.empty()) {
                        int i=q.front().first, j=q.front().second; q.pop();
                        if (c[i][j] != '.') continue;
                
                        for (int k=0; k<4; ++k) {
                            int I=i+di[k], J=j+dj[k];
                            if (I < 0 || R <= I || J < 0 || C <= J) continue;
                            if (dp[I][J] < dp[i][j]) continue;
                            if (c[I][J] != '.') continue;
                
                            //if (I == gy && J == gx) now = dp[i][j]+1;
                            if(dp[i][j]+1>ans) ans = dp[i][j]+1;
                
                            dp[I][J] = dp[i][j] + 1;
                            c[i][j] = '+';
                            q.emplace(I, J);
                        }
                    }
                    if(ans<now) ans = now;
                //}
            }
        //}
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
a,b,c=map(int,input().split())
i=0
while a%2==0 and b%2==0 and c%2==0:
    a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
    i+=1
    if i==10000:
        print(-1)
        sys.exit()
print(i)

Measured memory_bytes: 2940
N=int(input())
red_coodinates=[]
blue_coodinates=[]
for i in range(N):
    red_coodinates.append(list(map(int,input().split())))
for i in range(N):
    blue_coodinates.append(list(map(int,input().split())))

red_coodinates.sort(key=lambda x:-x[1])
blue_coodinates.sort()
number_of_pairs=0

for i in range(N):
    for j in range(0,len(red_coodinates)):
        if red_coodinates[j][0]<blue_coodinates[i][0] and red_coodinates[j][1]<blue_coodinates[i][1]:
            number_of_pairs+=1
            red_coodinates.remove(red_coodinates[j])
            break
        else:
            pass

print(number_of_pairs)

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


int main() {
  int A;
  int B;

  cin >> A;
  cin >> B;

  int n = 0;
  int a = 1;

  while(B > a){
    a = a-1+A;
    n++;
  }


  cout << n << endl;

  return 0;
}

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

int main()
{
    std::vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());

    std::cout << a[0] * 10 + a[1] + a[2] << std::endl;
}


Measured memory_bytes: 256