akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

set<int>S;
int n;
int main(){
	cin>>n;
	rep(i,n){
		int a; cin >> a;
		if(S.find(a) != S.end()){
			puts("NO"); return 0;
		}S.insert(a);
	}
	puts("YES");}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  int64_t m;
  for(int64_t i=1;i*i<=n;i++)
    if(n%i==0)
      m=i+n/i-2;
  cout<<m<<endl;
}

Measured memory_bytes: 384
#include<iostream>
int w,h,d[5]={1,0,-1,0,1},i,j,M,Y,X,T;std::string s[50];int r(int y,int x){T=s[y][x];if(T-41&&T-20)s[y][x]|=M;for(int i=0;i<5;){Y=y+d[i];X=x+d[++i];if(Y<0||h<=Y||X<0||w<=X||s[Y][X]==41||s[Y][X]==20||(s[Y][X]&M)==M)continue;r(Y,X);}}main(){for(;std::cin>>w>>h,w|h;printf("%d %d\n",X,Y)){for(M=i=0;i<h;i++)for(std::cin>>s[i],j=w;j-->0;)s[i][j]-=46;for(i=h;i-->0;)for(j=w;j-->0;M=2*(X==41)+(X==20),M&&r(i,j))X=s[i][j];for(X=Y=i=0;i<h;i++)for(j=w;j-->0;T==1&&X++,T==2&&Y++)T=s[i][j];}}

Measured memory_bytes: 0
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    if n % 2 == 1 {
        for i in 0..m {
            put!(i + 1, n - i);
        }
    } else {
        let mut ans = vec![];
        let s = min!(m, n / 4);
        for i in 0..s {
            ans.push((i, n-i-1));
        }
        for i in 0..(m - s) {
            ans.push((
                    n/2 - i - 1,
                    n/2 + i + 1
            ));
        }

        for &(a,b) in ans.iter() {
            put!(a + 1, b + 1);
        }
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 3108
INF = 10 ** 9 + 7
n = gets.to_i
nums = gets.split.map(&:to_i)
hash = Hash.new(0)
61.times do |pos|
  tmp = 0
  nums.each do |num|
    tmp += num[pos]
  end
  hash[pos] = tmp
end
ans = 0
hash.each do |key, value|
  ans += 2 ** key * value * (n - value)
  ans %= INF
end
puts ans


Measured memory_bytes: 34820
#include<stdio.h>
int n,m,f[1010];
int ff(int a,int b){
  if(a<b){
    if(a)return ff(a,b%a);
    return b;
  }
  if(b)return ff(b,a%b);
  return a;
}
int g(int s,int t,char d[1010][1010]){
  if(s==t)return 1;
  int i;
  for(i=0;i<n+m+2;i++){
    if(f[i]||d[s][i]==0)continue;
    f[i]=1;
    if(g(i,t,d)){
      d[s][i]=0;
      d[i][s]=1;
      return 1;
    }
  }
  return 0;
}
int main(){
  int i,j,a[510],b;
  while(scanf("%d %d",&n,&m),n||m){
    char d[1010][1010]={0};
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      d[0][i+1]=1;
    }
    for(j=0;j<m;j++){
      scanf("%d",&b);
      for(i=0;i<n;i++){
	if(ff(a[i],b)-1)d[i+1][n+j+1]=1;
      }
      d[n+j+1][n+m+1]=1;
    }
    for(i=0;i<n+m+2;i++)f[i]=0;
    for(b=0;g(0,n+m+1,d);b++){
      for(i=0;i<n+m+2;i++)f[i]=0;
    }
    printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(void){
    long long n,a,b;
    cin>>n>>a>>b;
    if(n==1&&a!=b){
        cout<<0<<endl;
    }else if(a<=b){
        cout<<(n-2)*(b-a)+1<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int y=0;
	string s;
	cin>>s;
	int n;
	n=s.size();
	string x=s;
	string t;
	cin>>t;
	if(s==t){
		cout<<"Yes"<<endl;
	}
	else{
		for(int i=0;n>i;i++){
			for(int j=0;n-1>j;j++){
				s.at(j)=x.at(j+1);
			}
			s.at(n-1)=x.at(0);
			x=s;
			if(s==t){
				cout<<"Yes"<<endl;
				y++;
				break;
			}
		}
		if(y==0){
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N; 
ll A[202020];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int j = 0; j < N; ++j) cin >> A[j];

    if (N == 1) {
        cout << (A[0] == 0 ? 0 : -1) << endl;
        return 0;
    }

    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }


    ll ans = 0, h = 0;
    for (int j = N-1; j > 0; --j) {
        if (h > A[j]) { cout << -1 << endl; return 0; }
        if (h < A[j]) ans += A[j];
        h = max(0LL, A[j]-1);
    }
    if (h > 0) ans = -1;
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;


int main() {
    int x, y, z, k, m;
    vector<ll>a;
    vector<ll>b;
    vector<ll>c;
    vector<ll>e;
    vector<ll>ans;
    ll val;
    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; i++) {
        cin >> val;
        a.push_back(val);
    }
    for (int i = 0; i < y; i++) {
        cin >> val;
        b.push_back(val);
    }
    for (int i = 0; i < z; i++) {
        cin >> val;
        c.push_back(val);
    }

    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            e.push_back(a[i]+b[j]);
        }
    }
    sort(e.begin(), e.end(), std::greater<ll>());


    m = (k < e.size()) ? k : e.size();
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < z; j++) {
            ans.push_back(e[i]+c[j]);
        }
    }
    sort(ans.begin(), ans.end(), std::greater<ll>());

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


