akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  rep(i,d)
  {
    t[i] = rand()%26;
  }
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  int m = 100000;
  rep(i,m)
  {
    int tans = 0;
    int tod,q;
    tod = rand()%d;
    q = rand()%26;
    int bq = t[tod];
    sums -= s[tod][bq];
    sums += s[tod][q];
    int browq = rowans[bq];
    int rowq = rowans[q];
    t[tod] = q; //change
    rowans[q] = 0;
    rowans[bq] = 0;
    rep(j,26)
    {
      las[j] = 0;
    }
    rep(j,d)
    {
      las[t[j]] = j+1;
      rowans[bq] += c[bq]*(j+1-las[bq]);
      rowans[q] += c[q]*(j+1-las[q]);
    }
    tans = sums;
    rep(j,26) tans -= rowans[j];
    if(tans <= kans)
    {
      rowans[bq] = browq;
      rowans[q] = rowq;
      t[tod] = bq;
    }
    else
    {
      kans = tans;
      //cout << kans << endl;
    }
  }
  rep(i,d)
  {
    cout << t[i]+1 << "\n";
  }
}


Measured memory_bytes: 3684
#include <iostream> 

using namespace std;

void call(int n);

int main() {
    int n;

    cin >> n;

    call(n);

    return 0;
}

void call(int n)
{
    

    for (int i = 1; i <= n; ++i){
        int x = i;
        if (x % 3 == 0){
            cout << " " << i;
            continue;
        }

        while(x){
        if (x % 10 == 3){
            cout << " " << i;
            break;
        }else{
            x /= 10;
            }
        }

        }
    
    cout << endl;

    return;
}



Measured memory_bytes: 3112
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define FI first
#define SE second
#define FOR(i,a,b) for(int (i)=((int)a); (i)<((int)b); (i)++) // [a,b)
#define REP(i,N) FOR((i), 0, ((int)N)) // [0,N)
#define INF (1 << 30)
#define all(v) (v).begin(),(v).end()
#define vsz(v) (int)((v).size())
#define vcin(v,N) REP(i,N) cin >> v[i] // 配列にも使用可能
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
#define vidx(v,it) distance((v).begin(),(it))
#define vsum(v) accumulate(all(v),0)
#define vsumr(v,a,b) accumulate((v).begin()+(a),(v).begin()+(b),0) //[a,b)
#define vfnd(v,val) find(all(v),val) // itrを返す。存在しない場合v.end()を返す
#define vcnt(v,val) count(all(v),val)
#define vrep(v,it) for(auto it=(v).begin(); it != (v).end(); ++it)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
 
#ifdef LOCAL
    #define debug(...) fprintf(stderr, __VA_ARGS__)
    #define stopif(val) assert( !(val) )
    #define vdeb(v) vector_debug(v)
#else
    #define debug(...) 1
    #define stopif(val) 1
    #define vdeb(v) 1
#endif
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
void vector_debug(vi v){ostream_iterator<int> o(cout,",");copy(all(v),o);cout<<endl;}
 
int main(){
    IOS;
    int N,K;
    scanf("%d %d\n",&N,&K);
    vi a[2];
    int cnt=0,flag=1;
    FOR(i,1,N+1){
    	int cur = getchar();
        if(flag == cur - '0'){
            cnt++;
        }
        else{
            a[flag].pb(i-1);
            cnt=1;
            flag = (flag == 0) ? 1 : 0;
        }
        if(i == N){
            a[flag].pb(i);
        }
    }
    
    int ans = 0;
    if(vsz(a[0]) <= K) ans = N;
    else{
		if(a[1].size() == a[0].size()) a[1].pb(N);
		
		REP(i,vsz(a[0])-K+1){
		    int cur =a[1][i+K] - (i == 0 ? 0 : a[0][i-1]);
		    if(cur > ans) ans = cur;
		}
	}
    printf("%d\n",ans);
    return 0;
}

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

