akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template<class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define Cin(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define VecIn(T,name,n) vector<T> name(n); for(auto &i:name)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
template<> void out(double a) { printf("%.20f\n", a); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	Cin(int, a, b);
	Yay(a <= 8 && b <= 8);
}

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

int main(){
    string s;
    int count=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='+'){
            count++;
        }
        else{
            count--;
        }
    }
    cout << count << endl;
}

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

public class Main {

	private static Scanner sc;
	
	public static void main(String[] args)throws IOException {
		
		sc = new Scanner(System.in);
		String aa = sc.next();
		int a = Integer.parseInt(aa);
		String bb = sc.next();
		int b = Integer.parseInt(bb);
		String cc = sc.next();
		int c = Integer.parseInt(cc);
		if((a==b && a==c)){
			System.out.println("1");
		}
		else if(a==b || b==c ||a==c){
			System.out.println("2");
		}
		else{
			System.out.println("3");
		}
		
	}
}


Measured memory_bytes: 9680
#include<bits/stdc++.h>
using namespace std;
/// Macros ---------------------
#define ll long long
#define sz(a) (int)a.size()
#define int long long
#define pb push_back
#define vi vector<int>
#define f first
#define s second
#define ii pair<int,int>
#define lb lower_bound
#define up upper_bound
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Constracts -----------------------------------------------
const int maxn=1e5;
const int INF=(1ll)<<(30ll);
const int inf=1000000000000000000;
const int eps=1e-9;
const int mod=1e9+7;
/// Quick Pow ------------------------------------------------
int qpow(int b,int e)
{
    if( !e ) return 1;
    if( e & 1 ) return qpow(b, e - 1) * b;
    int pwur = qpow(b, e >> 1);
    return pwur * pwur;
}

int lcm(int a,int b){
    return a*b/__gcd(a,b);
}

/// My Code ---------------------------------------------------

bool mk[1001];
bool can(int n){
    for(;n>0;n/=10){
        if(mk[n%10])return 0;
    }
    return 1;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    vi v;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')v.pb(0);
        if(s[i]=='1')v.pb(1);
        if(s[i]=='B'){
            if(v.size()>0)v.pop_back();
        }
    }
    for(auto it:v)cout<<it;

    return 0;
}


Measured memory_bytes: 3608
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:Vec<u32> = (0..5).map(|_| read()).collect();

    let k:u32 = read();

    println!("{}", if a[4]-a[0] <= k {"Yay!"} else {":("});
    
}


Measured memory_bytes: 4352
N, K, Q = map(int, input().split())

cnt = [0] * N
for _ in range(Q):
    Ai = int(input()) - 1
    cnt[Ai] += 1

for i in range(N):
    if K + cnt[i] - Q > 0:
        print('Yes')
    else:
        print('No')


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

const int N = 200005;

int n;
int c[N];
vector<int> edges[N];

long long ans[N];

int sz[N];
map<int, int> colors[N];
void dfs(int u, int p) {
  sz[u] = 1;
  int heavy = u;
  for (int v: edges[u]) {
    if (v == p) continue;
    dfs(v, u);

    sz[u] += sz[v];
    if (heavy == u || colors[heavy].size() < colors[v].size()) {
      heavy = v;
    }

    int comp = sz[v] - colors[v][c[u]];
    ans[c[u]] -= 1LL * comp * (comp + 1) / 2;
    colors[v].erase(c[u]);
  }

  swap(colors[u], colors[heavy]);

  for (int v: edges[u]) {
    if (v == p) continue;

    for (pair<int, int> p: colors[v]) {
      colors[u][p.first] += p.second;
    }
  }

  colors[u][c[u]] += sz[u];
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    --c[i];
    ans[i] = 1LL * n * (n+1) / 2;
  }
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;

    edges[u].push_back(v);
    edges[v].push_back(u);
  }

  dfs(0, 0);

  for (int i = 0; i < n; ++i) {
    int sz = n - colors[0][i];
    ans[i] -= 1LL * sz * (sz + 1) / 2;
  }

  for (int i = 0; i < n; ++i) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 71012
#include<cstdio>

int num[110];