Measured memory_bytes: 43384
n = int(input())
x, y = 0, 0
t = 0
for i in range(n):
    ti, xi, yi = map(int, input().split())
    dt = ti - t
    if not(abs(x - xi) <= dt and abs(y - yi) <= dt):
        print('No')
        exit()
    elif dt - (abs(x - xi) + abs(y - yi))> 0 and ((dt - abs(x - xi) + abs(y - yi)) % 2) != 0:
        print('No')
        exit()
    x = xi
    y = yi
    t = ti
print('Yes')


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

int main()
{
    int n;
    int flag=0;
    cin>>n;
    map<int,int> mp;
    for(int i=1;i<=n;i++)
    {
        int x;cin>>x;
        mp[x]++;
        if(mp[x]>=2) flag=1;
    }
    if(flag) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
int main(void) {
    int max = 0;
    int x=0;
    int n;
    string s;
    cin >> n >> s;
    REP(i,n) {
        if(s[i]=='I') x++;
        else x--;
        max = fmax(max, x);
    }
    cout << max << endl;                                                                             
}


Measured memory_bytes: 256
K, X = map(int, input().split())
if X-(-1000000)<=K:
  print(' '.join(map(str, list(range(-1000000, X+K)))))
elif 1000000-X<=K:
    print(' '.join(map(str,list(range(X-K+1, 1000000)))))
else:
    print(' '.join(map(str,list(range(X-K+1, X+K)))))

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

int main(){
  long n,m;
  cin >> n >> m;
  vector<vector<long>> edge(n);
  vector<vector<long>> w(n);
  long maxc = 0;
  rep(i,m){
    long a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    edge[a].push_back(b);
    w[a].push_back(c);
    maxc = max(labs(c),maxc);
  }
  vector<long> score(n,-n*maxc);
  vector<long> flag(n,0);
  score[0] = 0;
  flag[0] = 0;
  vector<bool> update(n);
  rep(ii,n){
    rep(i,n) update[i] = false;
    rep(i,n){
      if(score[i] == -n*maxc)continue;
      rep(j,int(edge[i].size())){
        if(score[i] + w[i][j] > score[edge[i][j]] || flag[edge[i][j]] == 0){
          update[edge[i][j]] = true;
          flag[edge[i][j]] = 1;
          score[edge[i][j]] = score[i] + w[i][j];
        }
      }
    }
  }
  /*
  long ans = score[n-1];
  rep(i,n)update[i] = false;
  rep(i,n){
    rep(j,n){
      rep(k,int(edge[j].size())){
        if(score[j] + w[j][k] > score[edge[j][k]]){
          score[edge[j][k]] = score[j] + w[j][k];
          update[edge[j][k]] = true;
        }
      }
    }
  }
  */
  if(update[n-1] == true){
    cout << "inf\n";
  }else cout << score[n-1] << endl;
  return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=2; i<=1000000; i++){
        ll nc=n;
        if(nc==i) break;
        bool divide=false;
        while(nc%i==0){
            nc /= i;
            divide=true;
        }
        if(divide){
            if(nc%i==1) ans++;
        }
    }
    vector<int> shoulder(1000,0);
    int counter=0;
    ll N=n-1;
    for(ll i=2; i<=1000000; i++){
        if(N<i) break;
        bool divide=false;       
        while(N%i==0){
            N /= i;
            shoulder.at(counter)++;
            divide=true;
        }
        if(divide) counter++;
    }
    if(N!=1) shoulder.at(counter)++;
    ll divisors=1;
    ll c=0;
    while(shoulder.at(c)){
        divisors *= shoulder.at(c)+1;
        c++;
    }
    ans += divisors;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  int d,n;
  cin >> d >> n;
  if(d==0){
    if(n<100)cout<<n<<endl;
    else cout<<101<<endl;
  }
  if(d==1){
    if(n<100)cout<<n*100<<endl;
    else cout<<10100<<endl;
  }
  if(d==2){
    if(n<100)cout<<n*10000<<endl;
    else cout<<1010000<<endl;
  }
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


string integer_to_bin(int n, int digits)
{
	string res;
	while (n)
	{
		res = (n & 1 ? '1' : '0') + res;
		n >>= 1;
	}
	return string(max(0, digits-(int)res.size()), '0') + res;
}
string fraction_to_bin(double n, int digits)
{
	string res;
	while (n > EPS)
	{
		n *= 2;
		if (n+EPS > 1)
		{
			n -= 1;
			res += '1';
		}
		else
			res += '0';
	}
	return res + string(max(0, digits-(int)res.size()), '0');
}
int main()
{
	double n;
	while (scanf("%lf", &n), n >= 0)
	{
		string integer = integer_to_bin((int)n, 8);
		string fraction = fraction_to_bin(n - (int)n, 4);
		if (integer.size() <= 8 && fraction.size() <= 4)
			printf("%s.%s\n", integer.c_str(), fraction.c_str());
		else
			puts("NA");
	}

	return 0;
}

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

int main(){
	int S, h, m, s;
	cin >> S;
	h = S / (60 * 60);
	m = S % (60 * 60) / 60;
	s = S % (60 * 60) % 60;
	cout << h << ":" << m << ":" << s << "\n";

	return 0;
}

Measured memory_bytes: 1164
import sys

N = int(input())
a = list(map(int, input().split()))
 
x = 0
y = 0
z = 0

if a.count(0) == N:
  print('Yes')
  sys.exit()
  

if N % 3 != 0:
  print('No')
 
elif a.count(0) != 0:
  if a.count(0) != N / 3:
    print('No')
    sys.exit()
    
  else:
    for i in range(N):
      if a[i] != 0 and a[i] != x:
        if x == 0:
          x = a[i]
          continue
        else:
          print('No')
          sys.exit()
        
    print('Yes')
    

else:
  for i in range(N):
    if a[i] != x and a[i] != y and a[i] != z:
      if x == 0:
        x = a[i]
        continue
      elif y == 0:
        y = a[i]
        continue
      elif z == 0:
        z = a[i]
        continue
      else:
        print('No')
        sys.exit()
  
  if x ^ y == z and a.count(x) == a.count(y) and a.count(y) == a.count(z):
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 14212
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long x = n;
        String res = "";
        while (x != 0) {
            int r = (int)(x % 26);
            if (r == 0) {
                r = 26;
            }
            char c = (char)(96 + r);
            res += String.valueOf(c);
            x = (x - r) / 26;
        }
        StringBuffer bufres = new StringBuffer(res);
        String res1 = bufres.reverse().toString();
        System.out.println(res1);
        sc.close();
    }
}

