akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	LLI mul = 1;
	bool overflow = false;
	bool zero = false;
	REP(i, n)
	{
		LLI a;
		cin >> a;
		if (a == 0)zero = true;
		LLI tmp = mul * a;
		if (tmp < mul || tmp < a || 1000000000000000000L < tmp)
		{
			overflow = true;
		}
		mul = tmp;
	}
	if (overflow)mul = -1;
	if (zero)mul = 0;
	cout << mul;
	return 0;
}


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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
ll dp[51][2600];
int main(){
	int n,a;
	cin>>n>>a;
	dp[0][0]=1;
	rep(i,n){
		int x;
		cin>>x;
		for(int j=2560-x;j>=0;j--)for(int k=50;k>=1;k--)dp[k][j+x]+=dp[k-1][j];	
	}
	ll ans=0;
	for(int i=1;i<2550;i++)for(int j=1;j<51;j++)if(i==a*j)ans+=dp[j][i];
	cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
pair<int,int> c[1000000];
int w[1000000];
int at[1000000];
int L[1000000];
char str[10];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int p;
		scanf("%d",&p);
		c[i]=make_pair(p,i);
	}
	std::sort(c,c+a);
	for(int i=0;i<a;i++)w[i]=c[i].first;
	w[a]=1000000000;
	for(int i=0;i<a;i++)at[c[i].second]=i;
	set<int> S;
	for(int i=0;i<b;i++){
		int v;
		scanf("%s%d",str,&v);
		if(str[0]=='A'){
			L[at[v-1]]=1;
			S.insert(at[v-1]);
		}
		if(str[0]=='R'){
			L[at[v-1]]=0;
			S.erase(at[v-1]);
		}
		if(str[0]=='C'){
			int left=-1;
			int right=1000000007;
			while(left+1<right){
				int M=(left+right)/2;
				int R=-1;
				int C=0;
				for(set<int>::iterator it=S.begin();it!=S.end();it++){
				//	printf("%d\n",*it);
					int l=lower_bound(w,w+a,w[(*it)]-M)-w;
					int r=upper_bound(w,w+a,w[(*it)])-w-1;
					if(R<l){
						C+=l-R-1;
					}
					R=r;
				}
				C+=a-1-R;
				if(C<=v){
					right=M;
				}else left=M;
			}
			if(right==1000000007)printf("NA\n");
			else printf("%d\n",right);
		}
	}
}

Measured memory_bytes: 19424
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if ((C * 2) >= A + B) {
		cout << (X * A) + (Y * B);
	}
	else if ((C *2 ) < A && (C * 2) < B) {
		cout << (C * 2 * max(X, Y));
	}else{
		int rem = abs(X - Y);
		cout << min((C * 2 * min(X, Y)) + ((X > Y) ? rem * A : rem * B) ,
			(C * 2 * max(X, Y)));
	}

	return 0;
}

Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#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;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

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

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),k=nxt();
    vc<ll> v(n);
    generate(all(v),nxt);
    while(k--)
    {
        vc<ll> v1(n,0);
        rep(a,0,n)
        {
            ll p=max(0*1LL,a-v[a]);
            v1[p]++;
            p=min(n,v[a]+a+1);
            if(p!=n)
                v1[p]--;
        }
        rep(a,1,n)
            v1[a]+=v1[a-1];
        if(v==v1)
            break;
        v=v1;
    }
    for(auto y:v)
        cout<<y<<" ";
    cout<<endl;
	printclock;
	return 0;
}

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

int main(void){
  
  int N,K;
  unsigned long long count = 0;
  cin >> N >> K;
  int data[N];
  for(int i=0;i<N;i++) cin >> data[i];
  sort(data,data+N,greater<int>());
  
  for(int i=0;i<N;i++){
      if(K > 0){
          K--;
      }
      else{
          count += data[i];
      }
  }
  cout << count << endl;
}

Measured memory_bytes: 4336
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        p:u8,
        a:[i32;n]
    }
    let mut f = false;
    for i in 0..n {
        if a[i]%2==1{
            f= true;
        }
    }
    if f==false {
        if p==0 {
            println!("{}", 2i64.pow(n as u32));
        }else{
            println!("0");
        }
    }else{
        println!("{}", 2i64.pow(n as u32 -1));
    }

}

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