int main()
{
    num[1]=0;num[2]=1;num[3]=0;
    for(int i=4;i<=100;i++)
    {
        if(i%2==1)num[i]=0;
        else num[i]=num[i/2]+1;
    }

    int n;
    while(scanf("%d",&n)==1)
    {
        int maxx=-1;
        int p=-1;
        for(int i=1;i<=n;i++)if(maxx<num[i]){maxx=num[i];p=i;}
        printf("%d\n",p);
    }
    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 100010;
vi g[maxn];
int col[maxn];

int build(int v, const vi& flg, const vector<vi>& vec) {
	int u = -1;
	if (flg[v]) u = v;

	for (int to : vec[v]) {
		int a = build(to, flg, vec);
		if (a != -1 && u != -1) {
			g[a].pb(u);
			g[u].pb(a);
			u = -1;
		} else if (a != -1) {
			u = a;
		}
	}
	return u;
}

void dfs(int v, int c) {
	col[v] = c;
	for (int to : g[v]) {
		if (col[to] == 0) {
			dfs(to, -c);
		}
	}
}

int main() {
	int N; cin >> N;
	vi A(N), B(N);

	vector<vi> ga(N), gb(N);
	vi flga(N, 1), flgb(N, 1);

	int ra = -1, rb = -1;

	rep(i, N) {
		cin >> A[i];
		if (A[i] != -1) {
			--A[i];
			flga[A[i]] ^= 1;
			ga[A[i]].pb(i);
		} else {
			ra = i;
		}
	}

	rep(i, N) {
		cin >> B[i];
		if (B[i] != -1) {
			--B[i];
			flgb[B[i]] ^= 1;
			gb[B[i]].pb(i);
		} else {
			rb = i;
		}
	}

	rep(i, N) if (flga[i] != flgb[i]) {
		puts("IMPOSSIBLE");
		return 0;
	}

	build(ra, flga, ga);
	build(rb, flgb, gb);

	rep(i, N) {
		if (col[i] == 0 && flga[i]) {
			dfs(i, 1);
		}
	}

	puts("POSSIBLE");
	rep(i, N) printf("%d%c", col[i], i == N-1 ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 16896
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x,y = IL()
    if 4*x<y or y%2!=0:
        print('No')
        exit()
    for i in range(x+1):
        if 4*i+2*(x-i)==y:
            print('Yes')
            exit()
    print('No')
    return

if __name__=='__main__':
    main()

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

const int MAXN=1000000;
int A[MAXN+5];
int G[MAXN+5];

int gcd(int a,int b)
{
	return b == 0 ? a : gcd(b,a%b) ;
}

int main()
{
	int n,x;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		++A[x];
		ans=gcd(ans,x);
	}	
	int ok=1;
	for(int i=2;i<=MAXN;++i)
	{
		int cnt=0;
		for(int j=i;j<=MAXN;j+=i)
		{
			cnt+=A[j];
		}
		if(cnt>1) ok=0;
	}
	if(ok) printf("pairwise coprime");
	else if(ans==1) printf("setwise coprime");
	else printf("not coprime");
	return 0;
} 

Measured memory_bytes: 7728
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

signed main(void){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int a;
	cin >> a;
	cout << a*a << '\n';
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,y;
    
    while(1){
        cin >> x >> y;

        if(x==0&&y==0){
            return 0;
        }
        cout << (x < y? x:y) << " " << (x < y? y:x) << endl;   
    }
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

void selectionSort(int A[],int N){
  int j,i,v,k,minj=0,cnt=0;
  for(i=0; i< N-1 ; i++){
    minj=i;
    for(j=i ; j < N ;j++){
      if(A[j] < A[minj])minj=j;
    }
	v=A[i];
	A[i]=A[minj];
	A[minj]=v;
	if(i != minj)cnt++;
	
  }
   for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k<N-1)printf(" ");
      else printf("\n");
    }
   printf("%d\n",cnt);
}

int main(){
  int N, i;
  int A[100];
  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  selectionSort(A,N);
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

bool func(pii a,pii b){
    return a.first>b.first;
}

int main(){
    int N; cin>>N;
    int l = 0;
    int r = N-1;
    string s,t,u;
    cout << l << endl;
    cin >> s;
    if(s=="Vacant"){ return 0;}
    cout << r << endl;
    cin >> t;
    if(t=="Vacant"){ return 0;}
    REP(i,30){
        int m = (l+r)/2;
        cout << m << endl;
        cin >> u;
        if(u=="Vacant"){break;}
        if( u==s && (m-l)%2==1){
            t = u;
            r = m;
        }else if( u!=s && (m-l)%2==0){
            t = u;
            r = m;
        }else{
            s = u;
            l = m;
        }        
    }
    
}

Measured memory_bytes: 852
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	Int ans = INF;
	Int temp;
	for (Int i = 0; i < N; i++) {
		temp = abs(a[0] - a[i]) + abs(a[N - 1] - a[i]);;
		ans = min(ans, temp);
	}
	cout << ans << "\n";
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int f(int n) {
    return n % 2 == 0 ? n / 2 : 3 * n + 1;
}

int main() {
    int S; cin >> S;
    set<int> memo;
    int last = S;
    repeat(m, 2, 1e6 + 1) {
        memo.insert(last);
        if(memo.count(f(last))) {
            cout << m << endl;
            break;
        }
        last = f(last);
    }

    return 0;
}


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

int main(){
    int n,k;
    cin >> n >>k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    int cnt=k;
    int ans=1;
    while(cnt<n){
        cnt+=k-1;
        ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
long long int GCD(long long a ,long long b){
  if (b==0) return a;
  else return GCD (b,a%b);
}

int main(){
  long long int X;
  cin >> X;
  long long int S=100,n=0;
  while(S<X){
    n++;
    S *= 1.01;
  }
  cout << n <<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  ll D, G;
  cin >> D >> G;
  ll p[D], c[D];
  rep(i, 0, D) cin >> p[i] >> c[i];

  ll rsl = 1e18;
  for(int bit = 0; bit < (1 << D); ++bit) {
      ll cur_point = 0;
      ll cnt = 0;
      for(int mask = 0; mask < D; ++mask) {
          if(bit & (1 << mask)) {
              cur_point += 100 * (mask + 1) * p[mask] + c[mask];
              cnt += p[mask];
          }
      }
      if(cur_point >= G) {
          rsl = min(rsl, cnt);
          continue;
      }

      for(int i = D - 1; i >= 0; --i) {
          if(bit & (1 << i)) continue;
          for(int j = 0; j < p[i]; ++j) {
              if(cur_point >= G) break;
              cnt++;
              cur_point += 100 * (i + 1);
          }
      }
      rsl = min(rsl, cnt);
  }
  cout << rsl << endl;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


int n;
vector<int> g[100005];

int pari[100005];
vector<int> g2[100005];
int rec(int v){
  int cur=-1;
  if(pari[v]==0) cur=v;
  for(auto to:g[v]){
    int nxt=rec(to);
    if(~cur){
      g2[cur].pb(nxt);
      g2[nxt].pb(cur);
      cur=-1;
    }else{
      cur=nxt;
    }
  }
  return cur;
}

void ng(){
  puts("IMPOSSIBLE");
  exit(0);
}

int col[100005];

void dfs(int v){
  for(auto to:g2[v]){
    if(col[to]==-1){
      col[to]=1-col[v];
      dfs(to);
    }
  }
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n;
  REP(t,2){
    REP(i,n) g[i].clear();
    int R=-1;
    REP(i,n){
      int p;scanf("%d",&p);--p;
      if(p!=-2){
        g[p].pb(i);
      }else R=i;
    }
    REP(i,n){
      if(t==0) pari[i]=g[i].size()&1;
      else if(pari[i]!=(g[i].size()&1)) ng();
    }
    rec(R);
  }
  memset(col,-1,sizeof(col));
  REP(i,n) if(col[i]==-1){
      col[i]=0;
      dfs(i);
    }

  puts("POSSIBLE");
  REP(i,n){
    int res;
    if(pari[i]==1) res=0;
    else if(col[i]==0) res=1;
    else res=-1;
    cout<<res<<endl;
  }




  return 0;
}






Measured memory_bytes: 13696
import java.util.*;

class Main {
	//?????¢??¢?´¢?????¬???
	public static boolean search(int[] A, int n, int key) {
		A[n] = key;
		int i = 0;
		while(A[i] != key)i++;
		return i != n;
	}
	
	public static boolean binarySearch(int[] A, int n, int key) {
		int left = 0;
		int right = n ;
		int mid = 0;
		while(left < right) {
			 mid = (left + right) / 2;
			if ( key == A[mid] ) return true;
			else if ( key > A[mid] ) left = mid + 1;
			else if ( key < A[mid] ) right = mid;
		}
	return false;
	}

	public static void main(String args[]) {

		Scanner scan = new Scanner(System.in);
		int[] arrayS = new int[100000]; //??°???S
		int[] arrayT = new int[50000];   //??°???T
		int count = 0;						 //?????°????¨???????????????°

		//????´??????°???????????????ArrayS?????°???S???????????????
		int sNum = scan.nextInt();
		for (int i = 0; i < sNum; i++)
			arrayS[i] = scan.nextInt();

		//????´??????°???????????????ArrayT?????°???T???????????????
		int tNum = scan.nextInt();
		for (int j = 0; j < tNum; j++)
			arrayT[j] = scan.nextInt();

		//??°???T???????´??????°???A????????????????????????????????????
		for (int j = 0; j < tNum; j++)
			if(binarySearch(arrayS, sNum, arrayT[j])) count++;

		System.out.println(count);
	}
}

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

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<t>

using namespace std;
using ll = long long;
using vecint = vec(int);
using vecll = vec(ll);
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const ll MOD=1e9+7;

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

    // cin....

    int a, b, h;
    cin >> a >> b >> h;

    cout << (b+a)*h/2 << endl;




    // ans

}

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


int main(void){
	int N;

	cin >> N;
  
  vector<int> W(N);
  int sum = 0;
  
  for (auto& i : W) {
    cin >> i;
    sum += i;
  }
  
  int r = 100000, f = 0;
  
  for (auto i : W) {
    f += i;
    sum -= i;
    if (sum != 0);
    	r = min(r, abs(f - sum));
  }

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,hantei = 0;
    cin >> a >> b;
    char s[a+b+1];
    cin >> s;
    for(long long i=0;i<a;i++){
        if(s[i] == '-'){
            hantei = 1;
            break;
        }
    }
    if(s[a] != '-') hantei = 1;
    for(int i=a+1;i<a+b;i++){
        if(s[i] == '-'){
            hantei = 1;
            break;
        }
    }
    if(hantei == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N,M,X;
    cin>>N>>M>>X;
    v A(M);
    ll a=0,b=0;
    rep(i,0,M){
        cin>>A[i];
        if(A[i]<X)a++;
        else b++;
    }
    cout<<min(a,b);
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_b
// +build ignore

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, count int
	var a, b, c string
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	as := strings.Split(a, "")
	bs := strings.Split(b, "")
	cs := strings.Split(c, "")
	for i := 0; i < n; i++ {
		if as[i] == bs[i] && as[i] == cs[i] {
		} else if as[i] == bs[i] {
			count++
		} else if as[i] == cs[i] {
			count++

		} else if bs[i] == cs[i] {
			count++
		} else {
			count += 2
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
int color[100001],d[100001],f[100001],tt;
bool matched[100001]={};
void dfs_visit(int u){
	color[u]=1;
	d[u]=tt;
	tt++;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(color[v]==0){
			dfs_visit(v);
			if(matched[u]==false&&matched[v]==false){
				matched[u]=matched[v]=true;
			}
		}
	}
	color[u]=2;
}
int main(){
	int N;
	int A[100001],B[100001];
	int edgecount[100001]={};
	int flag=1;
	scan(N);
	rep(i,N-1){
		scan(A[i]);scan(B[i]);
		A[i]--;B[i]--;
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
		edgecount[A[i]]++;
		edgecount[B[i]]++;
	}
	rep(i,N){
		color[i]=0;
	}
	tt=0;
	rep(i,N){
		if(edgecount[i]==1){
			dfs_visit(i);
			break;
		}
	}
	rep(i,N){
		//printf("%d d:%d matched:%d\n",i+1,d[i],matched[i]);
		if(matched[i]==false) flag=0;
	}
	if(flag) prin("Second");
	else prin("First");
	return 0;
}


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

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 330;

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

  vector<int> fac(N), finv(N);
  fac[0] = finv[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = mul(fac[i - 1], i);
    finv[i] = inv(fac[i]);
  }

  auto comb = [&](int n, int m) {
    assert(n >= m);
    int res = fac[n];
    res = mul(res, finv[m]);
    res = mul(res, finv[n - m]);
    return res;
  };

  int n, m;
  cin >> n >> m;
  vector< vector<int> > a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  auto lowbit = [](vector<int> a) {
    for (int i = 0; i < (int) a.size(); i++) {
      if (a[i] == 1) {
        return i;
      }
    }
    return -1;
  };

  auto Xor = [&](int i, int j) {
    for (int k = 0; k < m; k++) {
      a[i][k] ^= a[j][k];
    }
  };

  vector<int> base;
  for (int i = 0; i < n; i++) {
    for (auto j : base) {
      if (a[i][ lowbit(a[j]) ] == 1) {
        Xor(i, j);
      }
    }
    if (lowbit(a[i]) != -1) {
      base.push_back(i);
    }
  }

  int r = base.size();
  // cerr << r << '\n';
  int res = 0;
  for (int i = 1; i <= r; i += 2) {
    add(res, mul(comb(r, i), power(3, r - i)));
  }
  res = mul(res, power(2, (n - r) + (m - r)));
  cout << res << '\n';
  return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(a, b, c);

    std::cout << max(0LL, c - (a - b)) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n;cin>>a>>b;
  if(b<10)n=a*10+b;
  else if(b==100)n=a*1000+b;
  else n=a*100+b;
  int x=sqrt(n);
  double y=sqrt(n);
  if(x==y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n; double bx, by; pair<double, double> p[100009];
int main() {
	scanf("%d", &n);
	double sq = sin(1.234), cq = cos(1.234);
	for(int i = 0; i < n; i++) {
		scanf("%lf%lf", &bx, &by);
		double ex = bx * cq - by * sq;
		double ey = bx * sq + by * cq;
		p[i] = make_pair(ex, ey);
	}
	sort(p, p + n);
	double ret = 1.0e+10;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			double dx = p[i].first - p[j].first;
			if(dx * dx > ret) break;
			double dy = p[i].second - p[j].second;
			double dist = dx * dx + dy * dy;
			if(ret > dist) ret = dist;
		}
	}
	printf("%.15lf\n", sqrt(ret));
	return 0;
}

Measured memory_bytes: 4776
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    p = list(map(int, input().split()))
    xy = [list(map(int, input().split())) for _ in range(m)]

    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    
    def unite(x,y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True
    
    def same(x,y):
        return find(x) == find(y)
    
    par = [-1]*n

    for x, y in xy:
        if same(x-1, y-1) == False:
            unite(x-1, y-1)
    res = 0
    for i in range(n):
        if i == p[i]-1:
            res += 1
        else:
            if same(i, p[i]-1):
                res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 113040
#include <iostream>

using namespace std;

int main(){
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if(a < 0){
		cout << -a * c + d + b * e;
	}
	else if(a == 0){
		cout << d + (b - a) * e;
	}
	else{
		cout << (b - a) * e;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct edge{ll from,to,cost;};

int main(void){

  ll n,m;
  cin>>n>>m;

  struct edge es[2001];
  vector<ll> d(1001,INF);
  rep(i,m){
    struct edge e;
    cin>>e.from;
    cin>>e.to;
    cin>>e.cost;
    //e.from--;
    //e.to--;
    e.cost=-e.cost;
    es[i]=e;
  }

  d[1]=0;
  //d[0]=0;


  rep(cnt,n-1){
    rep(i,m){
      struct edge e=es[i];
      if(d[e.from] == INF) continue;
      if(d[e.to] > d[e.from]+e.cost){
        d[e.to] = d[e.from]+e.cost;
      }
    }
  }
  ll ans=d[n];
  //rep(i,n+1) d[i]=0;
  vector<bool> neg(1001,false);

  rep(i,n){
    rep(j,m){
      struct edge e=es[j];
      if(d[e.from] == INF) continue;
      if(d[e.to] > d[e.from]+e.cost){
        d[e.to] = d[e.from]+e.cost;
        neg[e.to]=true;
      }
      if(neg[e.from] == true) neg[e.to]=true;
    }
  }

  if(neg[n] == true) cout << "inf" << endl;
  else cout << -ans << endl;

  return 0;
}


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

using namespace std;

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

  int sum_vote = 0;
  vector<int> num_vote(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> num_vote[i];
    sum_vote += num_vote[i];
  }

  int result = 0;
  for (int i = 0; i < N; ++i)
  {
    if (num_vote[i] * 4 * M >= sum_vote) ++result;
  }

  if (result >= M) cout << "Yes" << endl;
  else             cout << "No"  << endl;
}

Measured memory_bytes: 256
class UnionFind():
  def __init__(self,n):
    self.n = n #今後も使う値、基本的には全て、self.n に代入する
    self.parents = [-1]*n # -1 で初期化
  def unite(self,x,y):
    x = self.find(x)
    y = self.find(y)
    if x == y: return
    if self.parents[x] > self.parents[y]:
      x,y = y,x
    
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def find(self,x):#rootを見つける
    if self.parents[x] < 0:
      return x
    else:
      #縮約
      self.parents[x] = self.find(self.parents[x])#再帰！親のさらにnodeを辿った値に更新する。
      return self.parents[x]
      #縮約なしver
      # return self.find(self.parents[x])
  def same(self,a,b):
    return self.find(a) == self.find(b)
if __name__ == "__main__":
  n,q = map(int,input().split())
  uf = UnionFind(n)
  for i in range(q):
    com,x,y = map(str,input().split())
    x = int(x)
    y = int(y)
    if com == "0": 
      uf.unite(x,y)
      #print(uf.parents,i)
    if com == "1": 
      if uf.same(x,y): print(1)
      else: print(0)
  #print(uf.parents)



Measured memory_bytes: 5780
n  = int(input())
ai = list(map(int, input().split()))

step = 1

for i in range(len(ai)):
    if ai[i] != step:
        ai[i] = 0
    else:
        step += 1

if sum(ai) == 0:
    print(-1)
else:
    print(ai.count(0))

Measured memory_bytes: 32256
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<20, mod = 1e9 + 7, i2 = (mod+1)/2;
ll dp[maxn], p[maxn], fp[maxn];
void add(ll &a, ll b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	dp[0] = 1;
	dp[1] = n-1;
	for(int i = 2; i <= n; i++) dp[i] = n*1ll*(n-1)%mod;
	fp[0] = 0;
	p[0] = 0;
	for(int i = 1; i <= n; i++) {
		p[i] = p[i-1];
		fp[i] = fp[i-1];
		if(i > 2)
			add(dp[i], mod - (mod + fp[i-3] - p[i-3]*i%mod + p[i-3] + p[i-3])%mod);
		add(fp[i], dp[i]*i%mod);
		add(p[i], dp[i]);
	}
	cout << (p[n]+1)%mod;
	return 0;
}


Measured memory_bytes: 24832
#include<stdio.h>
int main(void){
	int a,b,c;
	int i,rem;
	scanf("%d %d %d",&a,&b,&c);
		for(i=0;i<100;i++){
		rem=(c+60*i)%(a+b);
		if(rem<=a){
			printf("%d\n",c+60*i);
			break;
		}

		if(rem>a){
			continue;
			}
		}
		if(i==100){
			printf("-1\n");
		}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	if(a>b) rep(a) cout << b;
	else rep(b) cout << a;
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll inf = 1<<29;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//


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

    cout << n * n * n << endl;
}

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

const int DIM = 5e3 + 5;

int arr[DIM], dp1[DIM][DIM], dp2[DIM][DIM];

int main( void ) {
    
    int n, k;
    cin >> n >> k;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    dp1[0][0] = 1;
    for( int i = 1; i <= n; i ++ ) {
        for( int j = 0; j <= k; j ++ ) {
            dp1[i][j] = dp1[i - 1][j];
            
            if( j >= arr[i] )
                dp1[i][j] |= dp1[i - 1][j - arr[i]];
        }
    }
    
    dp2[n + 1][0] = 1;
    for( int i = n; i >= 1; i -- ) {
        for( int j = 0; j <= k; j ++ ) {
            dp2[i][j] = dp2[i + 1][j];
            
            if( j >= arr[i] )
                dp2[i][j] |= dp2[i + 1][j - arr[i]];
        }
    }
    
    int ans = n;
    for( int i = 1; i <= n; i ++ ) {
        for( int j = 1; j <= k; j ++ )
            dp2[i + 1][j] += dp2[i + 1][j - 1];
        
        for( int j = 0; j < k; j ++ ) {
            if( dp1[i - 1][j] == 0 )
                continue;
            
            int cnt = dp2[i + 1][k - j - 1];
            if( k - j - arr[i] >= 1 )
                cnt -= dp2[i + 1][k - j - arr[i] - 1];
            
            if( cnt != 0 ) {
                ans --;
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 195840
#include<bits/stdc++.h>
using namespace std;
long long const MAX= 1e9 + 7;
int main()
{long long t,i,n,k,j;
cin>>n;
long long a[n+1];
long long dp[n+1];
for(i=1;i<=n;i++)
{dp[i]=MAX;}
for(i=1;i<n+1;i++)
{cin>>a[i];}
dp[1]=0;
a[0]=0;
for(j=1;j<=n;j++)
{if(j+1<=n)
 dp[j+1]=min(dp[j+1],dp[j]+abs(a[j+1]-a[j]));
 if(j+2<=n)
 {dp[j+2]=min(dp[j+2],dp[j]+abs(a[j+2]-a[j]));}}   
cout<<dp[n];
return 0;}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
const int inf = 1e9 + 7 ; 
int n, m, c[N], w[N], tp[N], vis[N] ;
struct node {
	int a, b ;
} p[N] ;
struct Q {
	int l, r, id ; 
} q[N] ;
struct E {
	int to, next, id ; 
} e[N << 1] ;
int head[N], cnt, top, ans[N], idnum ; 
bool cmp( node x, node y ) {
	return x.a < y.a ; 
}
int check( int x ) {
	int l = 1, r = n + 1, ans = 0 ; 
	while( l <= r ) {
		int mid = ( l + r ) >> 1 ; 
		if( w[mid] >= x ) ans = mid, r = mid - 1 ; 
		else l = mid + 1 ; 
	} return ans ; 
}
int check2( int x ) {
	int l = 1, r = n, ans = 0 ; 
	while( l <= r ) {
		int mid = ( l + r ) >> 1 ; 
		if( w[mid] <= x ) ans = mid, l = mid + 1 ; 
		else r = mid - 1 ; 
	} return ans ; 
}
void add( int x, int y, int id ) {
	e[++ cnt] = (E){ y, head[x], id }, head[x] = cnt,
	e[++ cnt] = (E){ x, head[y], id }, head[y] = cnt ; 
}
int dfs( int x, int fa, int tt ) {
	int fl = 0 ; vis[x] = 1 ; 
	Next( i, x ) {
		int v = e[i].to ; if( vis[v] ) continue ; 
		fl ^= dfs( v, x, i ) ;
	}
	if( x == fa ) return fl ; 
	if( tp[x] ^ fl ) {
		ans[++ idnum] = e[tt].id ; 
		return 1 ; 
	}
	else return 0 ;
}
signed main()
{
	n = gi(), m = gi() ; 
	rep( i, 1, n ) p[i].a = gi(), p[i].b = gi() ; 
	sort( p + 1, p + n + 1, cmp ) ;
	rep( i, 1, n ) c[i] = p[i].b, w[i] = p[i].a ; 
	w[n + 1] = inf ; top = 0 ;
	rep( i, 1, m ) {
		int ll = gi(), rr = gi() ; 
		int l1 = check(ll), r1 = check2(rr) ;
		if( rr < ll ) continue ; 
		q[++ top].l = l1, q[top].r = r1, q[top].id = i ; 
	}
	rep( i, 1, n ) tp[i] = c[i] ^ c[i - 1] ; tp[0] = 0 ;
	rep( i, 1, top ) add( q[i].l, q[i].r + 1, q[i].id ) ;
	dfs( n + 1, n + 1, 0 ) ; int flag = 0 ;
	rep( i, 1, n ) {
		if( vis[i] ) continue ; 
		int u = dfs( i, i, 0 ) ;
		if( u != tp[i] ) flag = 1 ; 
	}
	if( flag ) puts("-1") ;
	else {
		printf("%d\n", idnum ) ;
		sort( ans + 1, ans + idnum + 1 ) ;
		rep( i, 1, idnum ) printf("%d ", ans[i] ) ;
	}
	return 0 ;
}


Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    ll n;
    cin >> s >> n;
    for(int i=0; i<min((ll)s.size(),n); i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    
    cout << 1 <<endl;
}


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

int main(){
    int n;
    while(cin>>n){
    int a=0;
    for(int i=0;i<10;i++)
        for(int j=0;j<10;j++)
            for(int p=0;p<10;p++)
                for(int q=0;q<10;q++)
                    if(i+j+p+q==n)
                        a++;
    cout<<a<<endl;
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit = 100010;
using edge = struct{int to;ll cost;};
vector<edge> tree[100010];
ll a[limit],b[limit],c[limit];
int subsize[limit];

int dfs(int v,int p){
	subsize[v]=1;
	for(auto &e:tree[v]){
		if(e.to==p) continue;
		subsize[v]+=dfs(e.to,v);
	}
	return subsize[v];
}

int find_centroid(int v,int p,int n){
	for(auto &e:tree[v]){
		if(e.to == p) continue;
		if(subsize[e.to] > n/2)
			return find_centroid(e.to,v,n);
	}
	return v;
}




int main(void){
	int n;
	cin >> n;
	
	rep(i,n-1){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--,b[i]--;
		tree[a[i]].push_back({b[i],c[i]});
		tree[b[i]].push_back({a[i],c[i]});
	}

	dfs(0,-1);

	ll ans = 0LL;
	rep(i,n-1){
		int sa = min(subsize[a[i]],subsize[b[i]]);
		int sb = n - sa;
		ans += 2LL * min(sa,sb) * c[i];
	}

	const int center = find_centroid(0,-1,n);

	ll target = 1LL << 60;

	for(auto &e:tree[center]){
		int sa = min(subsize[center],subsize[e.to]);
		int sb = n - sa;
		if(sa == sb){
			target = e.cost;
			break;
		}
		chmin(target,e.cost);
	}


	ans -= target;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14592
# input data
n = int(input())
b = list(map(int, input().split()))

# solve
ans = []

# necessary condition
def cond(_b):
	hist = [0]*(len(_b)+1)
	
	for i in range(0, len(_b)):
		if _b[i] > i + 1:
			return False
	
	return True

# check if _b can be constructed.
# returns True/False
def dfs(_b, _ans):
	
	if not cond(_b):
		return False
	
	for i in range(0, len(_b)):
		
		if i + 1 == _b[i]:
			_b2 = _b[:]
			_ans2 = _ans[:]
			_ans2.append(_b2[i])
			_b2.pop(i)
			
			if dfs(_b2, _ans2) == True:
				return True
	
	if len(_b) == 0:
		## print answer
		_ans.reverse()
		for i in _ans:
			print(i)
		return True
		
	else:
		return False


if not dfs(b,[]):
	print(-1)

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#define N 10000
int main()
{
  int i,j,k,C[N+1];
  unsigned short *A,*B;
  scanf("%d",&k);
  A=malloc(sizeof(short)*k+1);
  B=malloc(sizeof(short)*k+1);
  for(i=0;i<=N;i++)
    {
      C[i]=0;
    }
  for(i=0;i<k;i++)
    {
      scanf("%hu",&A[i+1]);
      C[A[i+1]]++;
    }
  for(i=1;i<=N;i++)
    {
      C[i]+=C[i-1];
    }
  for(j=1;j<=k;j++)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
  for(i=1;i<=k;i++)
    {
      if(i!=1) printf(" ");
      printf("%d",B[i]);
    }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 8464
#include <iostream>
#include <algorithm>
using namespace std;
static const int N_MAX = 200000;

int main() {
    int n,diffMax = -1e+9,nMin;
    cin >> n;
    int rt[N_MAX];

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

    nMin = rt[0];
    for (int i = 1; i < n; i++) {
        diffMax = max(diffMax, rt[i] - nMin);
        nMin = min(nMin, rt[i]);
    }

    cout << diffMax << endl;
    return 0;
}


Measured memory_bytes: 3852