akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
//        String s = sc.next();
//        Long x = sc.nextLong();
    if(a+b+c >21){
        System.out.println("bust");
    }else{
        System.out.println("win");
    }


    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll K,A,B;
ll ans;
int main(){
    scanf("%lld%lld%lld", &K, &A, &B);
    K -= A - 1;
    ans = A;
    //printf("%lld %lld\n", K, ans);
    if(K%2){
        ans += 1;
        K -= 1;
    }
    if(B-A>1){
        ans += (B - A) * K / 2;
    }else{
        ans += K;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long

int main() {
  int n, t, a, p;
  ll o = 0;
  scanf("%d %d", &n, &t);
  for(int i = 0; i < n; i++) {
    scanf("%d", &a);
    if(i)
      o += a - p < t ? a - p : t;
    else
      o = t;
    p = a;
  }
  printf("%lld\n", o);
}

Measured memory_bytes: 128
//#include "pch.h"
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;


int main()
{
	int N, K;
	cin >> N >> K;
	int length[60];
	for (int i = 0; i < N; i++)	cin >> length[i];

	sort(length, length + N, greater<int>());

	/*for(int i=0;i<N;i++)
	cout << "length[" << i << "]" << length[i]<<endl;*/

	int answer=0;

	for (int j = 0; j < K; j++) {
		answer += length[j];
	}

	cout << answer << endl;
	
	
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

string S;

int main()
{
    string hi = "hihihihihihi";
    cin >> S;

    if (S.size() % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    rep(i, 0, S.size())
    {
        if (S[i] != hi[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
// Problem : E - NEQ
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int testcase;
	cin >> testcase;
	cout << testcase + testcase*testcase + testcase*testcase*testcase;
	return 0;
}

Measured memory_bytes: 3188
h, w = map(int, input().split())
s_list = [list(input()) for _ in range(h)]
dx_list = [1, 0, -1, 0]
dy_list = [0, 1, 0, -1]
answer = 'Yes'
for i in range(h):
    for j in range(w):
        if s_list[i][j] == '#':
            num = 0
            for dx, dy in zip(dx_list, dy_list):
                x = j + dx
                y = i + dy
                if x < 0 or x >= w:
                    continue
                if y < 0 or y >= h:
                    continue
                if s_list[y][x] == '#':
                    num += 1
            if not num:
                answer = 'No'
print(answer)

Measured memory_bytes: 3064
#include <stdio.h>

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

  while(scanf("%d%d",&a,&b)!=EOF){
    int t,g;
    if (b>a){
      t=b;b=a;a=t;
    }
    g=gcd(a,b);
    printf("%d %d\n",g,a*(b/g));
  }

  return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define gcj "Case #"
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 998244353
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

ll a, b, c, d;
ll dp[3100][3100], inq[3100][3100];

int main() {
	fastio;

	cin>>a>>b>>c>>d;

	dp[a][b] = 1;
	queue< pl > q;
	q.push(mp(a, b));
	while (!q.empty()) {
		pl curr = q.front(); q.pop();
		ll x = curr.first-1, y = curr.second-1;
		if (x >= a and y >= b) {
			ll rem = (x*y)%mod;
			rem = (rem * dp[x][y])%mod;
			dp[x+1][y+1] = (dp[x+1][y+1] + mod - rem) % mod; 
		}
		x++; y++;

		//cout<<x<<" "<<y<<" "<<dp[x][y]<<endl;

		if (x+1 <= c) {
			dp[x+1][y] += (dp[x][y] * y)%mod;
			dp[x+1][y] %= mod;
			if (inq[x+1][y] == 0) {
				inq[x+1][y] = 1;
				q.push(mp(x+1, y));
			}
		}

		if (y+1 <= d) {
			dp[x][y+1] += (dp[x][y] * x)%mod;
			dp[x][y+1] %= mod;
			if (inq[x][y+1] == 0) {
				inq[x][y+1] = 1;
				q.push(mp(x, y+1));
			}
		}
	}

	cout<<dp[c][d]<<endl;

	return 0;
}

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  ll A,B,ans;
  cin >> A >> B;
  if(A>9 || B>9) ans=-1;
  else ans=A*B;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3612
#define pb push_back
#define ff first
#define ss second
#define ll long long unsigned
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 100005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;


int main() {
    bool ans = true;
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        int x;
        cin >> x;
        if(x % 2 == 0){
            if(x%3 != 0 && x%5 != 0) ans = false;
        }
    }
    if(ans) cout << "APPROVED"<< endl;
    else cout << "DENIED" << endl;


    return 0;
}

/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<random>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
int d;
int c[30]={};
int s[370][30];
int num=100000;
int koho=5;
int calc(vector<int>const& t,vector<vector<int>>& last_list){
  int res=0;
  vector<int> last(30,0);
  rep1(i,d){
    res+=s[i][t[i]];
    last[t[i]]=i;
    last_list[i]=last;
    int buf=0;
    rep1(j,26){
      buf+=c[j]*(i-last[j]);
    }
    res-=buf;
    //cout<<res<<"\n";
  }
  return res;
}
int change(int nd,int nq,int& res,vector<int>& t,vector<vector<int>>& last_list){
  int flag_t=false;
  int flag_q=false;
  int x=t[nd];
  t[nd]=0;
  res+=s[nd][nq];res-=s[nd][x];
  for(int i=nd;i<=d;++i){
    if(flag_t&&flag_q)break;
    if(t[i]==x||flag_t)flag_t=true;
    else{
      res+=c[x]*(i-last_list[i][x]);
      last_list[i][x]=last_list[i-1][x];
      res-=c[x]*(i-last_list[i][x]);
    }
    if(t[i]==nq||flag_q)flag_q=true;
    else{
      res+=c[nq]*(i-last_list[i][nq]);
      last_list[i][nq]=nd;
      res-=c[nq]*(i-last_list[i][nq]);
    }
  }
  t[nd]=nq;
  return res;
}
vector<int> greedy(int d,vector<vector<int>>& t_koho){
  vector<int> res(d+1,0);
  vector<int> last(30,0);
  rep1(i,d){
    int mx=-inf;
    int mx_ind=0;
    vector<P> kouho(26);
    rep1(j,26){
      int tmp=s[i][j];
      rep1(k,26){
        if(k==j)continue;
        tmp-=c[k]*(i-last[k]);
      }
      if(mx<tmp){
        mx=tmp;
        mx_ind=j;
      }
      kouho[j-1]={tmp,j};
    }
    sort(kouho.begin(),kouho.end());
    reverse(ALL(kouho));
    rep(x,koho){
      t_koho[i][x]=kouho[x].second;
    }
    last[mx_ind]=i;
    res[i]=mx_ind;
  }
  return res;
}
signed main(){
  cin>>d;
  rep1(i,26)cin>>c[i];
  rep1(i,d){
    rep1(j,26)cin>>s[i][j];
  }
  vector<vector<int>> t_koho(d+5,vector<int>(koho+5,0));
  vector<int> t=greedy(d,t_koho);
  vector<vector<int>> last_list(d+1,vector<int>(30,0));
  int res=calc(t,last_list);
  //cout<<res<<"\n";
  int param=2;
  rep(xx,num){
    random_device rand;
    mt19937 mt(rand());
    vector<int> nd(param);rep(i,param)nd[i]=mt()%d+1;
    vector<int> nq(param);rep(i,param)nq[i]=t_koho[nd[i]][mt()%koho];
    vector<int> bq(param);rep(i,param)bq[i]=t[nd[i]];
    int bval=res;
    rep(i,param){
      change(nd[i],nq[i],res,t,last_list);
    }
    int yakinamasi=mt()%100;
    //if(yakinamasi<20&&res+res/10000>bval)continue;
    if(bval>res){
      rep(i,param){
        change(nd[i],bq[i],res,t,last_list);
      }
    }
  }
  rep(xx,num){
    random_device rnd;
    mt19937 mt(rnd());
    int nd=mt()%d+1;
    int nq=mt()%26+1;
    int bq=t[nd];
    int bval=res;
    int hoge=change(nd,nq,res,t,last_list);
    if(hoge<bval){
      change(nd,bq,res,t,last_list);
    }
  }
  rep1(i,d){
    cout<<t[i]<<"\n";
  }
  //cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3880
from collections import *

N=int(input())
S=input()
c=Counter(S)

ans=c['R']*c['G']*c['B']

for i in range(N):
  for j in range(i+1,N):
    if S[i]==S[j]:
      continue
    k=j*2-i
    if k>=N or S[k]==S[i] or S[k]==S[j]:
      continue
    ans-=1

print(ans)


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i].first >> p[i].second;
  }
  sort(all(p),[](pair<int,int> &l, pair<int,int> & r){
    return l.second<r.second;
  });
  LL now=0;
  for(int i=0;i<n;i++){
    now+=p[i].first;
    if(now>p[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1792
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let r: usize = iterator.next().unwrap().parse().unwrap();
    let s: usize = iterator.next().unwrap().parse().unwrap();
    let p: usize = iterator.next().unwrap().parse().unwrap();

    let mut t: Vec<char> = iterator.next().unwrap().chars().collect();
    let mut ans = 0;
    for &c in t.iter() {
        if c == 'r' {
            ans += p;
        } else if c == 's' {
            ans += r;
        } else {
            ans += s;
        }
    }

    for i in k..n {
        if t[i] == t[i - k] {
            let c = t[i - k];
            if c == 'r' {
                ans -= p;
            } else if c == 's' {
                ans -= r;
            } else {
                ans -= s;
            }
            t[i] = 'x';
        }
    }

    return ans.to_string();
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll cnt[5] , a[N] , c[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll ans = 1 ;
    ll n ;
    cin >> n ;
    for (int i = 1; i <= n ; i ++) cin >> a[i] ;
    for (int i = 1; i  <= n ; i ++) {
    	ll x=  a[i] ;
    	ll res = 0 ;
    	for (int j = 1 ; j <= 3; j ++) if (cnt[j] == x) res ++ ;
    	ll id = 0 ;
    	for (int j = 1;  j <= 3 ; j ++) if (cnt[j] == x) id = j ;
    	ans *= res ;
    	ans %= Mod ;
    	c[i] = id ;
    	cnt[id] ++ ;
	}
	cout << ans ;
    return (0) ;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int x = stdIn.nextInt();
		int t = stdIn.nextInt();
		
		System.out.println((n+x-1)/x*t);
		
		

	}

}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; 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 inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(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()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

LL n, a[5];

int main() {
	cin >> n;
	inc(i, 5) { cin >> a[i]; }
	
	LL mi = 1e18;
	inc(i, 5) { setmin(mi, a[i]); }
	
	LL ans = ce(n, mi) + 4;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll a, b, c[200020], d[200020] = {}, cnt = 1, now = 0, ans = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		cin >> c[i];
	}
	sort(c, c + a);
	for (int i = 1; i < a; i++) {
		if (c[i] == c[i - 1])cnt++;
		else {
			d[now] = cnt;
			cnt = 1;
			now++;
		}
	}
	if (cnt) {
		d[now] = cnt;
		now++;
	}
	sort(d, d + now);
	now -= b;
	for (int i = 0; i < now; i++)ans += d[i];
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}
main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(c==-1||d==-1){
    if(a==b)puts("Draw");
    else if(a>b)puts("Bob");
    else puts("Alice");
  }
  else if(c==d) puts("Draw");
  else if(c>d) puts("Alice");
  else puts("Bob");


}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator >(const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, int cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

/*--------------------template--------------------*/
bool bellman_ford(Graph& g, Array &d, int s)
{
	fill(ALL(d), INF);
	d[s] = 0;
	int cnt = 0;
	while(1)
	{
		if(cnt > g.size()) return false;
		cnt++;
		bool update = false;
		REP(i, g.size())REP(j,g[i].size())
		{
			Edge e = g[i][j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost)
			{
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
	}
	return true;
}


int main()
{
	int v, e, r;
	cin >> v >> e >> r;
	Graph g(v);
	REP(i, e)
	{
		int a, b, c;
		cin >> a >> b >> c;
		add_edge(g, a, b, c);
	}
	Array d(v);
	if(!bellman_ford(g, d, r)) puts("NEGATIVE CYCLE");
	else
	{
		REP(i, v)
		{
			if(d[i] == INF) puts("INF");
			else cout << d[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1284
/// __Macro's__
// #pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long
#define II                   pair<int,int>
#define III                  pair<int, II>
#define VL                   vector<ll>
#define VI                   vector<int>
#define VII                  vector<II>
#define VIII                 vector<III>
#define VVI                  vector<vector<int>>
#define VVII                 vector<vector<II>>
#define fr                   first
#define sc                   second
#define mkpr                 make_pair
#define PQ                   priority_queue
#define pb                   push_back
#define eb                   emplace_back
#define all(v)               v.begin(), v.end()
#define LINE                 putc('\n', stdout)
#define SPACE                putc(' ' , stdout)
#define TAB                  putc('\t', stdout)
#define fillarr(arr, val)    fill((int*)arr, (int*)arr+(sizeof(arr)/sizeof(int)), val)
#define Log2(x)              (31^__builtin_clz(x))
#define inf                  2000000007 
#define MOD                  1000000007 
#define getint ReadInt()
const char IO_MODE = 3; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast 
inline ll ReadInt(){ll x=0,s=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')s=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';
c=getchar();}return s*x;}inline void WriteInt(ll x){char c[20];if(!x){putchar('0');return;}if(x<0)putchar('-'),x=-x;int i=0;while(x>0)
c[++i]=x%10,x/=10;while(i)putchar(c[i--]+48);}template <typename T>inline void out(T x){if(IO_MODE&1)WriteInt(x);else if(typeid(x)==typeid(int))
printf("%i", x);else printf("%lld", (ll)x);}template<typename T, typename... Args>inline void out(T x,Args...args){out(x);SPACE;out(args...);}
template <typename T>inline void in(T &x){if(IO_MODE&2) x=ReadInt();else if(typeid(x)==typeid(int))scanf("%i",&x);else if(typeid(x)==typeid(ll))
scanf("%lld",&x);}template<typename T, typename... Args>inline void in(T &x,Args&...args){in(x);in(args...);}
int aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
int tc;
///

#define nax 1010*1010
int InDeg[nax];
int f[nax];
int n;
VI adjList[nax];
int ans;
void KahnDAG(){
  queue<II> q;
  for(int i=0 ; i<nax ; i++)
    if(f[i] && !InDeg[i]) q.push(mkpr(i, 1));

  if(q.empty()) printf("-1\n"), exit(0);
  while(!q.empty())
  {
    int u = q.front().fr;
    int d = q.front().sc;
    ans=max(ans, d);
    q.pop();
    for(auto v : adjList[u])
      if(!--InDeg[v])
        q.push(mkpr(v, d+1));
  }
  for(int i=0 ; i<nax ; i++)
    if(InDeg[i]>0) printf("-1\n"), exit(0);
}
int main()
{
  in(n);
  for(int i=0 ; i<n ; i++){
    int pre=-1;
    for(int j=1 ; j<n ; j++)
    {
      int x = getint-1;
      int a = min(i, x);
      int b = max(i, x);
      int c = a*n+b;
      f[c]=1;
      if(pre!=-1){
        adjList[pre].pb(c);
        InDeg[c]++;
      }
      pre=c;
    }
  }
  KahnDAG();
  cout << ans << endl;

}

Measured memory_bytes: 47616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t a, b;
    cin >> a >> b;
    auto c = min(a, b);
    auto d = max(a, b);
    for (size_t i = 0; i < d; ++i)
        cout << c;
    cout << endl;
    return 0;
}




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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

struct xy{
  int x;
  int y;
};

int main(){
  int vecx[4] = {-1,0,1,0};
  int vecy[4] = {0,1,0,-1};
  int N;
  int kijun;
  int houkou;
  int minx,miny,maxx,maxy;
  while(1){
    cin >> N;
    if(N==0) return 0;
    vector<struct xy> seihoukei(N);
    seihoukei[0].x=seihoukei[0].y=0;
    minx=miny=maxx=maxy=0;
    for(int i=1;i<N;i++){
      cin >> kijun >> houkou;
      seihoukei[i].x=seihoukei[kijun].x+vecx[houkou];
      seihoukei[i].y=seihoukei[kijun].y+vecy[houkou];
      minx=min(minx,seihoukei[i].x);
      maxx=max(maxx,seihoukei[i].x);
      miny=min(miny,seihoukei[i].y);
      maxy=max(maxy,seihoukei[i].y);
    }
    cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3012
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if((abs(a-c)<=d) ||((abs(a-b)<=d) && (abs(b-c)<=d))) cout <<"Yes" <<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, cos
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B, H, M = map(int, input().split())
    a = H * 30 + M * 0.5
    b = M * 6

    d = min(abs(a - b), 360 - abs(a - b))
    ans = A * A + B * B + - 2 * A * B * cos(d * pi / 180)
    print(sqrt(ans))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 10228
import bisect 

def getlist():
	return list(map(int, input().split()))

INF = float("inf")
#受け取りなど
A, B, Q = getlist()
S = [-INF]
for i in range(A):
	s = int(input())
	S.append(s)
S.append(INF)

T = [-INF]
for i in range(B):
	t = int(input())
	T.append(t)
T.append(INF)

for i in range(Q):
	x = int(input())
	a = bisect.bisect_left(S, x)
	b = bisect.bisect_left(T, x)
	print(min(max(x - S[a - 1], x - T[b - 1]), max(S[a] - x, T[b] - x), (S[a] - x) * 2 + x - T[b - 1], (T[b] - x) * 2 + x - S[a - 1], S[a] - x + (x - T[b - 1]) * 2, T[b] - x + (x - S[a - 1]) * 2))

Measured memory_bytes: 12084
#!/snap/bin/pypy3


def main():
    M, D = map(int, input().split())

    counter = 0
    for m in range(2, M + 1):
        for dd in range(20, D + 1):
            d1 = dd % 10
            if d1 < 2:
                continue

            d10 = dd // 10
            if d1 * d10 == m:
                counter += 1

    print(counter)


if __name__ == '__main__':
    main()


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

int main() {
  int n, a, b;
  cin >> n;
  vector<int> p(n), q(n), r = {1, 2, 6, 24, 120, 720, 5040};
  for(int i = 0; i < n; ++i) cin >> p[i];
  for(int i = 0; i < n; ++i) cin >> q[i];
  a += (p[0]-1) * r[n-2];
  b += (q[0]-1) * r[n-2];
  for(int i = 1; i < n-1; ++i){
    int cp = p[i]-1, cq = q[i]-1;
    for(int j = 0; j < i; ++j){
      if(p[i] > p[j]) --cp;
      if(q[i] > q[j]) --cq;
    }
    a += cp * r[n-i-2];
    b += cq * r[n-i-2];
  }
  cout << max(a, b) - min(a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    int a1;
    int a2;
    int a3;
    int sum;

    cin >> a1 >> a2 >> a3;
    sum = a1 + a2 + a3;
    if(sum>=22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int INF = 10000000;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] d = new int[N+1][N+1];
		int[][] e = new int[N+1][N+1];
		for(int i=1; i<=N; i++) {
			for(int j=1; j<=N; j++) {
				d[i][j] = INF;
			}
		}
		for(int i=0; i<M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			d[a][b] = c;
			d[b][a] = c;
			e[a][b] = c;
			e[b][a] = c;
		}
		for(int k=1; k<=N; k++) {
			for(int i=1; i<=N; i++) {
				for(int j=1; j<=N; j++) {
					d[i][j] = Math.min(d[i][j], d[i][k]+d[k][j]);
				}
			}
		}
		int ans = 0;
		for(int i=1; i<=N; i++) {
			for(int j=1; j<=N; j++) {
				if(d[i][j] < e[i][j]) ans++;
			}
		}
		System.out.println(ans/2);
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 25956
N, C, K = map(int, input().split())
Ts = [0]*N
for i in range(N):
    Ts[i] = int(input())

Ts = sorted(Ts)
bus_num = 1
bus_i = [1]
bus_t = Ts[0]
for t in Ts[1:]:
    if (t<=(bus_t+K)) & (len(bus_i) < C):
        bus_i.append(1)
    else:
        bus_i = [1]
        bus_t = t
        bus_num +=1
print(bus_num)

Measured memory_bytes: 8240
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[500001];
int INF=1000100010;
int cnt;
void merge(int l,int mid,int r){
    int cl=mid-l,cr=r-mid;
    vector<int> vl,vr;
    rep(i,cl) vl.pb(a[l+i]);
    rep(i,cr) vr.pb(a[mid+i]);
    vl.pb(INF),vr.pb(INF);
    cl=0,cr=0;
    FOR(i,l,r){
        if(vl[cl]<=vr[cr]) a[i]=vl[cl++];
        else a[i]=vr[cr++];
        ++cnt;
    }
}
void mergesort(int l,int r){
    if(r-l>1){
        int mid=(r+l)/2;
        mergesort(l,mid);
        mergesort(mid,r);
        merge(l,mid,r);
    }
}
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    mergesort(0,n);
    rep(i,n) cout<<a[i]<<(i==n-1?"":" ");
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;

int main(){
    int a;
    ll b,n;
    cin>>a>>b>>n;
    ll ans=0;
    cout<<a*min(b-1,n)/b-a*(min(b-1,n)/b)<<endl;
return 0;
}

Measured memory_bytes: 3608
while True:
 a, op, b = input().split()   
 a = int(a)                   
 b = int(b)  
 if  op == "?":
  break
 if op == "+":
  x=a+b
  print(x)
 elif op == "-":
  y=a-b
  print(y)
 elif op == "*":
  c=a*b
  print(c)
 elif op == "/":
  v=a/b
  print(int(v))


Measured memory_bytes: 5596
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
            _out.println(0);
            return;
        }
        if (A == B && B == C) {
            _out.println(-1);
            return;
        }

        long cnt = 0;
        while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
            int ta = B / 2 + C / 2;
            int tb = A / 2 + C / 2;
            int tc = A / 2 + B / 2;
            A = ta;
            B = tb;
            C = tc;
            ++cnt;
        }
        _out.println(cnt);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
using namespace std;
int main() {
	string str, cm, p, yaju;
	int a, b, q;
	cin >> str >> q;
	for (int i = 0;i < q;i++) {
		cin >> cm;
		if (cm == "print") {
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (cm == "reverse") {
			cin >> a >> b;
			string tmp = str.substr(a,b-a+1);
			int n = tmp.size();
			for (int i = 0;i < n;i++)
				str[a + i] = tmp[n - i - 1];
		}
		else if (cm == "replace") {
			cin >> a >> b >> p;
			str.replace(a , b - a + 1, p);
		}

	}
	return 0;
}


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

using namespace std;
template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  vector<int> p(n),q(n),v(n);
  for(int i = 0; i < n; i++) v[i] = i + 1;

  Inparray(p,n);
  Inparray(q,n);

  int a=0,b=0,a_cnt,b_cnt,j=0;
  do {
    j++;
    a_cnt=0,b_cnt=0;
    for(int i = 0; i<n; i++){
      if(v[i]==p[i])a_cnt++;
      if(v[i]==q[i])b_cnt++;
    }
    if(a_cnt==n)a=j;
    if(b_cnt==n)b=j;
  } while(next_permutation(v.begin(), v.end()));
  cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)[:x]
q = sorted(list(map(int, input().split())), reverse=True)[:y]
r = sorted(list(map(int, input().split())), reverse=True)
if len(r) > x + y:
  r = r[:x+y]

ans = sum(p) + sum(q)
cp = x - 1
cq = y - 1
for tmp in r:
  if cp >= 0 and cq >= 0:
    if p[cp] > q[cq]:
      if tmp > q[cq]:
        ans += tmp - q[cq]
        cq -= 1
      else:
        break
    else:
      if tmp > p[cp]:
        ans += tmp - p[cp]
        cp -= 1
      else:
        break
  elif cp < 0:
    if tmp > q[cq]:
      ans += tmp - q[cq]
      cq -= 1
    else:
      break
  elif cq < 0:
    if tmp > p[cp]:
      ans += tmp - p[cp]
      cp -= 1
    else:
      break
      
  else:
    break
print(ans)

Measured memory_bytes: 22192
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());



struct DisjointSet {
    vector<int> par;
    vector<int> rak; // number of the vertices

    void init(int n) {
      par.resize(n);
      rak.resize(n);
      for(int i=0; i<n; i++) {
        par[i] = i;
        rak[i] = 1;
      }
    }

    int find(int x) {
      if (par[x] == x) {
        return x;
      } else {
        return par[x] = find(par[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x==y) return;
      if (rak[x] < rak[y]) {
        rak[y] += rak[x];
        par[x] = y;
      } else {
        rak[x] += rak[y];
        par[y] = x;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }
};


class ADisjointSetUnion {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, q; cin >> n >> q;
      DisjointSet d;
      d.init(n);
      while(q--) {
        int t; cin >> t;
        if (t==0) {
          int u, v; cin >> u >> v;
          d.unite(u, v);
        } else {
          int u, v; cin >> u >> v;
          cout << (d.same(u, v) ? 1 : 0) << '\n';
        }
      }
    }
};

signed main() {
  ADisjointSetUnion solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {

	long long n,k,ans=0;
	cin>>n>>k;

	vector <long long> m(n);
	for (auto& e:m) {
		cin>>e;
	}

	sort(m.begin(),m.end());

	for (long long i=0;i<n-k;i++) {
		ans+=m[i];
	}

	cout<<ans;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

struct Tree {
   Tree(Int n)
      : ps(n, -1) {}
   std::vector<Int> ps;
   Int root(Int x) {
      if( ps[x] == -1 ) return x;
      return ps[x] = root(ps[x]);
   }
   void connect(Int parent, Int child) {
      parent = root(parent), child = root(child);
      if( parent == child ) return;
      ps[root(child)] = root(parent);
   }
};

int main() {
   Int v, e, r;
   std::cin >> v >> e >> r;
   std::vector<Int> ss(e), ts(e), ws(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ws[i];
   std::vector<RQ<std::pair<Int,Int>>> qs(v);
   std::vector<Int> os(v);
   rep(i, e) {
      Int s = ss[i], t = ts[i], w = ws[i];
      qs[t].emplace(w, s);
   }
   Tree tree(v);
   auto f = [&]() -> Int {
      Int res = 0;
      std::vector<Int> pws(v), pis(v);
      std::vector<bool> finished(v);
      finished[r] = true;
      rep(i, v) {
         Int a = tree.root(i);
         guard( not finished[a] );
         std::vector<Int> ys;
         std::vector<bool> visited(v);
         while( not finished[a] ) {
            ys.emplace_back(a);
            visited[a] = true;
            if( qs[a].empty() ) return -1;
            Int w, p;
            do {
               std::tie(w, p) = qs[a].top(); qs[a].pop();
               w += os[a];
               p = tree.root(p);
            } while( p == tree.root(a) );
            pws[a] = w;
            pis[a] = p;
            res += w;
            if( not visited[p] ) {
               a = p;
            }
            else {
               Int nr = a;
               for(Int b = pis[a]; b != a; b=pis[b]) {
                  if( qs[nr].size() < qs[b].size() ) nr = b;
               }
               os[nr] -= pws[nr];
               for(Int b = pis[nr]; b != nr; b=pis[b]) {
                  tree.connect(nr, b);
                  while( not qs[b].empty() ) {
                     Int w2, p2; std::tie(w2, p2) = qs[b].top(); qs[b].pop();
                     Int nw = w2 + os[b] - pws[b] - os[nr];
                     qs[nr].emplace(nw, p2);
                  }
               }
               a = nr;
            }
         }
         for(Int y : ys) finished[y] = true;
      }
      return res;
   };
   printf("%ld\n", f());
}



Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int odd[111111] = {},even[111111] = {};
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        if(i % 2 == 0)
        {
            odd[x]++;
        }
        else
        {
            even[x]++;
        }
    }
    int odd_max1 = 0,odd_max2 = 0,even_max1 = 0,even_max2 = 0;
    int odd1 = 0,odd2 = 0,even1 = 0,even2 = 0;
    for(int i = 0;i < 111111;i++)
    {
        if(odd[i] >= odd_max1)
        {
            odd_max2 = odd_max1;
            odd2 = odd1;
            odd_max1 = odd[i];
            odd1 = i;
        }
        else if(odd[i] > odd_max2)
        {
            odd_max2 = odd[i];
            odd2 = i;
        }
        if(even[i] >= even_max1)
        {
            even_max2 = even_max1;
            even2 = even1;
            even_max1 = even[i];
            even1 = i;
        }
        else if(even[i] > even_max2)
        {
            even_max2 = even[i];
            even2 = i;
        }
    }
    if(odd1 != even1)
    {
        cout << n - (odd_max1 + even_max1);
    }
    else
    {
        cout << n - max(odd_max1 + even_max2,odd_max2 + even_max1);
    }
    
    return 0;
}

Measured memory_bytes: 1152
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int arr[122][123];
int a[123456];
int main(){
    std::ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    //int dir=1;
    int n,i,j,k;
    cin>>n;
    rep(i,n){
    	cin>>a[i];
    	
    }
    k=0;
    rep(i,h){
    	if(i%2==0){
    		rep(j,w){
	    		while(!a[k]){
	    			k++;
	    		}
	    		arr[i][j]=k+1;
	    		a[k]--;
	    	}

    	}
    	else{
    		fd(j,w-1,0){
	    		while(!a[k]){
	    			k++;
	    		}
	    		arr[i][j]=k+1;
	    		a[k]--;
	    	}
    	}
    	
    }
    rep(i,h){
    	rep(j,w){
    		cout<<arr[i][j]<<" ";
    	}
    	cout<<endl;
    }


    return 0;      

}



Measured memory_bytes: 384
label = list(map(int,input().split()))
direction = list(str(input()))
D=list(range(6))
Dtemp=[0,0,0,0,0,0]
for i in range(len(direction)):
    if direction[i] == 'N':
        Dtemp[0] = D[1]
        Dtemp[1] = D[5]
        Dtemp[2] = D[2]
        Dtemp[3] = D[3]
        Dtemp[4] = D[0]
        Dtemp[5] = D[4]
    elif direction[i] == 'E':
        Dtemp[0] = D[3]
        Dtemp[1] = D[1]
        Dtemp[2] = D[0]
        Dtemp[3] = D[5]
        Dtemp[4] = D[4]
        Dtemp[5] = D[2]
    elif direction[i] =='S':
        Dtemp[0] = D[4]
        Dtemp[1] = D[0]
        Dtemp[2] = D[2]
        Dtemp[3] = D[3]
        Dtemp[4] = D[5]
        Dtemp[5] = D[1]
    elif direction[i] =='W':
        Dtemp[0] = D[2]
        Dtemp[1] = D[1]
        Dtemp[2] = D[5]
        Dtemp[3] = D[0]
        Dtemp[4] = D[4]
        Dtemp[5] = D[3]
    D=Dtemp
    Dtemp=[0,0,0,0,0,0]
print(label[D[0]])



Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {

	int p,q,r;

	cin >> p >>  q >> r;

	println(p+q+r-max(max(p,q),r));

	return 0;
}


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

int main(void)
{
    int N;
    char S;
	cin >> N;
	while(cin >> S)
	{
		S += N;
		if(S > 90) S -= 26;
        cout << S;
	}
	cout << endl;

}

Measured memory_bytes: 256