akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

//i番目のビットを返す
bool getBit(int num, int i){
	return ((num & (1 << i)) != 0);
}

//i番目を1にする
int setBit(int num, int i){
	return num | (1 << i);
}

//i番目を0にする
int clearBit(int num, int i){
	int mask = ~(1 << i);
	return num & mask;
}

//i番目をvで置き換える
int updateBit(int num, int i, int v){
	int mask = ~(1 << i);
	return (num & mask) | (v << i);
}

signed main() {
	int n;
	cin >> n;

	vector<pair<int, int>> p(n);
	set<int> s;
	rep(i, n) {
		cin >> p[i].first;
		s.emplace(p[i].first);
	}
	rep(i, n) {
		cin >> p[i].second; 
		s.emplace(p[i].second);
	}
	rep(i, n){
		p[i].first = distance(s.begin(), s.lower_bound(p[i].first));
		p[i].second = distance(s.begin(), s.lower_bound(p[i].second));
	}

	//for(auto i : p){ cout << i << endl; }

	vector<vector<int>> dp(1 << n, vector<int>(36, 1e9));
	rep(i,36) dp[0][i] = 0;
	// dp[s][n] := 集合 s のカードを左から置いて，その時の最大値が n で，その時の転倒数が dp[s][n]

	rep(s,1 << n){
		int cost = 0; // 必要なスワップ回数
		rep(i,n){ // i := 新しく置くカード番号
			if(getBit(s, i)) continue;
			int loc = bitset<18>(s).count(); // 左からなんばんめに置くか
			int cur_num = abs(i - loc) % 2 == 0 ? p[i].first : p[i].second;
			rep(m, cur_num + 1){
				dp[setBit(s, i)][cur_num] = min(
						dp[setBit(s, i)][cur_num],
						dp[s][m] + cost
						);
				//cout << bitset<18>(setBit(s, i)) << ' ' << cur_num << ' ' << dp[setBit(s,i)][cur_num] << endl;
			}
			cost++;
		}
	}

	int ans = *min_element(all(dp.back()));
	if(ans == 1e9) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

lint MOD = 1e9 + 7;


int main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    
    int sum = 0;
    
    for(int i = 0; i < N; ++i){
        cin >> W[i];
        sum += W[i];
    }
    
    int smallest = sum;
    
    int ps = 0;
    for(int i = 0; i < N; ++i){
        ps += W[i];
        int temp = sum - ps;
        if(abs(temp - ps) <= smallest){
            smallest = abs(temp - ps);
        }
    }
    
    cout << smallest << endl;
}

Measured memory_bytes: 256
# にぶたん練習
n,k=map(int,input().split())
a=list(map(int,input().split()))

# カット後のaの最大長を取り、カット数を計算する
# k以下でカット可能ならばTrueを返す。
# にぶたんは、効率良くT/Fを判定できる関数が作れるかがみそ。
def f(n):
  cnt=0
  for aa in a:
    cuta=(aa-1)//n # (ceil(aa/n))と同値？良くわからない。
    cnt+=cuta
  if cnt>k:
    return False
  return True

# にぶたん実装
l,r=0,max(a)
while r-l>1:
  m=(r+l)//2
  if f(m):
    r=m
  else:
    l=m

# 今回は、rが必要な値。厳密な値は(l<x<=r)になるので、小数点切り上げでrとなる。
print(r)


Measured memory_bytes: 30804
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new C().doIt();
    }
    class C{
    	ArrayList<Integer> array = new ArrayList<Integer>();
    	ArrayList<Integer> array2 = new ArrayList<Integer>();
    	ArrayList<Integer> array3 = new ArrayList<Integer>();
        void doIt(){
        	int a[] = new int [1000001];
        	int b[] = new int [1000001];
        	int num = 1;
        	int cnt = 2;
        	while(num <= 1000000){
//        		System.out.println(num);
        		array.add(num);
        		num = num + cnt;
        		cnt += 1;
        	}
        	num = 1;cnt = 1;
        	while(num <= 1000000){
//        		System.out.println(num);
        		array2.add(num);
        		if(num % 2 == 1){
        			array3.add(num);
//        			System.out.println(num);
        		}
        		num = num + array.get(cnt);
        		cnt += 1;
        	}
//        	System.out.println(array2.size()+" "+array3.size());
        	Arrays.fill(a,100000);
        	a[0] = 0;
        	int length = array2.size();
        	for(int i = 0;i < 1000000;i++){
        		for(int j = 0;j < length;j++){
        			int pos = array2.get(j);
        			if(i + pos > 1000000)break;
        			a[i+pos] = Math.min(a[i]+1,a[i+pos]);
        		}
        	}
        	Arrays.fill(b,100000);
        	b[0] = 0;
        	length = array3.size();
        	for(int i = 0;i < 1000000;i++){
        		for(int j = 0;j < length;j++){
        			int pos = array3.get(j);
        			if(i + pos > 1000000)break;
        			b[i+pos] = Math.min(b[i]+1,b[i+pos]);
        		}
        	}
//        	for(int i = 0;i < 501;i++){
//        		System.out.println(i+" "+a[i]+" "+b[i]);
//        	}
        	while(true){
        		int n = sc.nextInt();
        		if(n == 0)break;
        		System.out.println(a[n]+" "+b[n]);
        	}
        }
    }
}

