akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	bool b[4][13];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++)b[i][j] = true;
	}
	int n;
	int p;
	char c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c >> p;
		if (c == 'S') b[0][p - 1] = false;
		else if (c == 'H') b[1][p - 1] = false;
		else if (c == 'C') b[2][p - 1] = false;
		else if (c == 'D') b[3][p - 1] = false;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (b[i][j]) {
				if (i == 0) cout << "S" << " " << j + 1 << endl;
				else if (i == 1) cout << "H" << " " << j + 1 << endl;
				else if (i == 2) cout << "C" << " " << j + 1 << endl;
				else if (i == 3) cout << "D" << " " << j + 1 << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3080
def main(n, a):
    x = [0] * n
    # print(a)
    # print(a[1:-1:2])
    x[0] = sum(a) - 2 * sum(a[1:-1:2])
    for i in range(n - 1):
        x[i + 1] = 2 * a[i] - x[i]
    return ' '.join([str(xi) for xi in x])


N = int(input())
A = list(map(int, input().split()))
print(main(N, A))
# print(main(3, [2, 2, 4]))


Measured memory_bytes: 19144
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::set<i64> A;
  for (i64 i = 0; i < N; ++i) {
    i64 A_i;
    std::cin >> A_i;
    A.insert(A_i);
  }

  while (true) {
    bool found = false;
    for (std::set<i64>::iterator prev_it = A.begin(), it = ++A.begin(); it != A.end(); ++prev_it, ++it) {
      if (A.insert(*it - *prev_it).second) found = true;
    }
    if (!found) break;
  }

  std::cout << *A.begin() << std::endl;
  return 0;
}

Measured memory_bytes: 13440
#include<iostream>
#include<vector>
#include<deque>
#include<algorithm>
using namespace std;
typedef long long ll;

int n;
ll k;
vector<int> a, pos[200001];

int main(){
    cin >> n >> k;
    a.resize(n);

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

    vector<int> ind;

    int start = 0;
    bool flag = true;
    vector<bool> used(n, 0);
    used[0] = true;

    while(flag){
        while(start < n){
            auto it = upper_bound(pos[a[start]].begin(), pos[a[start]].end(), start);
            if(it != pos[a[start]].end()){
                start = *it+1;
            }else{
                break;
            }
        }
        if(start == n){
            ind.push_back(-1);
            break;
        }else{
            ind.push_back(start);
            used[start] = true;
            if(pos[a[start]][0] != start){
                start = pos[a[start]][0]+1;
            }else{
                start++;
            }
        }
        if(used[start]){
            ind.push_back(-1);
            break;
        }  
    }

    int len = ind.size();
    k--;
    k %= len;
    start = ind[k];
    
    if(start == -1){
        cout << endl;
        return 0;
    }

    vector<int> res;
    while(start < n){
        auto it = upper_bound(pos[a[start]].begin(), pos[a[start]].end(), start);
        if(it != pos[a[start]].end()){
            start = *it+1;
        }else{
            res.push_back(a[start]);
            start++;
        }
    }

    for(int i = 0; i < res.size(); i++) cout << res[i] << " \n"[i+1==res.size()];
    return 0;
}

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

int main() {
 	long long int a,b,c,d; 
	cin >> a >> b >> c >> d;
	long long int ans = 0;
  
  /*	if(a>0 && c> 0)
    {ans = b*d;}
    else if(b<0 && d< 0)
    {ans = a*c;}*/
  
  if(b<0)
  {
    if(d<0)
      {ans = a*c;}
    else if(c<0 && d>=0)
      {ans = a*c;}
   	else if(c>=0)
   	 {ans = b*c;}
  }
    
  
  else if(a<0 && b>=0)
  {
    if(d<0)
  	{ans = a*c;}
    else if(c<0 && d>=0)
    {
      if(a*c >= b*d)
        {ans = a*c;}
      else
        {ans = b*d;}
    }
    else if (c >= 0)
       {ans = b*d;}
  }
      
  else if(a>=0)
  {
    if(d<0)
      {ans = a*d;}
    else if(c<0 && d>=0)
      {ans = b*d;}
   	else if(c>=0)
   	 {ans = b*d;}
  }
      
        
  
	cout << ans << endl;
}

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