#define p(x) cout << x << endl

int main()
{
    int n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
		if(i%3 != 0 && i%5 != 0)
			ans+=i;
	}
	p(ans);
}


Measured memory_bytes: 3636
// Problem H solution
// Prateek

#include<bits/stdc++.h>

#define mod (int )(1e9 +7)
using namespace std;

int h,w;

char ch[1003][1003];

int dp[1003][1003];



int solve(int x,int y)
{
    if((x == 0) && (y == 0))
    return dp[x][y] = 1;
    
    if((ch[x][y] == '#') || (x<0) || (y<0))
    return 0;
    
    if(dp[x][y] != -1)
    return dp[x][y];
    
    dp[x][y] = solve(x-1,y)%mod + solve(x,y-1)%mod;
    dp[x][y] %= mod;

    return dp[x][y];
    
}


int main()
{
    cin>>h>>w;
    
    int i,j;
    
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++){
        cin>>ch[i][j];
        dp[i][j] = -1;
        }
    }
    
    cout<<solve(h-1,w-1)<<endl;
    
    return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  cin >> a;
  rep(i, n) a[i]--;

  vector<vector<int> > dou(64, vector<int>(n));
  rep(i, n) dou[0][i] = i;
  dou[1] = a;
  rep3(i, 2, 64) {
    rep(j, n) dou[i][j] = dou[i - 1][dou[i - 1][j]];
  }

  int ans = 0;
  rep3(j, 1, 64) { // debuged, 1
    if (k % 2) {
      ans = dou[j][ans];
    }
    k /= 2;
  }
  cout << ans + 1 << endl;
  // rep(i, 5) cout << dou[i] << endl;
}


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