Measured memory_bytes: 35856
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}




int main(){
    double n,m;
    cin>>n>>m;
    vector<double> a(n);
    double sum = 0;
    for(ll i = 0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }
    
    sort(a.begin(),a.end(), greater<ll>());
    ll count = 0;
    for(ll i = 0; i<m; i++){
        if(a[i]<sum/(4*m))count++;
    }
    if(count != 0)puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=5e5;
int n,k,S,s[N];
int main()
{
    scanf("%d%d%d",&n,&k,&S);
	if(S==1000000000)
	{
		for(int i=1;i<=k;i++)printf("%d ",1000000000);
		for(int i=k+1;i<=n;i++)printf("%d ",1000000000-1);
	}
	else
	{
		for(int i=1;i<=k;i++)printf("%d ",S);
		for(int i=k+1;i<=n;i++)printf("%d ",1000000000);
	}
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005];
	scanf("%s", s);
	int i, n = strlen(s);
	int ans[100005];
	for (i = 0; i < n; i++)
		ans[i] = 0;
	int a, b;
	for (i = 0; i < n; i++)
	{
		a = b = 0;
		while (s[i] == 'R')
		{
			if ((a + b) % 2 == 0)
				a++;
			else
				b++;
			i++;
		}
		i--;
		if ((a + b) % 2 == 0)
		{
			ans[i] += b;
			ans[i + 1] += a;
		}
		else
		{
			ans[i] += a;
			ans[i + 1] += b;
		}
		a = i;
		i++;
		while (s[i] == 'L')
		{
			if ((i - a) % 2 == 0)
				ans[a]++;
			else
				ans[a + 1]++;
			i++;
			if (i == n)
				break;
		}
		if (i == n)
			break;
		i--;
	}
	for (i = 0; i < n - 1; i++)
		printf("%d ", ans[i]);
	printf("%d\n", ans[n - 1]);
	return 0;
}

Measured memory_bytes: 896
import sys
input = sys.stdin.readline
 
import heapq
N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
heap = []
ans = 0
j = 0
 
for i in range(1, M+1): # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i): # 支払いがi日以内
        heapq.heappush(heap, -X[j][1]) # 候補の追加。最大の値が欲しいためマイナスに
        j += 1
    if len(heap):
        ans += - heapq.heappop(heap) # 候補があるとき、候補から最大値を取り出す
print(ans)

Measured memory_bytes: 75612
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			for(int i=0; i<n; i++) {
				ArrayList<Integer> list=new ArrayList<>();
				Stack<String> stack=new Stack<String>();
				String str=sc.next();
				int len=str.length();
				int num=0;
				for(int j=0; j<len; j++) {
					if(str.charAt(j)=='[') {
						stack.push("]");
					}
					else if(str.charAt(j)==']') {
						if(num>0) {
							num/=10;
							num=num/2+1;
							stack.add(String.valueOf(num));
						}
						String k="";
						while((k=stack.pop())!="]") {
							int p=Integer.parseInt(k);
							list.add(p);
						}
						Collections.sort(list);
						int sum=0;
						for(int point=0; point<list.size()/2+1; point++) {
							sum+=list.get(point);
						}
						list.clear();
						stack.add(String.valueOf(sum));
						num=0;
					}
					else {
						num+=str.charAt(j)-'0';
						num*=10;
					}
					if(j==len-1) {
						System.out.println(stack.pop());
						break;
					}
				}
			}
			
			
		}
	}
}


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

ll n,a,b,c;
string s,t;

