akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...


int n,k;
void test_case(){
	cin>>n>>k;
	vector<int> v(n);
	for(auto & el : v)
		cin>>el;
	sort(all(v));
	cout<<accumulate(v.begin(),v.begin()+k,0ll);
	
	
}







int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	ll n, x;
	cin >> n >> x;

	vector<ll> w(n);
	vector<ll> v(n);

	for (int i = 0; i < n; i++)
	{
		cin >> w.at(i) >> v.at(i);
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(x + 1));



	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= x; j++)
		{
			if (j - w.at(i) >= 0)
			{
				dp.at(i + 1).at(j) = max(dp.at(i).at(j), dp.at(i).at(j - w.at(i)) + v.at(i));
			}
			dp.at(i + 1).at(j) = max(dp.at(i + 1).at(j), dp.at(i).at(j));
		}
	}

	cout << dp.at(n).at(x) << endl;
}


Measured memory_bytes: 80256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int total=0,maxs=0,mins=100000,score;
        for(int j=0;j<n;j++){
            total=0;
            for(int i=0;i<5;i++){
                cin>>score;
                total+=score;
            }
            if(maxs<total)maxs=total;
            if(mins>total)mins=total;
        }
        cout<<maxs<<" "<<mins<<endl;
    }
    return 0;
}

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

