akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll v0size=0,v1size=0;
ll C[100001];
struct edge{ll time,posi,abe,he;};
ll n,d,t=0,a[203],b[203],c[203];
ll dp[203][205]={};
ll SIZE=5040;
ll f[5003]={};
vector<int> v[2][5001];
int main() {
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
		t+=a[i];
	}
	int ans,k=100000;
	rep(i,0,n){
		if(abs(a[i]*n-t)<k){
			ans=i;
			k=abs(a[i]*n-t);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 10000005
using namespace std;
int n,a,b,tot;
int ans[maxn];
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if(n<a+b-1 || n>1ll*a*b)
	{
		printf("-1\n");
		return 0;
	}

	for(int i=n-a+1;i<=n;i++)
		ans[++tot]=i;
	n-=a;

	b--;

	for(int i=b;i>=1;i--)
	{
		int now=min(a,(n-i+1));
		for(int j=n-now+1;j<=n;j++)
			ans[++tot]=j;
		n-=now;
	}

	for(int i=1;i<=tot;i++)
		printf("%d ",ans[i]);
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

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

		String a = sc.nextLine();
		sc.close();

		if(a.equals("Sunny")){
			System.out.println("Cloudy");
		}else if(a.equals("Cloudy")){
			System.out.println("Rainy");
		}else{
			System.out.println("Sunny");
		}
	}
}

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

int N;
vector<int> G[101010];
ll dp[101010][2];
ll MOD = 1000000007;

void rec(int v, int parent) {
  for(int i=0; i<G[v].size(); i++){
    int to = G[v][i];
    if (to == parent) continue;
    rec(to, v);
    dp[v][0] *= (dp[to][0] + dp[to][1])%MOD;
    dp[v][1] *= dp[to][0];
    dp[v][0] %= MOD;
    dp[v][1] %= MOD;
  }
}

int main() {
  cin >> N;
  for(int i=0; i<N-1; i++) {
    int a,b;
    cin >> a;
    cin >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (N==1) {
    cout << 2 << endl;
    return 0;
  }
  for(int i=0; i<N; i++) {
    dp[i][0] = dp[i][1] = 1;
  }
  rec(0,-1);
  cout << (dp[0][0] + dp[0][1])%MOD << endl;
}

Measured memory_bytes: 14208
#include<stdio.h>
int main(){
  long long int n,a,b,sum;
  scanf("%lld%lld%lld",&n,&a,&b);
  if(n%(a+b)>a)
    printf("%lld\n",n/(a+b)*a+a);
  else
    printf("%lld\n",n/(a+b)*a+n%(a+b));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define INF 10000000
#define W 0
#define G 1
#define B 2
/*W,G,Bはcolor[v]を用いてvの訪問状態を表す*/
int prim(void);

int n,M[MAX][MAX];
/*M[u][v]はuからvへの辺の重みを記録する*/
int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1){
	M[i][j]=INF;
      }
      else{
	M[i][j]=e;
      }
    }
  }

  printf("%d\n",prim());
  
  return 0;
}

