akhauriyash/Code-Regression huggingface dataset:
/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

int a;
string s;

int read(){
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    cin>>a;
    cin>>s;
    if (a<3200)cout<<"red"<<endl;
    else cout<<s<<endl;

	return 0;
}


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


const ll mod = 1000000007;
#define MAX_N 2200000
ll f[MAX_N];
ll invf[MAX_N];

ll modpow(ll  a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll nCm(ll n,ll m){return ((f[n]*invf[m])%mod)*invf[n-m]%mod;  }

int gcd(int x,int y){
    if(x%y == 0)return y;
    return gcd(y%x,x);
}

map<P,int> mp1,mp2;
int non;
signed main()
{
    int n;cin >> n;
    rep(i,n){
        int a,b;cin >> a >> b;
        if( a == 0 && b == 0)non++;
        else if(a == 0){
            mp1[P(0,1)]++;
            mp2[P(1,0)]++;
        }
        else if(b == 0){
            mp1[P(1,0)]++;
            mp2[P(0,1)]++;
        }

        else if(a > 0 && b >0){
            int hoge = gcd(a,b);
            mp1[P(a/hoge,b/hoge)]++;
            mp2[P(-b/hoge,a/hoge)]++;
        }
        else if(a > 0 && b < 0){
            int hoge = gcd(a,-b);
            mp1[P(-a/hoge,-b/hoge)]++;
            mp2[P(-b/hoge,a/hoge)]++;


        }
        else if(a < 0 && b > 0){
            int hoge = gcd(-a,b);
            mp1[P(a/hoge,b/hoge)]++;
            mp2[P(b/hoge,-a/hoge)]++;

        }
        else if(a < 0 && b < 0){
            int hoge = gcd(-a,-b);
            mp1[P(-a/hoge,-b/hoge)]++;
            mp2[P(b/hoge,-a/hoge)]++;
        }

        
    }
    int ans = 1;
    for(auto tmp:mp1){
        
        auto pr = tmp.first;
        auto p = tmp.second;
        auto q = mp2[pr];
        
        int res =modpow(2ll,p,mod) + modpow(2ll,q,mod) -1;//仲の悪い集合A,Bについて、AとBどちらからもとるようなことがないように選ぶ場合の数
        int a = pr.first,b = pr.second;
        if(a == 0){
            mp2[P(1,0)] = 0;
            mp1[P(1,0)] = 0;

        }
        else if(b == 0){
            mp2[P(0,1)] = 0;
            mp1[P(0,1)] = 0;

        }
        if( a> 0 &&b > 0){
            mp2[P(-b,a)] = 0;
            mp1[P(-b,a)] = 0;
        }
        else if(a <0 && b >0){
            mp2[P(b,-a)] = 0;
            mp1[P(b,-a)] = 0;
        }
        res %= mod;

        ans *= res;
        ans = (ans%mod+mod)%mod;
        

    }
    ans -= 1;//一つも選ばない
    ans += non;//ゼロゼロは単体でしか選べない
    
    cout << (ans%mod+mod)%mod << endl;

    
    return 0;
}

Measured memory_bytes: 53436
import java.util.Scanner;



class Main {
	public static void main(String args[]) {
		
		//????????£????????§??´??°?????????????????????
	    Scanner sc = new Scanner(System.in);
	    String s1 = sc.next();
	    int a = Integer.parseInt(s1);
	    String s2 = sc.next();
	    int b = Integer.parseInt(s2);
	    String s3 = sc.next();
	    int c = Integer.parseInt(s3);
	    int sum = 0;
	    
	    //??´??°a???b???c????????¶??????????????????????????????????????????a<=b??§??????????¢????
	    if(1 <= a && a <= 10000){
	    	if(1 <= b && b <= 10000){
	    		if(1 <= c && c <= 10000){
	    			if(a <= b){
	    					
	    			    //c?´???°???a??????b?????§?????????????????????????¨????
	    				for(int i = a; i <= b; i++){
	    					if(c % i == 0){
	    					    sum++;
	    					}
	    				}
	    				
	    				//?´???°?????°?????¨???
	    				System.out.println( sum );
	    			}
	    		}
	    	}
	    }
	}
}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int a, b, c;
	cin >> a >> b >> c;
	int rem = a - b;
	cout << max(0, c - rem);
}

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


ll gcd(ll m, ll n)
{
    if (m < n)
    {
        ll tmp = m;
        m = n;
        n = tmp;
    }

    while (1)
    {
        ll mod = m % n;
        if (mod == 0)
            return n;
        m = n;
        n = mod;
    }
}
ll lcm(ll m, ll n)
{
    return m * n / gcd(m, n);
}