using namespace std;

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

    long n;
    cin >> n;
    // char s[n];
    string s;
    // scanf("%s", &s);
    cin >> s;
    long right_e = 0;
    // for (long i = 0; i < n; i++) if (s[i] == 'E') right_e++;
    for (long i = 0; i < n; i++) right_e += (s[i] == 'E');
    // for (long i = 1; i < n; i++) if (s[i] == 'E') right_e++;
    long min_count = right_e;
    long left_w = 0;
    for (long i = 0; i < n; i++) {
    // for (long i = 1; i < n; i++) {
    //     if (!min_count) break;
        if (s[i] == 'E') {
            right_e--;
        } else {
            right_e++;
        }
        // if (s[i ] == 'W') right_e++;
        // if (s[i -1] == 'W') left_w++;
        min_count = min(min_count, right_e);
        // min_count = min(min_count, right_e + left_w);
    }
    cout << min_count << '\n';
    
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define pr pair<int,int>
#define N 100005
#define mod 1000000007
#define INF 2147483647
using namespace std;
int main() {
	IOS;
	int n,ans=0;
	cin >> n;
	for (int i = 1; i < n; i++) {
		ans += n / i;
		if (n % i == 0)ans--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
	#define rev(i,n) for(i=n-1;i>=0;i--)
		#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
		#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int a=in(),b=in();
	int t=b;
	int keta=1;
	while(t){
		keta*=10;
		t/=10;
	}
	int n=a*keta+b;
	int i;
	for(i=1;i*i<=n;i++){
		if(i*i==n){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
# Aizu Problem 0266: Aka-beko and 40 Thieves

import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


routes = {'A': {'0': 'X', '1': 'Y'},
          'X': {'1': 'Z'},
          'Y': {'0': 'X'},
          'Z': {'0': 'W', '1': 'B'},
          'W': {'0': 'B', '1': 'Y'},
          'B': {'0': 'Y', '1': 'X'}}

def solve(inp):
    cur = 'A'
    k = 0
    while k < len(inp):
        route = inp[k]
        if route in routes[cur]:
            cur = routes[cur][route]
        else:
            return "No"
        k += 1
    return "Yes" if cur == 'B' else "No"


while True:
    inp = input().strip()
    if inp == "#":
        break
    print(solve(inp))

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i = 0; i < N; i++){
    cin >> m.at(i);
    X -= m.at(i);
  }
  sort(m.begin(), m.end());
  cout << N + X / m.at(0);
  return 0;
}


Measured memory_bytes: 3596
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u64 = input();
    if n % 2 == 0 {
        println!("{}", n / 2);
    } else {
        println!("{}", n / 2 + 1);
    }
}


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

const int MIMAX = INT_MAX;
const int MIMIN  INT_MIN;
const long long MLMAX = LLONG_MAX;
const long long MLMIN = LLONG_MIN;

const int MAXNe5 = 1e5+10;
const int MAXNe9 = 1e9+10;


using mll = long long;

template <typename T>
using mstk = std::stack<T>;
template <typename T>
using mque = std::queue<T>;

template <typename T>
using mvec = std::vector<T>;

template <typename T>
using mset = std::set<T>;
template <typename T>
using mdset = std::multiset<T>;
template <typename T>
using muset = std::unordered_set<T>;
template <typename T>
using mudset = std::unordered_multiset<T>;

template <typename T1, typename T2>
using mmap = std::map<T1, T2>;
template <typename T1, typename T2>
using mdmap = std::multimap<T1, T2>;
template <typename T1, typename T2>
using mumap = std::unordered_map<T1, T2>;
template <typename T1, typename T2>
using mudmap = std::unordered_multimap<T1,T2>;


int main()
{
    std::ios::sync_with_stdio(false);	
    int n;
    cin>>n;
    mvec<int> same;
    for(int i = 1 ; i <= n ; i++)
    {
        int tmp;
        cin>>tmp;
        if(tmp==i)
        {
            same.push_back(i);
        }
    }
    int ans = 0;
    int l = 0;
    while(l < same.size())
    {
        if(l+1 < same.size())
        {
            if(same[l]+1 == same[l+1])
            {
                l+=2;
            }
            else
            {
                l++;
            }
            ans++;
        }
        else
        {
            ans++;
            l++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

ll qpow(ll x,ll n){
    ll res = 1;
    while(n){
        if(n&1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


int main()
{

    ll n;
    cin >> n;
    ll t1 = qpow(10, n);
    ll t2 = qpow(9, n);
    ll t3 = qpow(8, n);
    cout << (t1 - t2 + mod - t2 + mod + t3) % mod;
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,par[ohara],ran[ohara],para[ohara],rana[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

void init(int nn) {
	for (int i=0; i<nn; i++) {
		par[i] = i;
		ran[i] = 0;
	}
}

ll root(ll xx){
    if(par[xx]==xx){
        return xx;
    }
    else{
        return par[xx]=root(par[xx]);
    }
}
//木の根を求めている。
 
bool same(ll xx,ll yy){
    return root(xx)==root(yy);
}
//同じ集合？？
 
void unite(ll xx,ll yy){
    xx=root(xx);
    yy=root(yy);
    if(xx==yy)return;
    
    if(ran[xx]<ran[yy]){
        par[xx]=yy;
    }
    else{
        par[yy]=xx;
        if(ran[xx]==ran[yy])ran[xx]++;
    }
}
//xとyの属する集合を併合

void inita(int nn) {
	for (int i=0; i<nn; i++) {
		para[i] = i;
		rana[i] = 0;
	}
}//初期化

ll roota(ll xx){
    if(para[xx]==xx){
        return xx;
    }
    else{
        return para[xx]=roota(para[xx]);
    }
}
//木の根を求めている。
 
bool samea(ll xx,ll yy){
    return roota(xx)==roota(yy);
}
//同じ集合？？
 
void unitea(ll xx,ll yy){
    xx=roota(xx);
    yy=roota(yy);
    if(xx==yy)return;
    
    if(rana[xx]<rana[yy]){
        para[xx]=yy;
    }
    else{
        para[yy]=xx;
        if(rana[xx]==rana[yy])rana[xx]++;
    }
}
//xとyの属する集合を併合


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

      
      cin>>x>>y;
      init(13);
      inita(13);
      unite(1,3);
      unite(1,5);
      unite(1,7);
      unite(1,8);
      unite(1,10);
      unite(1,12);
      unitea(4,6);
      unitea(4,9);
      unitea(4,11);
      if(root(x)==root(y)||roota(x)==roota(y))Cout("Yes");
      else Cout("No");
     

       
return 0;
}


Measured memory_bytes: 6400
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Stack;

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

        while (true) {
            int n = sc.nextInt();
            int s = sc.nextInt();

            if (n == 0 && s == 0) {
                break;
            }

            System.out.println(dfs(n, 0, s));
        }

        sc.close();
    }

    public static int dfs(int depth, int from, int sum) {
        if(depth == 0){
            if(sum == 0){
                return 1;
            }
            return 0;
        }

        int ans = 0;
        for(int v = from; v < 10;v++){
            ans += dfs(depth - 1, v + 1, sum - v);
        }
        return ans;
    }
}


Measured memory_bytes: 26380
n, m, x, y = gets.chomp.split(" ").map(&:to_i)

xx = gets.chomp.split(" ").map(&:to_i)
yy = gets.chomp.split(" ").map(&:to_i)

xxmax = [xx.max, x].max
yymin = [yy.min, y].min 

if xxmax < yymin
  puts "No War"
else
  puts "War"
end

Measured memory_bytes: 1788
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  int Ans = 1;
  while(2*Ans <= N){
    Ans *= 2;
  }
  printf("%d\n",Ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, k;
	cin >> n >> k;
	int c = 0;
	int t = 1;
	while (t < k) {
		t -= 1;
		t += n;
		c++;
	}
	cout << c << endl;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a==b && c!=a || a==c && b!=a || b==c && a!=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	return 0;
} 

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n, m;
    cin >> n >> m;

    if ( ( n % 2 ) != 0 ) {
        for ( long long int i = 0; i < m; i++ ) {
            cout << i + 1 << " " << n - 1 - i << endl;
        }
        return 0;
    }
    for ( long long int i = 0; i < m; i++ ) {
        long long int a = n / 2 - i;
        long long int b = n / 2 + 1 + i;
        if ( b - a - 1 >= a + n - b - 1 ) a--;
        cout << a << " " << b << endl;
    }

    return 0;

}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;
    vector<int> a(n); FOR (i, 0, n) cin >> a[i];
    vector<vector<ll> > d(n-1, vector<ll>(2,0));

    d[0][0] = a[0]+a[1];
    d[0][1] = -a[0]-a[1];
    for (int i = 1; i < n-1; i++) {
        d[i][0] = max(d[i-1][0] + a[i+1], d[i-1][1] + a[i+1]);
        d[i][1] = max(d[i-1][0] - 2*a[i] - a[i+1], d[i-1][1] + 2*a[i] - a[i+1]);
    }

    cout << max(d[n-2][0], d[n-2][1]) << endl;

    return 0;
}



Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
using u128 = __uint128_t;
#define rep(x,n) for(int x = 0 ; x < n ; x++)
#define pb push_back
#define all(c) (c).begin() , (c).end()
const ll mod = 1e9 + 7;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vi a(n);
    rep(i,n)    cin >> a[i];

    vi dp(k+1, 0);
    dp[0] = 2;
    for (int i = 1 ; i <= k ; i++)
    {
        ll flag = 0;
        for (int  j = 0; j < n ; j++)
        {
            if (i - a[j] >= 0 && dp[i - a[j]] == 2)
            {
                flag = 1;
                break;
            }
        }

        if (flag)
            dp[i] = 1;
        else
            dp[i] = 2;
    }

    if (dp[k] == 1)
        cout << "First" << endl;
    else
        cout << "Second" << endl;

    return 0;
}

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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}



void solve(){
	int x;
	cin>>x;
	
	if(x>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main(){
	
	fastio();
	
	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case #"<<tt+1<<": ";solve();
//		if(solve()) cout<<""<<endl;
		solve();
	}
	
	return 0;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k, d, x, count = 0; cin>>n>>k;
    bool vis[n+1] = {0};
    while(k--){
        cin>>d;
        while(d--){
            cin>>x;
            vis[x] = 1;
        }
    }
    for(int i = 1; i<=n; i++) if(!vis[i]) count++;
    cout<<count<<"\n";
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> h(n+1);
  h[n]=1000000000;
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=n-1;i>=0;i--){
    if(h[i]>h[i+1]+1) ans++;
    else if(h[i]==h[i+1]+1) h[i]--;
  }
  if(ans==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,m;
int p[200000],par[200000],ans;
int findrep (int x){
    if(par[x]==x)return x;
    else{
        par[x] = findrep(par[x]);
        return par[x];
    }
}
void join (int a, int b){
    int repa = findrep(a);
    int repb = findrep(b);
    if(repa>repb)swap(repa,repb);
    par[repb]=repa;
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=1;i<=n;i++)par[i]=i;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        join(x,y);
    }
    for(int i=1;i<=n;i++){
        int a,b;
        a = findrep(i);
        b = findrep(p[i]);
        if(a==b)ans++;
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 1024
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int t;
	cin>>t;
	string st;
	cin>>st;
	if(st.size()<=t)
	{
		cout<<st;
		return 0;
	}
	else
	{
		string ans;
		for(int i=0;i<t;i++)
			ans+=st[i];
		cout<<ans<<"...";
		return 0;
	}
	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

const int N = 202020;

using namespace std;

int n, m;
ll k, a[N], b[N];

int main(){

	cin >> n >> m >> k;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<=m; i++) cin >> b[i];

	for(int i=1; i<=n; i++) a[i] += a[i-1];
	for(int i=1; i<=m; i++) b[i] += b[i-1];

	int l=0, r=m, ans = 0;
	for(; l<=n && r>=0; l++){
		while(r>=0 && a[l]+b[r] > k) r--;
		ans = max(ans, l+r);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 6764
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,y;
	int i,j,flg=0;
	scanf("%d %d",&n,&y);
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			if(n-(i+j)<0) {
				break;
			}
			if(i+j+n-(i+j)==n&&y==i*10000+j*5000+(n-(i+j))*1000){
				flg=1;
				break;
			}
		}
		if(flg==1) break;
	}
	if(flg==1){
		printf("%d %d %d\n",i,j,n-(i+j));
	}
	else if(flg==0||flg==2){
		printf("-1 -1 -1\n");
	}
	return 0;
}

Measured memory_bytes: 1704
#include <list>
#include<iostream>
using namespace std;
list<int> sequenceb;
int main()
{
	int num, sequencea;
	bool flag = true;
	cin>> num;
	for (int i = 0; i<num; i++)
	{
		cin>>sequencea;
		flag = !flag;
		if (flag) sequenceb.push_back(sequencea);
		else sequenceb.push_front(sequencea);
	}
	if (!(num& 1)) sequenceb.reverse();
	for (auto i = sequenceb.begin(); i != sequenceb.end(); i++)
		cout<<*i<<" ";
	return 0;
}

Measured memory_bytes: 8448
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

string S;
int N;
vector< string > ans;

bool use[26];

void rec(int i, string s) {
	if (i == N) {
		ans.push_back(s);
		return;
	}
	
	int id = S[i] - 'a';
	char nx = S[i] + 1;
	
	if (use[id]) {
		rec(i + 1, s + S[i]);
	}
	
	if (S[i] !='z' && !use[id + 1]) {
		use[id + 1] = true;
		rec(i + 1, s + nx);
		use[id + 1] = false;
	}
}

void solve() {
	N = size_of(S);
	
	ans.clear();
	minit(use, 0);
	use[0] = true;
	rec(0, "");
	
	//sort(allof(ans));
	int n = size_of(ans);
	cout << n << endl;
	if (n <= 10) {
		for_(i,0,n) cout << ans[i] << endl;
	} else {
		for_(i,0,5) cout << ans[i] << endl;
		for_(i,n - 5, n) cout << ans[i] << endl;
	}
}

int main() {
	while (cin >> S) {
		if (S == "#") break;
		solve();
	}
	return 0;
}

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

#define llint long long

void openFile() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("test.inp", "r", stdin);
   // freopen("test.out", "w", stdout);
}

const int maxN = 1e5 + 5;
const int maxM = 1e6 + 5;
const llint INF = 1ll * 1000 * 1000 * 1000 * 10 + 7;
const int mx = 2200;

int N;
llint a[maxN];
llint rev[maxN];
map<llint, int> sl;
map<llint, llint> match;

void enter() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) {
        scanf("%lld", &a[i]);
        rev[i] = 1;
    }
}