int main(){
  int n,i;
  int a[30],b[30],c[30];
  int sum = 0;

  scanf("%d", &n);

  for(i = 1;i <= n;i++) scanf("%d", &a[i]);
  for(i = 1;i <= n;i++) scanf("%d", &b[i]);
  for(i = 1;i <= n - 1;i++) scanf("%d", &c[i]);

  for(i = 1;i <= n;i++){
    sum += b[a[i]];
    if(a[i] + 1 == a[i + 1]) sum += c[a[i]];
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int a, b, c, count = 0;

    scanf("%d %d %d", &a, &b, &c);
    while (a <= b){
        if (c % a == 0){
            count++;
        }
        a++;
    }
    printf("%d\n", count);
    return (0);
}


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

int main() {
  int A, B, C;
  int SWAP;
  cin >> A >> B >> C;
  SWAP = B;
  B = A;
  A = SWAP;
  SWAP = C;
  C = A;
  A = SWAP;
  cout << A << " " << B << " " <<  C <<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include "sys/time.h"
using namespace std;
#define HERE (cerr << "LINE: " << __LINE__ << " " << __FUNCTION__ << endl)

#define DBG(x) cerr << #x << ": " << x << endl

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[ ";
  for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
    os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " ]"; 
  return os; 
}
template<typename T> ostream& operator<<(ostream& os, const set<T>& v) {
  os << "{ ";
  for(typename set<T>::const_iterator it=v.begin(); it!=v.end(); ++it) {
    if (it != v.begin())
      os << ", ";
    os << *it; 
  }
  os << " }"; 
  return os; 
}
template<typename T1,typename T2> ostream& operator<<(ostream& os, const pair<T1,T2>& v) {
  os << "[ " << v.first << ", " << v.second << "]";
  return os; 
}
/* insert here */
bool validate(const vector<int>& v) {
  int s = 0;
  for (int i=0; i<v.size(); i++)
    s += v[i];

  if (v.size() < 10)
    DBG(v);
  for (int i=0; i<v.size(); i++) {
    assert(__gcd(s, s-v[i]) > 1);
  }

  int g = v[0];
  for (int i=0; i<v.size(); i++)
    g = __gcd(g, v[i]);
  assert(g == 1);

  DBG("OK");
  return true;
}


vector<int> solve(int N) {
  vector<int> v;
  set<int> ss;
  int sum = 0;

  for (int i=2; i<=30000 && v.size()<N-1; i++)
    if (i%2 == 0 || i%3 == 0) {
      v.push_back(i);
      ss.insert(i);
      sum += i;
      if (v.size() < 30)
	cerr << v.size() << " " << sum%6 << endl;
    }

  for (int i=5; i<=30000; i++)
    if ((i + sum)%6 == 0 && __gcd(sum, i) > 1 && !ss.count(i)) {
      v.push_back(i);
      break;
    }
  validate(v);
  return v;
}



int main()
{
  int N;
  cin >> N;
  auto sol = solve(N);
  assert(sol.size() == N);

  for (int i=0; i<N; i++) {
    if (i != 0)
      cout << " ";
    cout << sol[i];
  }
  cout << endl;
}



Measured memory_bytes: 1408
X, Y = map(int, input().split())
a=2*X-(1/2)*Y
b=-1*X+(1/2)*Y
if a.is_integer() and b.is_integer():
    if (a>=0 and b>0) or (a>0 and b>=0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define double long double
 
using namespace std;

int A[1001];
int B[1001];
int H;
int n;
int dp[10001];

int solve(int x)
{
    if(x <= 0)
        return 0;
    if(dp[x] != -1)
        return dp[x];
    dp[x] = INF;
    for(int i = 1;i <= n;i++)
        dp[x] = min(dp[x],B[i] + solve(x - A[i]));
    return dp[x];
}

int main()
{
    IOS;
    cin >> H >> n;
    for(int i = 1; i<=n;i++)
        cin >> A[i] >> B[i];
    memset(dp,-1,sizeof(dp));
    cout << solve(H);
}   

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

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

struct LCA{
  int logn,n;
  vector<vector<int>> adj;
  vector<vector<int>> par;
  vector<int> depth;
  LCA(){}
  LCA(vector<vector<int>>const& _adj,int _n,int r=0):adj(_adj),n(_n){
    logn = 1;
    while((1<<logn)<n)logn++;
    par = vector<vector<int>>(logn,vector<int>(n,-1));
    depth = vector<int>(n);
    dfs(r,-1,0);
    build();
  }
  void dfs(int cur,int prv,int dep){
    par[0][cur] = prv;
    depth[cur] = dep;
    for(auto nxt:adj[cur]){
      if(nxt==prv)continue;
      dfs(nxt,cur,dep+1);
    }
  }
  void build(){
    for(int i=1;i<logn;++i){
      for(int v=0;v<n;++v){
        if(par[i-1][v]==-1)continue;
        par[i][v] = par[i-1][par[i-1][v]];
      }
    }
  }
  int get_lca(int u,int v){
    if(depth[u]>depth[v])swap(u,v);
    int d = depth[v]-depth[u];
    for(int i=0;i<logn;++i)if(d>>i&1)v=par[i][v];
    if(u==v)return u;
    for(int i=logn;i-->0;){
      if(par[i][u]!=par[i][v]){
        u = par[i][u];
        v = par[i][v];
      }
    }
    return par[0][u];
  }
};

signed main(){

  int n;
  cin>>n;
  vector<vector<int>> adj(n);
  rep(i,n){
    int k;cin>>k;
    rep(_,k){
      int c;cin>>c;
      adj[i].emplace_back(c);
    }
  }
  LCA tree(adj,n);

  int q;
  cin>>q;
  while(q--){
    int u,v;cin>>u>>v;
    int lca = tree.get_lca(u,v);
    cout<<(lca)<<endl;
  }

}


Measured memory_bytes: 23620
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();
    let mut alphabet = [0; 26];

    for c in s.bytes() {
        alphabet[(c - b'a') as usize] += 1;
    }

    for (i, c) in alphabet.iter().enumerate() {
        if *c == 0 {
            println!("{}", (i as u8 + b'a') as char);
            return;
        }
    }
    println!("None");
}

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


Measured memory_bytes: 4352
def f(x):
    return x * (x - 1) // 2


n = int(input())
a = list(map(int, input().split()))
counter = [0] * n

for ai in a:
    ai -= 1
    counter[ai] += 1

m = 0
for c in counter:
    m += f(c)

for i, ai in enumerate(a):
    ai -= 1
    c = counter[ai]
    if c == 0:
        print(m)
    else:
        print(m - f(c) + f(c - 1))

Measured memory_bytes: 32200
x=int(input())
expo=[1]
p=2

for i in range(2,32):
    while i**p<=1000:
        expo.append(i**p)
        p+=1
    p=2

expo=set(expo)
expo=sorted(expo)

for j in range(len(expo)):
    if expo[j]<=x:
        ans=expo[j]

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  int count = 0;
  cin >> S;
  for(int i = 0; i < 4; i++){
    if(S[i] == '+') {
      count = count + 1;
    } else {
      count = count - 1;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N = SINGLE_INT()

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

if is_integer_num(N/2):
    print(N)
else:
    print(N*2)
    

Measured memory_bytes: 3060
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let a = get!();
    let b = get!();
    
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }
}

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


int main(void){
    
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];
    
    vector<vector<int>> dp(n, vector<int>(3));
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    
    for(int i = 1; i < n; i++){
        rep(j,3){
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[i][j];
        }
    }
    
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
    
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=2e5+5;
//#define local
#ifdef local
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif



void solve() {

    int n;
    cin >> n;
    set< string > st;
    for(int i=0 ;i<n ;i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout <<st.size() << endl;
}


signed main()
{
    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 19248
N = int(input())
L = list(map(int, input().split()))

if N<=2:
	print(0)
else:
	L.sort()
	cnt=0
	for i in range(len(L)-2):
		for j in range(i+1,len(L)-1):
			for k in range(j+1,len(L)):
				if L[i]!=L[j] and L[j]!=L[k] and L[i]+L[j]>L[k]:
					cnt+=1
	print(cnt)


Measured memory_bytes: 73160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

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

int main(){
	string s;
	cin>>s;
	int ans=700;
	REP(i,3){
		if(s[i]=='o')ans+=100;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
S = input().split()
S.append(None)

q = int(input())
T = input().split()

cnt = 0

for i in range(q):
    sentry = T[i]
    S[n] = sentry
    j = 0
    while S[j] != sentry:
        j += 1
    if j != n:
        cnt += 1

print(cnt)

Measured memory_bytes: 8328
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
#define L size


void solve()
{
    int n;
    cin >> n;
    if(n >= 30)
        cout << "Yes\n";
    else cout << "No";

}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
/*  int t;
    read(t);
    while(t--)*/
        solve();
    
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; ++i)
 
int debug = 1;
 
const int N = 1 << 18;
int t[N << 1][2], p[N], n, k, ord[N];
 
array <int, 2> get(int l, int r) {
    l += N - 1, r += N - 1;
    array <int, 2> res = {{N, -N}};
    while (l < r) {
        if (l % 2 == 0) {
            res[0] = min(res[0], t[l][0]);
            res[1] = max(res[1], t[l][1]);
        }
        if (r % 2 == 1) {
            res[0] = min(res[0], t[r][0]);
            res[1] = max(res[1], t[r][1]);
        }
        l = l / 2;
        r = (r - 2) / 2;
    }
    if (l == r) {
        res[0] = min(res[0], t[l][0]);
        res[1] = max(res[1], t[l][1]);
    }
    return res;
}
 
main() {
    cin >> n >> k;
    rep(i, 1, n + 1) {
        scanf("%d", &p[i]);
        t[i + N - 1][0] = t[i + N - 1][1] = p[i];
    }
    rep(i, 2, n + 1) {
        ord[i] = ord[i - 1];
        if (p[i] > p[i - 1]) ord[i]++;
    }
    for (int i = N - 2; i >= 0; --i) {
        t[i][0] = min(t[2 * i + 1][0], t[2 * i + 2][0]);
        t[i][1] = max(t[2 * i + 1][1], t[2 * i + 2][1]);
    }
    int ans = n - k + 1, f = 0;
    rep(i, k, n + 1) {
        if (ord[i] - ord[i - k + 1] == k - 1) {
            if (!f) f = 1;
            else ans--;
        } else if (i > k) {
            int mx = get(i - k + 1, i)[1];
            int mn = get(i - k, i - 1)[0];
            if (mn == p[i - k] && mx == p[i]) {
                ans--;
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 5888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
#include<list>
using namespace std;

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

	cout << ((N == M) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String s = in.readLine();
		String t = in.readLine();
		String S = s + s;

		Map<Character, List<Integer>> sMap = new HashMap<>();
		for (int i = 0; i < S.length(); ++i) {
			char c = S.charAt(i);
			if (!sMap.containsKey(c)) {
				sMap.put(c, new ArrayList<>());
			}
			sMap.get(c).add(i);
		}

		// まず可能かどうかを判別
		for (int i = 0; i < t.length(); ++i) {
			if (!sMap.containsKey(t.charAt(i))) {
				System.out.println("-1");
				return;
			}
		}

		long loop = 0L;
		int mod = 0;
		for (int i = 0; i < t.length(); ++i) {
			char c = t.charAt(i);
			List<Integer> list = sMap.get(c);
			int index = Collections.binarySearch(list, mod);
			// System.out.println(c + ", " + index + ", " + mod);
			if (index >= 0) {
				// list[index] - modの分だけ文字列長くなる
				mod += list.get(index) - mod;
			} else {
				// 挿入する部分のindexを求める
				index = (index + 1) * -1;
				// list[index]-modの分だけ文字列長くなる
				mod += list.get(index) - mod;
			}
			++mod;
			if (mod >= s.length()) {
				loop += mod / s.length();
				mod %= s.length();
			}
		}
		long length = (long) (s.length()) * loop + (long) mod;
		System.out.println((length));

	}
}


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

#define int long long

struct RSAQ{
  struct BIT{
    int size;
    vector<int> dat;
    BIT(){
      size=(1<<17);
      dat.clear();
      dat.resize((1<<17)+1);
    }
    void Add(int i,int x){
      while(0<i&&i<=size){
        dat[i]+=x;
        i+=(i&-i);
      }
    }
    int Sum(int i){
      int res=0;
      while(0<i){
        res+=dat[i];
        i-=(i&-i);
      }
      return res;
    }
  };
  BIT A,B;
  void add(int l,int r,int v){
    A.Add(l,v);
    A.Add(r-1,-v);
    B.Add(l,-v*(l-1));
    B.Add(r-1,v*(l-1)+v*(r-l));
  }
  int find(int l,int r){ l--; r--;
    return A.Sum(r)*r+B.Sum(r)-A.Sum(l)*l-B.Sum(l);
  }
};

main(){
  RSAQ A;
  int n,q;
  scanf("%lld %lld",&n,&q);
  for(int i=1;i<=q;i++){
    int type;
    int s,t,value;
    scanf("%lld",&type);
    if(type==0){
      scanf("%lld %lld %lld",&s,&t,&value);
      A.add(s,t+1,value);
    }
    if(type==1){
      scanf("%lld %lld",&s,&t);
      cout<<A.find(s,t+1)<<endl;
    }
  }
}


Measured memory_bytes: 4768
#include<stdio.h>

int main(void)
{
	int train[100];
	int i,j=0,n = 0;

	while (scanf("%d", &train[n]) != EOF && n <= 100) {
		if (train[n] >= 0 && train[n] <= 10) {
			n++;
		}
	}


	for (i = 0; i < n; i++) {
		j = 0;
		if (train[i] == 0) {
			while (j <= i) {
				if (train[i - j] != -1 && train[i - j] != 0) {
					printf("%d\n", train[i - j]);
					train[i] = -1;
					train[i - j] = -1;
					break;
				}
				else {
					j++;
	     	        	}
			}
		}
	}

	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, k;
    cin >> n >> k;
    int m = (n - 2) * (n - 1) / 2;
    if (k > m) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> v;
    rep(i, n - 1) { v.push_back(make_pair(0, i + 1)); }

    int a0 = 1, a1 = 2;
    m -= k;
    while (m > 0) {
        v.push_back(make_pair(a0, a1));
        if (a1 == n - 1) {
            a0++;
            a1 = a0 + 1;
        } else {
            a1++;
        }

        m--;
    }

    cout << v.size() << endl;
    rep(i, v.size()) {
        cout << v[i].first + 1 << " " << v[i].second + 1 << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 384
#include<iostream>

int main()
{
	int x, y;
	while (1) {
		std::cin >> x >> y;
		if (x == 0 && y == 0)break;

		if (x > y) {
			int t = x;
			x = y;
			y = t;
		}

		std::cout << x  << " " << y << std::endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
void treeDelete(Node);
Node treeSearch(Node, int);

#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
    while (u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void treeDelete(Node z){
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

     while (x != NIL){
         y = x;
         if (z->key < x->key)
             x = x->left;
         else 
             x = x->right;
     }
     z->parent = y;
    if (y == NIL)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else 
        y->right = z;

}

void inorder(Node u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}

void preorder(Node u){
    if(u == NIL) return;
    printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      }
      if(com[0] == 'i'){
          scanf("%d", &x);
      insert(x);
      }
      else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
 else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
}
  return 0;
}



Measured memory_bytes: 25172
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  long[int]cnt;
  foreach (e; a) {
    cnt[e]++;
  }
  long[int] res;
  long base;
  foreach (k; cnt.keys) {
    if (cnt[k] == 1) {
      res[k] = 0;
    } else {
      res[k] = (cnt[k] * (cnt[k] - 1)) / 2;
      base += res[k];
    }
  }

  foreach (i; 0..n) {
    auto sum = base - res[a[i]];
    if (cnt[a[i]] > 2) {
      sum += ((cnt[a[i]]-1) * (cnt[a[i]] - 2)) / 2;
    }
    sum.writeln;
  }
}


Measured memory_bytes: 41104
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    string s, t;
    cin >> s >> t;
    if((s+t[t.size()-1])==t) out("Yes");
    else out("No");

}

Measured memory_bytes: 3596
<?php
fscanf(STDIN, '%d', $n);
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 0;
for ($i = 0; $i < $n; $i++) {
    $ans += min($b[$i - 1] ?? $b[$i], $b[$i] ?? $b[$i - 1]);
}
echo $ans . PHP_EOL;

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

const int MAX = 5050;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int N, K;
bool dp[MAX][MAX];
vector <int> v;

bool check(int x) {
    int n = (int)v.size();
    memset(dp, false, sizeof(dp));
    dp[0][0] = true;
    rep(n, i) rep(K, j) {
        dp[i+1][j] = dp[i][j] || dp[i+1][j];
        if (j+v[i] < K && dp[i][j] && x != i) dp[i+1][j+v[i]] = true;
    }
    rep(K, j) if (dp[n][j] && j + v[x] >= K) return true;
    return false;
}

void solve(void){
    cin >> N >> K;
    rep(N, i) {
        int d; cin >> d;
        if (d < K) {
            v.pb(d);
        }
    }
    sort(all(v));
    int ok = (int)v.size(), ng = -1;
    while(abs(ok-ng)>1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ng+1 << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 25216
def max_crossing_subarray(A, low, mid, high):
    s = 0
    left_max = -10**9
    left_idx = mid
    for i in range(mid, low - 1, -1):
        s += A[i]
        if s > left_max:
            left_max = s
            left_idx = i

    s = 0
    right_max = -10**9
    right_idx = mid + 1
    for i in range(mid + 1, high + 1):
        s += A[i]
        if s > right_max:
            right_max = s
            right_idx = i
    return left_idx, right_idx, left_max + right_max


def max_subarray(A, low, high):
    #print ">> max_subarray(A, %d, %d)" % (low, high)
    if low == high:
        return low, low, A[low]
    mid = (low + high) / 2
    left_ret = max_subarray(A, low, mid)
    right_ret = max_subarray(A, mid + 1, high)
    cross_ret = max_crossing_subarray(A, low, mid, high)
    if left_ret[2] >= right_ret[2] and left_ret[2] >= cross_ret[2]:
        return left_ret
    elif right_ret[2] >= left_ret[2] and right_ret[2] >= cross_ret[2]:
        return right_ret
    else:
        return cross_ret


if __name__ == '__main__':
    n = int(raw_input())
    R = []
    for i in range(n):
        R.append(int(raw_input()))
    minv = R[0]
    maxp = -10**9
    for j in range(1, n):
        maxp = max(maxp, R[j] - minv)
        minv = min(minv, R[j])
    print maxp
    #A = [R[i] - R[i - 1] for i in range(1, n)]
    #print max_subarray(A, 0, len(A) - 1)[2]


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

int INF = (1<<24);
int dp[2][10002];
int t[2][10002];
string str;
int n;
char ch;

void init();

int main(){
  int Tc;
  int y,x;
  cin>>Tc;
  while(Tc--){
    cin>>n>>str;
    init();
    for(int i=0;i<4*n;i++){
      if(str[i]=='N')continue;
      y=i/(2*n);
      x=(  i%(2*n)  +1)/2;
      t[y][x]=1;
    }
    
    if(t[0][0]==1&&t[1][0]==1){
      dp[0][0]=3;
      dp[1][0]=2;  
    }else if(t[0][0]==1&&t[1][0]==0){
      dp[0][0]=1;
      dp[1][0]=1;  
    }else if(t[0][0]==0&&t[1][0]==1){
      dp[0][0]=3;
      dp[1][0]=2;  
    }else{
      dp[0][0]=0;  
      dp[1][0]=1;  
    }

    for(int i=1;i<=n;i++){
      if(t[0][i]==1&&t[1][i]==1){
	dp[0][i]=min(dp[0][i-1]+4,dp[1][i-1]+3);
	dp[1][i]=min(dp[0][i-1]+3,dp[1][i-1]+3);  
      }else if(t[0][i]==1&&t[1][i]==0){
	dp[0][i]=min(dp[0][i-1]+2,dp[1][i-1]+2);
	dp[1][i]=min(dp[0][i-1]+2,dp[1][i-1]+2);  
      }else if(t[0][i]==0&&t[1][i]==1){
	dp[0][i]=min(dp[0][i-1]+4,dp[1][i-1]+3);
	dp[1][i]=min(dp[0][i-1]+3,dp[1][i-1]+2);  
      }else{
	dp[0][i]=min(dp[0][i-1]+1,dp[1][i-1]+2);  
	dp[1][i]=min(dp[0][i-1]+2,dp[1][i-1]+1);  
      }
    }
    cout<<dp[0][n]<<endl;
  }
  return 0;
}

void init(){
  for(int i=0;i<10002;i++){
    dp[0][i]=dp[1][i]=INF;
    t[0][i]=t[1][i]=0;
  }
}

Measured memory_bytes: 1460
d = list(map(int, input().split()))
O = input()

class Dice():
 def __init__(self, d):
  self.dice = d

 def InsSN(self, one, two, five, six):
  self.dice[0] = one
  self.dice[1] = two
  self.dice[4] = five
  self.dice[5] = six

 def S(self):
  one = self.dice[4]
  two = self.dice[0]
  five = self.dice[5]
  six = self.dice[1]
  self.InsSN(one, two, five, six)

 def N(self):
  one = self.dice[1]
  two = self.dice[5]
  five = self.dice[0]
  six = self.dice[4]
  self.InsSN(one, two, five, six)
  
 def InsWE(self, one, three, four, six):
  self.dice[0] = one
  self.dice[2] = three
  self.dice[3] = four
  self.dice[5] = six
 
 def W(self):
  one = self.dice[2]
  three = self.dice[5]
  four = self.dice[0]
  six = self.dice[3]
  self.InsWE(one, three, four, six)

 def E(self):
  one = self.dice[3]
  three = self.dice[0]
  four = self.dice[5]
  six = self.dice[2]
  self.InsWE(one, three, four, six)

d = Dice(d)

for i in range(len(O)):
 if O[i] == 'S':
  d.S()
 elif O[i] == 'N':
  d.N()
 elif O[i] == 'E':
  d.E()
 elif O[i] == 'W':
  d.W()

print(d.dice[0])



 













  

Measured memory_bytes: 7832
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import combinations

while True:
    n,k,s = map(int,input().split(" "))
    if n == 0 and k == 0 and s == 0:
        break
    print(sum([1 if sum(t) == s else 0 for t in combinations(range(1,n+1),k)]))

Measured memory_bytes: 8136
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    ST = [tuple(input().split()) for _ in [0] * N]
    X = input()

    ans = 0
    for s, t in ST:
        ans += int(t)
    for s, t in ST:
        ans -= int(t)
        if s == X:
            print(ans)
            break


main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAXN 100010
int n,m,ans;
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int Sum[MAXN],vis[MAXN],flag[MAXN],cir,cx,cy,tot;
int st[MAXN],r;
void dfs(int u,int p)
{
	tot+=Sum[u];
	vis[u]=1;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			if(vis[V[i]])
			{
				cx=u,cy=V[i];
				cir=(Sum[V[i]]==Sum[u]);
				continue;
			}
			Sum[V[i]]=-Sum[u];
			dfs(V[i],u);
		}
}
void Solve(int u,int p)
{
	vis[u]=0;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p&&vis[V[i]])
		{
			Solve(V[i],u);
			Sum[u]+=Sum[V[i]];
			flag[u]+=flag[V[i]];
		}
}
int main()
{
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	Sum[1]=1;
	dfs(1,0);
	if(m==n-1)
	{
		if(tot!=0)
		{
			printf("-1\n");
			return 0;
		}
	}
	else if(cir)
	{
		if(tot%2!=0)
		{
			printf("-1\n");
			return 0;
		}
		Sum[cx]-=tot/2;
		Sum[cy]-=tot/2;
		ans+=abs(tot)/2;
	}
	else
	{
		if(tot!=0)
		{
			printf("-1\n");
			return 0;
		}
		flag[cx]=-1,flag[cy]=1;
	}
	Solve(1,0);
	for(int i=1;i<=n;i++)
	{
		if(flag[i]==0) ans+=abs(Sum[i]);
		else
		{
			if(flag[i]==1) Sum[i]=-Sum[i];
			st[++r]=Sum[i];
		}
	}
	sort(st,st+r+1);
	int K=st[r/2];
	for(int i=0;i<=r;i++)
		ans+=abs(st[i]-K);
	printf("%d\n",ans);
}

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <fstream>
#include <string>
#include <sstream>


using namespace std;

struct data {
	int x, y;
};

int main() {
	while (true) {
		int n, count = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 2; i < n; i++) {
			if (((n - i * (i + 1) / 2) >= 0)&&(((n - i * (i + 1) / 2) % i == 0))) count++;
		}
		cout << count << endl;
	}
	/*while (true) {
		int n, l, r;
		cin >> n >> l >> r;
		int a[51];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int count = 0;
		bool flag = false;
		for (int i = l; i < r + 1; i++) {
			flag = false;
			for (int j = 1; j <= n; j++) {
				if (i % a[j] == 0) {
					if (j % 2 == 1) {
						count++;
						flag = true;
						break;
					}
					else {
						break;
						flag = true;
					}
				}
				/*if (i % a[j] == 0 && j % 2 == 1) {
					count++;
					break;
				}
				else if (i % a[j] != 0 && j % 2 == 0) {
					count++;
					break;
				}
			}
			if (flag == false) {
				if (n % 2 == 0) {
					count++;
				}
			}
		}
		cout << count << endl;

	}*/
	/*
	while (true) {
		int n;
		int a[405][405];
		int l = 200;
		int r = 200;
		int u = 200;
		int d = 200;
		cin >> n;
		struct data data[201];
		data[0] = 
		for (int i = 1; i < n; i++) {
		
		}
	}*/
}



Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=1e2+10;
int main(){
    ll n,k;scanf("%lld %lld",&n,&k);
    n%=k;
    if(n<=k/2) printf("%lld\n",n);
    else printf("%lld\n",k-n);
    return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  n=int(input())
  a=tuple(map(int,sys.stdin.readline().split()))
  b=[None]*n
  i=1
  for j in a:
    b[j-1]=i
    i+=1
  print(" ".join(map(str,b)))
if __name__=="__main__":
  main()

Measured memory_bytes: 17740
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vi v(n);
	map<int,int> mp;
	rep(i,n){
		cin>>v[i];
		mp[v[i]]++;
	}
	for(auto x:mp){
		if(x.sec > 1){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n; cin >> n;
	ll a, b; cin >> a >> b;
	vector<ll> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	ll res = 0;
	for (int i = 0; i < n - 1; i++) {
		res += min(a*(x[i + 1] - x[i]), b);
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	inc(i, n) { cin >> a[i]; }
	
	int x = 1;
	inc(i, n) { if(a[i] == x) { x++; } }
	
	cout << (x == 1 ? -1 : n - (x - 1)) << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;

int main(){
  	string s;
  	cin >> s;
  	vector<char> ans;
      
  	rep(i,s.size()){
      if(s[i] == 'B' && ans.size() != 0){
        ans.pop_back();
      }
      else if(s[i] != 'B'){
        ans.push_back(s[i]);
      }
    }
 
  	
  	rep(i,ans.size()){
      cout << ans.at(i);
    }
  	cout << endl;
  
 	return 0; 
}

Measured memory_bytes: 256