int main()
{
    int N;
    string S;

    cin >> N >> S;

    for ( int i = 0; i < S.size(); i++ ) {
        cout << (char)((S[i] - 'A' + N) % 26 + 'A');
    }
    cout << endl;
    return ( 0 );
}


Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    vc<int> to[N];int dis[N];
    void dfs(int x,int fa){dis[x]=dis[fa]+1;for(auto y:to[x])if(y!=fa) dfs(y,x);}
    void main()
	{
        int n=qread();fo(i,2,n){int x=qread(),y=qread();to[x].PB(y),to[y].PB(x);}
        dfs(1,0);int a=1;fo(i,2,n) if(dis[i]>dis[a]) a=i;
        dis[a]=0;dfs(a,0);int mx=0;fo(i,1,n) chmax(mx,dis[i]);
        puts((mx-2)%3==0?"Second":"First");
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int result = 0;
	int hmax = 0;

	for( int i = 0; i < N; ++i ) {
		int h;
		cin >> h;

		if( h >= hmax ) {
			hmax = h;
			result += 1;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  char c; cin >> c;

  char judge[5] = {'a', 'i', 'u', 'e', 'o'};

  for(int i=0; i<5; i++)
    if(c == judge[i]){
      cout << "vowel" << endl;  
      return 0;
    }

  cout << "consonant" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int x, y, r, max, min;
    scanf("%d %d", &x, &y);

    if(x >= 1 && y >= 1 && y <= 1000000000){
       if(x > y){
           max = x;
           min = y;
       }else{
           max = y;
           min = x;
       }

       if(max > min){
           while(min > 0){
               r = max % min;
               max = min;
               min = r;
           }
           printf("%d\n", max);
       }else{
           printf("%d\n", max);
       }
    }
return 0;
}

Measured memory_bytes: 592
#include <iostream>

int main()
{
  int N,M,C;
  int B[1000];
  int A;
  int count=0;
  std::cin >> N >> M >> C;
  for(int i=0; i<M; i++){
    std::cin >>B[i];
  }
  for(int i=0; i<N; i++){
    int temp = C;
    for(int j=0; j<M; j++){
      std::cin >> A;
      temp += A*B[j];
    }
    if(temp > 0){
      count++;
    }
  }
  std::cout << count <<std::endl;
  return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Integer{
public:
    ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;}
    ll lcm(ll a,ll b){return a / gcd(a, b) * b;}

    bool isPrime(ll x){
        if(x < 2) return false;
        if(x == 2) return true;
        if(x % 2 == 0) return false;
        for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false;
        return true;
    }

    vector<ll> divisor(ll M){
        vector<ll> dd;
        for(ll i = 1; i * i <= M; i++){
            if(M % i == 0){
                dd.push_back(i);
                if(i * i != M) dd.push_back(M / i);
            }
        }
        sort(dd.begin(), dd.end());
        return dd;
    }

    vector<ll> factor(ll M){ //素因数分解
        vector<ll> dd;
        if(M == 1){
            dd.push_back(1);
            return dd;
        }
        for(ll i = 2; i*i <= M; i++){
            while(M % i == 0){
                dd.push_back(i);
                M /= i;
            }
        }
        if(M != 1) dd.push_back(M);
        sort(dd.begin(), dd.end());
        return dd;
    }
};
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    // ll ans = 0;
    Integer it;
    Combination cb(100010);
    ll ans = 0;
    ll dp[100010] = {};
    rrep(i,K,1){
        ll cnt = K / i;
        ll v = cb.power(cnt, N);
        for(ll j = i*2; j <= K; j += i){
            v = (v - dp[j]+MOD) % MOD;
        }
        dp[i] = v;
    }
    rep(i,1,K+1){
        ans += i * dp[i] % MOD;
        ans %= MOD;
    }
    print(ans);

    

}

Measured memory_bytes: 5604
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0; i<n; i++)

int main(){
	char a,b,c;
	int x[3]={1,0,0};
	while (cin>>a>>c>>b){
		int k = x[a-'A'];
		x[a-'A'] = x[b-'A'];
		x[b-'A'] = k;
	}
	REP(i,3)
		if (x[i]==1) cout<<char(i+'A')<<endl;
}

Measured memory_bytes: 1132
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	String S = sc.next();
    	int x = 0;
    	int max = 0;
    	for (char c : S.toCharArray()) {
    		if (c == 'I') {
    			x++;
    		} else if (c == 'D') {
    			x--;
    		}
    		if (max < x) {
    			max = x;
    		}
    	}
    	System.out.println(max);
    }
}