void solve() {
    for (int i = 1; i <= N; ++i) {
        llint remain = a[i];
        for (llint j = 2; j * j * j <= a[i]; ++j) {
            llint j3 = j * j * j;
            llint j2 = j * j;

            while (a[i] % j3 == 0) {
                a[i] /= j3;
                remain /= j3;
            }
            if (remain % j2 == 0) {
                rev[i] *= j;
            }
            else if (remain % j == 0) {
                rev[i] *= j2;
            }
            
            if (rev[i] > INF) rev[i] = INF;
            while (remain % j == 0) remain /= j;
        }

        llint sqrt_rem = trunc(sqrt(remain));
        if (sqrt_rem * sqrt_rem == remain) {
            rev[i] *= sqrt_rem;
            if (rev[i] > INF) rev[i] = INF;
        }
        else {
            rev[i] *= remain;
            if (rev[i] > INF) rev[i] = INF;
            rev[i] *= remain;
            if (rev[i] > INF) rev[i] = INF;
        }
    }

    for (int i = 1; i <= N; ++i) if (rev[i] != INF) {
        ++sl[a[i]];
    }

    int res = 0;
    bool F = true;
    
    for (int i = 1; i <= N; ++i) {
        if (a[i] == 1) {
            res += F;
            F = false;
            continue;
        }

        if (sl.count(rev[i]) == 0) {
            ++res;
            continue;
        }
        else {
            res = res + max(sl[a[i]], sl[rev[i]]);
            sl[a[i]] = sl[rev[i]] = 0;
        }
    }

    printf("%d", res);
}

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