int main()
{
    ll a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    a--;
    ans = b - a;
    b = b / c + b / d - b / lcm(c, d);
    a = a / c + a / d - a / lcm(c, d);
    ans-=b-a;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
// adios amigos!!
#include <bits/stdc++.h>
#include <chrono>
#include <random>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vll > vvll;
typedef pair< int,int > pi;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
const int N=500023;
#define PI 3.1415926535897932384626
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){if(b == 0) return a;return gcd(b, a%b);}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
//DEBUGGING
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
const int LG = 20;
//__builtin_popcount(n) -> returns number of set bits in n
ll expo(ll a, ll b, ll m); // a^(b) %m
//=======================

//vector<bool> vis;vis.assign(n,false); g.assign(n,{});
//vector<vll> g;
//void ipgraph(ll m){ll  u, v;while(m--){cin>>u>>v; u--, v--;g[u].pb(v);g[v].pb(u);}}
//ll lvl[N], p[N][LG];
//ll lca(ll u,ll v){if(lvl[u]<lvl[v])swap(u,v);ll i,lg; for(lg=0;(1<<lg)<=lvl[u];lg++);lg--;for(i=lg;i>=0;i--){if(lvl[u]-(1<<i)>=lvl[v]){u=p[u][i];}}if(u==v)return v;else{for(i=lg;i>=0;i--){if(p[u][i]!=-1 && p[u][i]!=p[v][i]){u=p[u][i];v=p[v][i];}}}return p[u][0];}

void solve(){
    ll n;cin>>n;
    vll a(n);rep(i,n){cin>>a[i];}
    
    ll jhc=0 ;
    ll sum=a[n-1];
    ll idx=n-2;
    while(idx>=0){
        jhc+=(a[idx]%mod * sum%mod)%mod;
        sum+=a[idx]%mod;
        sum%=mod;
        jhc%=mod;
        idx--;
    }
    
    cout<<jhc<<endl;
}

int main(){
 
   ll t = 1;
  //  cin >> t;
    while(t--) {
      solve();
    }
   return 0;
}


ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0)return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 

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