int prim(){
  int u,minv,i,v,sum;
  int color[MAX],d[MAX],p[MAX];
  /*color[v]はW,G,Bを用いてvの訪問状態を表す
    d[v]は頂点をつなぐ辺の中で、重みが最小の辺の重みを記録する
    p[v]は頂点vの親を記録する
  */
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=W;
  }
  d[0]=0;
  while(1){
    minv=INF;
    u=-1;
    for(i=0;i<n;i++){
      if((minv>d[i])&&(color[i]!=B)){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=B;
    for(v=0;v<n;v++){
      if((color[v]!=B)&&(M[u][v]!=INF)){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=G;
	}
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  return sum;
}



Measured memory_bytes: 2052
function main()
    T = pread(Int)
    for i in 1:T
        n,m,a,b = reads(Int,Int,Int,Int)
        ans = floorsum(n, m, a, b)
        println(ans)
    end
end

function floorsum(n, m, a, b)
    ans = 0
    if a >= m
        ans += (n-1) * n * (a÷m) ÷ 2
        a %= m
    end
    if b >= m
        ans += n * (b÷m);
        b %= m
    end

    ymax = (a * n + b) ÷ m
    xmax = (ymax * m - b)
    ymax == 0 && return ans
    ans += (n - (xmax + a - 1) ÷a ) * ymax
    ans += floorsum(ymax, a, m, (a - xmax % a) % a)
    return ans
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 227812
s = input()
t = input()

s1 = list(s)
t1 = list(t)

s2 = len(s1)
count = 0
for i in range(s2):
    if(s1[i] != t1[i]):
        s1[i] == t1[i]
        count += 1
        
print(count)
        

Measured memory_bytes: 12580
S = input()
Q = int(input())
qry = [input().split() for _ in range(Q)]
A = ''
B = ''
oq = 0
even = True
for q in qry:
    if q[0] == '1':
        even = not even
        if oq == '1':
            continue
    else:
        if even:
            if q[1] == '1':
                A = q[2] + A
            else:
                B += q[2]
        else:
            if q[1] == '1':
                B += q[2]
            else:
                A = q[2] + A
    oq = q

if even:
    print(A+S+B)
else:
    print(B[::-1]+S[::-1]+A[::-1])


Measured memory_bytes: 41460
from collections import Counter

S = Counter(list(input()))


def solve(S):
    if len(S) == 2:
        f = True
        for k, v in S.items():
            if v != 2:
                f = False
        if f:
            print("Yes")
            return 0
    print("No")
    return 0


solve(S)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define mx *max_element
#define mi *min_element
#define fn for(long long int i =0 ;i <n;i++)
#define fn1 for(long long int i =1;i<=n;i++)
#define fm for(long long int j =0 ;j <m;j++)
#define fm1 for(long long int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
const int N = 1e6;
ll ar[N];
ll dp[N];
int main(){
	Fast;
	ll n , k ;
	cin >> n >> k ;
	cout<<n-k+1;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main(){ 
  string a, b, c;
  cin >> a >> b >> c;
  char d = 'A' - 'a';
  
  cout << char(a[0] + d) << char(b[0] + d) << char(c[0] + d) << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    string s;
    cin >> s;
    for (int i = s.length()-1; i >= 0; i--){
        cout << s[i];
    }
    cout << endl;
    return 0;
}   



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9+5;
int main()
{
    int n;
    cin>>n;
    int a[n+5];
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int>dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j:{i+1,i+2}){
            if(j<=n){
                dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}


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

bool fnd;
int n, i, j;
string s, t;

int main(){
	cin >> s >> t;
	n = s.size();
	for(j=0;j<n;j++){
		bool flag = 0;
		for(i=0;i<n;i++){
			if(s[i]!=t[(j+i)%n]) flag=1;
		}
		if(!flag) fnd=1;
	}
	printf("%s\n",(fnd)?"Yes":"No");
	return 0;
}

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

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

    int m[N];
    int cnt = 0, sum = 0, min;
    for(int i = 0; i < N; i++){
        cin >> m[i];
        if(i == 0){
            min = m[0];
        }else if(min > m[i]){
            min = m[i];
        }
        sum += m[i];
        cnt++;
    }

    int left = X - sum;
    if(left != 0){
        cnt += left / min;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int A[251] = {0};
	int H;
	int id, k, pk, lk, rk;
	int i;

	scanf("%d", &H);
	for (i = 1; i <= H; i++){
		scanf("%d", &A[i]);
	}

	for (id = 1; id <= H; id++){
		printf("node %d: ", id);

		k = A[id];
		printf("key = %d, ", k);

		if (id != 1){
			pk = A[id / 2];
			printf("parent key = %d, ", pk);
		}

		if (2 * id <= H){
			lk = A[2 * id];
			printf("left key = %d, ", lk);
		}

		if (2 * id + 1 <= H){
			rk = A[2 * id + 1];
			printf("right key = %d, ", rk);
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 600
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,m,c;
  cin>>n>>m>>c;
  int b[m];
  REP(i,m){
    cin>>b[i];
  }
  int ans = 0;
  REP(i,n){
    int counter = 0;
    REP(j,m){
      int a;
      cin>>a;
      counter += a*b[j];
    }
    counter += c;
    if(counter>0)ans++;
  }
 cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args) {
    new Main().solve();
  }

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      int d = in.nextInt();

      int st = max(a, c);
      int en = min(b, d);

      int ans = (en - st) > 0 ? en - st : 0;
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

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

    public String nextLine() throws IOException {
      return br.readLine();
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<Int> A(N);
    for (Int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(all(A));
    A.push_back(INF);
    Int ok = N - 1;
    Int ng = -1;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        Int index = upper_bound(all(A), A[mid] + M) - A.begin();
        Int k = N - index + 1;
        Int v = V;
        if (mid < v - 1) {
            v -= mid + 1;
            if (k - 1 < v) {
                v -= k - 1;
                Int x = v * M;
                for (Int i = mid + 1; i < index; i++) {
                    x -= A[mid] + M - A[i];
                }
                if (x > 0) {
                    Int cnt = 0;
                    for (Int i = index - 1; i > mid; i--) {
                        x -= A[i] - A[mid];
                        cnt++;
                        if (x <= 0) break;
                    }
                    k += cnt;
                }
            }
        }
        if (k <= P) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    dump(N - ok);
    return 0;
}

Measured memory_bytes: 1792
count_al = list(0 for i in range(26))
while True :
    try :
        a = str(input())
        b = a.lower()
        for i in range(len(b)) :
            c = ord(b[i])
            if c > 96 and c < 123 :
                count_al[c - 97] += 1
    except EOFError :
        break
    
for i in range(97, 123) :
    print(chr(i), ":", count_al[i-97])


Measured memory_bytes: 5568
n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)],key=lambda x:x[0])
stop = set()
start = set()
for a,b in ab:
  if a == 1:
    stop.add(b)
  elif b == n:
    start.add(a)
print("POSSIBLE" if len(stop & start) > 0 else "IMPOSSIBLE")



Measured memory_bytes: 59524
def resolve():
    N, M = list(map(int, input().split()))
    A = [input() for i in range(N)]
    B = [input() for i in range(M)]
    for i in range(0, N-M+1):
        for j in range(0, N-M+1):
            flg = True
            for a, b in zip(A[i:i+M], B):
                if a[j:j+M] != b:
                    flg = False
                    break
            if flg:
                print("Yes")
                return
    print("No")
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38384
#include <stdio.h>
int main(){

  int n,i,a[10000];

  scanf("%d",&n);
  
  for (i = 0; i < n; i++){

    a[i]=i+1;

  }
  
  for (i = 0; i < n; i++){

    if (a[i]%3 == 0){

      printf(" %d",a[i]);

    } else if (a[i]%10 == 3){

      printf(" %d",a[i]);

    } else if (30 <= a[i]%100 && a[i]%100 <= 39){

      printf(" %d",a[i]);

    } else if (300 <= a[i]%1000 && a[i]%1000 <= 399){

      printf(" %d",a[i]);

    } else if (3000 <= a[i]%10000 && a[i]%10000 <= 3999){

      printf(" %d",a[i]);

    }

  }

  printf("\n");

  return 0;
  
}

Measured memory_bytes: 632
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			String str=sc.next();
			int[] vals=new int[10];
			for(int i=0;i<10;i++){
				vals[i]=str.charAt(i)-'0';
			}
			ln((vals[0]+vals[1]*9+vals[2]*36+vals[3]*84+vals[4]*126
			+vals[5]*126+vals[6]*84+vals[7]*36+vals[8]*9+vals[9])%10);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define ld long double
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    unordered_map<int,int> mp;
    int x,cnt,sum;
    int a[MAX];
    void solve()
    {
        cin>>n;
        fo(i,0,n)
        {
            cin>>x;
            a[i]=x;
            mp[x]++;
        }
        for(auto x:mp)
        {
            sum+=(x.S*(x.S-1))/2;
        }

        fo(i,0,n)
        {
            cnt=mp[a[i]];
            cout<<sum-(cnt*(cnt-1))/2+((cnt-2)*(cnt-1))/2<<endl;

        }
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void solve(void)
{
	int n,l;
	char s[100][101];
	int i;
	scanf("%d %d", &n, &l);
	for(i=0;i<n;++i){
		scanf("%s", &s[i][0]);
		s[i][l]='\0';
	}
	qsort(s, n, 101, strcmp);
	for(i=0;i<n;++i){
		printf("%s", s[i]);
	}
	printf("\n");
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long
typedef pair<int, int> ii;

const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int n, v[N], used[N], mx;

vector<ii> vec1, vec2;

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    mx = 0;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    int sum = 0;
    for(int i = 1; i <= n; i += 2) {
        used[v[i]]++;
        sum++;
    }
    for(int i = 1; i <= N - 5; i++) {
        vec1.pb({sum - used[i], i});
    }
    mx = 0;
    sum = 0;
    memset(used, 0, sizeof(used));
    for(int i = 2; i <= n; i += 2) {
        used[v[i]]++;
        sum++;
    }
    for(int i = 1; i <= N - 5; i++) {
        vec2.pb({sum - used[i], i});
    }
    sort(vec1.begin(), vec1.end()); sort(vec2.begin(), vec2.end());
    int cost = INT_MAX;
    for(int i = 0; i < vec1.size(); i++) {
        for(int j = 0; j < vec2.size(); j++) {
            if(vec1[i].se == vec2[j].se) continue;
            cost = min(cost, vec1[i].fi + vec2[j].fi);
            break;
        }
    }
    cout << cost << "\n";
}


Measured memory_bytes: 6512
#べき乗関数powを使った逆元の計算
def modinv2(a,m):
    return pow(a,m-2,m)
 
X,Y = map(int,input().split())
 
X,Y = min(X,Y),max(X,Y)
 
if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(b+1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv2(i,m)%m
print(ans)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n,m;
vector<int> ans;
int sum;
int ma;
int ki=-1;

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

	cin>>n;

	ans.pb(3);ans.pb(5);
	sum=8;

	int m=n-3;
	for(int i=2;i<=30000;i++) {
		if(m==0) break;
		if(i%2==0) {
			ans.pb(i);
			sum+=i;
			ma=i;
			m--;
		}
		else if(i%3==0||i%5==0) {
			if(i==3||i==5) continue;
			if(ki==-1) {
				ki=i;
			}
			else {
				if(m==1) {
					sum-=ans.back();
					ans.pop_back();
					m++;
				}
				ans.pb(ki);ans.pb(i);
				sum+=ki+i;
				ki=-1;
				ma=i;
				m-=2;
			}
		}
	}
	int lst=(30-sum%30);
	while(lst<=ma) lst+=30;
	ans.pb(lst);
	sum+=lst;

	for(auto x:ans) cout<<x<<' ';
	cout<<endl;

	return 0;
}


Measured memory_bytes: 640
from functools import reduce
import math
import collections
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    a = list(int(_) for _ in input().split())
    a.sort()
    d = collections.defaultdict(int)
    for a_i in a:
        d[a_i] +=1
    ans = 0
    for k,v in d.items():
        if v>k:
            ans += v - k
        elif v<k:
            ans += v
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 18660
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define N 201000
#define ll long long
#define mo 1000000007
using namespace std;
int n,a[N],ls[N];
ll ans=0,f[N];
int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fd(i,n,1) ls[a[i]]=i-1;
	f[1]=1;
	ls[a[1]]=1;
	fo(i,2,n)
	{
		f[i]=f[i-1];
		if(ls[a[i]]!=i-1) f[i]=(f[i]+f[ls[a[i]]])%mo;
		ls[a[i]]=i;
	}
	printf("%lld\n",f[n]);
}

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

# 解説AC
def f(n):
    if n % 2 == 1:
        return (1 if n % 4 == 1 else 0)
    else:
        return n ^ (1 if n % 4 == 2 else 0)


def main():
    A, B = map(int, input().split())
    print(f(A-1) ^ f(B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] arrayy=new double[n];
		String[] arrayb=new String[n];
		double sum=0;
		for(int i=0;i<n;i++) {
			arrayy[i]=sc.nextDouble();
			arrayb[i]=sc.next();
		}
		for(int i=0;i<n;i++) {
			if(arrayb[i].equals("JPY")) {
				sum+=arrayy[i];
			}else {
				sum+=arrayy[i]*380000.0;
			}
		}

		System.out.println(sum);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

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

	int cur = 1;
	int res = 0;
	while(cur < b){
		cur += a - 1; 
		res++;
	} 

	cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll dp[100001][4];


int main(){
	string s;
	cin >> s;

	dp[0][0] = 1;
	for (int i = 0; i < s.length(); i++){
		if (s[i] == '?'){
			for (int j = 0; j < 4; j++){
				dp[i+1][j] += (dp[i][j]*3)%MOD;
				dp[i+1][j] %= MOD;
			}
		}else{
			for (int j = 0; j < 4; j++){
				dp[i+1][j] += dp[i][j];
				dp[i+1][j] %= MOD;
			}
		}
		if (s[i] == 'A' || s[i] == '?'){
			dp[i+1][1] += dp[i][0];
			dp[i+1][1] %= MOD;
		}
		if (s[i] == 'B' || s[i] == '?'){
			dp[i+1][2] += dp[i][1];
			dp[i+1][2] %= MOD;
		}
		if (s[i] == 'C' || s[i] == '?'){
			dp[i+1][3] += dp[i][2];
			dp[i+1][3] %= MOD;
		}
	}

	cout << dp[s.length()][3]%MOD << endl;
	return 0;
}

Measured memory_bytes: 6864
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, long long Q, std::vector<long long> A){
    vector<int> plus(N, 0);
    for (int ai : A) {
        plus[ai - 1]++;
    }
    for (int pi : plus) {
        int score = K + pi - Q;
        cout << (score > 0 ? YES : NO) << endl;
    }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
N=int(input())
A=[int(x) for x in input().split()]
num={i:0 for i in range(N)}
for i in A:
    num[i-1]+=1
def set(k):
    if k >= 2:
        return (k)*(k-1)/2
    else:
        return 0
def selfset(k):
    if k >= 2:
        return (k-1)*(k-2)/2
    else:
        return 0

setnum={i:set(num[i]) for i in range(N)}
a=sum(setnum.values())

selfsetnum={i:selfset(num[i]) for i in range(N)}


for i in range(N):
    print(int(a-setnum[A[i]-1]+selfsetnum[A[i]-1]))

Measured memory_bytes: 82972
##stack level too deep を疑ってみる。
##https://qiita.com/cielavenir/items/764ee9eb24b1cb43e588
##https://arc045.contest.atcoder.jp/submissions/526902

if !ENV['RUBY_THREAD_VM_STACK_SIZE']
	#require 'rbconfig';RUBY=File.join(RbConfig::CONFIG['bindir'],RbConfig::CONFIG['ruby_install_name'])
	require 'rubygems';RUBY=Gem.ruby
	exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},RUBY,$0)
end

##ここまでコピペ

N = gets.to_i
@h = {}
@res = [nil, 0]

def f(i)
	@h[i].each do |x|
		next if !@res[x[0]].nil?
		@res[x[0]] = (@res[i] ^ x[1])&1
		f(x[0])
	end
end

a = $<.read.split.map(&:to_i).each_slice(3).flat_map { |u, v, w| [u, v, w, v, u, w] }
	.each_slice(3).map { |u, v, w| [u, [v, w]] }.sort

while a.size > 0 do
	k = a.bsearch_index { |x| a[0][0] < x[0] } || a.size
	@h[a[0][0]] = a[0,k].map(&:pop)
	a.shift(k)
end

f(1)
@res.shift
puts @res


Measured memory_bytes: 164932
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t K,A,B;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> K>>A>>B;
	size_t i = 0;
	int64_t num = 1;
	for (; i+2 <= K;)
	{
		if (num < A || (B - A)<2) {
			num += 1;
			i += 1;
		}
		else {
			num -= A;
			num += B;
			i += 2;
		}
	}
	if (i < K) {
		num += 1;
		i += 1;
	}
	out << num << endl;
	return 0;
}
#endif


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

int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << "0.5000000000";
    }
    else if (n == 1) {
        cout << "1";
    }
    else {
        printf("%.10lf", 1.0 * (n + 1) / (2 * n * 1.0));
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
          
bool comp(pair<string, int> a, pair<string, int> b){
    return a.S < b.S;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int x, y;
        cin >> x >> y;
        ans += (y - x) + 1;
    }
    cout << ans;
}


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

int main()
{
    long long a,b;
    std::cin >> a >> b;
    b++;

    std::vector<long long> cnt_a(60),cnt_b(60);
    int cnt = 0;
    for(long long i = 2; i < ((long long)1<<60); i<<=1){
        long long tmp = a / i;
        cnt_a[cnt] = (tmp * (i / 2));
        tmp = a % i;
        if(tmp >= i/2){
            cnt_a[cnt] += tmp - (i / 2);
        }

        tmp = b / i;
        cnt_b[cnt] = (tmp * (i / 2));
        tmp = b % i;
        if(tmp >= i/2){
            cnt_b[cnt] += tmp - (i / 2);
        }
        cnt++;
    }

    //for(int i = 0; i < 10; i++)std::cout << cnt_a[i] << " : " << cnt_b[i] << std::endl;




    long long ans = 0;
    for(long long i = 0; i < 60; i++){
        long long sa = cnt_b[i] - cnt_a[i];
        if(sa & 1){
            ans += ((long long)1 << i);
        }
        //std::cout << sa << std::endl;
    }
    std::cout << ans << std::endl;
}

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

int main(){
  int r;
  cin >> r;
  
  if(r < 1200){
    cout << "ABC" << endl;
  } else if(r < 2800){
    cout << "ARC" << endl;
  } else{
    cout << "AGC" << endl;
  }
  
  return 0;
}

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

using namespace std;

const int P = 998244353;

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

	int n, S;
	cin >> n >> S;

	vector<int> a;
	a.resize(n);

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

	vector<vector<long long> > dp;
	dp.resize(n + 1);

	for(int i = 0; i < n + 1; ++i) {
		dp[i].resize(S + 1);
	}

	dp[0][0] = 1;

	for(int i = 0; i < n; ++i) {
		if(a[i] <= S) {
			dp[i + 1][a[i]] += i + 1;
		}

		for(int j = 1; j <= S; ++j) {
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % P;
			if(j + a[i] <= S) {
				dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + dp[i][j]) % P;
			}
		}
	}

	long long ans = 0;

	for(int i = 0; i < n + 1; ++i) {
		ans = (ans + dp[i][S]) % P;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 70784
($n,$m)=glob<>;
for(1..$m){
    ($A,$B)=glob<>;
    $Q{$B}=($A>$Q{$B})?$A:$Q{$B};
}

$o=0;$r=-1;
for $i(sort{$a<=>$b}keys %Q){
    next if ($r>=$Q{$i});
    $r=$i-1;
    $o++;
} 
print$o

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define intt long long
#define in(a) scanf("%d",&a)
#define out(a) printf("%d\n",a)

using namespace std;

int main()
{
    int a, b;
    cin>>a>>b;
    if (a + b == 15)cout<<'+'<<endl;
    else if (a * b == 15)cout<<'*'<<endl;
    else cout<<'x'<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

int main(){
    int n; sc(n)
    ll ans = -1e10, tmp;
    vector<vector<int> > f(n, vector<int>(10)), p(n, vector<int>(11));
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 10; j++) sc(f[i][j])
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 11; j++) sc(p[i][j])
    }
    for (int i = 1; i < (1<<10); i++){
        tmp = 0;
        fill(cnt.begin(), cnt.end(), 0);
        for (int j = 0; j < 10; j++){
            if (!(i & (1<<j))) continue;
            for (int k = 0; k < n; k++){
                if (f[k][j] == 1) cnt[k] += 1;
            }
        }
        for (int j = 0; j < n; j++) tmp += p[j][cnt[j]];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second < secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int n;
    cin >> n;
    vpii join(n);
    for (int i = 0; i < n; ++i) {
        join[i].first = i + 1;
        cin >> join[i].second;
    }
    sort(join.begin(), join.end(), pairCompare<int, int>);
    for (auto j : join) {
        cout << j.first << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1664
# 偶数a ^ (a + 1)　は必ず1になる
# 従い、0 〜 4の倍数 - 1でXORは0になる

import sys
readline = sys.stdin.readline

A,B = map(int,readline().split())

def f(x):
  res = 0
  while x % 4 != 3:
    res ^= x
    x -= 1
  return res

print(f(A - 1) ^ f(B))


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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            int A = int.Parse(Console.ReadLine());
            var Ns = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            decimal N2 = 0;
            foreach(var N in Ns)
            {
                N2 += (1 / N);
            }
            Console.WriteLine(1 / N2);
        }
    }

}


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

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k;
    cin>>k;
    
    int s=7%k;
    int c=1;
    while(s!=0 && c<=2e6){
            s = ((s * 10) + 7)%k;
            c++;
    }

     cout<<(s ? -1 : c);
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int MIN=1001, MAX = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		MIN = min(MIN, a);
		MAX = max(MAX, a);
	}
	cout << MAX - MIN << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int a[100001],po[100001],cnt,book;
