akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;

    vector< pair<int, int> > point(N);
    vector<int> ans(N);
    for(int i=0; i<N; i++) point[i].second = i;
    for(int i=0; i<N*(N-1)/2; i++) {
        int A, B, C, D; cin >> A >> B >> C >> D;
        A--; B--;
        if(C == D) {
            point[A].first++;
            point[B].first++;
        }
        else if(C < D) {
            point[B].first += 3;
        }
        else {
            point[A].first += 3;
        }
    }
    sort(point.rbegin(), point.rend());

    int rank = 1, pre = -1;
    for(int i=0; i<N; i++) {
        if(pre < 0) {
            pre = point[i].first;
            ans[ point[i].second ] = rank;
        }
        else if(pre == point[i].first) {
            ans[ point[i].second ] = rank;
        }
        else {
            rank = i+1;
            ans[ point[i].second ] = rank;
        }
        pre = point[i].first;
    }

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



Measured memory_bytes: 3028
import sys
import math
from statistics import mean
from functools import reduce, lru_cache
from itertools import permutations


@lru_cache()
def distance(p1, p2):
    return math.sqrt(sum([(a - b) ** 2 for a, b in zip(p1, p2)]))


def distances(arr):
    return [distance(arr[i], arr[i+1]) for i in range(len(arr)-1)]


def main(n: int, points: list):
    ret = []
    for x in permutations(points):
        ret.append(sum(distances(x)))

    print(mean(ret))


if __name__ == '__main__':
    n = int(input())
    a = [input() for i in range(n)]

    points = [s.split(' ') for s in a]

    main(
        n,
        [(int(p[0]), int(p[1])) for p in points]
    )


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

long long k,i=0,n;
int main(){
	ios::sync_with_stdio(0);
    cin>>k;
    
    if(k%2==0||k%5==0){
	   cout<<"-1";
       return 0;
    }
    while(i<=1000000){
    	i++;
    	n=(n*10+7)%k;
    	
    	if(n==0){
		   cout<<i;
    	   return 0;
    	}
    }
	
	cout<<"-1";
	
	return 0;
}

Measured memory_bytes: 3612
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    string S;
    cin>>S;
    if(S[1]=='R')
    {
        S[1]='B';
    }
    else
    {
        S[1]='R';
    }
    cout<<S<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll INF = 9223372036854775807;