Measured memory_bytes: 7040
from itertools import combinations_with_replacement as combi

n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]

def points(A, queries):
    score = 0
    for query in queries:
        a, b, c, d = query
        if A[b-1] - A[a-1] == c:
            score += query[3]
    return score

score = 0
for iter in combi([i for i in range(1, m+1)], n):
    score = max(points(sorted(iter), queries), score)

print(score)

Measured memory_bytes: 9196
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	count := 0
	for {
		for i := range a {
			if a[i]%2 == 0 {
				a[i] /= 2
			} else {
				fmt.Println(count)
				return
			}
		}
		count++
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int main() {
	
	int s = 0,i = 0;
	vector<int> arr;
	map<int, int> cnt;

	cin >> s;

	while (1) {

		if (i == 0) {
			arr.push_back(s);
			cnt[s]++;
		}
		else {
			int tmp = 0;

			if (arr[i-1] % 2 == 0) {
				tmp = arr[i-1] / 2;
			}
			else {
				tmp = 3 * arr[i-1] + 1;
			}
			cnt[tmp]++;
			arr.push_back(tmp);

			if (cnt[tmp] == 2) {
				cout << i + 1<< endl;
				return 0;
			}

			
		}

		i++;

	}
	
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

    
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n,h,w;
    cin >> n >> h >> w;
    print((n - h + 1) * (n - w + 1));
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
count_minus=0
abs_min=10**9
for i in range(n):
    if a[i]<0:
        count_minus=count_minus+1
    if abs(a[i])<abs_min:
        abs_min=abs(a[i])
sum=0
if count_minus%2==0:
    for i in range(n):
        sum=sum+abs(a[i])
else:
    for i in range(n):
        sum=sum+abs(a[i])
    sum=sum-2*abs_min
print(sum)


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

int main() {
  int N,Z=1;
  cin>>N;
  vector<string> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(), p.end());
  for(int i=1;i<N;i++){
    if(p.at(i)!=p.at(i-1)){
      Z++;
    }
  }
  cout<<Z<<endl;

}

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

#define ll long long
#define ln "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define mod 1e9 + 7
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
    fastio;

    string s;
    cin>>s;
    if(s.back()!='s'){
        cout << s;
        cout << "s";
    }else{
        cout << s;
        cout << "es";
    }
    cout << ln;

    return 0;
}

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

