akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int n;
int a[200000], b[200000];

int bs(int k){
	int l=0, r=n-1;
	while(l<=r){
		int m=(l+r)/2;
		if(b[m]>=k) r=m-1; else l=m+1;
	}
	return l;
}

int main(void){
	n=nextpint();
	for(int i=0; i<n; i++){
		a[i]=b[i]=nextpint();
	}
	qsort(b, n, 4, comp);
	long ans=0;
	for(int i=0; i<n; i++){
		int l=bs(b[i]);
		int r=bs(b[i]+1);
		int x=r-l-1;
		ans+=x;
	}
	ans>>=1;
	for(int i=0; i<n; i++){
		int l=bs(a[i]);
		int r=bs(a[i]+1);
		int x=r-l-1;
		printf("%ld\n", ans-x);
	}
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int gcd(int x, int y) {
    return y ? gcd(y, x%y) : x;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    inc(i, 0, n) cin >> a[i];
    vector<int> l(n), r(n);
    l[0] = a[0];
    r[n-1] = a[n-1];
    inc(i, 1, n){
        l[i] = gcd(l[i-1], a[i]);
    }
    dec(i, 0, n-1){
        r[i] = gcd(r[i+1], a[i]);
    }
    int ans = max(r[1], l[n-2]);
    inc(i, 1, n-1){
        ans = max(ans, gcd(l[i-1], r[i+1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#すぬけくんが行くレストランは何を食べても 1食 800円
#15食食べる毎にその場で 200円もらえます。
#すぬけくんは今までで合計 N 食、食べました。
#今までに払った金額を x 円
#レストランからもらった金額を y 円
# x−y を求めなさい。

# 標準入力から食事回数（N）を取得する
input_num = int(input())

# x - y （円）を計算し出力する。
# x：今までに払った金額
x = input_num * 800

# y：レストランからもらった金額
y = int(input_num / 15) * 200

# 差額
result = x - y

print(result)

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

// use unordered_map to save memory usage
unordered_map<int, int> mp;
int get(int x) {
  int ret = mp[x];
  if (ret == 0) {
    mp.erase(x);
    ret = INT_MAX/2;
  }
  return ret;
}

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

  string s; cin >> s;
  int n=s.size();
  vector<int> a(n);
  a[0] = 1<<(s[0] - 'a');
  for(int i=1; i<n; i++) {
    a[i] = a[i-1] ^ (1<<(s[i]-'a'));
  }

  mp[0]=1;

  int opt;
  for(int i=0; i<n; i++) {
    int ai = get(a[i]);
    int mi = ai;
    for(int j=0; j<26; j++) {
      int x = 1<<j;
      chmin(mi, get(x^a[i]));
    }
    opt = mi+1;
    if (opt < ai) {
      mp[a[i]] = opt;
    }
  }

  cout << opt-1 << endl;
}


Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,x;cin>>a>>b>>x;
  x/=a;
  if((double)a*b/2>=(double)x){
    cout << fixed << setprecision(15)<<atan(b*b/(2*x))*180/(4*atan(1))<<endl;
    return 0;
  }
  else{
    cout << fixed << setprecision(15)<<atan(2*(a*b-x)/(a*a))*180/(4*atan(1))<<endl;
    return 0;
  }
}

Measured memory_bytes: 3928
#include<stdio.h>

void binary();

int num;
int set[100000000];
int count = 0;

int main(){
  int i;
  int j;
  int Qdata;
  int Time[500000];

  scanf("%d",&num);

  for(i = 0;i < num;i++){
    scanf("%d",&set[i]);
  }

  scanf("%d",&Qdata);

  for(i = 0;i < Qdata;i++){
    scanf("%d",&Time[i]);
    binary(Time[i]);
  }

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

void binary(int data){
  int left = 0;
  int right = num;

  while(left < right){
    int mid = (left + right) / 2;

    if(data == set[mid]){
      count++;
      break;
    }

    else if(data < set[mid]){
      right = mid;
    }

    else{
      left = ++mid;
    }
  }
}



Measured memory_bytes: 2292
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int l, n;
int x[200001];
llong sum[200001];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> l >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i];
    llong ans = 0;
    for (int it = 0; it < 2; ++it) {
    for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + x[i];
    for (int i = 0; i <= n; ++i) {
        int k = n - i;
        int s = x[i];
        ans = max(ans, s + ((l + s) * ((k + 1) / 2ll) - (sum[n] - sum[n - (k + 1) / 2])
                        + (sum[i + k / 2] - sum[i]) - s * (k / 2ll)) * 2ll
                        - ((k & 1) ? s + l - x[n - (k + 1) / 2 + 1] : x[i + k / 2] - s));
    }
    for (int i = 1; i <= n; ++i) x[i] = l - x[i];
    reverse(x + 1, x + n + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

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

int n, a[nmax];
map<int, int> cnt;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    if ((n + a[i] + 1) % 2)
      return 0 * printf("0\n");
  }

  for (const auto& e : cnt) {
    int x = e.first, y = e.second;
    if (x != 0 && y != 2) return 0 * printf("0\n");
  }

  if ((n - cnt[0]) % 2) return 0 * printf("0\n");
  int m = (n - cnt[0]) / 2;
  int ans = 1;
  for (int i = 1; i <= m; i++) {
    ans += ans;
    if (ans >= mod) ans -= mod;
  }

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


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  string t="CODEFESTIVAL2016";
  cin>>s;
  int ans=0;
  rep(i,s.size()){
    if(s[i]!=t[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){//double 处理果盘
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(),num=0;
		int k = in.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++){
			h[i] = in.nextInt();
		}
		for (int i=0;i<n;i++){
			if(h[i]>=k){
				++num;
			}
		}
		System.out.println(num);
	}
}	
		

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

n=int(input())
L=list(map(int,input().split()))

dp = [1000]*n

for i in range(n):
    dp[i]=max(dp[i-1],dp[i])
    st,rest=divmod(dp[i],L[i])
    for j in range(i+1,n):
        dp[j] = max(dp[j],L[j]*st+rest)
print(dp[-1])

    
        
        


Measured memory_bytes: 65000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        double[] list = new double[lines.length];
        int n = lines.length;
        while (n-- > 0) {
            list[n] = Double.parseDouble(lines[n]);
        }
        double a = list[0];
        double b = list[1];
        double radian = Math.PI * list[2] / 180.0;
        double s = a * b * Math.sin(radian) / 2;
        double l = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(radian));
        double h = b * Math.sin(radian);
        System.out.printf("%f\n%f\n%f\n", s, l, h);
    }
}

Measured memory_bytes: 24648
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	cout << max((int)0, A - 2 * B) << endl;
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

int dfs(int node,bool vis[],vector<int> v[])
{
	int curr=0;
	vis[node]=true;
	for(auto x:v[node])
	{
		if(!vis[x])
			curr+=dfs(x,vis,v);
	}

	return curr+1;
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n,m;
    cin>>n>>m;

    vector<int> v[n];
    map<pair<int,int>,bool> mp;
    for(int i=0;i<m;i++)
    {
    	int x,y;
    	cin>>x>>y;
    	x--;y--;
    	if(mp[{x,y}]) 
    		continue;

    	v[x].pb(y);
    	v[y].pb(x);
    	mp[{x,y}]=1;
    	mp[{y,x}]=1;
    }

    bool vis[n]={false};
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	if(!vis[i])
    		ans=max(ans,dfs(i,vis,v));
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 49068
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

type Card struct {
	suit  string
	value int
}

const INF = 1000000001
const MAX = 500000

var (
	sc   = bufio.NewScanner(os.Stdin)
	cnt  = 0
	L, R = make([]Card, MAX), make([]Card, MAX)
)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func merge(A []Card, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	dummy := Card{suit: "dummy", value: INF}
	L[n1], R[n2] = dummy, dummy

	l, r := 0, 0
	for i := left; i < right; i++ {
		cnt++
		if L[l].value <= R[r].value {
			A[i] = L[l]
			l++
		} else {
			A[i] = R[r]
			r++
		}
	}
}

func mergeSort(A []Card, left, right int) {
	if left+1 < right {
		mid := (left + right) / 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)
	}
}

func partition(A []Card, p, r int) int {
	x := A[r]
	i := p - 1
	for j := p; j < r; j++ {
		if A[j].value <= x.value {
			i++
			A[i], A[j] = A[j], A[i]

		}
	}
	A[i+1], A[r] = A[r], A[i+1]
	return i + 1
}

func quickSort(A []Card, p, r int) {
	if p < r {
		q := partition(A, p, r)
		quickSort(A, p, q-1)
		quickSort(A, q+1, r)
	}
}

func isChanged(A, B []Card) bool {
	for i := range A {
		if A[i].suit != B[i].suit || A[i].value != B[i].value {
			return true
		}
	}
	return false
}

func main() {
	n := scanInt()
	A := make([]Card, n)
	B := make([]Card, n)
	for i := range A {
		A[i] = Card{suit: scanString(), value: scanInt()}
		B[i] = A[i]
	}
	quickSort(A, 0, n-1)
	mergeSort(B, 0, n)

	if isChanged(A, B) {
		fmt.Println("Not stable")
	} else {
		fmt.Println("Stable")
	}

	buf := bytes.Buffer{}
	for _, card := range A {
		buf.WriteString(card.suit)
		buf.WriteString(" ")
		buf.WriteString(strconv.Itoa(card.value))
		buf.WriteString("\n")
	}

	fmt.Print(buf.String())
}



Measured memory_bytes: 15668
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n, k;

void solve()
{
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
	{
		cout << s << "es" << '\n';
	}
	else
	{
		cout << s << "s\n";
	}

}

signed main()
{
	io();
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

Measured memory_bytes: 3648
A, B, C, D = map(int, input().split(' '))

if B < C or A > D:
    print(0)
elif A <= C and D <= B:
    print(abs(C-D))
elif C <= A and B <= D:
    print(abs(B-A))
elif C <= A and D <= B:
    print(abs(D-A))
else:
    print(abs(B-C))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
//#define x first
//#define y second

using namespace std;
map<int,bool>k;
int main()
{
	int a[3][3],b,n;
	rep(i,3) rep(j,3) cin>>a[i][j];
	cin>>n;
	rep(i,n)
	{
		cin>>b;
		k[b]=1;
	}
	rep(i,3)
	{
		bool t=1;
		rep(j,3) if(!k.count(a[i][j])) t=0;
		if(t)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		t=1;
		rep(j,3) if(!k.count(a[j][i])) t=0;
		if(t)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	bool t=1;
	rep(j,3) if(!k.count(a[j][j])) t=0;
	if(t)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	t=1;
	rep(j,3) if(!k.count(a[j][2-j])) t=0;
	if(t)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;

  vector<vector<pair<int, int>>> p_to_qs(n);
  for (int i = 0; i < n; i++) {
    int q_count;
    cin >> q_count;
    for (int j = 0; j < q_count; j++) {
      int p, a;
      cin >> p >> a;
      p--;
      p_to_qs[i].push_back(make_pair(p, a));
    }
  }

  auto solve_set_fn = [&](int set) {
    for (int i = 0; i < n; i++) {
      if (set & (1 << i)) {
        for (const auto& q : p_to_qs[i]) {
          int t_p;
          int flag;
          tie(t_p, flag) = q;
          if (flag == 1 && ((set & (1 << t_p)) == 0)) return false;
          if (flag == 0 && ((set & (1 << t_p)) > 0)) return false;
        }
      }
    }
    return true;
  };

  auto bit_count_fn = [&](int x) {
    int r = 0;
    for (int i = 0; i < n; i++) {
      if (x & (1 << i)) r++;
    }
    return r;
  };

  int ans = 0;
  for (int s = 0; s < (1 << n); s++) {
    if (solve_set_fn(s)) {
      UpdateMax(ans, bit_count_fn(s));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc160/tasks/abc160_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll X;
  cin >> X;

  ll res = 0;

  ll a = X / 500;
  res += a * 1000;
  X -= a * 500;

  ll b = X / 5;
  res += b * 5;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
  int n, i, j, k, xlen, ylen;
  char x[1003], y[1003];
  int c[1001][1001];
  char buf[20];
  buf[19]='\0';
  scanf("%d\n", &n);
  for (k=0; k<n; k++) {
    fgets(x, 1002, stdin);
    xlen = strlen(x);
    if (x[xlen-1]=='\n') x[xlen-- -1]='\0';
    fgets(y, 1002, stdin);
    ylen = strlen(y);
    if (y[ylen-1]=='\n') y[ylen-- -1]='\0';

    c[0][0]=0;
    
    for (i=0; i<xlen; i++) {
      for (j=0; j<ylen; j++) {
        if (x[i]==y[j]) 
          c[i+1][j+1] = c[i][j]+1;
        else
          c[i+1][j+1] = c[i][j+1] > c[i+1][j] ? c[i][j+1] : c[i+1][j];
      }
    }
    if (c[xlen][ylen]==0) puts("0");
    else {
    for (i=18; c[xlen][ylen]>0; c[xlen][ylen]/=10) buf[i--]=(c[xlen][ylen]%10)+'0';
    puts(buf+i+1);
    }
  }
  return 0;
}


Measured memory_bytes: 5564
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int ans=0;
  int b=1;
  for(int i=0;i<N-1;i++){
    if(a.at(i)==a.at(i+1)){
      b++;
    }
    else{
      if(b>=a.at(i)){
        ans+=b-a.at(i);
      }
      else{
        ans+=b;
      }
      b=1;
    }
  }
  if(b>=a.at(N-1)){
    ans+=b-a.at(N-1);
  }
  else{
    ans+=b;
  }
    cout<<ans<<endl;
  
}

Measured memory_bytes: 640
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(n)]
AB.sort(key=lambda A:A[0])
okane=0
remain=m
for i in range(n):
    if remain>0:
        if remain-AB[i][1]>0:
            okane+=AB[i][1]*AB[i][0]
            remain-=AB[i][1]
        else:
            okane+=remain*AB[i][0]
            remain=0
    else:
        break
print(okane)

Measured memory_bytes: 29024
def main():
  n=int(input())
  T,X,Y=0,0,0
  for _ in [0]*n:
    t,x,y=map(int,input().split())
    if (t-T<abs(x-X)+abs(y-Y)) or (t-T+abs(x-X)+abs(y-Y))%2!=0:
      print('No')
      exit()
  print('Yes')
if __name__=='__main__':
  main()

Measured memory_bytes: 3828
import sys
from collections import defaultdict

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


class UnionFind:
    def __init__(self, size):
        self.par = [i for i in range(size)]
        self.rk = [0] * size

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rk[x] < self.rk[y]:
            self.par[x] = y
        elif self.rk[x] > self.rk[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            self.rk[y] += 1


N, M, K = map(int, input().split())
uf = UnionFind(N)
friend = defaultdict(set)
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf.unite(a, b)
    friend[a].add(b)
    friend[b].add(a)

block = defaultdict(set)
for _ in range(K):
    c, d = map(lambda x: int(x) - 1, input().split())
    block[c].add(d)
    block[d].add(c)

group = defaultdict(set)
for i in range(N):
    group[uf.find(i)].add(i)

ans = [0] * N
for people in group.values():
    for p in people:
        ans[p] = len(people) - 1 - sum(1 if i in people else 0 for i in friend[p]) - sum(1 if i in people else 0 for i in block[p])

print(' '.join(map(str, ans)))




Measured memory_bytes: 141256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
#include <queue>
#include <stack>
using namespace std;

int main(){
  int N, L; cin >> N >> L;
  vector<string> S(N);
  for(auto &s : S) cin >> s;
  sort(S.begin(), S.end());
  for(auto &s : S) cout << s;
  cout << endl;
}


Measured memory_bytes: 256
import copy
N=int(input())
p=list(map(int,input().split()))
s=sorted(p)
if s==p:
  print('YES')
else:
  flag=0
  tmp=[]
  for i in range(N):
    for j in range(i+1,N):
      tmp=copy.deepcopy(p)
      tmp[i],tmp[j]=tmp[j],tmp[i]
      if tmp == s:
        flag=1
  print('NYOE S'[flag::2])

Measured memory_bytes: 3444
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	s1a := make([]rune, b)
	s2a := make([]rune, a)
	var c rune
	c = []rune(fmt.Sprintf("%d", a))[0]
	for i := 0; i < b; i++ {
		s1a[i] = c
	}
	c = []rune(fmt.Sprintf("%d", b))[0]
	for i := 0; i < a; i++ {
		s2a[i] = c
	}
	s1 := string(s1a)
	s2 := string(s2a)
	if s1 < s2 {
		fmt.Printf("%s\n", s1)
	} else {
		fmt.Printf("%s\n", s2)
	}
}


Measured memory_bytes: 512
N, M = map(int, input().split())
drinks = []  # (price, quantity)
for i in range(N):
    drinks.append(tuple(map(int, input().split())))

drinks = sorted(drinks, key=lambda d: d[0])
i = 0
while M > 0:
    M -= drinks[i][1]
    i += 1
ans = sum([d[0] * d[1] for d in drinks[:i]])
if M < 0:
    ans -= abs(M) * drinks[i - 1][0]
print(ans)


Measured memory_bytes: 18912
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int n;
    cin>>n;
    double ans;
    if(n%2==0){
        ans=1.0/2.0;
    }else{
        ans=(n+1)/2.0/n;
    }
    cout<<fixed<<setprecision(7)<<ans;
    return 0;
}


Measured memory_bytes: 256
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=2e6+5,M=2e5+5;
int n;
int head[N],to[N*4],Next[N*4],cnt;
void add(int x,int y)
{
	Next[++cnt]=head[x];head[x]=cnt;to[cnt]=y;
}
int dep[M],ans[M];
vector<int> v[3];
void dfs(int x,int fa)
{
	dep[x]=dep[fa]+1;
	v[dep[x]&1].pb(x);
	for(int i=head[x];i;i=Next[i])
	{
		int u=to[i];
		if(fa==u) continue;
		dfs(u,x);
	}
}
bool vis[M];
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	cin>>n;
	for(i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	dfs(1,1);
	int num=n/3;
	if(v[1].size()<v[0].size())
		swap(v[0],v[1]);
	
	if(v[0].size()<=num)
	{
		for(i=0;i<v[0].size();i++)
		{
			ans[v[0][i]]=(i+1)*3;
			vis[(i+1)*3]=1;
		}
		int tot=1;
		for(i=0;i<v[1].size();i++)
		{
			while(vis[tot]) tot++;
			ans[v[1][i]]=tot;
			vis[tot]=1;
		}
	}
	else 
	{
		int num1=num+(n%3>=1);
		for(i=0;i<num1;i++)
		{
			ans[v[0][i]]=i*3+1;
			vis[i*3+1]=1;
		}
		int j=0;
		for(i;i<v[0].size();i++)
		{
			j++;
			ans[v[0][i]]=j*3;
			vis[j*3]=1;
		}
		int tot=1;
		for(i=0;i<v[1].size();i++)
		{
			while(vis[tot]) tot++;
			ans[v[1][i]]=tot;
			vis[tot]=1;
		}
	}
	for(i=1;i<=n;i++)
		cout<<ans[i]<<" ";
}
/*
7
1 2
2 3
3 4
4 5
5 6
6 7
*/

Measured memory_bytes: 16884
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10桁出力 cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	LL a, b, x;
	cin >> a >> b >> x;
	LL ans = 0;
	
	// 0からbまでの割り切れる個数
	LL bx = b / x;
	// 0からa-1までの割り切れる個数
	LL ax = 0;
	if (a == 0) {
		bx++;
	}
	else {
		ax = (a - 1) / x;
	}
	ans = bx - ax;
	cout << ans << endl;


	return 0;
}

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

int main(){
	long long N,P;cin>>N>>P;
	map<long long,int> m;
	for(long long i=2;i*i<=P;i++){
		while(P%i == 0){
			m[i] += 1;
			P /= i;
		}
	}
	
	if(P > 1) m[P] += 1;
	long long ans = 1;
	for(auto x: m) {
		int times = x.second / N;
		for(int i=0;i<times;i++) ans *= x.first;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
using namespace std;
#define ll long long
#define fr(n) for(ll i = 0; i < n; i++)

#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
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s1,s2;
    cin >> s1 >> s2;
    int l1 = s1.length();
    int l2 = s2.length();
    int c[l1+1][l2+1];
    string lcs = "";
    for(int i = 0; i <= l1; i++) c[i][0] = 0;
    for(int i = 0; i <= l2; i++) c[0][i] = 0;
    for(int i = 1; i <= l1; i++){
        for(int j = 1; j <= l2; j++){
            if(s1[i-1] == s2[j-1]){
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max( c[i-1][j] , c[i][j-1] );
            }
        }
    }
    
    int i = l1; int j = l2;
    while(i >= 1 && j >= 1){
        // trace(i,j);
        if( c[i][j] > c[i-1][j] && c[i][j] > c[i][j-1]){
            lcs += s1[i-1];
            i--;j--;
        }else if( c[i-1][j] > c[i][j-1] ){
            i--;
        }else{
            j--;
        }
        
    }
    // cout << lcs << endl;
    for(int i = lcs.length()-1; i >= 0; i-- ) cout << lcs[i];


    
    
}

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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = inputs[0];
            var b = inputs[1];
            var c = inputs[2];

            if (a[a.Length - 1] != b[0] || b[b.Length - 1] != c[0])
            {
                Console.WriteLine("NO");
                return;
            }

            Console.WriteLine("YES");
        }
    }
}