Measured memory_bytes: 21844
//縦H cm 横W cmの長方形を'#'で描くプログラム

#include <stdio.h>

//プロトタイプ宣言
void vdPrintRectangle(int iHeight, int iWide);

int main(void)
{
    //変数定義
    int iHeight;        //長方形の縦の長さ 
    int iWide;          //長方形の横の長さ

    //変数初期化
    iHeight = 1;
    iWide = 1;

    //長方形の縦(H)と横(W)を入力
    while (iHeight != 0 && iWide != 0)
    //while (1)
    {
        scanf("%d%d",&iHeight,&iWide);
        //iHeight = 0, iWide = 0が入力されたら入力を終わる
        if (iHeight == 0 && iWide == 0)
        {
            break;
        }
        vdPrintRectangle(iHeight,iWide);
    }
    return 0;
}

void vdPrintRectangle(int iHeight, int iWide)
{
    //変数定義
    int iHeightcount;   //縦カウンタ    
    int iWidecount;     //横カウンタ

    //iHeightcount行目に行くまでループ
    for (iHeightcount = 0; iHeightcount < iHeight; iHeightcount++)
    {
        
        //iWidecount列目に達するまでループ    
        for (iWidecount = 0; iWidecount < iWide; iWidecount++)
        {
            printf("#");
        }
        //'#'がiWide個出力されたら改行する。
        printf("\n");
    }
    //出力と出力の間は改行をいれる。
    printf("\n");
    return;
}


Measured memory_bytes: 2104
from math import ceil, log2

N, K = map(int, input().split())
p = 0

if N < K:
    for n in range(1, N + 1):
        p += (1 / N) * (1 / 2) ** ceil(log2(K / n))
else:  # N >= K
    for n in range(1, K):
        p += (1 / N) * (1 / 2) ** ceil(log2(K / n))
    for n in range(K, N + 1):
        p += (1 / N)

print(p)


Measured memory_bytes: 3060
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

unordered_map<int,int> mp1,mp2;
main(){
    fast();per(0);
    //get_fact();
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        int a;cin>>a;
        mp1[a]++;
    }
    int m;cin>>m;
    for(int i=1;i<=m;i++){
        int a;cin>>a;
        mp2[a]++;
    }
    for(auto i:mp2)
        if(mp1[i.F]<mp2[i.F])
            return cout<<"NO",0;
    cout<<"YES";
}


Measured memory_bytes: 16712
def print_board( X):
    print("\n".join(map(lambda x: "".join(map(str, x)), X)))