int main(){

	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else                                              cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int k,n;
int main() {
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}


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

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

  string S,T;
  cin >> S >> T;

  cout << T << S << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<ll> as(N, 0);
    vector<ll> bs(N, 0);
    rep(i, N){
        cin >> as[i];
    }

    rep(i, N){
        cin >> bs[i];
    }

    ll cnt = 0;

    rep(i, N){
        if(as[i] > bs[i]){
            //cnt -= 2 * (as[i] - bs[i]);
            cnt -=   (as[i] - bs[i]);
        }
        if(as[i] < bs[i]){
            //cnt += bs[i] - as[i];
            cnt += (bs[i] - as[i]) / 2;
        }
    }

    cout << (cnt >= 0 ? "Yes" : "No") << endl;

    return 0;
}


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

namespace cp {
	#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
	#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
	#define REP(a) for (int i = 0; i < (a); i++)
	#define pb push_back
	#define sz(x) (int)(x).size()
 
	typedef long long ll;
	typedef vector<int> vi;
	
	const ll INF = 9223372036854775807;
	const int MOD = 1e9 + 7;
	
	// to_string methods
	string ts(int n) { return to_string(n); }
	string ts(double n) { return to_string(n); }
	string ts(long double n) { return to_string(n); }
	string ts(long long n) { return to_string(n); }
	string ts(char c) { return to_string(c); }
	string ts(bool b) { return b ? "true" : "false"; }
	string ts(string s) { return s; }
	