int main(){
    cin>>s;
    n=s.size();
    for(ll i=0;i<n;i++){
        cout<<'x';
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; i++)cin >> p[i];
	sort(p.begin(), p.end());
	int ans = INF / 2;
	for (int i = 0; i <= N - K; i++) {
		ans = min(p[i + K - 1] - p[i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;
		for (int i = 0; i < s.length(); ++i) {
			if (i == 0 || s.charAt(i) != s.charAt(i - 1))
				++ans;
		}
		--ans;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 13848
# -*- coding: utf-8 -*-
"""
Created on Sat May 25 21:24:29 2019

@author: Yamazaki Kenichi
"""

N, M, K = map(int,input().split())
mod = 10**9+7

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, N*M+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

def a(N,M):
    return N*(N+1)//2*(M+1) + M*(M+1)//2*(N+1)
def b(N):
    return N*(N+1)//2

ans = 0
for i in range(N):
    for j in range(M):
        ans += a(i,j) + a(N-i-1,j) + a(i,M-j-1) + a(N-i-1,M-j-1)
        ans -= b(i) + b(j) + b(N-i-1) + b(M-j-1)
        ans %= mod
#        print(i,j,a(i,j),a(N-i-1,j),a(i,M-j-1),a(N-i-1,M-j-1),b(i),b(j),ans)
ans *= g2[2]

ans *= cmb(N*M-2,K-2,mod)
ans %= mod

print(ans)


Measured memory_bytes: 26896
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<Int> ps(a),qs(b),rs(c);
  for(Int i=0;i<a;i++) cin>>ps[i];
  for(Int i=0;i<b;i++) cin>>qs[i];
  for(Int i=0;i<c;i++) cin>>rs[i];

  sort(ps.rbegin(),ps.rend());
  sort(qs.rbegin(),qs.rend());

  ps.resize(x);
  qs.resize(y);
  for(Int r:rs) qs.emplace_back(r);

  sort(qs.rbegin(),qs.rend());

  Int sum=0;
  for(Int i=0;i<x;i++) sum+=ps[i];
  for(Int i=0;i<y;i++) sum+=qs[i];

  Int ans=sum;
  for(Int i=0;i<x;i++){
    if(y+i>=(Int)qs.size()) break;
    sum-=ps[x-(i+1)];
    sum+=qs[y+i];
    chmax(ans,sum);
  }

  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3456
import numpy as np
n= int(input())
m = np.zeros((n,2))
sum1 = 0
count =0
for i in range(n):
    m[i] = list(map(int,input().split()))
for j in range(n):
    for k in range(j+1,n):
        sum1 = sum1 + ((m[j][0] - m[k][0])**2 + (m[j][1]-m[k][1])**2)**(1/2)
        count +=1

ans = 0

mul =1
for l in range(n):
    mul *= n-l
po =0
if n ==2:
    po = 1
elif n ==3:
    po =2
else:
    for m in range(n):
        po += m

ans = sum1*(n-1)/count
print(ans)

Measured memory_bytes: 27080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(x,a)for(auto &x: a)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll>pii;
typedef vector<ll>vi;
typedef map<ll,ll>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
ll lcm(ll a,ll b)
{
	ll c=a*b;
	ll p=__gcd((int)a,(int)b);
	return c/p;
}
int main()
{
	//fopen();
	fastio;
	ll a,b;
	cin>>a>>b;
	cout<<lcm(a,b);
	//cout<<m<<" "<<e;
	
	
}
	


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
H_val = [H[i] for i in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    if H[A] > H[B]:
        H_val[B] = 0
        
    elif H[B] > H[A]:
        H_val[A] = 0
        
    else:
        H_val[A], H_val[B] = 0, 0

count = 0
for i in range(N):
    if H_val[i] != 0:
        count+= 1

print(count)


Measured memory_bytes: 20064
// ALDS1_13_C.cpp
// Heuristic Search - 15 Puzzle
// ??????26???????????¨???

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int N = 4;
const int N2 = 16;
const int INF = 50;
struct Puzzle {
    int f[N2];
    //int space;
    string path;

    bool operator < (const Puzzle &p) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};
Puzzle in;
int ministep = INF;
int sx = 0;
int sy = 0;
int limit;

void swap(int& a, int& b)
{
    int t = a;
    a = b;
    b = t;
}

bool isTarget(Puzzle p)
{
    for (int i = 0; i < N2; i++) {
        if (p.f[i] != i + 1)
            return false;
    }
    return true;
}

int getAllMD(Puzzle p)
{
    int dist = 0;
    int x, y;
    int ux, uy;
    for (int i = 0; i < N2; i++) {
        if (p.f[i] == N2) continue; // ??????0??????
        x = (p.f[i] - 1) / N;
        y = (p.f[i] - 1) % N;
        ux = i / N;
        uy = i % N;
        dist += abs(x - ux) + abs(y - uy);
    }
    return dist;
}

bool bfs(int i, int prev)
{
    if (isTarget(in)) {
        ministep = min(ministep, i);
//        cout << "ministep = " << ministep << endl;
        return true;
    }
    if (limit < i + getAllMD(in)) {
        return false;
    }

    for (int u = 0; u < 4; u++) {
        int tx = sx + dx[u];
        int ty = sy + dy[u];
        if (tx < 0 || tx >= N || ty < 0 || ty >= N)
            continue;
        if (max(prev, u) - min(prev, u) == 2) continue;
        swap(in.f[sx * N + sy], in.f[tx * N + ty]);
        sx = tx;
        sy = ty;
        in.path += dir[u];
        /* test */
//    cout << "(i = " << i << ") " << in.path << endl;
//    for (int j = 0; j < N2; j++)
//        cout << " " << in.f[j];
//    cout << endl;
//    cout << "MD: " << getAllMD(in) << endl;
        if(bfs(i+1, u)) return true;
        sx = sx - dx[u];
        sy = sy - dy[u];
        swap(in.f[sx * N + sy], in.f[tx * N + ty]);
        in.path.pop_back();
    }
    return false;
}

string iterative_deepening()
{
    limit = getAllMD(in);
    for ( ; limit <= INF; limit++) {
        if (bfs(0, -100)) {
            return in.path;
        }
    }
}

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

    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            sx = i / N;
            sy = i % N;
            in.f[i] = N2; // ??????isTarget?????????
        }
    }
    string ans = iterative_deepening();
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int n,k;
int arr[107];
ll dp[107][100007];

int rec( int i, int x )
{
    if( x>k )
        return 0;

    if( i>n )
    {
        if(x==k)
            return 1;
        return 0;
    }
    int ret= 0;

    for( int j=0; j<=arr[i]; j++ )
        ret= ( ret+rec( i+1, x+j ) )%mod;

    return ret;
}

int main()
{
    cin>>n>>k;

    for( int i=1; i<=n; i++ )
        cin>>arr[i];

    vector<ll>sum;
    for( int i=0; i<k; i++ )
        sum.push_back(0);
    sum.push_back(1);


    for( int peep=n; peep>=1; peep-- )
    {
        vector<ll>now;

        for( int total=0; total<=k; total++ )
        {
            if(total)
                dp[peep][total]= (sum[ min(k,total+arr[peep]) ]-sum[total-1]+mod)%mod;
            else
                dp[peep][total]= sum[ min(k,total+arr[peep]) ];

            if(total)
                now.push_back( (now.back()+dp[peep][total])%mod );
            else
                now.push_back( dp[peep][total] );
       }

        sum.swap(now);
    }

    cout<< dp[1][0] <<endl;
}


Measured memory_bytes: 84016
#include <stdio.h>

int n,a,sequence[100010],ind=1;

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

    for(int i=0; i<n; i++){
        scanf("%d",&a);
        if(i==0){
            sequence[0]=a;
            continue;
        }
        if(a>sequence[ind-1]){
            sequence[ind++]=a;
            continue;
        }

        int ini=0,fin=ind-1;

        while(ini<fin){
            int md=(ini+fin)/2;

            if(sequence[md]>=a){
                fin = md;
            }else{
                ini = md+1;
            }
        }

        sequence[ini]=a;
    }

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

Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  int n = sz(s);
  int cnt =0;
  rep(i,n){
    if(s[i] == '?') s[i] = 'D';
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;



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

	string S;
	cin >> S;
	rep(i, S.size() - 1)if (S[i] == S[i + 1]) {
		cout << i + 1 << " " << i + 2 << endl;
		return 0;
	}
	rep(i, S.size() - 2)if (S[i] == S[i + 2]) {
		cout << i + 1 << " " << i + 3 << endl;
		return 0;
	}

	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int n; cin >> n;
  
  deque<int> d;
  
  rep(i, n) {
    int a; cin >> a;
    if(i%2 == 0) {
      d.push_back(a);
    } else {
      d.push_front(a);
    }
  }
  
  if(n%2 == 0) {
    rep(i, n) {
      cout << d.front() << " ";
      d.pop_front();
    }
  } else {
    rep(i, n) {
      cout << d.back() << " ";
      d.pop_back();
    }
  }
  
  cout << endl;
  
}


Measured memory_bytes: 3840
package main

import "fmt"

func main() {
	for {
		var n, x int
		count := 0
		fmt.Scan(&n, &x)

		if n == 0 && x == 0 {
			break
		}

		for i := 1; i <= n; i++ {
			for j := i+1; j <= n; j++ {
				for k := j+1; k <= n; k++ {
					if i+j+k == x{
						count++
					}
				}
			}
		}

		fmt.Println(count)
	}
}


Measured memory_bytes: 1124
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    vector<double> l(3);
    l[0] = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    l[1] = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2));
    l[2] = sqrt(pow(x3 - x1, 2) + pow(y3 - y1, 2));
    sort(l.begin(), l.end());

    double s = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
    s = abs(s) / 2;
    double r = s * 2 / (l[0] + l[1] + l[2]);
    double ans = l[2] / (2 + l[2] / r);
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


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

lt = len(t)
ls = len(s)
ans = lt
for i in range(ls-lt+1):
    x = s[i:i+lt]
    count = 0
    for j in range(lt):
        if t[j] != x[j]:
            count += 1
    ans = min(count, ans)
print(ans)

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

const int MAX_N = 500;
int N;
int C[MAX_N],S[MAX_N],F[MAX_N];

ll go(int at, ll time)
{
	if(at == N-1) return time;
	ll x = 0;
	while(S[at]+F[at]*x < time) x++;
	return go(at+1, S[at]+F[at]*x + C[at]);
}

void solve()
{
	for(int i=0;i<N-1;++i){
		cout<< go(i, 0) << '\n';
	}	
	cout<<0<<'\n';
}

int main()
{
	cin >> N;
	for(int i=0;i<N-1;++i){
		cin >> C[i] >> S[i] >> F[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 3600
# union-find を使う

# unionするクエリが飛んでくる(クエリ:要求)
# find(どのグループ,集合かわかるようにする)
# findはある要素とある要素が同じグループに属するか,そのグループのサイズはどうか
# この二つを処理する

# 計算量 O(log N) か 工夫すると O(a(N)):アッカーマン計算量の逆関数... ならし計算量

##木構造を作っていく. グループのidはnodeのidにする. findするときは根の番号に辿るようにする

## 計算量を落とす.
### 木がどんどん深くなると処理が長くなる.

## 1. くっつける先を根に向かうようにする, グループとグループは根から根に繋げるようにする
## 小さい方を大きい方にくっつける
## -> 一回あたりO(log(N))
### 高さが高々 log(N)にしかならないから
#### 根から辿ると,一個辿ると頂点の個数が半分以下になっていくから
##### 証明できる: 辺が張られた後は そのグループはいじられない
##### さらに,最初につけたときに既に 残りのグループの方が大きいため

## 2. 経路縮約的な考え
# 計算結果をメモしておく
# 一回計算したところは直接つなぐ　-> メモ化で　ならしlog(N)

##3. 両方を採用すると ならし　アッカーマン関数の逆関数



##実装の工夫

# 根にマイナスのサイズを持つようにする。
# 葉には親のidを持つようにする
# メモ化するためにd[x]を親のfindと一致させるようにする

# MSTを考えてuniteでくっつけられるかどうかを考える

class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n #各親を格納する,自分が親ならマイナスサイズを持つ
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y) ##親を見た方が楽
        if x==y:
            return
        
        if self.parents[x] > self.parents[y]:
            x,y = y,x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self,x):
        return -self.parents[self.find(x)]
    
def main():
    n,m = map(int,input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        uf.union(a-1,b-1)
    
    ans = 1
    for i in range(n):
        ans = max(ans, uf.size(i))
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14408
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	char arr[5] = { 0 };
	while (n--)
	{
		getchar();
		char c;
		scanf("%c", &c);
		if (c == 'G')
			arr[0] = 1;
		if (c == 'W')
			arr[1] = 1;
		if (c == 'P')
			arr[2] = 1;
		if (c == 'Y')
			arr[3] = 1;
	}
	int ans = 0;
	for (int i = 0; i < 5; i++)
	{
		if (arr[i] == 1)
			ans++;
	}
	if (ans == 3)
		printf("Three\n");
	else
		printf("Four\n");
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);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 INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n;
    map<int,vector<P>> tree;
    cin >> n;
    REP(i,n-1)
    {
        int u,v,w;
        cin >> u >> v >> w;

        tree[u - 1].PB(make_pair(v - 1, w % 2));
        tree[v - 1].PB(make_pair(u - 1, w % 2));
    }


    vector<int> ans(n, -1);
    queue<int> que;
    que.push(0);
    ans[0] = 0;
    while (!que.empty())
    {
        int now = que.front();que.pop();
        auto nodes = tree[now];
        REP(i,SIZE(nodes))
        {
            if (ans[nodes[i].F] == -1)
            {
                ans[nodes[i].F] = (nodes[i].S + ans[now]) % 2;
                que.push(nodes[i].F);
            }
            
        }
    }
    

    REP(i,n)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 12288
#include <iostream>
#include <complex>

using namespace std;

typedef complex<int> Point;

int main()
{
	int n; cin>>n;
	while(n--){
		Point cur,res;
		for(Point p;cin>>real(p)>>imag(p),norm(p);){
			cur+=p;
			if(norm(cur)>norm(res) || norm(cur)==norm(res) && real(cur)>real(res))
				res=cur;
		}
		cout<<real(res)<<" "<<imag(res)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include  <iostream>
#include  <string>
using namespace std;
int main()
{
    int i;
    string s;
    cin>>s;
    int count = 0;
    for(i=0;i<3;i++){
    if(s[i]=='1'){
        ++count;
    }
    };
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=1;i<=m;i++){
		int x;
		cin>>x;
		ans+=x;
	}
	cout<<max(n-ans,-1LL);
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

int main(){
	long long int sum=0;

	int n;
	std::cin>>n;

	std::map<std::string, long long int> mp;

	for (int i = 0; i < n; i++) {
		std::string s;
		
		std::cin >> s;

		std::sort(s.begin(), s.end());

		mp[s]++;

	}

	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		sum = sum + ((itr->second)*((itr->second) - 1) / 2);
	}



	std::cout<<sum<<std::endl;
	return 0;
}

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

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
#endif
}
 
int main()
{
    c_p_c();
   string a;
    cin >> a;
    ll sum=0;
    for(ll i=0;i<a.length();i++)
        sum+=a[i]-'0';
    if(sum%9)
        cout << "No";
    else
        cout << "Yes";

    return 0;
} 




Measured memory_bytes: 3752
#include<stdio.h>
int main(void){
  int n;
  int i;
  double a;
  double sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&a);
    sum+=(1/a);
  }
  printf("%lf",1/sum);
  return 0;
}