Measured memory_bytes: 25732
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
long long int all[100005];
bool F(long long int a,long long int b)
{
    return a<b;
}
int main()
{
    long long int N,M,i,j,k,ans=0,con=0,l,r,t1,t2,a,b,c,d;
    scanf("%lld",&N);
    l=1;
    r=N-1;
    for(i=0;i<N;i++)
    {
        scanf("%lld",&all[i]);
    }

    sort(all,all+N,F);
    t1=t2=all[0];
    for(con=1;con<N;con++)
    {
        if(abs(all[r]-t1)>=abs(all[r]-t2))
        {
            if(abs(all[l]-t1)>=abs(all[l]-t2))
            {
                if(abs(all[r]-t1)>=abs(all[l]-t1))
                {
                    ans+=abs(all[r]-t1);
                    t1=all[r];
                    r--;
                }
                else
                {
                    ans+=abs(all[l]-t1);
                    t1=all[l];
                    l++;
                }
            }
            else
            {
                if(abs(all[r]-t1)>=abs(all[l]-t2))
                {
                    ans+=abs(all[r]-t1);
                    t1=all[r];
                    r--;
                }
                else
                {
                    ans+=abs(all[l]-t2);
                    t2=all[l];
                    l++;
                }
            }
        }
        else
        {

            if(abs(all[l]-t1)>=abs(all[l]-t2))
            {
                if(abs(all[r]-t2)>=abs(all[l]-t1))
                {
                    ans+=abs(all[r]-t2);
                    t2=all[r];
                    r--;
                }
                else
                {
                    ans+=abs(all[l]-t1);
                    t1=all[l];
                    l++;
                }
            }
            else
            {
                if(abs(all[r]-t2)>=abs(all[l]-t2))
                {
                    ans+=abs(all[r]-t2);
                    t2=all[r];
                    r--;
                }
                else
                {
                    ans+=abs(all[l]-t2);
                    t2=all[l];
                    l++;
                }
            }
        }



    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1152
#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)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int count = 0;
    REP(i,A+1){
        REP(j,B+1){
            REP(k,C+1){
                if(500*(i)+100*(j)+50*(k) == X){
                    count++;
                }
            }
        }
    }
    cout << count <<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=10+3;
char s[MAXN];
int len;
long long ans;
bool vis[MAXN];
void dfs(int k){
	if(k==len-1){
		long long cnt=0;
		for(int i=0;i<len-1;i++){
			cnt=cnt*10+s[i];
			if(vis[i]){
				ans+=cnt;
				cnt=0;
			}
		}
		ans+=cnt*10+s[len-1];
		return;
	}
	vis[k]=0;
	dfs(k+1);
	vis[k]=1;
	dfs(k+1);
}
int main(){
	scanf("%s",&s);
	len=strlen(s);
	for(int i=0;i<len;i++){
		s[i]-='0';
	}
	dfs(0);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	ll h; cin >> h;
	ll ans = 0;
	ll add = 1;
	while(h){
		h /= 2;
		ans += add;
		add *= 2;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=5005,mod=1e9+7,inv2=(mod+1)/2;
int f[N][N],s2[N][N],pw[N],ipw[N],n,m,ans;

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1) res=(ll)res*x%mod;
	return res;
}
int mul(int x,int y){
	return (ll)x*y%mod;
}
void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}
int pw2(int x){
	return x>=0?pw[x]:ipw[-x];
}

int main(){
	read(n),read(m);
	swap(n,m);
	pw[0]=ipw[0]=1;
	rep(i,1,5000){
		pw[i]=mul(pw[i-1],2);
		ipw[i]=mul(ipw[i-1],inv2);
	}
	rep(i,1,n){
		f[0][i]=1;
		s2[0][i]=mul(i,pw2(-i));
		add(s2[0][i],s2[0][i-1]);
	}
	rep(i,1,m){
		rep(j,1,n){
			f[i][j]=mul(j+1,f[i-1][j]);
			if(j>=2) add(f[i][j],mul(s2[i-1][j-1],pw2(j-1)));
			s2[i][j]=mul(f[i][j],mul(j,pw2(-j)));
			add(s2[i][j],s2[i][j-1]);
		}
	}
	cout<<f[m][n]<<endl;
	return 0;
}


Measured memory_bytes: 199160
#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

int main(int, char**)
{
	unsigned int n, h, w;
	unsigned long long ans = 0;

	std::cin >> n >> h >> w;

	for (unsigned int i = 0; i < n; ++i) {
		unsigned int x, y;
		cin >> x >> y;
		if (x >= h && y >= w)
			ans++;
	}
	
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<int> > GRAPH(N);
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
  vector<int> used(N,-1);
  vector<int> mark(N,-1);
  queue<int> q;
  q.push(0);
  while(!q.empty())
  {
    int V = q.front();
    q.pop();

    if(used[V] != -1)continue;
    used[V] = 1;
    for (auto &&i : GRAPH[V])
    {
      if(used[i] == -1)
      {
        q.push(i);
        if(mark[i] == -1)
        mark[i] = V;
      }
    }
  }

  for (int i = 0; i < N; i++)
  {
    if(used[i] == -1)
    {
      cout<<"No"<<endl;
      return;
    }
    
  }
  cout<<"Yes"<<endl;
  for (int i = 1; i < N; i++)
  {
    cout<<mark[i]+1<<endl;
  }
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 13940
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
#define f first
#define s second
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

bool pairCompare(const pair<pair<string, ll>, ll>& firstElof, const pair<pair<string, ll>, ll>& secondElof)
{
	if(firstElof.f.f!=secondElof.f.f)
		return firstElof.f.f < secondElof.f.f;
	else
		return firstElof.f.s > secondElof.f.s;
}

int main()
{
	// 入力
	ll N;
	cin >> N;
	vector<pair<pair<string, ll>, ll>> rest(N);
	REP(i, N) {
		string s;
		ll  p;
		cin >> s >> p;
		rest[i].f = make_pair(s, p);
		rest[i].s = i+1;
	}

	sort(rest.begin(), rest.end(), pairCompare);

	REP(i,N){
		cout<<rest[i].s<<endl;
	}



	return 0;
}

Measured memory_bytes: 256
program ABC064C
    implicit none
    integer(8)::N,i
    integer(8),allocatable,dimension(:)::A
    integer(8),dimension(9)::flgs
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    flgs=0

    do i=1,N
        if(A(i)<=399)then
            if(flgs(1)==0)then
                flgs(1)=1
            end if
        else if(A(i)<=799)then
            if(flgs(2)==0)then
                flgs(2)=1
            end if
        else if(A(i)<=1199)then
            if(flgs(3)==0)then
                flgs(3)=1
            end if
        else if(A(i)<=1599)then
            if(flgs(4)==0)then
                flgs(4)=1
            end if
        else if(A(i)<=1999)then
            if(flgs(5)==0)then
                flgs(5)=1
            end if
        else if(A(i)<=2399)then
            if(flgs(6)==0)then
                flgs(6)=1
            end if
        else if(A(i)<=2799)then
            if(flgs(7)==0)then
                flgs(7)=1
            end if
        else if(A(i)<=3199)then
            if(flgs(8)==0)then
                flgs(8)=1
            end if
        else
            flgs(9)=flgs(9)+1
        end if
    end do

    print'(i0,1x,i0)',max(sum(flgs(1:8)),1),sum(flgs)
end program ABC064C

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n, m; cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n));
    vector<vector<char>> b(m, vector<char>(m));
    rep(i, n) {
        string s; cin >> s;
        rep(j, n) a[i][j] = s[j];
    }
    rep(i, m) {
        string s; cin >> s;
        rep(j, m) b[i][j] = s[j];
    }
    rep(i, n-m+1) {
        rep(j, n-m+1) {
            bool fl = true;
            rep(k, m) {
                rep(l, m) {
                    if(a[i+k][j+l] != b[k][l]) fl = false;
                }
            }
            if(fl) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
pii a[N];
pii b[N];
int p[N];
int n;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i].first);
		b[i].second = i;
	}
	sort(a, a + n);
	sort(b, b + n);
	for (int i = 0; i < n; i++)
		if (a[i].first > b[i].first) {
			printf("No\n");
			return 0;
		}
	for (int i = 0; i < n - 1; i++) {
		if (a[i + 1].first <= b[i].first) {
			printf("Yes\n");
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		p[a[i].second] = b[i].second;
	}
	int x = 0;
	int len = 0;
	do {
		x = p[x];
		len++;
	} while(x != 0);
	if (len == n)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}