int x;
int ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)  cin>>a[i];
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		{
			ans++;
			if(book==1&&a[i]==x+1){
				book=0;
				ans--;
			}
			else
			{
				book=1;
			}
			x=i;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
def run(n):
    cost = [6**i for i in range(7)]
    cost.extend([9**i for i in range(1, 6)])
    cost = sorted(cost)
    # print(cost)
    
    dp = {0: 0}
    for i in range(1, n+1):
        dp[i] = dp[i-1] + 1
        for c in cost:
            if i >= c:
                dp[i] = min(dp[i-c]+1, dp[i])
            else:
                break
        # print(i, dp[i])
    return dp[n]


def main():
    n = int(input())
    print(run(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 15084
#include<stdio.h>
int main()
{
    int a,b;
    do{
        scanf("%d %d",&a,&b);
        if(a==0 && b==0)
        break;
        for(int i=0;i<a;i++)
        {
        	if(i%2!=0){
        	for(int j=0;j<b;j++)
            {
            	if(j%2==0){
                printf(".");}
                else
                printf("#");
            }}
            else
            for(int j=0;j<b;j++)
            {
            	if(j%2==0){
                printf("#");}
                else
                printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }while(a!=0 && b!=0);
}


Measured memory_bytes: 1928
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b / 2 << endl;
    else cout << 0 << endl;
    
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	(a<9 && b<9)? cout<<"Yay!\n":cout<<":(\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

int main() {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - (x + y);
      if (z < 0) continue;
      if (z <= K) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int m;
	cin >> m;
	ll res = 0;
	vector<ll> d(m), c(m);
	REP(i, m) {
		cin >> d[i] >> c[i];
	}
	vector<vector<int>> pre(10);
	vector<vector<int>> pre2(10);
	vector<vector<ll>> cn(10,vector<ll>(1,0));

	REP(i, 10) {
		int t = i;
		int te = t;
		int cnt = 1;
		pre[i].push_back(0);
		pre2[i].push_back(te);

		te += t;
		if (te >= 10) {
			te = te % 10 + te / 10;
			cnt++;
		}
		pre[i].push_back(cnt);
		pre2[i].push_back(te);
		cn[i].push_back(cnt + cn[i].back());
		while (te != t) {
			cnt = 1;
			te += t;
			if (te >= 10) {
				te = te % 10 + te / 10;
				cnt++;
			}
			pre[i].push_back(cnt);
			pre2[i].push_back(te);
			cn[i].push_back(cnt + cn[i].back());
		}
	}
	vector<int> nok;
	REP(i, m) {
		ll temp = 0;
		ll p = (c[i]-1) / (pre[d[i]].size()-1);
		ll q = (c[i]-1) % (pre[d[i]].size()-1) + 1;
		temp += p * cn[d[i]].back();
		temp += cn[d[i]][q - 1];
		res += temp;
		nok.push_back(pre2[d[i]][q - 1]);
	}
	int temp = 0;
	res += m - 1;
	REP(i, m) {
		temp += nok[i];
		if (temp >= 10) {
			temp = temp % 10 + temp / 10;
			res++;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 4600