	template <typename T, typename V>
	string ts(pair<T,V> p) {
		return "{" + ts(p.first) + ", " + ts(p.second) + "}";
	}
	
	template <typename T>
	string ts(T arr[], int len) {
		ostringstream oss;
		oss << "[";
		string delim = "";
		for (int i = 0; i < len; i++) {
		   oss << delim << ts(arr[i]);
		   delim = ", ";
		}
		oss << "]";
		return oss.str();
	}
	
	template<typename Container>
	string ts(const Container &v) {
		ostringstream oss;
		oss << "[";
		string delim = "";
		for (const auto &x : v) {
		   oss << delim << ts(x);
		   delim = ", ";
		}
		oss << "]";
		return oss.str();
	}
	
	template <typename T, typename V>
	string ts(map<T,V> m) {
		ostringstream oss;
		oss << "[";
		string delim = "";
		for (pair<T,V> p : m) {
		   oss << delim;
		   oss << "{" << p.first << ": " << p.second << "}";
		   delim = ", ";
		}
		oss << "]";
		return oss.str();
	}
	
	struct custom_hash {
	    static uint64_t splitmix64(uint64_t x) {
	        // http://xorshift.di.unimi.it/splitmix64.c
	        x += 0x9e3779b97f4a7c15;
	        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
	        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
	        return x ^ (x >> 31);
	    }
	    
	    size_t operator()(uint64_t x) const {
        	static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        	return splitmix64(x + FIXED_RANDOM);
    	}
	    
	    size_t operator()(pair<uint64_t,uint64_t>& x) const {
			static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
			return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
		}
	};
	
	// IO
	void setI(string s) { freopen(s.c_str(), "r", stdin); }
	void setO(string s) { freopen(s.c_str(), "w", stdout); }
	void setIO(string s1, string s2) { setI(s1); setO(s2); }
	void setUsacoIO(string s) { setIO(s + ".in", s + ".out"); }
	