Measured memory_bytes: 2176
N = int(input())
S = input()
white = black = 0
W = S.count('.')
B = N - W #黒石の数
answer = W
for i in range(N):
    if S[i] == '.':
        white += 1
    else:
        black += 1
    change = black + W - white
    if change < answer:
        answer = change
    
print(answer)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
  set<int> S;
  int N;
  cin >> N;
  vector<int> data(N);
  rep(i,0,N){
      int a;
      cin >> a;
      data.at(i) = a;
  }
  int check = 0;
  for(int i:data){
      if(S.count(i)){
          check = 1;
          break;
      }else{
          S.insert(i);
      }
      
  }
  if(check ==1 ){
      cout << "NO" << endl;
  }else{
      cout << "YES" << endl;
  }

  return 0;
}

Measured memory_bytes: 10368
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	LL ans = 0;
	for(int i=0;i<N;++i){
		LL L,R;
		cin >> L >> R;
		ans +=(R-L+1);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
use proconio::{fastout, input};

fn gcd(x: i64, y: i64) -> i64 {
    let mut x = x;
    let mut y = y;
    if x == 0 {
        return y;
    } else if y == 0 {
        return x;
    }
    if x < y {
        let temp = x;
        x = y;
        y = temp;
    }
    let m = x % y;
    if m == 0 {
        y
    } else {
        gcd(y, m)
    }
}

const A: i64 = 1_000_005;

#[fastout]
fn main() {
    input! {
        n: usize,
        a_vec: [i64; n],
    };
    let mut c_vec: Vec<i64> = vec![0; A as usize];
    a_vec
        .iter()
        .for_each(|a| *c_vec.get_mut(*a as usize).unwrap() += 1);
    let mut pairwise = true;
    for i in 2..A as usize {
        let mut cnt = 0;
        for j in (i..A as usize).step_by(i) {
            cnt += c_vec[j];
        }
        if cnt > 1 {
            pairwise = false;
        }
    }
    if pairwise {
        println!("pairwise coprime");
        return;
    }

    let mut g = 0;
    for i in 0..n {
        g = gcd(g, a_vec[i]);
    }
    if g == 1 {
        println!("setwise coprime");
        return;
    }
    println!("not coprime");
}


Measured memory_bytes: 24560
# include <bits/stdc++.h>
using namespace std;
# define int long long
const int N = 2e5 + 10, mod = 1e9 + 7, INF = 8e18;
int n, m, r, p, s, ans = 0;
string t;
bool c[N];
int rps(char c){
	if(c == 'r')return p;
	if(c == 'p')return s;
	if(c == 's')return r; 
}
main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> r >> s >> p >> t; 
	for(int i = 0; i < n; i ++){
		if(i >= m && t[i] == t[i - m]){
			if(c[i - m] == true){
				ans += rps(t[i]);
				continue;
			}
			c[i] = true;
			continue;
		}
		ans += rps(t[i]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 592
# -*- coding: utf-8 -*-

import sys
import os

s = input().strip()

apple_key = 'a)@#%^(@#)$&@'
peach_key = 'p#*$^(#$&#)(*'

s = s.replace('apple', apple_key)
s = s.replace('peach', peach_key)

s = s.replace(apple_key, 'peach')
s = s.replace(peach_key, 'apple')

print(s)

Measured memory_bytes: 7300
#include<stdio.h>

int s[100001];
int main() {
	int n; scanf("%d", &n);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		if (s[a] == i)cnt++;
		s[i] = a;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 512