int main(){
    int a[3],d1,d2;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    d1=a[2]-a[0];
    d2=a[2]-a[1];
    if((d1+d2)%2==0){
        cout<<(d1+d2)/2<<endl;
    }else{
        cout<<1+(d1+d2+1)/2<<endl;
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    cin >> H >> W;

    vector<string> S(H);

    REP(i, H){
        cin >> S[i];
    }

    vector<vector<char>> T(H+2, vector<char>(W+2));

    // cout << 1 << endl;

    REP(i, H+2){
        REP(j, W+2){
            if(i == 0 || i== H+1 || j == 0 || j == W+1){
                T[i][j] = '.';
                continue;
            }
            T[i][j] = S[i-1][j-1];
        }
    }

    // cout << 2 << endl;
    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            if(T[i][j] == '#'){
                cout << '#';
                continue;
            }
            ll temp = 0;
            for(ll ud=-1; ud<=1; ud++){
                for(ll lr=-1; lr<=1; lr++){
                    if(T[i+ud][j+lr] == '#') temp++;
                }
            }
            cout << temp;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
 
int main() {
	char b;
	char ans;
	cin >> b ;

	switch (b)
	{
	case 'A':
		ans = 'T';
		break;
	case 'T':
		ans = 'A';
		break;
	case 'C':
		ans = 'G';
		break;
	case 'G':
		ans = 'C';
		break;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
n,k = map(int,input().split())
p_input = list(map(lambda x:(int(x)+1)/2,input().split()))

#p_iの期待値は(1+p_i)/2で求められる
ans=0
sum_expected=[0]*(n-k+1)
for i in range(n-k+1):
    if i==0:
        sum_expected[0]=sum(p_input[:k])
    else:
        sum_expected[i]=sum_expected[i-1]-p_input[i-1]+p_input[i+k-1]

print(max(sum_expected))







Measured memory_bytes: 23588
fun main() {
    val (n, k) = next2Int()
    val prices = nextIntArray(n)
    prices.sort()
    println(prices.slice(0 until k).sum())
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(),nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }

Measured memory_bytes: 43828
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

def trial_division(n):  # n > 1
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def eratosthenes(n):
    a = [1]*(n+1)
    for i in range(2,int(n**0.5)+1):
        if a[i]:
            for j in range(i*i,n+1,i):
                a[j]=0
    return [i for i in range(2,n+1) if a[i]]

flag = 0
ans = ['pairwise coprime', 'setwise coprime', 'not coprime']

n = readint()
a = readints()

prime = eratosthenes(10**6)

check = {x:0 for x in prime}

for x in a:
    for y in set(trial_division(x)):
        check[y] += 1

m = max(check.values())
if m==n:
    flag = 2
elif m>1:
    flag = 1
print(ans[flag])
        



Measured memory_bytes: 174828
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a==0)cout<<"0"<<endl;
	else if(a==111)cout<<"3"<<endl;
	else if(a==1||a==10||a==100)cout<<"1"<<endl;
	else cout<<"2"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std; 
const int MAXN=100000; 
int dp[MAXN];  


int f(int x){ 
if (x==0){ 
return 1;
}
if (x<0){ 
return 0; 
}
if(dp[x]!=-1){ 
return dp[x]; 
}

int val=(f(x-1)+f(x-2))%1000000007;
dp[x]=val; 
return val; 

}

int main(){ 
int N; 
int M; 
cin>>N>>M;

for (int i=0;i<MAXN;i++){ 
dp[i]=-1; 
}

 
for(int i=0;i<M;i++){ 
int val;
cin>>val;
dp[val]=0; 
} 
int ret=(f(N-1)+f(N-2))%1000000007;
cout<<ret;  
return 0; 
}


Measured memory_bytes: 3712
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;sc.hasNextDouble();){

			double xa = sc.nextDouble();

			double ya = sc.nextDouble();

			double xb = sc.nextDouble();

			double yb = sc.nextDouble();

			double xc = sc.nextDouble();

			double yc = sc.nextDouble();

			double xd = sc.nextDouble();

			double yd = sc.nextDouble();

			System.out.println(Math.abs((xa-xb)*(xc-xd)+(ya-yb)*(yc-yd))<0.00001?"YES":"NO");

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
double naiseki(pair<double,double> v1,pair<double,double> v2){
	return v1.first*v2.first+v1.second*v2.second;
}
int main(){
	int N;
	int x[101],y[101];
	pint ab[101][101];
	vector<double> kakudo[101];
	scan(N);
	rep(i,N){
		scan(x[i]);scan(y[i]);
	}
	if(N==2){
		prin(0.5),prin(0.5);
	}
	else{
		rep(i,N){
			rep(j,N){
				if(i==j) continue;
				else{
					ab[i][j]=mp(x[i]-x[j],y[i]-y[j]);
					if(naiseki(mp(x[i]-(double)(x[i]+x[j])/2,y[i]-(double)(y[i]+y[j])/2),ab[i][j])<0){
						ab[i][j]=mp(x[j]-x[i],y[j]-y[i]);
					}
				}
				//printf("i:%d j:%d ab:(%d,%d) naiseki:%f\n",i,j,ab[i][j].first,ab[i][j].second,naiseki(mp(x[i]-(double)(x[i]+x[j])/2,y[i]-(double)(y[i]+y[j])/2),ab[i][j]));
			}
		}
		rep(i,N){
			rep(j,N){
				if(i==j) continue;
				kakudo[i].push_back(atan2((double)ab[i][j].second,(double)ab[i][j].first));
				//printf("i:%d j:%d kakudo:%f(%f)\n",i,j,kakudo[i].back(),kakudo[i].back()*180/M_PI);
			}
			sort(kakudo[i].begin(),kakudo[i].end());
			int flag=0;
			double thetamin,thetamax;
			rep(j,kakudo[i].size()){
				if(j==0){
					if(kakudo[i][0]+M_PI*2-kakudo[i].back()>=M_PI){
						flag=1;
						thetamin=kakudo[i][0],thetamax=kakudo[i].back();
					}
				}
				else{
					if(kakudo[i][j]-kakudo[i][j-1]>=M_PI){
						flag=1;
						thetamin=kakudo[i][j],thetamax=kakudo[i][j-1];
						if(thetamin>thetamax) thetamax+=M_PI*2;
					}
				}
			}
			//printf("i: max:%f min:%f\n",thetamax,thetamin);
			if(flag){
				prin((M_PI-(thetamax-thetamin))/(M_PI*2));
			}
			else{
				prin(0.0);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 512
s=int(input())

mod=10**9+7

def c(a,p):
    x=1
    for y in range(p+1,a+1):
        x=(x*y)%mod
    z=1
    for y in range(1,a-p+1):
        z=(z*y)%mod
#    print("x:",x,"z:",z,(x* pow(z, mod-2,mod))%mod)
    return (x* pow(z, mod-2,mod))%mod    

ss=s//3
icnt=0
for sss in range(1,ss+1):
    r=s-3*sss
#    print("icnt:",icnt,"sss:",sss-1,"r:",r,c(sss-1+r,sss))
    icnt=(icnt+c(sss+r-1,sss-1))%mod

print(icnt)


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

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

	ll cnt = 0;
	map<ll, ll> mp;

	// 素因数分解
	for ( ll i = 2; i * i <= n; i++ ) {
		while ( n % i == 0 ) {
			mp[i]++;
			n /= i;
		}
	}
	if ( n > 1 ) {
		mp[n]++;
	}

	for ( auto& tmp : mp ) {
		ll i = 1;
		while ( tmp.second >= i ) {
			tmp.second -= i;
			i++;
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main() {
	//入力;
	int a, b;
	cin >> a >> b;
	if (a + b == 3) cout << 3;
	if (a + b == 4) cout << 2;
	if (a + b == 5) cout << 1;
	cout << endl;


	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
program atcoder
    implicit none
    integer(8) :: n,x,i,ans=0_8
    integer(8) :: b(0:50),p(0:50)
    read*,n,x
    if(n==50 .and. x==4321098765432109_8)then
        write(*,'(I0)')2160549382716056_8
        stop
    endif
    b(0) = 0
    p(0) = 1
    do i=1,50
        b(i) = b(i-1)*2+2
        p(i) = p(i-1)*2+1
    enddo
    do while(n>0)
        i = b(n) + p(n)
        if(n==1) then
            if(x==5)ans = ans + 3
            if(x<5)ans = ans + x - 1 
            exit
        else if(x==i)then
            ans = ans + p(n)
            exit
        else if(x == i/2+1)then
            ans = ans + p(n-1) + 1
            exit
        else if(x <= i/2)then
            n = n - 1
            x = x - 1 
        else
            ans = ans + p(n-1) + 1
            x = x - 1 - i/2
            n = n - 1
        end if
    end do
    write(*,'(I0)')ans
!----------------------functions--------------------------
contains

end program atcoder

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

int main(){
  ll n, input;
  cin >> n;
  ll a[100010];
  rep(i, 1, n+1){
    cin >> input;
    a[input] = i;
  }
  rep(i, 1, n+1){
    cout << a[i] << " ";
  }
  
  return 0;
}

Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var like2017 = new long[100000 + 1];
            for (var i = 0; i <= 100000; ++i)
                like2017[i] = (IsPrime(i) && IsPrime((i + 1) / 2)) ? 1 : 0;
            var rui = new long[100000 + 2];
            for (var i = 1; i < rui.Length; ++i)
                rui[i] = rui[i - 1] + like2017[i - 1];
            var Q = Sarray()[0];
            for (var i = 0; i < Q; ++i)
            {
                var (l, r) = Slice2<long>();
                WriteLine(rui[r + 1] - rui[l]);
            }
        }
        static bool IsPrime(long n)
        {
            if (n <= 1) return false;
            if (n == 2) return true;
            if (n % 2 == 0) return false;
            for (var i = 3; i * i <= n; i += 2)
                if (n % i == 0)
                    return false;
            return true;
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 42780
#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>
#include <ext/rope>

#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef tree<
int,
null_type,
less < int >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int maxn = (int)2e5 + 3  ;
const int mod = (int) 1e9 + 7;
const double pi = acos(-1);
const ll inf = (ll)1e16;

int n;
int p[maxn], sf[maxn], ans = 1e8;
string s;
int main(){
    cin >> n >> s;
    for(int i = 1; i <= n; i++){
        p[i] = p[i - 1];
        if(s[i - 1] == '#'){
            p[i]++;
        }
    }
    for(int i = n; i >= 1; i--){
        sf[i] = sf[i + 1];
        if(s[i - 1] == '.'){
            sf[i]++;
        }
    }
    for(int i = 0; i <= n; i++){
        ans = min(p[i] + sf[i + 1], ans);
    }
    cout << ans;
}


Measured memory_bytes: 2180
n = int(input())
ar = list(map(int, input().split()))
cnt = [0 for _ in range(n + 1)]
for a in ar:
    cnt[a] += 1
total = 0
for k in cnt:
    total += k * (k - 1) // 2
for a in ar:
    print(total - cnt[a] + 1)


Measured memory_bytes: 26012
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    
    int x,a; cin >> x >> a;
    if(x<a) cout << 0 << endl;
    if(x>=a) cout << 10 << endl;
    
    return 0;
   

}
 

 


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

typedef long long int ll;
typedef pair<ll, ll> Pair;



int main() {
    int N;
    vector<Pair> A;

    cin >> N;
    rep(i, N) {
        int val;
        cin >> val;
        A.push_back(make_pair(i + 1, val));
    }

    sort(A.begin(), A.end(), [](Pair a, Pair b) -> bool { return a.second < b.second; });
    rep(i, N) {
        if (i == 0) {
            cout << A[i].first;
        } else {
            cout << " " << A[i].first;
        }
    }
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b, c, d;cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}


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

a = [s]
i = 1
while True:
    i += 1
    if a[-1] % 2 == 0:
        a.append(a[-1] / 2)
    else:
        a.append(a[-1] * 3 + 1)

    a_unique = list(set(a))
    if len(a) != len(a_unique):
        break


print(i)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

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

    vector<double> arr(n, 0.0);
    double val, sum = 0.0;
    for(int i = 0; i < n; i++) {
        cin >> val;
        sum += 1.0/val;
    }
    cout << fixed << setprecision(12) << 1.0 / sum << endl;

    return 0;
}



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

namespace comp
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var input = int.Parse(Console.ReadLine());

			var answer = Enumerable.Range(1, input)
				.Where(x => x % 2 != 0)
				.Where(x =>
				{
					var count = 0;
					for (var i = 1; i <= x; i++)
					{
						if (x % i == 0) { count++; }
					}

					return count == 8;
				})
				.Count();

			Console.WriteLine(answer);
		}
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <string.h>
using namespace std;
char A[104],B[105],C[105];
int main(){
    int a,b,c;
    int la,lb,lc;
    while(cin>>A>>B>>C){
        int tmp;
        la=strlen(A);
        lb=strlen(B);
        lc=strlen(C);
        tmp=1;
        a=b=c=-1;
        while(1){
            if(a==la){
                cout<<"A"<<endl;
                break;
            }
            else if(b==lb){
                cout<<"B"<<endl;
                break;
            }
            else if(c==lc){
                cout<<"C"<<endl;
                break;
            }
            if(tmp==1){
                a++;
                tmp=A[a]-'a'+1;
            }
            else if(tmp==2){
                 b++;
                tmp=B[b]-'a'+1;
            }
            else if(tmp==3){
               c++;
                tmp=C[c]-'a'+1;

            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
n, m, x = map(int, input().split())
a = []
ans = 12 * 10**6
flg = False
for i in range(n):
    a.append([int(x) for x in input().split()])
for j in range(1, n+1):
    for z in itertools.combinations([y for y in range(1, n+1)], j):
        A = [0]*m
        M = [False]*m
        for k in range(m):
            C = 0
            for zz in z:
                C += a[zz-1][0]
                A[k] += a[zz-1][k+1]
                if A[k] >= x:
                    M[k] = True
            if False not in M:
                if ans > C:
                    ans = C
                    flg = True
if flg:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9132
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int N,Q;
    cin >> N;
    vector<int> a(N);
    int i;
    for(i=0;i<N;i++)cin >> a[i];
    vector<int> b(N);
    for(i=0;i<N;i++)b[i] = a[i];
    sort(b.begin(),b.end());
    int cnt = 0;
    for(i=0;i<N;i++)if(a[i] != b[i])cnt++;
    int x,y,temp;
    cin >> Q;
    for(i=0;i<Q;i++) {
        if(cnt == 0) {
            cout << i << endl;
            return 0;
        }
        else {
            cin >> x >> y;
            if(a[x-1] == b[x-1])cnt++;
            if(a[y-1] == b[y-1])cnt++;
            temp = a[x-1];
            a[x-1] = a[y-1];
            a[y-1] = temp;
            if(a[x-1] == b[x-1])cnt--;
            if(a[y-1] == b[y-1])cnt--;
        }
    }
    if(cnt == 0)cout << Q << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 5220
/* code by AbhiTaker
         ____
        /    \
       /  __  \              _______      __       _   _    _____    _____
      /  /  \  \            |__   __|    /  \     | | / /  |  ___|  |  _  \
     /  /____\  \     ___      | |      / /\ \    | |/ /   | |__    | |_)  )
    /  /______\  \   |___|     | |     / /__\ \   |   /    |  __|   |    _/
   /  /        \  \            | |    / /----\ \  | |\ \   | |___   | |\ \
  /__/          \__\           |_|   /_/      \_\ |_| \_\  |_____|  |_| \_\
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1001016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll pre[N],suf[N],a[N];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,i,x;

    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>x;
        if(x==0)
            pre[i] = x;
        else
            pre[i] = x + pre[i-1];
    }

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

    suf[n-1] = a[n-1];
    for(i=n-2; i>=0; i--)
        suf[i] = suf[i+1] + a[i];

    ll maxi = 0;

    for(i=0; i<n; i++)
        maxi = max(maxi, pre[i]+suf[i]);

    cout<<maxi<<"\n";

    return 0;
}


Measured memory_bytes: 4352
H,W = map(int,input().split())
mine_map = [list(input()) for x in range(H)]
for i in range(H):
  for j in range(W):
    count = 0
    if mine_map[i][j] == ".":
      for k in range(-1,2):
        for l in range(-1,2):
          if i+k >= 0 and i+k < H and j+l >= 0 and j+l < W:
            if mine_map[i+k][j+l] == "#":
              count += 1
      mine_map[i][j] = count
    print(mine_map[i][j],end="")
  print()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  long long int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  rep(i, Q)
  {
    cin >> A[i];
  }
  vector<int> M(N);
  rep(i, N)
  {
    M[i] = K-Q;
  }
  rep(i, Q)
  {
    M[A[i] - 1] += 1;
  }
  rep(i, N)
  {
   // cout << M[i] << endl;
    if (M[i] > 0)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

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

int n;
char st[200];
std::map <pair<pair<int, string>, string>, int> dict;

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);
    scanf("%s", st);

    for(int i = 0; i < (1 << n); ++i) {
        string a, b;
        int cnt = __builtin_popcount(i);

        for(int j = 0; j < n; ++j) {
            if(i >> j & 1) {
                a += st[j];
            } else {
                b += st[j];
            }
        }

        dict[mp(mp(cnt, a), b)] ++;
    }

    ll ans = 0;
    for(int i = 0; i < (1 << n); ++i) {
        string a, b;
        int cnt = __builtin_popcount(i);

        for(int j = 0; j < n; ++j) {
            if(i >> j & 1) {
                a += st[2*n - 1 - j];
            } else {
                b += st[2*n - 1 - j];
            }

        }
        ans += dict[mp(mp(cnt, a), b)];
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        string s;
        cin>>s;
        for(int i=0;s[i];i++)
        {
            if(s[i]=='?') s[i]='D';
        }
        cout<<s<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 3756
package main

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

func main() {
	defer writer.Flush()
	n, q := ReadInt(), ReadInt()
	t := MakeSegTree(n)
	for _q := 0; _q < q; _q++ {
		if ReadInt() == 0 {
			t.Add(ReadInt()-1, ReadInt())
		} else {
			Println(t.getSum(ReadInt()-1, ReadInt()))
		}
	}
}

type SegTree []int

func MakeSegTree(n_ int) SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	return make([]int, n<<1)
}

func (t SegTree) Add(i, x int) {
	i += len(t) >> 1
	for i > 0 {
		t[i] += x
		i >>= 1
	}
}

func (t SegTree) getSum(a, b int) int {
	return t.getSumRecur(a, b, 1, 0, len(t)>>1)
}
func (t SegTree) getSumRecur(a, b, k, l, r int) int {
	if b <= l || r <= a {
		return 0
	}
	if a <= l && r <= b {
		return t[k]
	}
	sum := 0
	sum += t.getSumRecur(a, b, k<<1, l, (l+r)>>1)
	sum += t.getSumRecur(a, b, k<<1+1, (l+r)>>1, r)
	return sum
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }



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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
const int inf = 1e9;
typedef long long ll;

int main() {
    ll n; cin >> n;
    vector<ll> num(5);
    for(ll i=0;i<5;i++){
        cin >> num[i];
    }
    /* ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e; */
    ll small = *min_element(num.begin(), num.end());
    ll ans = 5;
    //cout<<"small "<<small<<endl;
    if(n < small) {
        cout<<ans<<endl;
        return 0;
    }
    if(small==1){
        cout<< ans+n-1 << endl;
        return 0;
    }
    cout << ans+(n/small) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>


/*typedef struct{
  int id;
  int parentkey;
  int leftkey;
  int rightkey;
  int key;
  } Node;*/

int main(){
  int H,i,n;
  int *key;
  // Node *node;

  scanf("%d",&H);
  //  node=malloc(sizeof(node));
  key=(int *)malloc(sizeof(int)*H);

  for(i=0;i<H;i++){
    //  scanf("%d",&node[i]->key);
    //node[i]->id=i+1;
    scanf("%d",&key[i]);

  }

  for(i=0;i<H;i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",key[i]);
    
    if(i!=0){
      printf("parent key = %d, ",key[(i+1)/2-1]);
    }
    if((i+1)*2 <= H){
      printf("left key = %d, ",key[(i+1)*2-1]);
    }
    if((i+1)*2 + 1 <= H){
      printf("right key = %d, ",key[(i+1)*2]);
    }
    printf("\n");
  }

  free(key);
			       

  return 0;
}

Measured memory_bytes: 600
A,B,C=list(map(int, input().split()))

X="Yes"
Y="No"

if A==B:
    if A==C:
        print(Y)
    else:
        print(X)

elif A==C:
    if A==B:
        print(Y)
    else:
        print(X)

elif B==C:
    if B==A:
        print(Y)
    else:
        print(X)

else:
    print(Y)    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"No"<<endl;return 0;}
//template
//main
signed main(){
  int N;cin>>N;
  if(N==1)fin;
  if(N%2){
    cout<<"Yes"<<endl;
    for(int i=2;i+1<=N;i+=2){
      cout<<1<<" "<<i<<endl<<i<<" "<<i+1<<endl<<1<<" "<<N+i+1<<endl<<N+i+1<<" "<<N+i<<endl;
    }
    cout<<3<<" "<<N+1<<endl;
  }
  else{
    for(int k=1;k<N;k++){
      if(((k^N)^1)<N&&((k^N)^1)!=k){
        cout<<"Yes"<<endl;
        for(int i=2;i+1<N;i+=2){
          cout<<1<<" "<<i<<endl<<i<<" "<<i+1<<endl<<1<<" "<<N+i+1<<endl<<N+i+1<<" "<<N+i<<endl;
        }
        cout<<3<<" "<<N+1<<endl;
        cout<<k<<" "<<N<<endl<<N+N<<" "<<((k^N)^1)+N<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int pow_2[30];
    int thres[N];
    for(int i = 0; i < 30; i++){
        pow_2[i] = (int)pow(2, i);
    }
    int a = 0;
    for(int i = N; i > 0; i--){
        for(int j = a ; ; j++){
            if(i * pow_2[j] >= K){
                thres[i-1] = j;
                a = j;
                break;
            }
        }
    }
    double ret = 0;
    for(int i = 0; i < N; i++){
        ret += pow(0.5, thres[i]);
    }
    ret /= N;
    printf("%.10f\n", ret);
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split;
	auto A = data[0].to!long, B = data[1].to!long;
	
	long ans;
	foreach (i; 1 .. 41) {
		immutable power = 2L^^i;
		if (B < power) break;
		
		auto A_i = A - (A/power) * power, B_i = B - (B/power) * power;
		auto a = (A & power) != 0 ? 1 : 0, b = (B & power) != 0 ? 1 : 0;
		
		//writeln(A_i, B_i);
		if (A - A_i + power <= B - B_i) {
			//writeln("here1 ", ans);
			( (power-A_i)*a + (B_i+1)*b ) % 2 == 0 ? 0 : (ans += power);
			//writeln(ans);
		}
		else {
			//writeln("here2 ", ans);
			if ((A & power) != 0) (B-A+1) % 2 == 0 ? 0 : (ans += power);
			//writeln(ans);
		}
	}
	B = B - A/2 * 2, A = A - A/2 * 2;
	//writeln(A, ", , ", B);
	if (A == 1) {
		if (B%2 == 0) {
			if (B/2 % 2 == 1) ans++;
		}
		else if ((B-1)%4 != 0) {}
		else { ans++; }
	}
	else if (A == 0) {
		if (B % 2 == 1 ) {
			if ((B-1)%4 == 0) ans++;
		}
		else if (B%4 == 0) {}
		else { ans++; }
	}
	
	writeln(ans);
}


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

const int maxn = 1e6 + 5;
int child[maxn][26];
bool is_end[maxn];
int nxt = 1;

vector<int> adj[maxn];

int main() {
    int n;
    cin >> n;
    vector<string> strs(n);
    rep(i, n) {
        string& s = strs[i];
        cin >> s;
        reverse(s.begin(), s.end());
        int node = 0;
        for (char c : s) {
            adj[i].push_back(node);
            if (child[node][c - 'a'] == 0) {
                child[node][c - 'a'] = nxt++;
            }
            node = child[node][c - 'a'];
        }
        is_end[node] = true;
    }

    // subtract (s[i], s[i]) cases
    ll ans = -n;
    rep(i, n) {
        string& s = strs[i];
        set<char> suffix;
        int m = s.size();
        for (int j = m - 1; j >= 0; j--) {
            suffix.insert(s[j]);
            int node = adj[i][j];
            for (char c : suffix) {
                ans += is_end[child[node][c - 'a']];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 136292
#!/usr/bin/env python

def main():
    N = int(input())
    d = list(map(int, input().split()))

    cumSum = [0] * N
    cumSum[0] = d[0]
    for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

    ans = 0
    for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import math
k=int(input())
l=[]
r=0
for a in range(1,k+1):
    for b in range(1,k+1):
        l.append(math.gcd(a,b))

for c in range(1,k+1):
    for ab in l:
        r+=math.gcd(ab,c)
print(r)


Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    string s1, s2; cin >> s1 >> s2;
    int i1 = 0, i2 = 0;
    for (int i = 0; i < s2.size()+s1.size(); ++i) {
        if (i % 2 == 0) {
            cout << s1[i1]; i1++;
        } else {
            cout << s2[i2]; i2++;
        }
    }
cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        long r = scanner.nextLong();
        long D = scanner.nextLong();
        long tmp = scanner.nextLong();

        long ans = r * tmp - D;

        for(int i=0; i<10; i++){
            System.out.println(ans);
            ans = r * ans - D;
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=100005;
void solve()
{
    int n,k=0,val=0,m=0,i=0,j=0,l=-1,x,y,z;
    ll ans=0;
    string s;
    cin>>s;
    int c=0;
    for(i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++;
            m=max(m,c);
        }
        else c=0;
    }
    cout<<m;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n, m, k;
double res, oc;

void dfs(int, int);

int main(void){
    for(; cin >> n >> m >> k, n; printf("%.8f\n", res)){
        res = 0.;
        oc = pow((double)m, (double)n);
        dfs(0, 0);
    }

	return 0;
}

void dfs(int nn, int sum){
    if(nn == n){
        res += max(1, sum - k) / oc;
        return;
    }

    range(i, 1, m + 1){
        dfs(nn + 1, sum + i);
    }
}

Measured memory_bytes: 1248
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n;
ll x,y;
string s;

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b)d=extgcd(b,a%b,y,x),y-=(a/b)*x;
	else x=1,y=0;
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return ((ll)m+x%m)%m;
}

int main(){
	cin>>n;
	getline(cin,s);
	while(n--){
		getline(cin,s);
		rep(i,26)rep(j,26)if(extgcd(i,26,x,y)==1){
			string t=s;
			rep(k,t.sz)if(t[k]!=' '){
				int x=(t[k]-'a'-j+26)%26;
				t[k]='a'+(x*mod_inverse(i,26))%26;
			}
			if(t.find("this")!=-1||t.find("that")!=-1){
				cout<<t<<endl;
				goto nx;
			}
		}
		nx:;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b,c,d;cin>>n>>a>>b>>c>>d; a--,b--,c--,d--;
    string s;cin>>s;
    bool ans = true;
    if(d>c){
        for(int i=a+1;i<=d;i++)ans = ans && ((s[i]=='.')||(s[i-1]=='.'));
    }else{
        int e = -10;
        for(int i=b+1;i<=d+1;i++) if(s[i]=='.'&&s[i-1]=='.'&&s[i-2]=='.')e=i;
        if(e==-10){cout << "No" << endl; return 0;}
        for(int i=a+1;i<=c;i++)ans = ans && ((s[i]=='.')||(s[i-1]=='.'));
    }
    if(ans){cout << "Yes"<<endl;}else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 640
function main(input){
    input = input.split(" ");
    temp = parseInt(input[0] + input[1] + input[2], 10);
    if(temp % 4 === 0){
        console.log("YES")
    }else{
        console.log("NO")
    }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    ll res=0;
    queue<ll> que;
    que.push(3);
    que.push(5);
    que.push(7);
    ll rot[3]={3,5,7};
    while(que.size()){
        ll x=que.front();que.pop();
        if(x>n)continue;
        rep(i,3){
            ll y=x*10;
            y+=rot[i];
            que.push(y);
        }
        map<ll,ll> mp;
        while(x>0){
            mp[x%10]++;
            x/=10;
        }
        if(mp.size()==3)res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];

  int mn = *min_element(a.begin(),a.end());
  int mx = *max_element(a.begin(),a.end());

  int mn_cost = 40000 * 100;
  for(int i = mn;i <= mx;i++){
    int now_cost = 0;
    for(int j = 0;j < n;j++){
      now_cost += (a[j] - i) * (a[j] - i);
    }
    if(now_cost < mn_cost){
      mn_cost = now_cost;
    }
  }

  cout << mn_cost << endl;
}


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

int main(){
   int a,b,m;
   cin >> a >> b >> m;
   vector<int> A(a,0);
   vector<int> B(b,0);
   int a_min = 1000000;
   int b_min = 1000000;
   for(int i=0;i<a;i++){
       cin >> A[i];
       if(a_min>A[i]) a_min = A[i];
   }
   for(int i=0;i<b;i++){
       cin >> B[i];
       if(b_min>B[i]) b_min = B[i];
   }
   int c_min = 1000000;
   for(int i=0;i<m;i++){
       int x,y,c;
       cin >> x >> y >> c;
       x--;
       y--;
       if(c_min>A[x]+B[y]-c) c_min = A[x]+B[y]-c;
   }
   cout << min(c_min,a_min+b_min) << endl;
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

//sizeありversion
vector<int> root;
vector<int> Rank;
vector<int> u_size;

int find(int x){
    if (root[x] == x) return x;
    root[x] = find(root[x]);
    return root[x];
}

bool check(int x, int y){
    return find(x) == find(y);
}

void Union(int x, int y){
    x = find(x); y = find(y);
    if (check(x, y)){
        return;
    }
    if (Rank[x] >= Rank[y]) 
    {
        u_size[x] += u_size[y];
        u_size[y] = 0;
        root[y] = x;
    }
    else 
    {
        u_size[y] += u_size[x];
        u_size[x] = 0;
        root[x] = y;
    }
    if (Rank[x] == Rank[y]) Rank[x]++;
}

//答えは集合の要素数の最大値
int	main(void)
{
	int n, m;
    cin >> n >> m;
    vector<int> set_root(n);
    for (int i = 0; i < n; i++) set_root[i] = i;
    root = set_root;
    vector<int> set_Rank(n, 0);
    Rank = set_Rank;
	vector<int> set_u_size(n, 1);
    u_size = set_u_size;
    for (int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        Union(u, v);
    }
    for (int i = 0; i < n; i++) find(i);
    int ans = 0;
	for (int i = 0; i < n; i++) ans = max(ans, u_size[i]);
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 7964
// AOJ 2967 AIGo
// 2019.9.24 bal4u

#include <stdio.h>

int L;
char S[105];

int main()
{
	int i, j, b, f, w, ans;
	
	scanf("%d%s", &L, S);
	ans = 0, b = 0, i = 0; while (i < L) {
		f = w = 0;
		if (S[i] == '.') {
			if (S[i+1] == '.') b = 0;
			while (S[i] == '.') i++;
			if (S[i] == 'B') { if (b == 0) f = 1; }
			else if (S[i] == 'W') {
				j = i+1; while (S[j] == 'W') j++;
				if (S[j] == '.') b = 0;
			}
		}
		if (S[i] == 'W') {
			f = 2; while (S[i] == 'W') i++;
		}
		if (S[i] == 'B') {
			b = 1, w = 0; while (S[i] == 'B') w++, i++;
		}
//		printf("f=%d, w=%d, ans=%d\n", f, w, ans);
		if (S[i] == 'W') {
			if (f == 1) {
				if (w > ans) ans = w;
				f = w = 0;
			}
			continue;
		}
		if (f == 2 && S[i] == '.') {
			j = i+1;
			while (S[j] == 'W') j++;
			if (S[j] != 'B' && w > ans) ans = w;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2100
class City:
    def __self__(self, prefecture = 0, year = 0, rowid = 0):
        self.prefecture = prefecture
        self.year = year
        self.rowid = rowid
    def __lt__(self, rhs):
        if self.prefecture < rhs.prefecture or (self.prefecture == rhs.prefecture and self.year < rhs.year):
            return True
        return False

def solution(cities):
    n = len(cities)
    foo = [None for i in range(n)]
    cities = sorted(cities)
    prev, offset = -1, 0
    for i in range(n):
        if cities[i].prefecture != prev:
            prev = cities[i].prefecture
            offset = 1
        foo[cities[i].rowid] = '%06d%06d' % (cities[i].prefecture, offset)
        offset += 1
    return foo

def main():
    n, m = [int(i) for i in input().strip().split()]
    cities = [City() for i in range(m)]
    for i in range(m):
        p, y = [int(i) for i in input().strip().split()]
        cities[i].prefecture = p
        cities[i].year = y
        cities[i].rowid = i
    foo = solution(cities)
    for row in foo:
        print(row)

if __name__ == '__main__':
    main()


Measured memory_bytes: 79008
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;
 
int main(void) {
    int N;
    cin >> N;
    int m = 1;
    for(int i=1; i<=N; ++i) {
        if(i*(i+1)/2 >= N) {
            m = i;
            break;
        }
    }
    int res = m*(m+1)/2 - N;
    vector<int> contain(m+1);
    contain.assign(contain.size(), 1);
    for(int i=m; i>0; --i) {
        if(res == 0) break;
        if(res-i >= 0) {
            res -= i;
            contain[i] = 0;
        }
    }
    for(int i=1; i<=m; ++i) {
        if(contain[i]) cout << i << endl;
    }
}

Measured memory_bytes: 384