Measured memory_bytes: 39120
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  string ans="";
  while(n){
    long long k=n/26;
    long long z=n%26;
    if(z==0){
      k--;
      ans=(char)('z')+ans;
    }
    else ans=(char)('a'+z-1)+ans;
    n=k;
  }
  cout<<ans;
  return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;

  vector<string>s(H);
  for(int i=0;i<H;i++){
    cin >> s.at(i);
  }
  vector<bool>row(H,false);
  vector<bool>col(W,false);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s.at(i).at(j)=='#'){
        row.at(i)=true;
        col.at(j)=true;
      }
    }
  }

  for(int i=0;i<H;i++){
    if(row.at(i)){
      for(int j=0;j<W;j++){
        if(col.at(j)){
          cout << s.at(i).at(j);
        }
      }
      cout <<endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;
vi a;

int main(){
	cin>>n>>k;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vi dp(n,inf);
	dp[0]=0;
	for(int i=0;i<n;i++) for(int j=1;j<=k;j++) if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
k=int(input())
nums=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(nums[k-1])


Measured memory_bytes: 2940
s = input()
gp = [1, 0]
p = 0
if s[0] == 'p':
    p -= 1
for i in range(1, len(s)):
    if s[i] == 'g':
        if gp[0] > gp[1]:
            gp[1] += 1
            p += 1
        else:
            gp[0] += 1
    if s[i] == 'p':
        if gp[0] > gp[1]:
            gp[1] += 1
        else:
            gp[0] += 1
            p -= 1
print(p)

Measured memory_bytes: 9180
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " : " << x << " " << endl
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,q,ok;

int a[maxn];

signed main()
{
	cin>>n;
	for(int i = 1; i <= n; i++) 
	{
		cin>>a[i];
	}
	int ans = inf;
	for(int i = 1; i <= 100; i++) 
	{	
		int res = 0;
		for(int j = 1; j <= n; j++) 
		{
			res += (i-a[j])*(i-a[j]);
		}
		ans = min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import numpy as np
n = int(input())
a_list = np.array(list(map(int, input().split())))
y = np.argsort(a_list)
if a_list[y[0]] == 0:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[y[n - 1 - i]])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)



Measured memory_bytes: 40072
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,s[5];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=4;i++){
        s[5-i]=n%10;
        n/=10;
    }
    if(s[1]+s[2]+s[3]+s[4]==7) cout << s[1] << '+' << s[2] << '+' << s[3] << '+' << s[4] << "=7";
    else if(s[1]+s[2]+s[3]-s[4]==7) cout << s[1] << '+' << s[2] << '+' << s[3] << '-' << s[4] << "=7";
    else if(s[1]+s[2]-s[3]+s[4]==7) cout << s[1] << '+' << s[2] << '-' << s[3] << '+' << s[4] << "=7";
    else if(s[1]+s[2]-s[3]-s[4]==7) cout << s[1] << '+' << s[2] << '-' << s[3] << '-' << s[4] << "=7";
    else if(s[1]-s[2]+s[3]+s[4]==7) cout << s[1] << '-' << s[2] << '+' << s[3] << '+' << s[4] << "=7";
    else if(s[1]-s[2]+s[3]-s[4]==7) cout << s[1] << '-' << s[2] << '+' << s[3] << '-' << s[4] << "=7";
    else if(s[1]-s[2]-s[3]-s[4]==7) cout << s[1] << '-' << s[2] << '-' << s[3] << '-' << s[4] << "=7";
    else if(s[1]-s[2]-s[3]+s[4]==7) cout << s[1] << '-' << s[2] << '-' << s[3] << '+' << s[4] << "=7";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

int a[1000], n, ans;

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  for(int i = 1; i <= n; i++)
    if(a[i] > a[i - 1]) ans += a[i] - a[i - 1];
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,z,i;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	z=0;
	
	for(i=a ;i<=b ;i++) {	
		
		if(c%i ==0) {
			z=z+1;
		}
	}
	printf("%d\n",z);
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    double s,x;
    cin>>n;
    x=n;
    if(n%2==0)
        s=(x/2)/x;
    else
        s=((x+1)/2)/x;
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(min(b,d) >= max(a,c)) cout << min(b,d)-max(a,c) << endl;
    if(min(b,d) < max(a,c)) cout << 0 << endl;
}

Measured memory_bytes: 256
class Prime():
    def __init__(self, n):
        self.p = [] # self.p[i] = i番目の素数 < n
        self.d = [0] * n # self.d[i] = iを割り切る最小の素数

        # エラトステネスの篩
        for i in range(2, n):
            if self.d[i] == 0:
                self.p.append(i)
                for j in range(i, n, i):
                    if self.d[j] == 0:
                        self.d[j] = i

        self.ind = [-1] * n # self.ind[i] = self.p.index[i]
        for i in range(len(self.p)):
            self.ind[self.p[i]] = i

    def prime_factorization_index(self, x): # xの素因数のlistをreturn(重複なし)
        l = [self.ind[self.d[x]]]
        x //= self.d[x]
        while x != 1:
            if l[-1] != self.ind[self.d[x]]:
                l.append(self.ind[self.d[x]])
            x //= self.d[x]
        return l

    def num_prime(self): # n未満の素数の個数をreturn
        return len(self.p)

def main():

    from math import gcd
 
    n = int(input())
    a = list(map(int, input().split()))

    # 'not coprime'かどうか判定
    g = a[0]
    for i in a:
        g = gcd(g, i)
        if g == 1:
            break
    else:
        print('not coprime')
        exit()

    # 'setwise coprime'かどうか判定
    p = Prime(10**6 + 1)

    tf = [False] * p.num_prime() # tf[i] == True: i番目の素数を素因数とするものが存在する

    for i in a:
        if i == 1:
            continue

        l = p.prime_factorization_index(i)
        for j in l:
            if tf[j]:
                print('setwise coprime')
                exit()
            else:
                tf[j] = True

    print('pairwise coprime')

main()


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

#define MAX_N 200001

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp(left_char,right_char);
}