	// Sorting lambda syntax
//	auto check = [&](int x, int y) {
//	    return x < y;
//	};
//
//	set<int, decltype(check)> s(check);
//	map<int, int, decltype(check)> mp(check);
//	priority_queue<int, vi, decltype(check)> pq(check); // remember pq.top() is the largest by default (descending order)
}
using namespace cp;

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

	int n;
	cin >> n;
	cout << (n*n*n) << endl;	

	return 0;
}

Measured memory_bytes: 3656
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
  k <- fst . fromJust . BS8.readInt <$> BS8.getLine
  [a, b] <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

  putStrLn $ if (not $ null [x | x <-[a..b], x `mod` k == 0]) then "OK" else "NG"


Measured memory_bytes: 3776
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner in=new Scanner(System.in);
      	String S=in.next();
      	String res="Yes";
      	for(int i=0;i<S.length();i++){
        	if( (i+1)%2==1 && S.charAt(i)=='L' ){
            	res="No";
              	break;
            }
           	else if( (i+1)%2==0 && S.charAt(i)=='R' ){
            	res="No";
              	break;
            }
        }
        System.out.println(res);
        in.close();
    }      
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
    ll n;
    cin >> n;
    if (n >= 400 and n <= 599) cout << 8 << endl;
    if (n >= 600 and n <= 799) cout << 7 << endl;
    if (n >= 800 and n <= 999) cout << 6 << endl;
    if (n >= 1000 and n <= 1199) cout << 5 << endl;
    if (n >= 1200 and n <= 1399) cout << 4<< endl;
    if (n >= 1400 and n <= 1599) cout << 3 << endl;
    if (n >= 1600 and n <= 1799) cout << 2 << endl;
    if (n >= 1800 and n <= 1999) cout << 1 << endl;
}

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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int range = b - a + 1;
  if (a > 0 && b > 0) {
    cout << "Positive\n";
  } else if (a <= 0 && b >= 0) {
    cout << "Zero\n";
  } else if (range % 2 == 0) {
    cout << "Positive\n";
  } else {
    cout << "Negative\n";
  }
  return 0;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())

ans = False
for i in range(K):
    if A < B < C:
        ans = True
        break

    if B <= A:
        B *= 2
    elif C <= B:
        C *= 2

if A < B < C:
    ans = True


if ans:
    print("Yes")
else:
    print("No")


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
	ll n;
	cin>>n;
	VL arr(n);
	fr(i,0,n)
	{
		cin>>arr[i];
	}
	VL ans;
	ll x=n;
	fr(i,0,n)
	{
		ll fg=-1;
		VL tmp;
		frr(j,x,0)
		{
			if(arr[j]==j+1&&fg==-1)
			{
				//cout<<arr[j]<<endl;
				ans.pb(arr[j]);
				// auto it=arr.begin()+j;
				// arr.erase(it);
				fg=j;
				//break;
			}
		}

		//x--;
		if(fg==-1)
		{
			cout<<"-1\n";
			return;
		}
		fr(j,0,x)
		{
			if(j!=fg)
			{
				tmp.pb(arr[j]);
			}
		}
		x--;
		arr=tmp;
	}
	reverse(ALL(ans));
	fr(i,0,n)
	{
		cout<<ans[i]<<endl;
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, x, y = map(int, input().split())

    ans1 = x*a + y*b
    min_num = min(x, y)
    max_num = max(x, y)
    x, y = x-min_num, y-min_num
    ans2 = min_num*c*2 + max(x, 0)*a + max(y, 0)*b
    ans3 = max_num*c*2
    ans = min(ans1, ans2, ans3)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9012
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int cnt = Integer.parseInt(scan.next());
        //int total = Integer.parseInt(scan.next());
        int total = 0;
        for(int i=1; i<=cnt; i++) {
            for(int j=1; j<=cnt; j++) {
                for (int k = 1; k <= cnt; k++) {
                    int tmp = gcd(i,j);
                    total += gcd(tmp,k);
                }
            }
        }
        System.out.println(total);

//        int[] input = new int[5];
//        for(int i=0;i<5;i++) {
//            input[i] = Integer.parseInt(scan.next());
//        }
        //int c = Integer.parseInt(scan.next());
//        int cnt = 0;
//        while(h>0) {
//            h = h-a;
//            cnt++;
//        }
//        if(cnt*500 >= total) {
//            System.out.println("Yes");
//        } else {
//            System.out.println("No");
//        }
//        List<Integer> result = new ArrayList<Integer>();
//        for(int i=0;i<input.length; i++) {
//            for(int j=i+1;j<input.length; j++) {
//                for (int k = j+1; k<input.length; k++) {
//                    result.add(i+j+k);
//                }
//            }
//        }
//        Collections.sort(result, Collections.reverseOrder());
//        System.out.println(result.get(2));
    }
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}