int main(void){
    int n;
    cin >> n;
    vector<ll> a(n),rui(n+1);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        rui[i+1] = rui[i] + a[i];
    }
    ll ans = INF;
    for(int i = 0;i < n-1;i++){
        ans = min(ans,abs(rui[n]-2*rui[i+1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.io.*;
import java.util.StringTokenizer;

public class Main{

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Twinkle little = new Twinkle();
        little.star(1, in, out);
        out.close();


    }
static class Twinkle {
        public void star(int testNumber, InputReader in, PrintWriter out) {
            int test = in.nextInt();
            int max =0;
            int sum=0;
            while (test -- !=0)
            {
                int x = in.nextInt();
                sum+=x;
                if(max<x)
                    max=x;
            }
            System.out.println(sum-(max/2));
}
}
  


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

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

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return false;
                    }
                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    n, m = [int(x) for x in input().split()]
    s = []
    ii = []
    jj = []
    cols = [[] for _ in range(m)]
    for i in range(n):
        r = [x for x in input()]
        if '#' not in set(r):
            ii.append(i)
        for j in range(m):
            cols[j].append(r[j])
        s.append(r)
    for j in range(m):
        if '#' not in set(cols[j]):
            jj.append(j)
    
    for i in range(n):
        if i in ii:
            continue
        for j in range(m):
            if j in jj:
                continue
            print(s[i][j], end='')
        print()


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""



Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll n,k;
ll dp[120000];
ll ar[200];
int main()
{
    IOS
    cin>>n>>k;
    REP(i,n)    cin>>ar[i];
    dp[0]=2;
    for(int i=1;i<=k;i++)
    {
        bool a=0;
        REP(j,n)
        {
            if(ar[j]<=i)
            {
                if(dp[i-ar[j]]==2)
                {
                    a=1;
                    break;
                }
            }
        }
        if(a==1)
        {
            dp[i]=1;
        }
        else
        {
            dp[i]=2;
        }
    }
    // REP(i,k+1)
    // {
    //     cout<<dp[i]<<" ";
    // }
    // cout<<endl;
    if(dp[k]==1)
    {
        cout<<"First\n";
    }
    else
    {
        cout<<"Second\n";
    }
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;cin >> n >> d;
    int ans=0;
    for(int i=0;i<n;i++){
        int p;cin >> p;
        if(p>d){
            ans+=p-d;
        }
    }
    if(ans>0){
        cout << ans << endl;
    }
    else{
        cout << "kusoge" << endl;
    }
}


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

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

const int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
int main() {
	mint p[100010];
	for(int i = 1; i < 100010; ++i) {
		p[i] = p[i - 1] + ((mint)1 / (mint)i);
	}
	int n; cin >> n;
	mint x[n]; for(int i = 0; i < n; ++i) cin >> x[i];
	mint ans = 0;
	for(int i = 1; i <= n - 1; ++i) {
		ans += p[i] * (x[i] - x[i - 1]);
	}
	for(int i = 1; i <= n - 1; ++i) {
		ans *= i;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define N 1000000
void insertionSort(int *A,int n,int g);
void shellSort(int *A,int n);
int m=7,cnt;
int main(){
  int i,n,A[N];
  
  scanf("%d",&n);
    
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  shellSort(A,n);
  
  for(i=0;i<n;i++) printf("%d\n",A[i]);
  
  return 0;
}
void insertionSort(int *A,int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int *A,int n){
  int i,x=0,G[]={1093,364,121,40,13,4,1};
  cnt=0;
  if(n<1093) x++;
  if(n<364) x++;
  if(n<121) x++;
  if(n<40) x++;
  if(n<13) x++;
  if(n<4) x++;
  printf("%d\n",m-x);
  for(i=x;i<m;i++){
    if(i<m-1)  printf("%d ",G[i]);
    else printf("%d\n",G[i]);
    }
  
    for(i=x;i<m;i++){
      insertionSort(A,n,G[i]);
    }
  printf("%d\n",cnt);
}

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

int main(){
    int x;
    cin>>x;
    for(ll i=-1000; i<=1000; ++i){
        for(ll j=-1000; j<=1000; ++j){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

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

int main()
{
	int i,b,count=0,co=0;
	char a[105];
	cin >> b;
	for( i = 0; i < b; i++ ){
		cin >> a[i];
	}

	for( i = 0; i < b; i++ ){
		if( a[i] == 'R' ){
			count++;
		}else if( a[i] == 'B' ){
			co++;
		}
	}

	if( count > co ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a[100005],b[100005];
	long long times=0;
    scanf("%d",&n);
    for(int i=0;i<=n;i++)b[i]=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==i)b[i]=0;
    }
    for(int i=1;i<n;i++)
    {
        if(b[i]==0&&b[i+1]==0)
        {
            times++;
            b[i]=1;
            b[i+1]=1;
        }
        else if(b[i]==0&&b[i+1]!=0)
        {
            times++;
            b[i]=1;
        }
    }
    if(b[n]==0)
    {
        times++;
        b[n]=1;
    }
    printf("%lld\n",times);
}

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

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

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    vector<int> sa(N + 1);
    int g = 0;
    for (int i = 0; i < N; i++)
    {
        sa[i] = abs(X - x[i]);
        g = gcd(sa[i], g);
    }
    cout << g << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int gcd(int a,int b) {

  if(b==0) return a;

  else return gcd(b,a%b);

}

int main() {

  long long a,b;

  long long g,l;

  
  while(cin >> a >> b) {

    g=gcd(a,b);

    l=a*b/g;

    cout << g << " " << l << endl;

  }

  return 0;

}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  int k, n, ai;

  cin >> k >> n;

  vector<int> a(n);

  int mx = 0;

  rep(i, 0, n){
    cin >> ai;
    a[i] = ai;
    if(i != 0){
      int dis = ai - a[i-1];
      chmax(mx, dis);
    }
  }
  chmax(mx, k-a[n-1]+a[0]);

  cout << k - mx << endl;

  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n =sc.nextLong();
		int[] a = new int[(int) n];
		
		for(int i=1;i<n;i++) {
			a[sc.nextInt()-1]++;
		}
		
		for(int i=0;i<n;i++) {
			System.out.println(a[i]);
		}
		sc.close();
	}
}


Measured memory_bytes: 60480
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n,x; cin >> n >> x;
	vector<int> v(n);
	rep(i,n) cin >> v[i], x -= v[i];
	int min = *min_element(all(v));
	int count = v.size();
	while(x >= min){
		count++;
		x -= min;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  if(S>=86400 || S<0){
    printf("error");
  }
  
  h = S/3600;
  S = S%3600;
  m = S/60;
  s = S%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0;i <= b;i++) {
        if (a*i % b == c) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int stage[12][12] = {{0}};
    int n;
    int j = 0;
    int x = 0,y = 0,xx = 0;
    for(;;){
        cin >> n;
        if(n == 0)break;
        for(int i = 0;i < n; i++){
            for(j = 0;j < n; j++){
                cin >> stage[i][j];
                x += stage[i][j];
                if(j == n-1){
                    stage[i][n] = x;
                    xx += stage[i][n];
                    x = 0;
                }
            }
        }
        for(int i = 0;i < n; i++){
            for(j = 0;j < n; j++){
                y += stage[j][i];
                if(j == n-1){
                    stage[n][i] = y;
                    y = 0;
                }
            }
        }
        stage[n][n] = xx;
        for(int i = 0;i <= n; i++){
            for(int j = 0;j <= n; j++){
                printf("%5d",stage[i][j]);
            }
            printf("\n");
        }
        x = 0,y = 0,xx = 0;
    }
    return 0;
}

Measured memory_bytes: 1164
N = int(input())
X = list(map(int,input().split()))
ans = 10000000000000000000000000000000000000
for i in range (-201,202):
  p = 0
  for j in range (0,N):
    p = p + (X[j] - i - 1) ** 2
  ans = min(ans,p)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b >> s;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

//  if(a<9 && b < 9) anss = "Yay!";
//  else anss = ":(";
s[b-1] = tolower(s[b-1]);
  cout << s << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vec h(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  vec ans(n,1);
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    if(h[a]>=h[b]) {
      ans[b]=0;
    }
    if(h[b]>=h[a]) {
      ans[a]=0;
    }
  }
  ll res=0;
  for(ll i=0;i<n;i++) {
    res+=ans[i];
  }
  cout << res << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> tree(N, vector<int>());
    for(int i=0; i<N-1; i++){
        int a, b;  cin >> a >> b;
        a--;  b--; // 頂点の番号を 0-indexed とする。
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<int> c(N);
    for(int i=0; i<N; i++){
        cin >> c[i];
    }
    // c を降順にソートする
    sort(c.begin(), c.end(), greater<int>());

    vector<int> d(N,0);          // d[i] は頂点 i に書き込む整数
    int idx = 0;               // 探索で到達した頂点に c[idx] を書き込む
    queue<pair<int,int>> que;  // pair<int,int> = {現在の頂点, 現在の頂点の親}
    que.push({0, -1});         // 頂点 0 からスタートする。0 の親は適当に -1 としておく。

    // 幅優先探索
    while(!que.empty()){
        int now = que.front().first;   // 現在の頂点
        int pre = que.front().second;  // 現在の頂点の親
        que.pop();

        d[now] = c[idx];               // 現在の頂点には c[idx] を書き込む
        idx++;

        for(int i=0; i<tree[now].size(); i++){
            // 現在の頂点と直接つながる頂点のうち、親以外へ遷移する
            int nxt = tree[now][i];    
            if(d.at(nxt)==0) que.push({nxt, now});
        }
    }

    int M = 0; // M は c[0] 以外の和
    for(int i=1; i<N; i++){
        M += c[i];
    }

    cout << M << endl;
    for(int i=0; i<N; i++){
        cout << d[i] << " ";
    }cout << endl;
}


Measured memory_bytes: 1024
n = int(input())
min_s = []
max_s = []
for i in range(n):
    a, b = map(int, input().split())
    min_s.append(a)
    max_s.append(b)

min_s.sort()
max_s.sort()
if n % 2 == 0:
    min_med = (min_s[n // 2 - 1] + min_s[n // 2]) / 2
    max_med = (max_s[n // 2 - 1] + max_s[n // 2]) / 2
    print(int((max_med - min_med) * 2 + 1))

else:
    min_med = min_s[(n + 1) // 2 - 1]
    max_med = max_s[(n + 1) // 2 - 1]
    print(int((max_med - min_med)+1))

Measured memory_bytes: 99008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}

		int sum = 0;

		for(int i = 0; i < N - 1; i++) {
			for(int j = i + 1; j < N; j++) {
				sum += list.get(i) * list.get(j);
			}
		}

		System.out.println(sum);

		sc.close();
	}
}


Measured memory_bytes: 19924
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

template <typename T> int sgn(T val) {
    return (T(0) < val) - (val < T(0));
}

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

    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    REP(i, n) {
        cin >> x[i];
    }

    ll min_move = INF;
    if (n == 1) {
        min_move = abs(x[0]);
    }
    REP(i, n-k+1) {
        // signs are different
        if (sgn(x[i]) != sgn(x[i+k-1])) {
            ll temp = min(abs(x[i]), abs(x[i+k-1])) * 2;
            temp += max(abs(x[i]), abs(x[i+k-1]));
            min_move = min(min_move, temp);
        }
        // signs are the same
        else {
            ll temp = max(abs(x[i]), abs(x[i+k-1]));
            min_move = min(min_move, temp);
        }
    }
    P(min_move);

    return 0;
}


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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        //if (vs.empty()) return os << "[]";
        //auto i = vs.begin();
        //os << "[" << *i;
        //for (++i; i != vs.end(); ++i) os << " " << *i;
        //return os << "]";
        for (auto i = vs.begin(); i != vs.end(); i++) os << *i << endl;
        return os;
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    struct Point {
        int x, y;
        Point() {}
        Point(int x, int y) : x(x), y(y) {}
    };
    istream& operator>>(istream& is, Point& p) {
        is >> p.y >> p.x;
        p.y--;
        p.x--;
        return is;
    }
    bool operator<(const Point& a, const Point& b) {
        return a.x == b.x ? a.y < b.y : a.x < b.x;
    }

    int H, W, N;
    vector<Point> P;
    void input() {
        cin >> H >> W >> N;
        P.resize(N); cin >> P;
    }

    void solve() {
        set<Point> M;
        for (int i = 0; i < N; i++) {
            //cout << P[i].x << " " << P[i].y << endl;
            M.insert(P[i]);
        }
        ll nonzero_c = 0;
        set<Point> used;
        vector<ll> ans(10, 0);
        for (int i = 0; i < N; i++) {
            for (int px = -1; px <= 1; px++) {
                for (int py = -1; py <= 1; py++) {
                    int c = 0;
                    int cx = P[i].x + px;
                    int cy = P[i].y + py;
                    Point C(cx, cy);
                    for (int dx = -1; dx <= 1; dx++) {
                        for (int dy = -1; dy <= 1; dy++) {
                            int nx = cx + dx;
                            int ny = cy + dy;
                            if (nx < 0 || nx >= W || ny < 0 || ny >= H) goto next;
                        }
                    }
                    if (used.count(C)) continue;
                    used.insert(C);
                    nonzero_c++;
                    for (int dx = -1; dx <= 1; dx++) {
                        for (int dy = -1; dy <= 1; dy++) {
                            c += (M.count(Point(cx + dx, cy + dy)));
                        }
                    }
                    //cout << cx << " " << cy << " -> " << c << endl;
                    ans[c]++;
                    next:;
                }
            }
        }
        ans[0] = ll(H - 2) * ll(W - 2) - nonzero_c;
        cout << ans;
    }
}

int main() {
    input(); solve();
    return 0;
}



Measured memory_bytes: 47872
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define ll long long int
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;

int main() {
    int N,ans=0;
    
    cin >> N;
    vector<int> L(N);
    REP(i,N) cin >> L[i];

    sort(ALL(L), greater<int>());
    int sum = 0;
    FOR(i,1,N) sum += L[i];
    
    if(L[0] < sum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)


int main(){
	lli h,w,k,ans=0;
	char arr[10][10],a;
	cin>>h>>w>>k;

	for (lli i = 0; i < h; i++){
		for (lli j = 0; j < w; j++){
			cin>>a;
			arr[i][j]=a;
		}
	}

	for(int t=0;t<pow(2,h);t++){
		for(int t2=0;t2<pow(2,w);t2++){
			lli tmp=0;
	    	lli i=0;
	    	lli b=t;
		    while (i<h)
			{
				if(b & 1){
					lli i2=0;
					lli b2=t2;
			    	while (i2<w){
						if(b2 & 1){
							if(arr[i][i2]=='#') tmp++;
						}
						b2 = b2 >> 1;
						i2++;
					}
				}
				b = b >> 1;
				i++;
			}
			if(tmp==k){
				ans++;
			}
		}
	}
	cout<<ans;

}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	string s;
	int ans=0;
	cin >>n>>k>>s;
	char last = '1';
	int cnt   = 0;
	Vi data;
	rep(i,n){
		if(s[i]==last){
			cnt++;
		}else{
			data.pb(cnt);
			cnt = 1;
		}
		last = s[i];
	}
	data.pb(cnt);
	//clog << data <<" "<<len<< endl;
	cnt = 0;
	int stand = 0;
	int left  = 0;
	for (int i = 0; i < data.size();i++){
		cnt += data[i];
		if(i%2==1){
			stand++;
		}
		if(stand>k){
			cnt -= data[left];
			cnt -= data[left + 1];
			left += 2;
			stand--;
		}
		chmax(ans, cnt);
		//	clog << i << " " << cnt<<": "<<ans << endl;
	}
	 cout << ans << endl;
}
/*
010101


*/

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

int main() {

    char x;
    char y;

    scanf("%c %c", &x, &y);

    if (x == y) {
        puts("=");
    } else if (x > y) {

        puts(">");

    } else {

        puts("<");

    }
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
//通过999...9和1000...0确定N的位数
//通过二分答案(比N多一位)确定N的大小 
bool smaller_than_N(int n){
	cout<<"? "<<n<<"0\n"<<flush;
	char c;cin>>c;
	return c=='N';
}
int main(){
	int t=1;
	//N!=10^m
	rep1(w,9){
		char c1,c2;
		cout<<"? ";rep(k,w)cout<<'9';cout<<'\n'<<flush;cin>>c1;
		cout<<"? 1";rep(k,w)cout<<'0';cout<<'\n'<<flush;cin>>c2;
		if(c1=='Y'&&c2=='N'){
			int l=t,r=t*10-1;
			while(l<r){
				int mid=(l+r)>>1;
				if(smaller_than_N(mid))l=mid+1;
				else r=mid;
			}
			cout<<"! "<<r<<'\n'<<flush;
			return 0;
		}
		t*=10;
	}
	//N=10^m
	rep1(w,10){
		cout<<"? ";rep(k,w)cout<<'2';cout<<'\n'<<flush;
		char c;cin>>c;
		if(c=='Y'){
			cout<<"! 1";rep(k,w-1)cout<<'0';cout<<'\n'<<flush;
			return 0;
		}
	}
	return 0;
}

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

#define ll long long

int main(){
	ll n,a,b,res1,res2;
	cin>>n>>a>>b;
	res1=a,res2=b;
	for (int i=1;i<n;i++){
		cin>>a>>b;
		ll t1=res1/a;
		ll t2=res2/b;
		if (res1%a) t1++;
		if (res2%b) t2++;
		res1=a*max(t1,t2);
		res2=b*max(t1,t2);
	}
	cout<<res1+res2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <math.h>
#include <stdio.h>
#define pai 3.1415926535
using namespace std;

int a, b, c, d, e, f;
int A, B, C, D, E, F;
string x;

int main() {

	cin >> a >> b >> c >> d >> e >> f;
	A = a;
	B = b;
	C = c;
	D = d;
	E = e;
	F = f;

	cin >> x;

	for (int i = 0; i < x.size(); i++) {
		if (x[i] == 'S') {
			A = e;
			B = a;
			C = c;
			D = d;
			E = f;
			F = b;

			a = A;
			b = B;
			c = C;
			d = D;
			e = E;
			f = F;
		}
		if (x[i] == 'W') {
			A = c;
			B = b;
			C = f;
			D = a;
			E = e;
			F = d;

			a = A;
			b = B;
			c = C;
			d = D;
			e = E;
			f = F;
		}
		if (x[i] == 'E') {
			A = d;
			B = b;
			C = a;
			D = f;
			E = e;
			F = c;

			a = A;
			b = B;
			c = C;
			d = D;
			e = E;
			f = F;
		}
		if (x[i] == 'N') {
			A = b;
			B = f;
			C = c;
			D = d;
			E = a;
			F = e;

			a = A;
			b = B;
			c = C;
			d = D;
			e = E;
			f = F;
		}
	}

	cout << A << endl;

	return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+5;
map<string,int> m;
map<string,bool> tag;
ll n,i,anss,ans,len;
char s[N][20];
string ss[N];
string str[N];
bool cmp(string a,string b)
{
	return a<b;
}
int main()
{
	cin>>n;
	ans=1;
	fori(i,1,n)
	{
		cin>>ss[i];
		if (m.find(ss[i])==m.end()) m[ss[i]]=1;
		else {
			m[ss[i]]++;
			anss=m[ss[i]];
			ans=max(ans,anss);
		}
	}
	fori(i,1,n)	
	if (tag.find(ss[i])==tag.end()&&m[ss[i]]==ans)
	{
		tag[ss[i]]=true;
		len++;
		str[len]=ss[i];
	}
	sort(str+1,str+1+len,cmp);
	fori(i,1,len)
	cout<<str[i]<<endl;
}

Measured memory_bytes: 41728
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける



ll n,k,x,y;
ll a,b,c;
int main(){
  ll ans=0;
  cin >> a >> b>>c;
  //2*sqrt(a*b)<c-a-b


  c=c-a-b;
  if (c<0){
    cout<<"No"<<endl;
    return 0;
  }
  
  if ((a*b*4<c*c)){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    int N;
    cin >> N;
    int bunsi = N/2+N%2;

    double ans = (double)(bunsi/(double)(N));
    
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
time=map(int,open(0).read().split())

def dist(n,th):
  amari=n%th
  if amari == 0:
    return amari
  else:
    return th-amari

arr=sorted([[dist(t,10),t] for t in time] ,key=lambda x: x[0])
print(sum([sum(x) for x in arr[:-1]])+arr[-1][1])

Measured memory_bytes: 3060
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  vector<int> e(4);
  for (int i = 0; i < 4; i++) cin>>e[i];
  sort(e.begin(), e.end());
  if (e[0] == e[1] && e[2] == e[3]) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}



Measured memory_bytes: 3132
n = int(input())

l = []

for i in range(n):
    l1 = [0 for i in range(26)]
    s = list(input())
    for c in s:
        l1[ord(c)-ord("a")] += 1
    l.append(l1)

res = l.pop()

for s in l:
    for i in range(26):
        res[i] = min(res[i],s[i])

r = []
for i in range(26):
    for j in range(res[i]):
        r.append(chr(ord("a")+i))

print("".join(r))










Measured memory_bytes: 3316
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	char str[1010];
	int w;
	
	cin >> str >> w;
	
	for (int i = 0; i < (int)strlen(str); i += w) {
		cout << str[i];
	}
	
	cout << endl;
	
	return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int X = scan.nextInt();
		int Y = scan.nextInt();

		if(X * 2 <= Y && X * 4 >= Y && Y % 2 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 27084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int so = 1;
        sc.nextLine();
        int count = 0;
        while(so < b){
            so += a - 1;
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n<1200) printf("ABC\n");
        else if(n<2800) printf("ARC\n");
        else printf("AGC\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

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

int main(){
  int n; cin>>n;
  // vector<int> a(n);
  // rep(i,n){
  //   cin>>a[i];
  // }
  string ans="No";
  rep(i,n){
    rep(j,n){
      if(4*i+7*j==n){
        ans="Yes";
        goto fin;
      }
    }
  }
  fin:
  cout<<ans;

  // cout<<a[0];
    
  
  
  return 0;
}

Measured memory_bytes: 384
VAR
  b : array [0..100000] of longint ;
  x, i, n : longint ;
BEGIN
  readln(n) ;
  for i := 1 to n do
    begin
      read(x) ;
      b[x] := i ;
    end ;
  for i := 1 to 100000 do
    if b[i] <> 0 then write(b[i],#32) ;
  writeln ;
END.

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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a=0;
	for(int i=1;i<n;i++)
	{
		int cn=0;
		for(char c='a';c<='z';c++)
		{
			bool l=false,r=false;
			for(int j=0;j<i;j++)
			if(s[j]==c)
			l=true;
			for(int j=i;j<n;j++)
			if(s[j]==c)
			r=true;
			if(l&&r)
            cn++;
    		}
		if(a<cn)
		a=cn;
	
		
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstddef>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <queue>
#include <stack>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

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

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  std::sort(a.begin(), a.end());
  intmax_t res = 0;
  for (size_t i = 0; i < n; ++i)
    for (size_t j = i+1; j < n; ++j) {
      auto itl = a.begin() + j+1;
      auto itr = std::lower_bound(a.begin(), a.end(), a[i]+a[j]);
      res += std::max(0_jd, itr-itl);
    }

  printf("%jd\n", res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans = 0, ansc = 0, a, b;
  cin >> N >> a >> b;
  for (int i = 0; i < N - 1; i++) {
    if (a >= b) {
      ansc++;
      if (i == N - 2) {
        ans = max(ans, ansc);
      }
    }
    else {
      ans = max(ans, ansc);
      ansc = 0;
    }
    a = b;
    if (i < N - 2) {
      cin >> b;
    }
  }
  cout << ans << endl;
}

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

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


Measured memory_bytes: 256
N = gets.to_i

Ss = []

a = 0
b = 0
ba = 0

sum = 0

N.times do
  s = gets.chomp
  
  sum += s.scan('AB').length

  if s[0] == "B" && s[s.length-1] == "A"
    ba += 1
  elsif s[0] == "B"
    b += 1
  elsif s[s.length-1] == "A"
    a += 1
  end
end


pair = [a, b].min

sum += pair

if !(a == 0 && b == 0)
  sum += ba
else
  if ba != 0
    sum += (ba - 1)
  end
end


puts sum


Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  int h = 0, w = 0, m = 0;

  cin >> h >> w >> m;

  vector<pair<int, int > > xt(h), yt(w);

  set<pair<int,int> > have;

  for(int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    xt[--x].fi++;
    yt[--y].fi++;
    have.insert(mp(x, y));
  }

  int ans = 0;

  for(int i = 0; i < h; i++) xt[i].se = i;

  for(int i = 0; i < w; i++) yt[i].se = i;

  sort(rall(xt)); sort(rall(yt));

  for(int i = 0; i < min(h, 10); i++)
    for(int j = 0; j < w; j++) {
      int cur = xt[i].fi + yt[j].fi - (have.count(mp(xt[i].se, yt[j].se)));
      ans = max(ans, cur);
    }

  for(int j = 0; j < min(w, 10); j++)
    for(int i = 0; i < h; i++) {
      int cur = xt[i].fi + yt[j].fi - (have.count(mp(xt[i].se, yt[j].se)));
      ans = max(ans, cur);
    }


  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    vector<int> a(10);
    iota(ALL(a), 0);
    vector<int> f(10, true);
    int K, N;
    cin >> N >> K;
    REP(i, K) {
        int k;
        cin >> k;
        f[k] = false;
    }

    auto check = [&](int x) {
        while (x != 0) {
            int a = x % 10;
            if (f[a] == false) {
                return false;
            }
            x /= 10;
        }
        return true;
    };

    FOR(i, N, 100000) {
        if (check(i)) {
            std::cout << i << '\n';
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

int const N = 2e5 + 41;
int n, k, l, colR[N], colW[N], p[N];
map<pair<int, int>, int> cnt;

int find(int u){
	if(p[u] == u){
		return u;
	}
	return p[u] = find(p[u]);
}

void unite(int a, int b){
	a = find(a);
	b = find(b);
	if(a != b){
		p[a] = b;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
#endif
	scanf("%d %d %d",&n,&k,&l);
	for(int i=1;i<=n;++i){
		p[i] = i;
	}
	for(int i=0;i<k;++i){
		int u, v;
		scanf("%d %d",&u,&v);
		unite(u, v);
	}
	
	for(int i=1;i<=n;++i){
		colR[i] = find(i);
	}
	for(int i=1;i<=n;++i){
		p[i] = i;
	}
	for(int i=0;i<l;++i){
		int u, v;
		scanf("%d %d",&u,&v);
		unite(u, v);
	}
	for(int i=1;i<=n;++i){
		++cnt[make_pair(colR[i], find(i))];
	}
	for(int i=1;i<=n;++i){
		printf("%d ",cnt[make_pair(colR[i], find(i))]);
	}


	return 0;
}

Measured memory_bytes: 13568