Measured memory_bytes: 128
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;

int n, a, b, c, d;
string s;
bool used[200005];

void dfs(int x) {
    if (x > n) return;
    if (s[x - 1] == '#') return;
    if (used[x]) return;
    used[x] = true;
    dfs(x + 1);
    dfs(x + 2);
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    if (c > d) {
        dfs(b);
        if (!used[d]) {
            cout << "No\n";
            return 0;
        }
        bool t = false;
        for (int i = b; i <= d; ++i) if (i > 1 && i < n && s[i - 2] == '.' && used[i] && s[i] == '.') {
            t = true;
            break;
        }
        if (!t) {
            cout << "No\n";
            return 0;
        }
        memset(used, false, sizeof(used));
        dfs(a);
        if (!used[c]) {
            cout << "No\n";
            return 0;
        }
        cout << "Yes\n";
        return 0;
    }
    dfs(a);
    if (!used[c]) {
        cout << "No\n";
        return 0;
    }
    memset(used, false, sizeof(used));
    dfs(b);
    if (!used[d]) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 2000
import java.util.*;
public class Main {
	static int maxn=212345;
	static long mod=1000000007;
	static long[] fac=new long[maxn];
	static long[] rev=new long[maxn];
	static long ksm(long x,long n) {
		long ret=1;
		while (n>0) {
			if ((n&1)>0) ret=ret*x%mod;
			x=x*x%mod;
			n>>=1;
		}
		return ret;
	}
	static long C(int x,int y) {
		return fac[x]*rev[y]%mod*rev[x-y]%mod;
	}
	static long get(int x,int y) {
		return C(x+y-2,y-1);
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int h=in.nextInt();
		int w=in.nextInt();
		int n=in.nextInt();
		long[] a=new long[n+1];
		long[] dp=new long[n+1];
		for (int i=0;i<n;++i) {
			int r=in.nextInt();
			int c=in.nextInt();
			a[i]=200000L*r+c;
		}
		a[n++]=200000L*h+w;
		fac[0]=rev[0]=1;
		for (int i=1;i<maxn;++i) fac[i]=fac[i-1]*i%mod;
		rev[maxn-1]=ksm(fac[maxn-1],mod-2);
		for (int i=maxn-2;i>=0;--i) rev[i]=rev[i+1]*(i+1)%mod;
		Arrays.sort(a);
		for (int i=0;i<n;++i) {
			int x=(int)(a[i]/200000);
			int y=(int)(a[i]%200000);
			dp[i]=get(x,y);
			for (int j=0;j<i;++j) {
				int tx=(int)(a[j]/200000);
				int ty=(int)(a[j]%200000);
				if (tx>x||ty>y) continue;
				dp[i]-=dp[j]*get(x-tx+1,y-ty+1)%mod;
				dp[i]=(dp[i]%mod+mod)%mod;
			}
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 33308
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int arr[3];
  cin >> arr[0] >> arr[1] >> arr[2];
  sort(arr,arr+3);
  cout << ((arr[0] == 5 && arr[1] == 5 && arr[2] == 7)?"YES":"NO");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String inputStr = sc.nextLine();

		String[] inputStrArray = inputStr.split(" ");
		int[] inputIntArray = new int[inputStrArray.length];

		try {
			for (int index = 0; index < inputIntArray.length; index++) {
				inputIntArray[index] = Integer.parseInt(inputStrArray[index]);
			}
			int tmp;

			for (int i = 0; i < inputIntArray.length; i++) {
				for (int j = 0; j < inputIntArray.length -1; j++) {
					if (inputIntArray[j] > inputIntArray[j +1]) {
						tmp = inputIntArray[j];
						inputIntArray[j] = inputIntArray[j +1];
						inputIntArray[j +1] = tmp;
					}
				}
			}
			boolean firstFlg = false;
			for (int i : inputIntArray) {
				if (firstFlg) {
					System.out.print(" ");
				}
				System.out.print(i);
				firstFlg = true;
			}
			System.out.println();

		} catch (NumberFormatException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 26132
#include <cfenv>
#include <cmath>
#include<iostream>

using namespace std;

int main(){

    int a;
    int b;

    cin >> a;
    cin >> b;

    int x =0;

    for(int i=0;i<10100;i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            x = i;
            break;
        }
    }

    if(x==0) x =-1;

    cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int col[4100],a[4100];
int b[2][2100];
int f[2100][2100];
int c[4100],n;
void add(int x,int k){for(int i=x;i<=n;i+=(i&-i))c[i]+=k;}
int query(int x){int ans=0;for(int i=x;i;i-=(i&-i))ans+=c[i];return ans;}
int main()
{
	scanf("%d",&n);n*=2;
	for(int i=1;i<=n;i++)
	{
		char c[2];scanf("%s%d",c,&a[i]);
		col[i]=(c[0]=='W'?0:1);b[col[i]][a[i]]=i;
	}
	memset(f,127/2,sizeof(f));f[0][0]=0;
	for(int i=0;i<=n/2;i++)
	{
		memset(c,0,sizeof(c));
		for(int j=1;j<=n;j++)add(j,1);
		for(int j=1;j<=i;j++)add(b[0][j],-1);
		for(int j=0;j<=n/2;j++)
		{
			if(j)add(b[1][j],-1);
			if(i)f[i][j]=min(f[i][j],f[i-1][j]+query(b[0][i]));
			if(j)f[i][j]=min(f[i][j],f[i][j-1]+query(b[1][j]));
		}
	}
	printf("%d",f[n/2][n/2]);return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    int len = S.length();

    for (int i = 0; i < len / 2; i++) {
        if (S[i] != S[len - (i + 1)]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

# A - Integer Product

from math import gcd
from collections import Counter

def parse(s):
    """小数点付き数字列をパース"""
    p = s.find('.')
    i, f = (s[:p], s[p + 1:]) if p >= 0 else (s, '')
    n = int(i + f)    # 分子 = 小数点なし数字列
    d = 10 ** len(f)  # 分母 = 10のべき乗
    g = gcd(n, d)
    return (n // g, d // g)  # 約分して返す

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

MAX_FLEN = 9  # 小数部の長さ

def twofive(x):
    """素因数2と5の個数を返す"""
    store = {}
    for d in (2, 5):
        store[d] = 0
        while x % d == 0:
            store[d] += 1
            x //= d
    return (store[2], store[5])

frac = [twofive(n) + twofive(d) for n, d in a]
frac = [(min(MAX_FLEN, n1), min(MAX_FLEN, d1), n2, d2)
        for n1, d1, n2, d2 in frac]
count = Counter(frac)

# count[(a, b, c, d)] = a' >= a and b' >= b and c' <= c and d' <= d
#                       である (a', b', c', d') の個数

for a in range(MAX_FLEN, -1, -1):
    for b in range(MAX_FLEN, -1, -1):
        for c in range(MAX_FLEN + 1):
            for d in range(MAX_FLEN + 1):
                count[(a, b, c, d)] = (count[(a, b, c, d)]
                    + count[(a + 1, b, c, d)]
                    + count[(a, b + 1, c, d)]
                    + count[(a, b, c - 1, d)]
                    + count[(a, b, c, d - 1)]
                    - count[(a + 1, b + 1, c, d)]
                    - count[(a + 1, b, c - 1, d)]
                    - count[(a + 1, b, c, d - 1)]
                    - count[(a, b + 1, c - 1, d)]
                    - count[(a, b + 1, c, d - 1)]
                    - count[(a, b, c - 1, d - 1)]
                    + count[(a + 1, b + 1, c - 1, d)]
                    + count[(a + 1, b + 1, c, d - 1)]
                    + count[(a + 1, b, c - 1, d - 1)]
                    + count[(a, b + 1, c - 1, d - 1)]
                    - count[(a + 1, b + 1, c - 1, d - 1)])

# 数(a1, b1, c1, d1)と(a2, b2, c2, d2)の積が整数
# <-> a2 >= c1 and b2 >= d2 and c2 <= a1 and d2 <= b1

s = sum(count[(c, d, a, b)] - (1 if c == d == 0 else 0)
        for a, b, c, d in frac)
print(s // 2)


Measured memory_bytes: 154584
N,K=map(int,input().split())
A=[]
for i in range(K):
  d=input()
  #A.append(list(map(int, input().split())))
  A.extend(map(int, input().split()))
#print(A)
B=set(A)
count=0
for i in range(1,N+1):
  if i not in B:
    count+= 1

print(count)

#for i in 

Measured memory_bytes: 9176
n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
s0=s[0]
for i in range(n):
  s0_copy=s0
  si=s[i]
  for c in s0_copy:
    if c in si:
      si=si.replace(c,'',1)
    else:
      s0=s0.replace(c,'',1)
print(s0)

Measured memory_bytes: 3060
import heapq

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(len(a)):
        a[i] *= -1
    heapq.heapify(a)
    for _ in range(m):
        x = heapq.heappop(a)
        x = (x+1) // 2
        heapq.heappush(a, x)
    print(sum(a) * -1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14180
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

int main() {
	
	string str;
	int sum;
	for (;;) {
		cin >> str;

		if (str[0] == '0')break;
		sum = 0;
		for (int i = 0;; i++) {
			if (str[i] == '\0')break;
			sum += (str[i] - '0');

		}

		printf("%d\n", sum);

	}

	//system("pause");
	return 0;
}


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

int main()
{
	int n=0;cin>>n;
	int a[100]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		int minj=i,f=0;
		for(int j=i;j<n;j++)
		{
			if(a[j]<a[minj])
			{
				minj=j;
				f=1;
			}
		}
		swap(a[i],a[minj]);
		if(f==1)cnt++;
	}
	
	cout<<a[0];
	for(int i=1;i<n;i++)
	{
		cout<<" "<<a[i];
	}
	cout<<endl<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0)
    {
        cout << (B - A) / 2 << endl;
    }else{
        cout << min(A-1,N-B) + 1  + (B - A - 1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a==b) cout<<"EQUAL"<<endl;
  else if(a.size()>b.size()) cout<<"GREATER"<<endl;
  else if(b.size()>a.size()) cout<<"LESS"<<endl;
  else if(a>b) cout<<"GREATER"<<endl;
  else cout<<"LESS"<<endl;
}


Measured memory_bytes: 3632
local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do t[i] = false end
for i = 1, k do
  local d = io.read("*n")
  for j = 1, d do
    x = io.read("*n")
    t[x] = true
  end
end
c = 0
for i = 1, n do
  if not t[i] then c = c + 1 end
end
print(c)


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

#include <bits/stdc++.h>


using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;


//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BGoodDistance {
public:
    void solve(istream& cin, ostream& cout) {
      int n, d; cin >> n >> d;
      vector<vector<int>> mat(n, vector<int>(d));
      rep(i, n) {
        rep(j, d) {
          cin >> mat[i][j];
        }
      }
      set<int> st;
      for(int i=1; i<=10000; i++) {
        st.insert(i*i);
      }
      int ans = 0;
      rep(i, n) {
        for(int j=i+1; j<n; j++) {
          int now = 0;
          rep(k, d) {
            auto diff = mat[i][k] - mat[j][k];
            now += diff*diff;
          }
          if (st.find(now) != st.end()) {
            ans++;
          }
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  SPEED;
  BGoodDistance solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

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

    if(n >= 10) cout << r << endl;
    else cout << r + 100*(10-n) <<endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
lst = []
for i in range(m):
    lst.append(list(map(int,input().split())))

min = lst[0][0]
max = lst[0][1]
for v in lst:
    if v[0] > min:
        min = v[0]
    if v[1] < max:
        max = v[1]
if min <= max:
    print(max-min + 1)
elif min > max:
    print(0)


Measured memory_bytes: 27064
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>


#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

mt19937 mrand(random_device{} ());
int rnd() {
	return mrand();
}


int main(){
    srand(17);
 	ios_base::sync_with_stdio(0);
 	int n;
 	cin >> n;
 	vector<int> s(n);
 	int cnt = 0;
 	multiset<int> lst;
 	for (int i = 0; i < n; i++){
 		cin >> s[i];
 		if (lst.size() > 0 && *(lst.begin()) < s[i])
 			lst.erase(--lst.lower_bound(s[i]));
 		else
 			cnt++;
 		lst.insert(s[i]);
 	}
 	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int f[N],a[N],ma[N],ans[N];
int Find(int x) {
	if(x==f[x]) return x;
	return f[x]=Find(f[x]);
}
int main() {
	//freopen("in.txt","r",stdin);
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=0,x,y;i<m;i++) {
		scanf("%d%d",&x,&y);
		a[x]++,a[y]++;
		f[Find(x)]=Find(y);
	}
	for(int i=1;i<=n;i++) {
		ma[Find(i)]++;
	}
	for(int i=1;i<=n;i++) {
		ans[i]=ma[f[i]]-a[i]-1;
	}
	for(int i=0,x,y;i<k;i++) {
		scanf("%d%d",&x,&y);
		if(f[x]==f[y]) ans[x]--,ans[y]--;
	}
	for(int i=1;i<=n;i++) {
		printf("%d%c",ans[i],i==n?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s[26][26]; int h,w; string ans;
int main(){
  cin >> h >> w;
  for (size_t y = 0; y < h; y++) {
    for (size_t x = 0; x < w; x++) {
      cin >> s[y][x];
      if(s[y][x] == "snuke"){
        ans = 'A'+x;
        ans+= to_string(y+1);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=105;
bool vis[maxn];
int prime[maxn],len,a[maxn];
void init()
{
	vis[0]=vis[1]=1;
	for(int i=2;i<maxn;i++)
	{
		if(vis[i]==0)
		{
			prime[++len]=i;
			for(int j=i+i;j<maxn;j+=i)
				vis[j]=1;
		}
	}
}
int main()
{
	init();
	int n;scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int x=i;
		for(int j=1;j<=len;j++)
		{
			while(x%prime[j]==0)
			{
				a[j]++;
				x/=prime[j];
			}
		}
	}
	int x1=0,x2=0,x3=0,x4=0,x5=0;
	for(int i=1;i<=len;i++)
	{
		if(a[i]>=74)
			x5++;
		if(a[i]>=24)
			x4++;
		if(a[i]>=14)
			x3++;
		if(a[i]>=4)
			x2++;
		if(a[i]>=2)
			x1++;
	}
	int ans=x5+x4*(x1-1)+x3*(x2-1)+x2*(x2-1)*(x1-2)/2;
	//printf("%d %d %d %d %d",x1,x2,x3,x4,x5);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;

    rep(i, 0, 50001){
        if(floor(i * 1.08) == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
Q = int(input())

M = 10**5+5
primes = [True] * M
primes[0] = False
primes[1] = False


for i in range(2, M):
    if primes[i]:
        for j in range(2, (M-1)//i+1):
            primes[i*j] = False

# print(primes)                                                                    
cnt = [0] * M

for i in range(3, M):
    cnt[i] = cnt[i-1]
    if primes[i] and primes[(i+1)//2]:
        cnt[i] += 1
# print(cnt)                                                                       
queues = []
for q in range(Q):
    l, r = map(int, input().split())
    queues.append((l, r))

for l, r in queues:
    print(cnt[r] - cnt[l-1])



Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if((b-a)==(c-b))
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256