Measured memory_bytes: 35704
from collections import deque
 
N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    indegs[y-1] += 1
 
dp = [0] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        dp[v2] = max(dp[v2], dp[vNow] + 1)
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)
 
print(max(dp))

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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(n);
    ll p[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    ll f=0;
    ll s=0;
  ll u=0;
  ll q=0;
  ll w=0;
  	ll k=0;
  ll o=0;
    FOR(i,0,14){
      k=0;
	FOR(j,1,6){
      k+=n/pow(p[i],j);
    }
      if(k>3+o){
            f++;
        }
      if(k>1+o){
            s++;
        }
      if(k>13+o){
        u++;
      }
      if(k>23+o){
      	q++;
      }
      if(k>73+o){
      	w++;
      }
    }
    sal(((s-2)*f*(f-1))/2+u*(f-1)+q*(s-1)+w);
  
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, L;
    cin >> N >> L;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    int maxlen = -1;
    int maxidx = -1;

    for (int i = 0; i < N - 1; i++) {
        if (A[i] + A[i+1] > maxlen) {
            maxidx = i;
            maxlen = A[i] + A[i+1];
        }
    }

    if (maxlen >= L) {
        cout << "Possible" << endl;
        for (int i = 0; i < maxidx; i++) cout << i + 1 << endl;
        for (int i = N - 2; i > maxidx; i--) cout << i + 1 << endl;
        cout << maxidx + 1 << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}

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

int main() {
   int N;
   cin >> N;
   int f[N];
   for (int i=0; i<N; i++) {
       f[i]=0;
   }
   for (int i=1; i<100; i++) {
       for (int j=1; j<100; j++) {
           for (int k=1; k<100; k++) {
               if (i*i+j*j+k*k+i*j+j*k+k*i<=N) {
                   f[i*i+j*j+k*k+i*j+j*k+k*i-1]++;
               }
           }
       }
   }
   for (int i=0; i<N; i++) {
       cout << f[i] << endl;
   }
}

Measured memory_bytes: 3584
import sys

input = lambda :sys.stdin.readline().rstrip()

def main():
    n, m, Q = map(int, input().split())
    Train= [[0 for _ in range(n)] for _ in range(n)]
    
    for i in range(m):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        Train[l][r] += 1
    
    P_Train = [[0 for _ in range(n + 1)] for _ in range(n)]
    for i in range(n):
        tmp = 0
        for j in range (n):
            tmp += Train[i][j]
            P_Train[i][j + 1] = tmp

    for i in range(Q):
        p, q = map(int, input().split())
        p, q = p - 1, q - 1
        ans = solve(P_Train, n, p, q)
        print(ans)

def solve(P_Train, n, p, q):
    ans = 0
    for i in range(p, q + 1):
        ans += P_Train[i][q + 1] - P_Train[i][p]
    return ans


if __name__ == '__main__':
    main()

Measured memory_bytes: 59316