typedef struct{
    char str[11];
    int time;
} word;

int main(void){

    int N,i,j = 0,k = 0,max_time = 0,word_time[MAX_N];
    char S[MAX_N][11];
    word Str[MAX_N];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%s",S[i]);
        Str[i].time = 0;
    }

    qsort(S,N,sizeof(S[0]),compare_char);

    strcpy(Str[0].str,S[0]);
    for(i = 1;i < N;i++){
       if(strcmp(Str[j].str,S[i]) != 0){
           //printf("c\n");
           if(max_time < Str[j].time){
               max_time = Str[j].time;
           }
           j++;
           strcpy(Str[j].str,S[i]);
       }else{
           Str[j].time++;
           if(max_time < Str[j].time){
               max_time = Str[j].time;
           }
       }
    }

    //printf("\n");
    for(i = 0;i < N;i++){
        if(Str[i].time == max_time){
            printf("%s\n",Str[i].str);
        }
    }
    return 0;
}


Measured memory_bytes: 7548
s = input()

for i in range(8):
    siki = s[0]
    for j in range(3):
        bitchk = 2 ** j
        if i & bitchk:
            siki += '+'
        else:
            siki += '-'
        siki += s[j+1]
    ans = eval(siki)
    if ans == 7:
        print(siki, '=7', sep='')
        exit()