int main() {
	int N;
	cin >> N;
	unsigned long sum = 0;
	for (int i = 0; i < N; i++) {
		unsigned long l, r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool can_make_it(vector<int>& input) {
  for (int i = 1; i+1 < (int)input.size(); i++) {
    if (input.at(i-1) < input.at(i)) {
      input.at(i)--;
    }
    if (input.at(i) > input.at(i+1)) {
      return false;
    }
  }
  return true;
}

int main()
{
  int n;
  cin >> n;
  vector<int> input(n+2);
  input.front() = -1;
  input.back() = 1e9+1;
  for (int i = 1; i <= n; i++) {
    cin >> input.at(i);
  }
  if (can_make_it(input)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxn=2e5+10;
int n,a[maxn],rnk[maxn],ans=1;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],rnk[a[i]]=i;
	for(int i=2,now=1;i<=n;++i){
		if(rnk[i-1]<rnk[i])
			++now;
		else
			now=1;
		if(now>ans)
			ans=now;
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [i for i in range(1,int((n)**0.5 +1))]
a.reverse()
#print(a)
for j in range(len(a)):
    if n%int(a[j]) == 0:
        print(int(int(a[j]) + n//int(a[j]) -2))
        break

Measured memory_bytes: 42648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for (int i = a; i <= b; i++) {
    if (i/10000 == i%10 && (i%10000)/1000 == (i%100)/10) {
      cnt++;
    }
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl
#abc85_c.pl
#Sun Jan  7 20:56:35 2018
#

use warnings;
use strict;

my $n = <STDIN>;
chomp $n;

my @param = split(" ",$n);

my $bill = $param[0];
my $amount = $param[1]/1000;

my $x = $bill;
my $y = 0;
my $z = 0;

my $tamount;

my $flag = 0;

if ($amount > $bill*10){
	print "-1 -1 -1\n";
	$flag = 1;
}else{
while ($x >= 0){
	if ($flag == 1){
		last;
	}
#	$tamount = 10*$x + 5*$y + 1*$z;

#	print $x," ",$y," ",$z," ",$tamount,"testtest\n";

#	if ($tamount == $amount){
#		print $x," ",$y," ",$z,"\n";
#		$flag = 1;
#		last;
#	}
	$y = $bill-$x;
	while ($y >= 0){
		$z = $bill-$x-$y;
		$tamount = 10*$x + 5*$y + 1*$z;

#		print $x," ",$y," ",$z," ",$tamount,"testtest\n";

		if ($tamount == $amount){
			print $x," ",$y," ",$z,"\n";
			$flag = 1;
			last;
		}
		$y--
	}
	$y = 0;
	$z = 0;
	$x--;
}
}

if ($flag==0){
	print "-1 -1 -1\n"
}

Measured memory_bytes: 640
X,N = map(int,input().split(" "))
if N == 0:
    print(X)
else:
    p = [int(i) for i in input().split(" ")]
    if not(X in p):
        print(X)
    else:
        un = sorted([i for i in p if i < X],reverse = True)
        hi = sorted([i for i in p if i > X])
        X1 = X-1
        X2 = X+1
        while(1):
            if not(X1 in un):
                print(X1)
                break
            if not(X2 in hi):
                print(X2)
                break
            X1 -= 1
            X2 += 1

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int A,B,C,X,Y;
cin >> A >> B >> C >> X >> Y;

int ans = INF;

for(int i = 0; i <= 100000 ; i++) {
    int cur = 2*C*i + A*max(0, X-i) + B*max(0, Y-i);
    ans = min(ans, cur);
}

cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split( ))

a = list(map(int, input().split( )))

dp = [0]*(k+1)

for i in range(k+1):
    win = 0
    for j in a:
        if i>=j and dp[i-j] == 0:
            win = 1
            break
    dp[i] = win
#print(*dp)            
if dp[k] == 1:
    print("First")
else:
    print("Second")

Measured memory_bytes: 42952
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

int n, m, q;
vector<int> a, b, c, d;

int dfs(vector<int> &A){
    int res = 0;
    if(A.size() == n){
        int ans = 0;
        REP(i,q){
            if(A[b[i]-1]-A[a[i]-1] == c[i]){
                ans += d[i];
            }
        }
        
        return ans;
    }

    int num = A.empty()? 1: A.back();
    for(int i = num; i <= m; i++){
        A.push_back(i);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return res;
}

int main(void){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    REP(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> A;
    cout << dfs(A) << endl; 
    
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int f[70000000],a[1000000],sum,l;
char s[1000000];
int main(){
	ios::sync_with_stdio(false);
	cin>>s;l=strlen(s);for (int i=1;i<=l;i++)a[i]=a[i-1]^(1<<(s[i-1]-'a'));
	memset(f,10,sizeof(f));f[0]=0;
	for (int i=1;i<=l;i++){
		sum=f[a[i]]+1;for (int j=0;j<26;j++)sum=min(sum,f[a[i]^(1<<j)]+1);
		f[a[i]]=min(f[a[i]],sum);
	}cout<<sum<<endl;
}
/*
aabcddee
*/

Measured memory_bytes: 275584
n = int(input())
s = map(int, input())

dp = tuple([0] * 1000 for _ in range(4))
dp[0][0] = 1
# dp[x][int(str)]:=x文字のstrは構成可能か？0/1

for x in s:
    for incomplete_key in range(100):
        dp[3][incomplete_key * 10 + x] |= dp[2][incomplete_key]
    for incomplete_key in range(10):
        dp[2][incomplete_key * 10 + x] |= dp[1][incomplete_key]
    dp[1][x] = 1

print(sum(dp[3]))

# dp


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cmath>

int main(void){
	int count = 0;
  	int result = 0;
  
  	std::string STR;
  	std::cin >> STR;
  
  	size_t i = 0;
  	for(; i < STR.length()-1; ++i){
    	if(STR[i] == 'A' || STR[i] == 'G' || STR[i] == 'C' || STR[i] == 'T'){
        	++count;
        }
      	else{
        	result = std::max(result, count);
          	count = 0;
        }
    }
  
	if(STR[i] == 'A' || STR[i] == 'G' || STR[i] == 'C' || STR[i] == 'T'){
        ++count;
    }
    
  	result = std::max(result, count);
  
  	std::cout << result;
  	return 0;
}

Measured memory_bytes: 256
import sys

def hantei(h1, h2, h3):
    if h1 is True and h2 is True and h3 is True:
        return True
    else:
        return False


A = []
for _ in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(3):
    for j in range(len(A[i])):
        if A[i][j] in b:
            A[i][j] = True

for i in range(3):
    if hantei(A[i][0], A[i][1], A[i][2]):
        print("Yes")
        sys.exit()
    elif hantei(A[0][i], A[1][i], A[2][i]):
        print("Yes")
        sys.exit()

if hantei(A[0][0], A[1][1], A[2][2]) or hantei(A[0][2], A[1][1], A[2][0]):
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

const int MAX_N = 300005;
int N, A, B, p[MAX_N];

int main() {
  scanf("%d%d%d", &N, &A, &B);
  if (A + B - 1 > N) {
    puts("-1");
    return 0;
  }
  if (A > B) {
    int r = N, l = 1, pos = 0;
    for (int i = 1; i <= A; ++i)
      p[++pos] = N - A + i;
    for (int i = 1; i < B; ++i)
      p[++pos] = B - i;

    r = N - A, l = B;
    int num1 = 1, num2 = 1;
    while (l <= r) {
      if (num1 >= B && num2 >= A) {
	puts("-1");
	return 0;
      }
      int len = max(0, min(A - num2, r - l + 1));
      for (int i = 1; i <= len; ++i)
	p[++pos] = r - len + i;
      r -= len, num1++;
      len = max(0, min(B - num1, r - l + 1));
      for (int i = 1; i <= len; ++i)
	p[++pos] = l + len - i;
      l += len, num2++;
    }
    if (num1 > B || num2 > A) {
      puts("-1");
      return 0;
    }
  } else {
    int r = N, l = 1, pos = 0;
    for (int i = 1; i <= B; ++i)
      p[++pos] = B - i + 1;
    for (int i = 1; i < A; ++i)
      p[++pos] = N - A + i + 1;

    r = N - A + 1, l = B + 1;
    int num1 = 1, num2 = 1;
    while (l <= r) {
      if (num1 >= B && num2 >= A) {
	puts("-1");
	return 0;
      }
      int len;
      len = max(0, min(B - num1, r - l + 1));
      for (int i = 1; i <= len; ++i)
	p[++pos] = l + len - i;
      
      l += len, num2++;
      len = max(0, min(A - num2, r - l + 1));
      for (int i = 1; i <= len; ++i)
	p[++pos] = r - len + i;
      r -= len, num1++;
    }
    if (num1 > B || num2 > A) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= N; ++i)
    printf("%d ", p[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 3328
(let* ((lst1 (list (car (concatenate 'list (symbol-name (read)))) (car (concatenate 'list  (symbol-name (read))))))
       (lst2 (sort (copy-list lst1) #'char-lessp)))

  (format t "~A~%"
          (if (= (length (remove-duplicates lst1)) 1)
            #\=
            (if (equal lst1 lst2)
              #\<
              #\>))))


Measured memory_bytes: 24136
N = int(input())
A = list(map(int, input().split()))

dict_ans = {}
for i in range(N):
    dict_ans[A[i]] = i+1

dict_sort_ans = sorted(dict_ans.items(), key=lambda x:x[0])
for i in range(N):
    print(dict_sort_ans[i][1], end=' ')

Measured memory_bytes: 25400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int x = sc.nextInt();
        int y = sc.nextInt();

        boolean isAns = true;

        if (y % 2 == 1)
            isAns = false;

        if (y < 2*x || y > 4*x)
            isAns = false;

        System.out.println(isAns ? "Yes" : "No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 32676
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng { using namespace boost; using namespace boost::range; }
namespace adp { using namespace boost::adaptors; }

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << nl;
    else cout << "ABC" << nl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = double;
int n;
ld dp[305][305][305];
bool visited[305][305][305];

ld memo_rec(int One, int Two, int Three){
    if(visited[One][Two][Three])    return dp[One][Two][Three];
    if(One + Two + Three == 0){
        visited[One][Two][Three] = true;
        return dp[One][Two][Three] = 0.0;
    }
    
    ld res = n;
    if(One > 0) res += memo_rec(One - 1, Two, Three) * One;
    if(Two > 0) res += memo_rec(One + 1, Two - 1, Three) * Two;
    if(Three > 0)   res += memo_rec(One, Two + 1, Three - 1) * Three;
    res *= 1.0 / (One + Two + Three);

    visited[One][Two][Three] = true;
    return dp[One][Two][Three] = res;
}

int main(){
    cin >> n;
    vector<int> cnt(4, 0);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        ++cnt[a];
    }
    
    cout << fixed << setprecision(15);
    cout << memo_rec(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 246016
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int N = 17;

int n, x[N], y[N], p[N], cnt, tmp;
int lnx[N] = {1, 0}, lny[N] = {1, 0};
long long ans[N], ret;
bool sel[N];

void dfs(int i){
	if(i > n){
		ret = 0;
		for(int j = 1; j <= n; j++) if(!sel[j]){
			tmp = 10000;
			for(int k = 1; k <= *lnx; k++)
				tmp = min(tmp, abs(x[j] - lnx[k]));
			for(int k = 1; k <= *lny; k++)
				tmp = min(tmp, abs(y[j] - lny[k]));
			ret += 1ll * tmp * p[j];
		}
		ans[cnt] = min(ans[cnt], ret);
		return;
	}
	dfs(i + 1);
	sel[i] = true, cnt++;
	lnx[++*lnx] = x[i];
	dfs(i + 1);
	--*lnx;
	lny[++*lny] = y[i];
	dfs(i + 1);
	--*lny;
	sel[i] = false, cnt--;
}

int main(){
	memset(ans, 0x7f, sizeof(ans));
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d%d%d", x + i, y + i, p + i);
	dfs(1);
	for(int i = 0; i <= n; i++)
		printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 3816
#include<stdio.h>
int main(void)
{
	int a,g=0,max=0,i;
	for(i=0; i<3; i++)
	{
		scanf("%d", &a);
		g+=a;
		if(max<a)
		max=a;
	}
	printf("%d\n", g-max);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
 
int main(){
    string number;
    int s, i;
    while(1){
        s = 0;
        cin >> number;
        for(i = 0;i < number.size();i++){
            s += number[i] - '0';
        }
        if(s == 0){
            break;
        }
        cout << s << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int X,K,Q;
int r[MC];
int t[MC] , a[MC];
int amin,amax;
int ansmin,ansmax;
int ans[MC];

int main(){
	scanf("%d%d" , &X , &K);
	repp(i,1,K+1){
		scanf("%d" , r + i);
	}
	scanf("%d" , &Q);
	repp(i,0,Q){
		scanf("%d%d" , t + i , a + i);
	}
	amin = ansmin = 0;
	amax = ansmax = X;
	int pt = 0;
	int sum = 0;
	repp(i,0,K){
		int z = (i%2?1:-1);
		while(pt < Q && t[pt] < r[i+1]){
			if(a[pt] < amin) ans[pt] = max(0,min(X,ansmin+z*(t[pt]-r[i])));
			else if(a[pt] > amax) ans[pt] = max(0,min(X,ansmax+z*(t[pt]-r[i])));
			else ans[pt] = max(0,min(X,a[pt]+sum+z*(t[pt]-r[i])));
			++pt;
		}
		sum += z*(r[i+1]-r[i]);
		if(sum > X) sum = X;
		if(sum < -X) sum = -X;
		amin = max(amin,min(X,-sum));
		amax = min(amax,max(0,X-sum));
		ansmin = max(0,min(X,ansmin+z*(r[i+1]-r[i])));
		ansmax = max(0,min(X,ansmax+z*(r[i+1]-r[i])));
	}
	int z = (K%2?1:-1);
	while(pt < Q){
		if(a[pt] < amin) ans[pt] = max(0,min(X,ansmin+z*(t[pt]-r[K])));
		else if(a[pt] > amax) ans[pt] = max(0,min(X,ansmax+z*(t[pt]-r[K])));
		else ans[pt] = max(0,min(X,a[pt]+sum+z*(t[pt]-r[K])));
		++pt;
	}
	repp(i,0,Q){
		printf("%d\n" , ans[i]);
	}
	return 0;
}


Measured memory_bytes: 2816
package main

import (
	"fmt"
)

func main() {
	var a, v int
	fmt.Scan(&a, &v)
	var b, w int
	fmt.Scan(&b, &w)
	var t int
	fmt.Scan(&t)
	if (v-w)*t >= abs(a-b) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;scanf("%d",&n);
	double ans=0;
	for(int i=0;i<n;i++){
		scanf("%d",&x),ans+=1.0/x;
	}
	printf("%.10lf",1/ans);
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python2

import sys

input = iter(sys.stdin.readlines()).next

def main():
   K = int(input())
   S = input().strip()
   if len(S) <= K:
      print(S)
   else:
      print(S[:K] + '...')

   return 0

if __name__ == '__main__':
   sys.setrecursionlimit(10000)
   main()


Measured memory_bytes: 84816
#!/usr/bin/env python3
import sys

def solve(N: int, S: str):
    answer = 0
    for i in range(1000):
        target = str(i).zfill(3)
        index = 0
        for i in range(N):
            if S[i] == target[index]:
                index += 1
            
            if index == 3:
                answer += 1
                break
    
    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
#include<stdio.h>
int main (void){
    int h1=0,h2=0,h3=0,input,s;
    for(s=0;s<10;s++){
        scanf("%d\n",&input);
        if(h1 < input){
            h3 = h2;
            h2 = h1;
            h1 = input;
        }else{
            if(h2 < input){
                h3 = h2;
                h2 = input;
            }else{
                if(h3 < input){
                    h3 = input;
                }
            }
        }
    }
    printf("%d\n%d\n%d\n",h1,h2,h3);
    return(0);
}

Measured memory_bytes: 604
#include<stdio.h>
int main(void){
	int x,y,tmp;
	while(1){
		scanf("%d %d",&x,&y);
		if (x==0 && y==0){
			break;
		}
		if (x>y){
			tmp=x;
			x=y;
			y=tmp;
		}
		printf("%d %d\n",x,y);
	}
return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B; cin >>A>>B;
    cout << ((A%3==0||B%3==0||(A+B)%3==0)?"Possible":"Impossible") << endl;
}


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

vector<int> primeFactorization(int n) {
    vector<int> result;
    int i = 2;
    while (i <= sqrt(n)) {
        if (n%i == 0) {
            result.push_back(i);
            n /= i;
        }
        else i += 1;
    }
    if (n != 1) result.push_back(n);
    return result;
}

int main() {
    lint k; cin >> k;
    
    lint aa = 7%k;
    lint ans = -1;
    for (int i=1; i<100000000; i++) {
        if (aa == 0) {
            ans = i;
            break;
        }
        aa = aa*10 + 7;
        aa = aa % k;
    }
    cout << ans << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, t) for (int i = (s); i < (int)(t); i++)
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    } else if (B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

long long stoi(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}
void solve() {
	int n;
	string s;
	cin >> n >> s;
	int count = 0;
	int check = 0;
	rep(i, n) {
		if (s[i] == '('){
			check++;
		}
		else {
			if (check == 0) {
				count++;
			}
			else {
				check--;
			}
		}
	}
	rep(i, count) {
		s = '(' + s;
	}
	rep(i, check) {
		s = s + ')';
	}
	P(s);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
	int xx=0;
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		if(xx==1)cout<<endl;
		xx=1;
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int memo=a*10+b*50+c*100+d*500;
		memo-=n;
		d-=memo/500;
		memo%=500;
		c-=memo/100;
		memo%=100;
		b-=memo/50;
		memo%=50;
		a-=memo/10;
		if(a>0) cout<<"10 "<<a<<endl;
		if(b>0) cout<<"50 "<<b<<endl;
		if(c>0) cout<<"100 "<<c<<endl;
		if(d>0) cout<<"500 "<<d<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

#define P pair<int, int>

int main() {
    int n;
    cin >> n;
    P ar[n];
    for (int i = 0, x, l; i < n; i++) {
        cin >> x >> l;
        ar[i] = P(x + l, x - l);
    }
    sort(ar, ar+n);
    int cur = ar[0].first, ans = 1;
    for (int i = 1; i < n; i++) {
        if (cur <= ar[i].second) {
            ans++;
            cur = ar[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
ParseInt(x) = parse(Int,x)
ParseMap(x::Array{SubString{String},1}) = map(ParseInt,x)
function main()
    a = chomp(readline())
    cnt = 0
    if a[1] == '1'
        cnt += 1
        end
        if a[2] == '1'
            cnt += 1
            end
            if a[3] == '1'
                cnt += 1
                end
                println(cnt)
end
main()

Measured memory_bytes: 155868
N, Z, W = map(int, input().split())
A = list(map(int, input().split()))
if N == 1:
  print(abs(A[0]-W))
  quit()

dp = [[0, 0] for i in range(N)]
dp[-1][0] = abs(A[-1]- W)
dp[-1][1] = - 1
dp[-2][0] = dp[-2][1] = dp1min = abs(A[-2] - A[-1])
dp0max = max(dp1min, dp[-1][0])

for i in range(N-3, -1, -1):
  ai = A[i]
  diff = abs(ai - A[-1])
  dp[i][0] = min(diff, dp1min)
  dp[i][1] = max(diff, dp0max)
  dp0max = max(dp0max, dp[i][0])
  dp1min = min(dp1min, dp[i][1])

print(dp0max)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    int answer=0;
    if(k-a<0)
    {
         answer+=k;
         k=0;
    }
    else
    {
        answer+=a;
        k-=a;
    }

    if(k-b<0)
        k=0;
    else
        k-=b;

    if(k-c<0)
        answer-=k;
    else
    {
        answer-=c;
    }
    cout<<answer<<endl;
    return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

const double pi=3.141592653589793;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,h,m;
    rd(a,b,h,m);
    double hour=2*pi*(h*60+m)/720;
    double mn=2*pi*m/60;
    double ang=abs(hour-mn);
    double ans=sqrt(a*a+b*b-2*a*b*cos(ang));
    cout<<fixed<<setprecision(9)<<ans;
    return 0;
}



Measured memory_bytes: 4276
m=int(input())
pf={m:1}
a=[0]
for i in range(2,int(m**0.5)+1):
    if m ==1:
        break
    pf[i]=pf.get(i,0)+1
    if i!=m//i:
        pf[m//i]=pf.get(m//i,0)+1
for i in pf:
    if m!=1and m//(i-1)==m%(i-1):
        a.append(a[-1]+i-1)
print(a[-1])


Measured memory_bytes: 211188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int n,m;
ll ans = 0;

void dfs(int v, vector<vector<int>> &g, vector<bool> vis){

    vis[v] = true;

    bool end = true;
    rep(i,0,n-1) if(vis[i] == false) end = false;
    if(end == true){
        ans++;
        return;
    }

    /*rep(i,0,n-1) cout<<vis[i];
    cout<<endl;*/

    //vis[v] = true;
    for(int nv : g[v]){
        if(vis[nv] == true) continue;
        dfs(nv, g, vis);
    }
}

int main(){
    cin>>n>>m;
    vector<vector<int>> g(n);
    vector<bool> vis(n,false);
    rep(i,0,m-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0,g,vis);

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],b[100010],now=0,res=0,ans;
multiset <pii> s,t;

void calc(int i)
{
	int x,y;
	if(i==0)
	{
		x=s.begin()->se;
		y=s.begin()->fi;
		s.erase(s.begin());
		t.erase(t.find({-x,y}));
	}
	else
	{
		x=-(t.begin()->fi);
		y=t.begin()->se;
		t.erase(t.begin());
		s.erase(s.find({y,x}));
	}
	if(x<=now&&now<=y) return;
	if(abs(now-x)<abs(now-y))
	{
		res+=abs(now-x);
		now=x;
	}
	else
	{
		res+=abs(now-y);
		now=y;
	}
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		s.insert({b[i],a[i]});
		t.insert({-a[i],b[i]});
	}
	for(int i=0,j=0;i<n;i++,j^=1) calc(j);
	res+=abs(now);
	ans=res;
	rep(i,n)
	{
		s.insert({b[i],a[i]});
		t.insert({-a[i],b[i]});
	}
	now=res=0;
	for(int i=0,j=1;i<n;i++,j^=1) calc(j);
	res+=abs(now);
	ans=max(ans,res);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
#include<string.h>
#include<math.h>
#define anD &&
#define oR ||
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define rep(i,n) for((i)=0;(i)<(n);(i)++)

void doswap(int*p,int *q,int *r) {
	int tmp;
	tmp = *p;
	*p = *q;
	*q = tmp;
	*r=*r+1 ;
}



int main(void) {
	int n, num = 0;
	scanf("%d", &n);
	int a[101] ;
	int i,j,mini;
	rep(i,n) {
		scanf("%d", &a[i]);
	}


	rep(i,n) {
		mini = i;
		for (j = i; j < n; j++) {
			if (a[mini] > a[j]) {
				mini = j;
			}
		}
		if(mini!=i)doswap(&a[i], &a[mini], &num);
	}
	rep(i,n) {
		if (i > 0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n%d\n", num);
	return 0;
}

Measured memory_bytes: 604
x = int(input())

if x <= 2 :
  print(x)
  exit()

if x % 2 ==0:
  x += 1
comp = True
while comp :
  comp = False
  for i in range(2,x):
    if x % i == 0:
      comp = True
      break

  if comp :
    x += 2

print(x)  


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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int W, H;
bool m[20][20];
bool hou[20][20];

int dfs(int r, int c)
{
	if (r < 0 || c < 0 || r >= H || c >= W) return 0;
	if (hou[r][c] || !m[r][c]) return 0;
	hou[r][c] = true;
	int res = 1;
	int dr[] = {-1, 0, 0, 1};
	int dc[] = { 0,-1, 1, 0};
	rep(i, 4) res += dfs(r+dr[i], c+dc[i]);
	return res;
}

signed main()
{
	cin >> W >> H;
	while (W) {
		int r=0, c=0;
		rep(i, H) rep(j, W) {
			CIN(char, t);
			if (t == '#') m[i][j] = false;
			else {
				m[i][j] = true;
				if (t == '@') {
					r = i;
					c = j;
				}
			}
		}
		cout << dfs(r, c) << endl;
		cin >> W >> H;
		rep(i, 20) rep(j, 20) hou[i][j] = false;
	}
}



Measured memory_bytes: 3088
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        StringBuilder ans;
//        long cnt = 0;
        int cnt = 0;
        for (int i = 1; i <= n; i++) {

            ans = new StringBuilder(""+i);
            if (ans.length() % 2 != 0) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }

}


Measured memory_bytes: 36692
#H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(3)]
#print(A)
A_flt = []
for s in A:
    A_flt.extend(s)
#print(A_flt)
import collections
A_cnt = collections.Counter(A_flt)
#print(A_cnt)
if A_cnt.most_common()[0][1] >= 3:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<numeric>

using namespace std;

struct edge{
  int x,y,d;
  bool operator<(edge e)const{
    return d<e.d;
  }
};

int par[200000];
int nod[200000];

int find(int x){
  return (x==par[x])?x:par[x]=find(par[x]);
}

long long unite(int a,int b){
  int pa=find(a);
  int pb=find(b);
  par[pa]=pb;
  long long n=nod[pa]*1LL*nod[pb];
  nod[pb]+=nod[pa];
  return n;
}

int main(){
  int n;
  cin>>n;
  static edge e[200000];
  iota(par,par+n,0);
  fill(nod,nod+n,1);
  for(int i=0;i<n-1;i++){
    cin>>e[i].x>>e[i].y>>e[i].d;
  }
  sort(e,e+n-1);
  long long ans=0;
  for(int i=0;i<n-1;i++){
    ans+=unite(e[i].x,e[i].y)*e[i].d;
  }
  cout<<ans<<endl;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

  int ans = 0;

  int center = s.size() / 2;
  if (s.size() % 2) {
    char c = s[center];
    int a = 0;
    REP(i, s.size()) {
      if (s[center - i] != c or s[center + i] != c)
        break;
      else
        a = i;
    }
    ans = (center + 1) + a;
  } else {
    int a = 0;
    char cl = s[center - 1];
    char cr = s[center];
    if (cl == cr) {
      REP(i, s.size()) {
        if (s[center - 1 - i] != cl or s[center + i] != cr)
          break;
        else
          a = i;
      }
      a++;
    }
    ans = center + a;
  }

  cout << ans << endl;
  return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	string s;
	cin >> s;
	int lastl = SZ(s) - 1, lastr = 0;
	int d[MAX], res[MAX];
	FILL(res, 0);
	REP(i, SZ(s)){
		if (s[i] == 'L') d[i] = i - lastr;
		else lastr = i;
	}
	RREP(i, SZ(s)){
		if (s[i] == 'R') d[i] = lastl - i;
		else lastl = i;
	}
	REP(i, SZ(s)){
		if (s[i] == 'R') {
			if (d[i] & 1) res[i + d[i] - 1]++;
			else res[i + d[i]]++;
		}
		else{
			if (d[i] & 1) res[i - d[i] + 1]++;
			else res[i - d[i]]++;
		}
	}
	REP(i, SZ(s)){
		cout << res[i] << endl;
	}
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 1488
# https://atcoder.jp/contests/agc013/tasks/agc013_a

n = int(input())

nums = [int(i) for i in input().split()]

ans = 1

flag = None
pre = nums[0]
for i in range(n):
    if pre == nums[i]:
        continue
    elif pre < nums[i]:
        if flag == False:
            ans += 1
            flag = None
        else:
            flag = True
    else:
        if flag == True:
            ans += 1
            flag = None
        else:
            flag = False
    pre = nums[i]
print(ans)


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

template<typename T> struct Edge {
    int to;
    T cost;
    Edge(int t, T c) : to(t), cost(c) {}
};

template<typename T> vector<T> Dijkstra(const vector<vector<Edge<T>>>& g, int s) {
    T INF = (T)1e18;
    vector<T> d(g.size(), INF);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<>> q;
    d.at(s) = 0;
    q.emplace(d.at(s), s);
    while ( !q.empty() ) {
        auto p = q.top();
        q.pop();
        int v = p.second;
        if ( d.at(v) < p.first ) continue;
        for ( auto e : g[v]) {
            if ( d.at(e.to) > d.at(v) + e.cost ) {
                d.at(e.to) = d.at(v) + e.cost;
                q.emplace(d.at(e.to), e.to);
            }
        }
    }
    return d;
}

ll solve() {
    ll N, M, S, T, a, b;
    cin >> N >> M >> S >> T;
    S--, T--;
    int u, v;
    vector<vector<Edge<ll>>> G1(N), G2(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> u >> v >> a >> b;
        u--, v--;
        G1[u].push_back(Edge<ll>(v, a));
        G1[v].push_back(Edge<ll>(u, a));
        G2[u].push_back(Edge<ll>(v, b));
        G2[v].push_back(Edge<ll>(u, b));
    }

    vector<ll> d1 = Dijkstra(G1, S);
    vector<ll> d2 = Dijkstra(G2, T);
    ll f = 1e15;
    vector<ll> c(N, f);
    for ( int i = N-1; i >= 0; i-- ) {
        c[i] = d1[i] + d2[i];
        if ( i < N-1 ) c[i] = min(c[i], c[i+1]);
    }
    for ( int i = 0; i < N; i++ ) {
        cout << f - c[i] << "\n";
    }
    return 0;
}

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

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  if (s.at(k-1) == 'A') {
    s.at(k-1) = 'a';
    cout << s << endl;
  }
  else if (s.at(k-1) == 'B') {
    s.at(k-1) = 'b';
    cout << s << endl;
  }
  else {
    s.at(k-1) = 'c';
    cout << s << endl;
  }
}

Measured memory_bytes: 256
from collections import defaultdict


S = input()
T = input()
S_count = defaultdict(int)
T_count = defaultdict(int)

for s, t in zip(S, T):
    S_count[s] += 1
    T_count[t] += 1

A = list(S_count.values())
B = list(T_count.values())

A.sort()
B.sort()

if A == B:
    print('Yes')
else:
    print('No')

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

int main() {
  int a,b,c,d,l,r;
  cin >> a >> b >> c >> d;
  l=a+b;
  r=c+d;
  if (l>r) cout << "Left\n";
  else if (l==r) cout << "Balanced\n";
  else cout << "Right\n";
}

Measured memory_bytes: 256