H, W = [int(x) for x in input().split()]
board = [ list(input() ) for i in range(H)]
means = [ [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
for i in range(H):
    for j in range(W):
        if board[i][j] == ".":
            mean = [ board[ i + m[0]][j + m[1]] for m in means if 0 <= i + m[0] < H and 0 <= j + m[1] < W  ]
            board[i][j] = mean.count("#")

print_board(board)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T,U;
    int A,B;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(U==S){
        cout<<A-1<<" "<<B<<endl;
    }
    else if(U==T){
        cout<<A<<" "<<B-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc178/tasks/abc178_e
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    cin >> N;
    vector<ll> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    /*
      z = x + y, w = x - y と変換する(いわゆる45度回転)
      マンハッタン距離 |xi - xj| + |yi - yj| の最大値を求める問題は
      z, w それぞれの最大値と最小値を求める問題に帰着される
    */
    vector<ll> z(N), w(N);
    REP(i, N)
    {
        z[i] = x[i] + y[i];
        w[i] = x[i] - y[i];
    }

    ll zmin = numeric_limits<ll>::max(), zmax = -numeric_limits<ll>::max(),
    wmin = numeric_limits<ll>::max(), wmax = -numeric_limits<ll>::max();
    for (int i = 0; i < N; ++i)
    {
        zmin = min(zmin, z[i]);
        zmax = max(zmax, z[i]);
        wmin = min(wmin, w[i]);
        wmax = max(wmax, w[i]);
    }
    ll ans = max(zmax - zmin, wmax - wmin);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9568
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<u8> = itr.next().unwrap().bytes().collect();
    let n = s.len();
    let mut dp = vec![vec![vec![false; 200]; 2]; n + 1];
    dp[0][0][0] = true;
    for i in 0..n {
        let x = (s[i] - '0' as u8) as usize;
        for j in 0..=9 {
            for k in 0..160 {
                if j == x {
                    dp[i + 1][0][j + k] |= dp[i][0][k];
                } else if j < x {
                    dp[i + 1][1][j + k] |= dp[i][0][k];
                }
                dp[i + 1][1][j + k] |= dp[i][1][k];
            }
        }
    }

    let mut ans = 0;
    for i in 0..160 {
        if dp[n][0][i] || dp[n][1][i] {
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	int n;cin>>n;map<int,int>mp;ll s=0;
	vector<int>a(n);for(int i=0;i<n;i++){
		cin>>a[i];mp[a[i]]++;s+=a[i];
	}
	int q;cin>>q;int b,c;
	for(int i=1;i<=q;i++){
		cin>>b>>c;
		s+=(c-b)*mp[b];
		cout<<s<<'\n';
		mp[c]+=mp[b];
		mp[b]=0;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 7992
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();

        int[] arr = new int[w + 2];
        for (int i = 1; i < w + 1; i++) {
            arr[i] = i;
        }

        for (int i = 0; i < n; i++) {
            String[] s = sc.next().split(",");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);

            int temp = arr[a];
            arr[a] = arr[b];
            arr[b] = temp;
        }

        for (int i = 1; i < w + 1; i++) {
            System.out.println(arr[i]);
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    while(h.at(i) >0){
      for(int j=i;j<N;j++){
        if(h.at(i) <= h.at(j)){
          if(j == N-1){
            ans++;
            for(int k=i;k<N;k++){
              h.at(k) = h.at(k) -1;
            }
            break;
          }
        }
        else{
          ans++;
          for(int k=i;k<j;k++){
              h.at(k) = h.at(k) - 1;
          }
          break;
        }
      }
    }
  }
  cout << ans <<endl;
  
}


Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
signed main()
{
    fast;
  
    ll h,n,i,ans ,j;
    cin>>h>>n;
    vector<pii> v;
    for(i=0;i<n;i++)
    {
    	ll a,b;
    	cin>>a>>b;
    	v.pb({a,b});
    }
    ll dp[h+2];
    dp[0] = 0;
    for(i=1;i<=h;i++)
    {
    	ll x = LLONG_MAX;
    	for(j=0;j<n;j++)
    	{
    		ll st = max(0LL, i - v[j].fi);
    		x = min(x , v[j].se + dp[st]);
    	}
    	dp[i] = x;
    }
    cout<<dp[h];
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    char c;
    cin>>c;
    if(c=='A') cout<<'T'<<endl;
    if(c=='T') cout<<'A'<<endl;
    if(c=='C') cout<<'G'<<endl;
    if(c=='G') cout<<'C'<<endl;
    return 0;
}





Measured memory_bytes: 256
package main

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

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	x := scanInt(sc)
	v := 100.0
	y := 0
	for v < float64(x) {
		v *= 1.01
		v = float64(int(v))
		y++
	}
	return y
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1764
#include <stdio.h>
#include <math.h>
#define maxn 65
#define eps 1e-8
double x[maxn],y[maxn],c[maxn],X[65*65*2],Y[65*65*2],r[maxn];
int tot,N,K;
double dis(double x,double y,double c,double X,double Y){
	return c*sqrt((X-x)*(X-x)+(Y-y)*(Y-y));
}
void cal(double x1,double y1,double r1,double x2,double y2,double r2){//计算两圆交点坐标
	double D;//A=a*a,H=h*h,D=d*d;
	double ad,h;//ad=a*d;
	D=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	if(D==0)return;
	ad=(r1*r1+D-r2*r2)/2;//2*a*d=r1*r1+D-r2*r2
	h=D*r1*r1-ad*ad;
	if(h<0)return;//漏了此句的判定
	h=sqrt(h);
	tot++,X[tot]=x1+ad*(x2-x1)/D-(y2-y1)*h/D,Y[tot]=y1+ad*(y2-y1)/D+(x2-x1)*h/D;
	tot++,X[tot]=x1+ad*(x2-x1)/D+(y2-y1)*h/D,Y[tot]=y1+ad*(y2-y1)/D-(x2-x1)*h/D;
}
int judge(double t){
	int i,j,cnt;
	for(i=1;i<=N;i++)r[i]=t/c[i];
	tot=0;
	for(i=1;i<=N;i++){
		tot++,X[tot]=x[i],Y[tot]=y[i];//tot++,X[i]=x[i],Y[i]=y[i];
		for(j=i+1;j<=N;j++)
			cal(x[i],y[i],r[i],x[j],y[j],r[j]);
	}
	for(i=1;i<=tot;i++){
		cnt=0;
		for(j=1;j<=N;j++)
			if(dis(x[j],y[j],c[j],X[i],Y[i])<t+eps)cnt++;//浮点比大小无等于的情况，这是由浮点误差决定的。
		if(cnt>=K)return 1;
	}
	return 0;
}
int main(){
	double l,r,mid;
	int i;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++)scanf("%lf%lf%lf",&x[i],&y[i],&c[i]);
	l=0,r=1000010;
	while(l+eps<r){
		mid=(l+r)/2;
		if(judge(mid))r=mid;
		else l=mid;
	}
	printf("%.6lf\n",r);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    int a,b,c,temp=0,temp2=0;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;


    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    long long n;
    cin >> n;
    long long ans=1;
    for(long long i=1; i<=n; i++){
        ans*=i;
    }
    cout<<ans<<endl;
    
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    if(b % a == 0){
        print(a + b);
    } else{
        print(b - a);
    }
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()
hh = inpl()
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    tmp = INF
    for j in range(1,K+1):
        tmp = min(abs(hh[i]-hh[i-j])+dp[i-j],tmp)
        if i == j:
            break
    dp[i] = tmp

print(dp[-1])


Measured memory_bytes: 57344
def m():
    n, m = map(int, input().split())
    if n == 1 and m == 1:
        return 1
    if n == 1:
        return m-2
    if m == 1:
        return n-2
    if n == 2 or m == 2:
        return 0
    return (m-2) * (n-2)

print(m())

Measured memory_bytes: 3060
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str, T fix) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

long[] dijkstra(long from, long to, long[][] edges)
{
	long[] path;
	auto cost = new long[](edges.length); fill(cost, long.max); cost[from] = 0;
	long[][] open = [[from]];
	while (!open.empty)
	{
		auto n = open.front; open.popFront;
		auto p = n[0];
		foreach (i; 0..edges.length)
		{
			if (edges[p][i] == -1) continue;
			auto c = cost[p] + edges[p][i];
			if (c < cost[to] && c < cost[i]) { cost[i] = c; if (i == to) path = i ~ n; else open ~= i ~ n; }
		}
	}
	return cost[to] ~ path;
}

void main()
{
	auto N = RD!long;
	auto S1 = RD!string;
	auto S2 = RD!string;
	
	long ans = 1;
	long last;
	foreach (i; 0..N)
	{
		if (S1[i] == S2[i])
		{
			if (last == 0)
				modm(ans, 3);
			else if (last == 1)
				modm(ans, 2);
			last = 1;
		}
		else
		{
			if (last == 0)
				modm(ans, 6);
			else if (last == 1)
				modm(ans, 2);
			else if (last == 3)
				modm(ans, 3);

			if (last == 2)
				++last;
			else
				last = 2;
		}
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    double a, b, c, d, e, f;
    double x, y;
        while ( scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF) {
              y = (( c*d ) - ( a*f )) / ((b*d) - (a*e));
              x = (c - b*y) / a;
              printf("%.3f %.3f\n", x, y);
        }
        return 0;
}

Measured memory_bytes: 1080
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+30;
LL a[maxn], b[maxn], ans=0;
template <class T>
inline void scan(T &ret)
{
    char c;ret = 0;
    while((c=getchar())<'0' || c>'9');
    while(c>='0' && c<='9') ret=ret*10+(c-'0'), c=getchar();
}
void out(LL ret)
{
    if(ret>=10) out(ret/10);
    putchar(ret%10+'0');
}
int main()
{
    int n, l, r;
    scan(n);
    for(int i=0; i<n; ++i) scan(a[i]);
    for(int i=0; i<n; ++i) scan(b[i]);
    for(int i=28; ~i; --i)
    {
        LL s = 1LL<<i, tmp=0;
        for(int j=0; j<n; ++j) a[j]%=(s<<1), b[j]%=(s<<1);
        sort(b,b+n);
        for(int j=0; j<n; ++j)
        {
            l = lower_bound(b,b+n,s-a[j])-b;
            r = lower_bound(b,b+n,(s<<1)-a[j])-b;
            tmp += r-l;
            l = lower_bound(b,b+n,(s<<1|s)-a[j])-b;
            r = lower_bound(b,b+n, (s<<2)-a[j])-b;
            tmp += r-l;
        }
        if(tmp&1) ans |= s;
    }
    out(ans);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
c = input()
l = 0
r = n-1
ans = 0
while l<r:
    while l<n and c[l]=='R':
        l+=1
    while r>=0 and c[r]=='W':
        r-=1
    if l>r:
        break
    ans += 1
    l += 1
    r -= 1
print(ans)

Measured memory_bytes: 9348
#include <stdio.h>
#include <math.h>

int main(void) {

	double n;
	double s[1000];
	double sum, m, a, tmp;

	while (1) {
		sum = 0;
		tmp = 0;

		scanf("%lf", &n);

		if (n == 0)
			break;

		int i;

		for (i = 0; i < n; i++) {
			scanf("%lf", &s[i]);

			sum += s[i];
		}

		m = sum / n;

		for (i = 0; i < n; i++) {
			tmp += pow(s[i] - m, 2);
		}

		a = sqrt(tmp / (float)n);

		printf("%f\n", a);
	}
	return 0;
}

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

int main()
{
    int a, b;

    cin >> a >> b;
    if (a == b)
        cout << "a == b" << endl;
    else if (a > b)
        cout << "a > b" << endl;
    else
        cout << "a < b" << endl;

    return 0;
}



Measured memory_bytes: 3080
import sys


def solve(L: int, R: int, d: int):
    count = 0
    for i in range(L, R+1):
        if i % d == 0:
            count += 1

    print(count)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(L, R, d)

if __name__ == '__main__':
    main()

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    int n;
    bool first = true;
    while (cin >> n && n > 0) {
        if (first) first = false;
        else       cout << endl;
        
        
        vector<int> num(4);
        REP(i, 4)    cin >> num[i];

        vector<pair<int, int>> coin(4);
        
        coin[0] = make_pair(10, num[0]);
        coin[1] = make_pair(50, num[1]);
        coin[2] = make_pair(100, num[2]);
        coin[3] = make_pair(500, num[3]);

        /* お釣りで帰ってくるお金を計算する */
        int sum = 10*num[0] + 50*num[1] + 100*num[2] + 500*num[3];
        sum -= n;

        /* 値の大きなコインからお釣りをもらっていく　*/
        for (int i = 3; i >= 0; i--) {
            coin[i].second = sum / coin[i].first;
            sum -= coin[i].first * coin[i].second;
        }

        /* もともと持っていたコインとお釣りで帰ってきたコインの収支をとる */
        for (int i = 0; i < 4; i++) {
            if (coin[i].second < num[i])
            cout << coin[i].first << " " << num[i] - coin[i].second << endl;
        }
    }
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int ans=n/2 + (n%2==1);
    (ans>=k) ? cout<<"YES":cout<<"NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
using namespace std;
int main(){
  int n,anser=0,count=0,f,i=1;
  cin>>n;

  for(int i=1;i<=n;i++){
    if(i>0&&i<10)count++;
    if(i>99&&i<1000)count++;
    if(i>9999&&i<100000)count++;

  }

  cout<<count;
}


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

int main() {
  int N;
  int K;
  int a = 1;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    if (a > K) {
      a += K;
    }else {
      a *= 2;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
n = int(input())
d, m = divmod(n, 26)
ans = ""
if m == 0:
    ans += 'z'
    d -= 1
else:
    ans += chr(m+96)

# ans = ""
while(not d==0):
    d, m = divmod(d, 26)
    if m == 0:
        ans += 'z'
        d -= 1
    else:
        ans += chr(m+96)

# ans += tmp
print(ans[::-1])


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N; scanf("%d", &N);
  int ans = 0;
  for(int i=0; i<N; ++i)
  {
    int a; scanf("%d", &a);
    while(a%2==0)
    {
      ++ans; a/=2;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, i, j, x;
    char s[100001];

    scanf("%d%s",&n, s);

    x = 0;
    for(i=0; i<n; i++){
        x++;    
        j = i+1;
        while(s[i] == s[j]){
            j++;
        }
        i = j-1;
    }
    printf("%d\n", x);
}


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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    int life[2], atk[2];
    cin >> life[0] >> atk[0] >> life[1] >> atk[1];
    while(1){
        life[1]-=atk[0];
        if(life[1]<=0){
            cout<<"Yes"<<endl;
            break;
        }
        life[0]-=atk[1];
        if(life[0]<=0){
            cout<<"No"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int nn[5001] = { 0 }, temp, n, max = -110000;
	while (cin >> n && (n != 0)){
		for (int i = 0; i < n; i++){
			cin >> nn[i];
		}
		temp = nn[0];
		for (int i = 1; i < n; i++){
			temp += nn[i];
			if (temp < nn[i]) temp = nn[i];
			if (max < temp) max = temp;
		}if (max < nn[0]) cout << nn[0] << endl;
		else cout << max << endl;
		max = -110000;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
using namespace std;
int main()
{
  int a[3],sum=0;
  for(int i=0;i<3;i++){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum<=21){
    cout<<"win"<<endl;
  }
  else{
    cout<<"bust"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long sum = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    int a = gcd(i, j);
                    sum += gcd(a, k);
                }
            }
        }
        System.out.println(sum);
    }

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


Measured memory_bytes: 35824
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
	int n,m,a;
	while(cin>>n>>m>>a,n,m,a){
		vector<map<int,int,greater<int> > > amida(101);
		int maxh=0;
		for(int i=0,h,p,q;i<m;++i){
			cin>>h>>p>>q;
			amida[p][h]=q;
			amida[q][h]=p;
			if(h>maxh)maxh=h;
		}
		int current_h=maxh+1;
		int current_a=a;
		map<int,int>::iterator it=amida[a].begin();
		map<int,int>::iterator end=amida[a].end();
		for(;it!=end;++it){
			//cerr<<(*it).first<<":"<<(*it).second<<"\n";
			if((*it).first<current_h){
				current_h=(*it).first;
				current_a=(*it).second;
				end=amida[current_a].end();
				it=amida[current_a].begin();
			}
		}
		cout<<current_a<<"\n";
	}
	return 0;
}

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

int n,m,a,b;
int ans[10];
map<int,int> vis;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>m;
  for(int i = 1;i <= m;i++){
    cin>>a>>b;
    if(a == 1 && b == 0 && n != 1){
      cout<<"-1"<<endl;
      return 0;
    }
    if(vis[a] && ans[a] != b){
      cout<<"-1"<<endl;
      return 0;
    }
    vis[a] = 1;
    ans[a] = b;    
  }
  for(int i = 1;i <= n;i++){
    if(i == 1 && !ans[i] && n != 1) cout<<"1";
    else cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

int main() {

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int n;
    cin>>n;
    map<int, int> m;
    int curr;
    for (int i=1; i<=n; i++){
        cin>>curr;
        m[curr] = i;
    }
    for (auto it=m.begin(); it!=m.end(); it++){
        cout<<it->second<<" ";
    }
}

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

int main(){
    long long n;
    cin >> n;
    long long dist = 0;
    long long answer = n-1;
    for(int i = 1; i <= sqrt(n); i++){
        if(n%i == 0){
            dist = ((n/i)-1)+(i-1);
            answer = min(answer,dist);
        }
    }
    cout << answer;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
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);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        static int MOD = 998244353;
        public void solve(InputReader in, PrintWriter out){
            int n = in.nextInt();
            int a[] =new int[n];
            long cnt[] = new long[100001];
            long total = 0;
            for (int i=  0; i < n; i++){
                a[i] = in.nextInt();
                cnt[a[i]]++;
                total+= a[i];
            }
            int q = in.nextInt();
            for (int i = 0; i < q; i++){
                int b = in.nextInt();
                int c = in.nextInt();
                cnt[c] += cnt[b];
                total  += (cnt[b]) * (c - b);
                cnt[b] = 0;
                out.println(total);
            }
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 55652
A, B, C= map(int, input().split())
if (A!=5 and A!=7) or (B!=5 and B!=7) or (C!=5 and C!=7):
    print("NO")
elif A==5:
    if (B==5 and C==7) or (B==7 and C==5):
        print ("YES")
    else:
        print("NO")
elif (B==5 and C==5):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
#include <iostream>
 
using namespace std;
 
int A[100];
int main(){
	int n;
  cin >> n;
  for(int i=0;i<n;i++){
  	cin >> A[i];
  }
  long double sum = 0;
  for(int i=0;i<n;i++){
  	sum += (long double)1 / A[i];
  }
  cout << (long double)1/sum;
  return 0;
}

Measured memory_bytes: 256
def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0
S = list(input())
length = len(S)
flag = 0
if length == 2:
    print(0)
    flag = 1
elif length == 3:
    length -= 1
    ans = hantei(S,2)
    print(ans)
    flag = 1
elif length % 2 == 1:
    length -= 1
    ans = 0
else:
    length -= 2
    ans = 0
while length >= 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if flag == 0:
    if ans == 0:
        print(1)
    else:
        print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
ll a, b;

int main(){
	IOS
	cin >> a >> b;
	ll ans1=ceil((double)(a*100)/8);
	ll ans2=ceil((double)(b*100)/10);
	//cout << ans1 << " " << ans2 << endl;
	bool kesatu=false, kedua=false;
	if((ans2*8)/100==a&&(ans2*10)/100==b){
		kesatu=true;
	}
	if((ans1*8)/100==a&&(ans1*10)/100==b){
		kedua=true;
	}
	if(kesatu&&kedua){
		cout << min(ans1, ans2) << '\n';
	}
	else if(kesatu){
		cout << ans2 << '\n';
 	}
 	else if(kedua){
 		cout << ans1 << '\n';
 	}
 	else{
 		cout << -1 << '\n';
 	}
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll L, R;
    cin >> L >> R;
    ll m = 2018;
    if((R - L + 1) >= 2019) m = 0;
    else { 
        REP(i,L,R) {
            REP(j,i+1,R+1) {
                m = MIN((i*j)%2019,m);
            }
        }
    }
    PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 256
g=->{gets.split.map &:to_i};n,C=g[];d=(1..C).map{g[]};c=(1..n).map{g[]};a=(0..2).map{Array.new(C,0)};C.times{|u|n.times{|i|n.times{|j|a[(i+j)%3][u]+=d[c[i][j]-1][u]}}};p [*0...C].permutation(3).map{|x,y,z|a[0][x]+a[1][y]+a[2][z]}.min

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int X;
  int Y;
  cin >> X >> Y;
  
  if(X % Y == 0){
    cout << "-1" << endl;
  }
  else{
    while(true){
      if(!(X % Y == 0)){
        cout << X << endl;
        break;
      }
      X = X * X;
    }
  }
  
}

Measured memory_bytes: 256
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(0,n-i-1):
  if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j]
 m=i
 for j in range(i,n):
  if d[m][1]>d[j][1]:m=j
 d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d)
print(['Not s','S'][c==d]+'table')


Measured memory_bytes: 5608
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  rep(i,n){
    ans+=i+1;
    if((i+1)%3==0) ans-=i+1;
    if((i+1)%5==0)  ans-=i+1;
    if((i+1)%15==0)  ans+=i+1;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int n;
  string s,t;
  cin>>n;
  cin>>s>>t;

  rep(i,0,n){
      cout<<s[i]<<t[i];
  }
  cout<<endl;
}

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

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

    if(s == "SUN"){
        cout << 7 << "\n";
        return 0;
    }
    if(s == "MON"){
        cout << 6 << "\n";
        return 0;
    }
    if(s == "TUE"){
        cout << 5 << "\n";
        return 0;
    }
    if(s == "WED"){
        cout << 4 << "\n";
        return 0;
    }
    if(s == "THU"){
        cout << 3 << "\n";
        return 0;
    }
    if(s == "FRI"){
        cout << 2 << "\n";
        return 0;
    }
    if(s == "SAT"){
        cout << 1 << "\n";
        return 0;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	long long n, m, ans;
	scanf("%llu%llu", &n, &m);
	if (n >= m / 2) {
		ans = m / 2;
	}
	else {
		if (m - n * 2< 4) {
			ans = n;
		}
		else {
			ans = n + (m - n * 2) / 4;
		}
	}
	printf("%llu\n", ans);
}

Measured memory_bytes: 128
import collections
h, w = map(int, input().split())
s = [input() for _ in range(h)]

def bfs(sx, sy):
    q = collections.deque([(sx, sy)])
    checked = [[0 for _ in range(w)] for _ in range(h)]
    checked[i][j] = 1
    res = 0
    while q:
        qx, qy = q.popleft()
        for dx, dy in [(0,1),(1,0),(-1,0),(0,-1)]:
            x = qx+dx
            y = qy+dy
            if 0<=x<h and 0<=y<w and s[x][y] == "." and checked[x][y]==0:
                q.append((x,y))
                checked[x][y] = checked[qx][qy]+1
                res = max(checked[x][y],res)
    return res


ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            ans = max(ans, bfs(i, j)-1)

print(ans)

Measured memory_bytes: 3316