Measured memory_bytes: 2940
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $k);
$xs = explode(' ', trim(fgets(STDIN)));
$d = 0;
foreach ($xs as $x) {
	$d += min($x, abs($k - $x));
}
echo $d * 2, "\n";

Measured memory_bytes: 4984
n, m = gets.chomp.split.map(&:to_i)
a = Array.new( n )
b = Array.new( m )

n.times do |i|
  a[i] = gets.chomp.split.map(&:to_i)
end

m.times do |i|
  b[i] = gets.chomp.to_i
end

a.each do |row|
  sum = 0
  row.each.with_index(0) do |num, i|
    sum += num * b[i]
  end
  puts sum
end

Measured memory_bytes: 8880
N,M=map(int,input().split())

if N>M:
    tmp=N
    N=M
    M=tmp

if N==1:
    if M==2:
        print(0)
    elif M==1:
        print(1)
    else:
        print(M-2)
elif N==2:
    print(0)
else:
    print((N-2)*(M-2))



Measured memory_bytes: 3060
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

for = flip map

main :: IO ()
main = do
  s <- getLine
  let a = array (1,length s) $ zip [1..] s

  (\(x,y) -> printf "%d %d\n" x y) (solve a)

  where
    solve a = solve' l
      where
        (l,u) = bounds a
        solve' i
          | i == u = (-1,-1)
          | a!i == a!(i+1) = (i,i+1)
          | i+2 <= u  && a!i == a!(i+2) = (i,i+2)
          | otherwise = solve' (i+1)


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

int PON(int N){
  int sum = 0;
  while(N > 0){
    sum += (N%10);
    N /= 10;
  }
  return sum;
}
  
int main(){
  int N;
  cin >> N;
  int sum = PON(N);
  if(N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define inf 0x3f3f3f
typedef long long ll;
const int maxn = 1e2+5;
int k;
queue <ll > que;
int main(){
	cin >> k;
	for(int i = 1;i <= 9;i++)
		que.push(i);
	ll ans = 0;
	for(int i = 1;i <= k;i++){
		ans = que.front();que.pop();
		ll cnt = ans % 10;
		if(cnt)
			que.push(ans * 10 + cnt - 1);
		que.push(ans * 10 + cnt);
		if(cnt != 9)
			que.push(ans * 10 + cnt + 1);
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


ll num(string&);
ll term(string&);
ll expr(string&);
int pos;
map<char, int> mp;
ll calc(ll a, ll b, char op) {
	if (op == '-')return a - b;
	if (op == '+')return a + b;
	if (op == '*')return a * b;
	throw("wrong op");
}
ll num(string& s) {
	ll res = 0;
	while (isdigit(s[pos])) {
		res *= 10;
		res += s[pos] - '0';
		pos++;
	}
	return res;

}
ll term(string& s) {
	if (s[pos] == '(') {
		pos++;
		return expr(s);
	}
	else {
		ll a = num(s);
		return a;
	}
}
ll expr(string& s) {
	vl res;
	res.push_back(term(s));
	vector<char> ops;
	while (pos < s.size()) {
		if (s[pos] == ')') {
			pos++;
			break;
		}
		ops.push_back(s[pos]);
		pos++;
		ll b = term(s);
		res.push_back(b);
	}
	REP(j, 3)REP(i, ops.size()) {
		if (mp[ops[i]] == j) {
			ll tmp = calc(res[i], res[i + 1], ops[i]);
			res.insert(res.begin() + i, tmp);
			res.erase(res.begin() + i + 1, res.begin() + i + 3);
			ops.erase(ops.begin() + i);
			--i;
		}
	}

	return res[0];
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	//cout << exp(s) << endl;
	string t = "-+*";
	ll ans = numeric_limits<ll>::min();
	REP(i, 3)REP(j, 3)REP(k, 3) {
		mp.clear();
		mp['-'] = i;
		mp['+'] = j;
		mp['*'] = k;
		pos = 0;
		ll tmp = expr(s);
		chmax(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3244
def main():

	
	n = int(input())
	a = 0
	b = 0
	ans_list = []
	for i in range(1,int(n**0.5)+1):
		if n % i ==0:
			a = i
			b = n//a
			ans_list.append(a+b-2)
	print(min(ans_list))


	



 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N,M,sum=0;
	cin>>N;
	vector<int>T(N);
	for(int i=0;i<N;i++){
		cin>>T[i];
		sum+=T[i];
	}
	cin>>M;
	vector<int>P(M);
	vector<int>X(M);
	for(int i=0;i<M;i++){
		cin>>P[i]>>X[i];
		cout<<sum+X[i]-T[P[i]-1]<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int H, W;
    while (true) {
        std::cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1) {
                    std::cout << '#';
                } else if (j == 0 || j == W - 1) {
                    std::cout << '#';
                } else {
                    std::cout << '.';
                }
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3064
n,m = map(int,input().split(" "))
h = [int(_) for _ in input().split(" ")] 

tmp=[0]*n

for i in range(m):
  a,b = map(int,input().split(" "))
  if h[a-1] > h[b-1]:
    if tmp[a-1] != 1:
      tmp[a-1]=2
    tmp[b-1]=1
  elif h[a-1] < h[b-1]:
    tmp[a-1]=1
    if tmp[b-1] != 1:
      tmp[b-1]=2
  else:
    tmp[a-1]=1
    tmp[b-1]=1

ans=tmp.count(0)+tmp.count(2)

print(ans)

Measured memory_bytes: 20128
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
vector<vector<int>> edge;
P dfs(int n,int par){
    rep(i,edge[n].size()){
        int it=edge[n][i];
        if(it==par)continue;
    }
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int m,n,sum=0;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end(),greater<>());
    if(a[m-1]*m*4<sum)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll v = n;
  int c = 0;
  while (v > 0) {
    c += v % 10;
    v /= 10;
  }
  cout << (n % c == 0 ? "Yes" : "No") << endl;
}


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

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

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

    int sum_all = 0, sum, lev = 0;
    stack<int> st;
    stack<P> stP;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '\\')
            st.push(i);
        else if (s[i] == '/') {
            if (st.empty()) continue;
            int j = st.top(); st.pop();

            sum_all += i - j;
            sum = i - j;
            while (stP.size() > 0 && j < stP.top().first) {
                sum += stP.top().second;
                stP.pop();
            }
            stP.push(P(j, sum));
        }
    }

    vector<int> v;
    while (stP.size()) {
        v.push_back(stP.top().second);
        stP.pop();
    }
    reverse(v.begin(), v.end());


    cout << sum_all << endl;
    cout << v.size();
    for (int  i = 0; i < v.size(); i++)
        cout << " " << v[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ld long double
const int maxn = 3e5 + 10 , mod = 1e9 + 7;

ll n, l[maxn], r[maxn];
string s;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
		l[i] = l[i - 1] + (s[i-1] == 'E');
	ll res = n;
	for (int i = 1; i <= n; i++)
	{
		//cout << i << ' ' << i-1 - l[i-1] + l[n] - l[i] << endl;
		res = min (res, i-1 - l[i-1] + l[n] - l[i]);
	}
	cout << res << endl;
	return 0;
}

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

int main(){
  string W, T;
  int cnt = 0;
  cin>>W;
  while(true){
    cin>>T;
    if(T == "END_OF_TEXT") break;
    for(int i=0;i<T.size();i++){
      if('A' <= T[i] && T[i] <= 'Z'){
	T[i] += 32;
      }
    }
    if(W == T) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template <typename T>
using gtree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// usage:
// find_by_order(Int k): return the iterator of k-th smallest element (0-indexed)
// order_of_key(T key):  return the index of key in tree

//INSERT ABOVE HERE
signed main(){
  Int w,h,n;
  cin>>w>>h>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];

  using P = pair<Int, Int>;
  gtree<P> gx,gy;
  for(Int i=0;i<n;i++){
    gx.insert(P(x[i],i));
    gy.insert(P(y[i],i));
    gx.insert(P(x[i],n+i));
    gy.insert(P(y[i],n+i));
  }

  Int ans=1e18;
  Int ax=-1,ay=-1;

  map<Int, Int> mx,my;
  
  for(Int i=0;i<n;i++){    
    gx.erase(P(x[i],i));
    gy.erase(P(y[i],i));

    
    Int tx=gx.find_by_order(n-1)->first;
    Int ty=gy.find_by_order(n-1)->first;

    if(!mx.count(tx)){
      mx[tx]=0;
      for(Int j=0;j<n;j++)
	mx[tx]+=abs(x[j]-tx)*2;
    }
    if(!my.count(ty)){
      my[ty]=0;
      for(Int j=0;j<n;j++)
	my[ty]+=abs(y[j]-ty)*2;
    }
    
    Int res=mx[tx]+my[ty]-(abs(x[i]-tx)+abs(y[i]-ty));
    if((res< ans)||
       (res==ans&&tx< ax)||
       (res==ans&&tx==ax&&ty< ay)){
      ans=res;
      ax=tx;
      ay=ty;
    }
    
    gx.insert(P(x[i],i));
    gy.insert(P(y[i],i));
  }
  
  cout<<ans<<endl;
  cout<<ax<<" "<<ay<<endl;
  return 0;
}



Measured memory_bytes: 29536
from collections import Counter

n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

Count = Counter(D)

for t in T:
    if not Count[t]:
        print("NO")
        exit()
    else:
        Count[t] -= 1
print("YES")

Measured memory_bytes: 44772
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  long long int ans=0;
  if(k>0){
    ans+=min(a,k);
    k-=a;
  }
  if(k>0){
    k-=b;
  }
  if(k>0){
    ans-=k;
  }
  cout<<ans<<"\n";  
  return 0; 
}

Measured memory_bytes: 3648
N=int(input())
g=[[-1 for i in range(15)]for j in range(15)]

for i in range(N):
  m=int(input())
  for j in range(m):
    x,y=map(int,input().split())
    #人iによる人xについての証言を格納
    g[i][x-1]=y

ans=0
for i in range(1<<N):
  honests=[0 for _ in range(N)]
  for j in range(N):
    if (i>>j)&1==1:
      honests[j]=1
  judge=True
  for k in range(N):
    if honests[k]==1:
      for l in range(N):
        if g[k][l]==-1:
          continue
        if g[k][l]!=honests[l]:
          judge=False
  if judge:
    ans=max(ans,honests.count(1))

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int x;
    scanf("%d",&x);
    if(x<=599){printf("8");}
    else if(x<=799){printf("7");}
    else if(x<=999){printf("6");}
    else if(x<=1199){printf("5");}
    else if(x<=1399){printf("4");}
    else if(x<=1599){printf("3");}
    else if(x<=1799){printf("2");}
    else if(x<=1999){printf("1");}
}


Measured memory_bytes: 1660
#include<stdio.h>

int selectionSort(int A[],int N){
	int i,j,t,sw=0,minj;
	for(i=0;i<N;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		t=A[i];
		A[i]=A[minj];
		A[minj]=t;
		if(i!=minj){
		sw++;
		}
	}
	return sw;
}
int main(){
	int A[100],N,i,sw;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	sw=selectionSort(A,N);
	
	for(i=0;i<N;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	return 0;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

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

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int count = 0;
	int tmp = 0;
	while (tmp < n - 1) {
		tmp += k;
		tmp--;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
#define ll long long
#define INF  0x7fffffff
#define M 200000
#define N 100000
#define legal(x) ((1<=(x))&&((x)<=M))
const ll  mod=1e9 + 7;
ll n,k,ans[M],p[M],t,l,r,f[M],sum;
int main(void){
	p[1] = 1;
	for(ll i = 2;i <= N;i++){
		if(!p[i])
		ans[++sum] = i;
		for(ll j = 1;j <=sum&&i*ans[j]<=N;j++){
			p[ans[j]*i] = 1;
			if(i %ans[j]==0)
			break;
		}
	}
//	p[2] = 0;
	for(ll i = 1;i <= N;i++){
		if(p[i]==0&&p[(i+1)/2]==0&&i!=2){
			f[i] =f[i-1]+1;
		}
		else
		f[i] = f[i-1];
	}
	cin>>t;
	while(t--){
		cin>>l>>r;
		cout<<f[r] -f[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3968
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e6)+10;
vii adj(N);
int a[N];
int inv[N];
int fac[N];
int invfac[N];
void infac(){
    fac[0]=1;
    fac[1]=1;
    for(int i=2;i<N;i++){
        fac[i]=(i*fac[i-1])%mod;
    }
}
void ininv(){
   inv[0]=inv[1]=1;
   for(int i=2;i<N;i++){
       inv[i]=(inv[mod%i]*(mod-mod/i))%mod;
   } 
}
void ininvfac(){
   invfac[0]=invfac[1]=1;
   for(int i=2;i<N;i++){
       invfac[i]=(inv[i]*invfac[i-1])%mod;
   } 
}
int ncr(int n,int r){
    int ans=(((fac[n]*invfac[r])%mod)*invfac[n-r])%mod;
    return ans;
}
int32_t main()
{
    FIO
    int k; cin>>k;
    string s; cin>>s;
    int n=s.length()+k;
    infac();
    ininv();
    ininvfac();
    int ans=expo(26,n,mod);
    for(int i=0;i<s.length();i++){
        int p=(ncr(n,i)*expo(25,n-i,mod))%mod;
        ans=(ans-p+mod)%mod;
    }
    cout<<ans<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 238632
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int count = Integer.parseInt(sc.nextLine());
        int a = 0;
        int b = 0;
        int c = 0;

        String[] req;
        for (int i = 0; i < count; i++) {
            sc.hasNext();
            String s = sc.nextLine();
            req = s.split(" ");
            a = Integer.parseInt(req[0]);
            b = Integer.parseInt(req[1]);
            c = Integer.parseInt(req[2]);

            if (a * a + b * b == c * c || b * b + c * c == a * a || c * c + a * a == b * b) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 31188
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine().Split(' ');
            var input2 = Console.ReadLine().Split(' ');
            var ans = 0;
            for (int i = 0; i < int.Parse(input1[0]); i++)
            {
                var s = int.Parse(input1[2]);
                var z = Console.ReadLine().Split(' ');
                for (int i1 = 0; i1 < int.Parse(input1[1]); i1++)
                {
                    s += int.Parse(z[i1]) * int.Parse(input2[i1]);
                }
                if (s > 0)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, B, K = map(int, input().split())

    MAX_V = max(A, B)
    cd = set()
    for i in range(MAX_V, 0, -1):
        if A % i == 0 and B % i == 0:
            cd.add(i)
    print(sorted(cd, reverse=True)[K-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940