akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

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

long long fac[510000], finv[510000], inv[510000];
struct Comb {
    Comb()
    {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < 510000; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long COM(int n, int k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    ll PERM(int n, int k)
    {
        if (n < k)
            return 0;
        return (fac[n] * finv[n - k]) % MOD;
    }
};

int main()
{
    int N, M;
    cin >> N >> M;
    Comb C;
    ll ans = C.PERM(M, N);
    ans = ans * C.PERM(M, N) % MOD;
    REP(i, N)
    {
        ll c = (((i % 2) ? 1 : -1) * C.PERM(M, N) + MOD) % MOD;
        c = (c * C.COM(N, i + 1)) % MOD;
        c=(c*C.PERM(M-(i+1),N-(i+1)))%MOD;
        ans = (ans + c)%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15540
#include <queue>
#include <tuple>
#include <cstdio>
#include <cstring>
using namespace std;
#define SENTINEL 99999
typedef tuple<int,int,int> tiii; //building, floor, depth
int M[2][101],B[2][101],n;
int bfs(int i){
	memset(M,99,sizeof(M));
	queue<tiii> q;
	q.push(make_tuple(i,0,0));M[i][0]=0;
	for(;!q.empty();){
		tiii t=q.front();q.pop();
		int building=get<0>(t);
		int floor=get<1>(t);
		int depth=get<2>(t);
		for(;B[building][floor]==1&&B[building][floor+1]==1;){
			if(M[building][floor+1]>M[building][floor])M[building][floor+1]=M[building][floor];
			floor++;
		}
		for(;B[building][floor]==2;){
			if(M[building][floor-1]>M[building][floor])M[building][floor-1]=M[building][floor];
			floor--;
		}
		if(floor==n-1)return depth;
		for(i=2;i>=0;i--)if(floor+i<n&&M[building^1][floor+i]>M[building][floor]){
			M[building^1][floor+i]=M[building][floor];
			q.push(make_tuple(building^1,floor+i,depth+1));
		}
	}
	return SENTINEL;
}
int main(){
	int i,j;
	for(;scanf("%d",&n),n;){
		for(j=0;j<2;B[j][i]=0,j++)for(i=0;i<n;i++)scanf("%d",B[j]+i);
		i=min(bfs(0),bfs(1));
		printf(i==SENTINEL?"NA\n":"%d\n",i);
	}
}

Measured memory_bytes: 1016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

string ABCD;
string op;

bool dfs(int sum, string opc) {
    int len = opc.length();
    if (len == 3) {
        op = opc;
        return sum == 7;
    }

    if (dfs(sum + (ABCD[len+1] - '0'), opc + '+')) return true;

    if (dfs(sum - (ABCD[len+1] - '0'), opc + '-')) return true;

    return false;
}

int main() {
    cin >> ABCD;

    if (dfs(ABCD[0] - '0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", ABCD[0], op[0], ABCD[1], op[1], ABCD[2], op[2], ABCD[3]);
    } else {
        cout << "NO" << "\n";
    }

    return 0;
}


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

#ifdef LOCAL
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define dbgv(x) cerr << #x << " = " << x << endl
#define dbga(arr, len) {cerr << #arr << " = "; for (int _ = 0; _ < len; _++)\
cerr << arr[_] << " "; cerr << endl;}
#define dbgi(it) {cerr << #it << " = "; for (const auto& _ : it)\
cerr << _ << " "; cerr << endl;}
#else
#define dbg(...) (void)0
#define dbgv(x) (void)0
#define dbga(arr, len) (void)0
#define dbgi(it) (void)0
#endif

using ll = long long;
using dbl = long double;
using pii = pair<int, int>;

const int N = 30500;

int n;
char s[N];
int lmost[10], rmost[10];
bool has[10][10][10];

void solve() {
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 0; i < n; ++i) {
        s[i] -= '0';
    }

    fill(lmost, lmost + 10, n);
    fill(rmost, rmost + 10, -1);
    for (int i = 0; i < n; ++i) {
        lmost[s[i]] = min(lmost[s[i]], i);
        rmost[s[i]] = max(rmost[s[i]], i);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int a = 0; a < 10; ++a) {
            for (int b = 0; b < 10; ++b) {
                if (lmost[a] < i && i < rmost[b]) {
                    if (!has[a][s[i]][b]) {
                        ++ans;
                    }
                    has[a][s[i]][b] = true;
                }
            }
        }
    }

    printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    dbg("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int[] h = new int[100];
		int[] w = new int[100];

		int numData;
		for (int i = 0; ; i++)
		{
			int tempH = sc.nextInt();
			int tempW = sc.nextInt();

			if (tempH == 0 && tempW == 0)
			{
				numData = i;
				break;
			}

			h[i] = tempH;
			w[i] = tempW;
		}

		for (int i = 0; i < numData; i++)
		{
			for (int j = 0; j < h[i]; j++)
			{
				for (int k = 0; k < w[i]; k++)
				{
					if (j == 0 || j == h[i] - 1)
					{
						System.out.print("#");
					}
					else
					{
						if (k == 0 || k == w[i] - 1)
						{
							System.out.print("#");
						}
						else
						{
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}


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

int main(){
    int h, w;
    std::cin >> h >> w;
    
    std::vector<std::string> a;
    for(int i = 0; i < h; i++){
        std::string s;
        std::cin >> s;
        a.push_back(s);
    }
    
    for(int y = h - 1; y >= 0; y--){
        bool flag = true;
        for(int x = 0; x < w; x++){
            if(a[y][x] == '#'){
                flag = false;
                break;
            }
        }
        if(flag){
            a.erase(a.begin() + y);
            h--;
        }
    }
    
    for(int x = w - 1; x >= 0; x--){
        bool flag = true;
        for(int y = 0; y < h; y++){
            if(a[y][x] == '#'){
                flag = false;
                break;
            }
        }
        if(flag){
            for(int y = 0; y < h; y++){
                a[y].erase(x, 1);
            }
            w--;
        }
    }
    
    for(std::string s : a){
        std::cout << s << std::endl;
    }
    return 0;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


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

  lint k=1, l=1;
  for(lint i=1;i<(lint)s.size();i++) {

    if(s[i] == s[i-1]) {
      if(l == 1) {
        if(i == (lint)s.size()-1) {
          k--; // last word
        } else {
          l=2;
          i++;
        }
      } else {
        l=1;
      }

    } else { l=1; }

    k++;
  }

  cout << k << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    vector<string> s(N); for(auto& in:s) cin >> in;
    ll M; cin >> M;
    vector<string> t(M); for(auto& in:t) cin >> in;
    ll res = 0;
    for(int i = 0; i < N;i++){
        res = max(res,ll(count(s.begin(),s.end(),s[i])-count(t.begin(),t.end(),s[i])));
    }
    cout << res << endl;
    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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1000000007;
struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a){
        if((x+=a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1){
        fact[0] = 1;
        for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;  
    }
    mint operator()(int n, int k){
        if(k < 0 || n < k) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
} comb(100005);

mint permutation(int n, int k){
    if(n<0) return 0;
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}

int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p=-1){
    for(int u : to[v]){
        if(u==p) continue;
        dfs(u,v);
    }
    int nk = (p==-1) ? k:k-2;
    //自分が根なら自分とその子、それ以外なら子の数
    int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
    ans *= permutation(nk,c);
}

int main(){
    int n; 
    cin >> n >> k;
    rep(i,n-1){
        int a, b; 
        cin >> a >> b;
        --a, --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans = 1;
    dfs(0);
    cout << ans.x << endl;
    return 0;

}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define ll long long
#define     f           first
#define     s           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<long long,long long>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a)  for(int i=0;i<int(a);i++)
#define repb(i,b,a) for(int i=(int)b;i>=(int)a;i--)
vector<ll> adj[N];
bool visited[N]={false};
int main()
{
  ll k,m;
  cin>>k;
  string s;
  for(int i=0;i<k;i++)
  {
      s+='A';
      s+='C';
      s+='L';
  }
  cout<<s<<endl;
   // getch();
    return 0;
}

Measured memory_bytes: 8324
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

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

void solve() {
    string s; cin >> s;
    if (s == "BBB" || s == "AAA") {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
    }
}

int main() {
    fast_io; cin_exception;
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
dic = {}
lst = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a in dic)==False:
        dic[a] = b
        lst.append(a)
    else:
        dic[a] += b
lst.sort()

for i in range(len(dic)):
    if k > (dic[lst[i]] + ans):
        ans += dic[lst[i]]
    else:
        ans = lst[i]
        break
print(ans)

Measured memory_bytes: 10764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll ,ll >
#define f first
#define s second 
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
vector<int> prime;
void seive(int x){
    vector<bool> isprime(x,true);
    for(int p=2;p*p<=x;p++){
        if(isprime[p]){
            for(int i=p*p;i<=x;i+=p) isprime[i]=false;
        }
    }
    for(int i=2;i<=x;i++) prime.push_back(i);
}
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
/*------------------------------------------------------------
------------------------------------------------------------*/
int find(int p,vector<int> &parent){
    if(parent[p]==p) return p;
    return parent[p]=find(parent[p],parent);
}
void merge(int u,int v,vector<int> &parent){
    parent[v]=u;
}
int main(void){
    ll n,m,a,b,ans=0;
    boost;
    cin>>n>>m;
    vector<pii > v;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back({b,a});
    }
    sort(v.begin(),v.end(),greater<pii>());
    vector<int> parent(m+1,0);
    for(int i=0;i<=m;i++) parent[i]=i;
    for(int i=0;i<n;i++){
        int index=m-v[i].s+1,avl=0;
        if(index>=0)
        avl=find(index,parent);
        if(avl>0){
            merge(find(avl-1,parent),avl,parent);
           // cout<<index<<" "<<v[i].f<<" "<<v[i].s<<endl;
            ans+=v[i].f;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

use std::collections::HashSet;

fn gcd(mut a:usize, mut b:usize) -> usize {
    while b > 0 {
        let c = b;
        b = a % b;
        a = c;
    }
    a
}

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [usize; n]
    }
    let m = 1_000_001;
    let mut g = vec![0; m];
    g[1] = 1;
    for i in 2..m {
        if g[i] == 0 {
            g[i] = i;
            for j in i..(m-1)/i+1 {
                g[i*j] = i;
            }
        }
    }
    let mut gc = a[0];
    let mut d = HashSet::new();
    let mut fl = true;
    for &x in &a {
        gc = gcd(gc, x);
        if fl {
            let mut y = x;
            let mut b = Vec::new();
            while y > 1 {
                let v = g[y];
                if d.contains(&v) {
                    fl = false;
                    break;
                } else {
                    b.push(v);
                    y /= v;
                }
            }
            if fl {
                for &v in &b {
                    d.insert(v);
                }
            }
        }
    }
    let ans = if fl {
        "pairwise coprime"
    } else if gc == 1 {
        "setwise coprime"
    } else {
        "not coprime"
    };
    println!("{}", ans);
}


Measured memory_bytes: 25672
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        int min = 129;
        int idx = 5;
        for(int i=0; i<5; i++) {
            a[i] = Integer.parseInt(sc.next());
            if((a[i] % 10) != 0 && (min % 10) > (a[i] % 10)) {
                min = a[i];
                idx = i;
            }else if((a[i] % 10) != 0 && min > a[i] && (min % 10) >= (a[i] % 10)) {
                min = a[i];
                idx = i;
            }
            
        }
        int sum = 0;
        for(int i=0; i<5; i++) {
            if(i == idx) {
                sum += a[i];
            }else {
                if(a[i] % 10 == 0) {
                    sum += a[i];
                }else {
                    sum += a[i];
                    sum += 10 - a[i] % 10;
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int count =0;
	int ans =0;
    for(int i=1;i<=N;i++) {
    	if(i%2==1) {
    		for(int j=1;j<=i;j++) {
    			if(i%j==0) {
    				count++;}
    			}
    		if(count==8) {
    			ans++;
    		}
    		else {
    			count=0;
    		}
    }
	}
    System.out.println(ans);
	}
	}


Measured memory_bytes: 21844
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	string A, B;
	cin >> A >> B;
	int i = 0;
	if (A.length() > B.length()) {
		cout << "GREATER" << endl;
	}
	else if (A.length() < B.length()) {
		cout << "LESS" << endl;
	}
	else {
		while (i<A.length()) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				break;
			}
			else if (A[i] < B[i]) {
				cout << "LESS" << endl;
				break;
			}
			++i;
		}
		if (i == A.length()) {
			cout << "EQUAL" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

vector<ll> dec(ll n){
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            if(n / i == i) ret.pb(i);
            else ret.pb(i), ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

bool ok(ll b, ll n, ll s){ // nをb進法したものの各桁の和はsか?
    ll ret = 0;
    while(n > 0){
        ret += n % b;
        n /= b;
    }
    if (ret == s) return true;
    else return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll n, s;
    cin >> n >> s;
    if(n == s){
        output(n + 1, 0);
        return 0;
    }
    if(n < s){
        output(-1, 0);
        return 0;
    }
    vector<ll> D = dec(n - s);
    rep(i, D.size()) D[i]++;
    rep(i, D.size()){
        if(ok(D[i], n, s)){
            output(D[i], 0);
            return 0;
        }
    }
    output(-1, 0);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  ll x, y, min_x = 1, min_y = 1;

  re(i, n){
    std::cin >> x >> y;
    ll k = min_x/x + (min_x%x?1:0), t = min_y/y + (min_y%y?1:0);
    x*=max(k, t), y*=max(k, t);
    //std::cout << x << " " << y << '\n';
    min_x = x, min_y = y;
  }
  std::cout << min_x + min_y << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205000;

int n;
pair <int, int> v[MAXN];
int ans[MAXN];

int main() { 

  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i].first);
    v[i].second = i;
  }
  sort(v, v + n);

  for (int i = 0; i < n; i++) {
    if (i < n / 2) {
      ans[v[i].second] = v[n / 2].first;
    } else {
      ans[v[i].second] = v[(n / 2) - 1].first;
    }
  }

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

  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;

  int a = 1;

  for (int i = 0 ; i < N; i++) {

   if ( a < K ){
     a *= 2;
   } else {
     a += K;
   }
  }

  cout << a << endl;
}

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

int main()
{
	int N,T,A;
	cin >> N >> T >> A;
	double mintemp = 100000;
	int ans;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		double t = T - tmp * 0.006;
		if (mintemp > abs(t-A))
			ans = i + 1;
		mintemp = min(mintemp, abs(t - A));
	}
	cout << ans << endl;
	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 ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {
  ll N,K;
  cin >> N >> K;

  ll ans=N%K;

  ans=min(ans,abs(ans-K));
 
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  int datasets;
  double xa, ya, ra, xb, yb, rb;
  double dist;
  int i;

  scanf("%d", &datasets);
  for(i=0; i<datasets; i++){
    scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
    dist=sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
    if(dist>ra+rb) printf("0\n");
    else if(ra>dist+rb) printf("2\n");
    else if(rb>dist+ra) printf("-2\n");
    else printf("1\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

vector<bool> prime_judge() {
    vector<bool> is_prime(101010, true);
    is_prime[0] = is_prime[1] = false;
    rep(i, 2, 101010) {
        if (!is_prime[i]) {
            continue;
        }
        for (int now = i * 2; now < 101010; now += i) {
            is_prime[now] = false;
        }
    }
    return is_prime;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q;
    cin >> Q;
    vector<bool> is_prime = prime_judge();
    vector<int> cumsum(101010, 0);
    rep(i, 1, 101010) {
        cumsum[i] = cumsum[i - 1] + (i % 2 && is_prime[i] && is_prime[(i + 1) / 2]);
    }
    int L, R;
    rep(_, 0, Q) {
        cin >> L >> R;
        cout << cumsum[R] - cumsum[L - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> w(n);
    for (int i = 0; i < n; ++i) scanf("%d", &w.at(i));
    for (int i = 1; i < n; ++i) w.at(i) += w.at(i - 1);
    auto p = lower_bound(w.begin(), w.end(), w.back() / 2);
    printf("%d\n", min(*p * 2 - w.back(), w.back() - *(p - 1) * 2));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

ll nij(int a,int b){
  if(a==0) return 0;
  ll ans=1;
  if(b==1) return a;
  if(b%2==0) ans=nij(a,b/2)*nij(a,b/2);
  else ans=nij(a,b-1)*a;
  return ans%=MOD;
}

int main(){
  int n,k; cin >> n >> k;
  ll ans=0;
  vector<ll> mem(k+1,0);
  for(int i=k; i>=1; i--){
    int num=k/i;
    mem[i]=nij(num,n);
    for(int j=i*2; j<k+1; j=j+i){
      mem[i]-=mem[j];
      if(mem[i]<0) mem[i]+=MOD;
      else mem[i]%=MOD;
    }
    ans+=mem[i]*i;
    ans%=MOD;
  }
  cout << ans << endl;
return 0;
}


Measured memory_bytes: 4052
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  string str; cin >> str;
  const ll n = str.size();
  ll K; cin >> K; --K;
  set<string> s;
  rep(i, n) {
    rep(j, 1, 6) {
      if (i + j <= n) {
        s.insert(str.substr(i, j));
      }
    }
  }
  assert(s.size() > K);
  cout << *next(s.begin(), K) << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int x, y;
    cin >> x >> y;
    bool ans = false;
    rep(i, x + 1)
    {
        int now = 4 * i + 2 * (x - i);

        if (ans || now == y)
        {
            ans = true;
            break;
        }
    }

    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine()) != null) {
                string[] strs = line.Split(' ');
                double time0 = double.Parse(strs[0]);
                double time1 = double.Parse(strs[1]);

                if (time0 >= 70 || time1 >= 148) { Console.WriteLine("NA"); }
                else if (time0 >= 55 || time1 >= 116) { Console.WriteLine("E"); }
                else if (time0 >= 50 || time1 >= 105) { Console.WriteLine("D"); }
                else if (time0 >= 43 || time1 >= 89) { Console.WriteLine("C"); }
                else if (time0 >= 40 || time1 >= 83) { Console.WriteLine("B"); }
                else if (time0 >= 37.5 || time1 >= 77) { Console.WriteLine("A"); }
                else if (time0 >= 35.5 || time1 >= 71) { Console.WriteLine("AA"); }
                else { Console.WriteLine("AAA"); }

            }
        }
    }

}

Measured memory_bytes: 5668
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//****************************************************************************************************************************************//

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

//*****************************************************************************************************************************************//

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

//*****************************************************************************************************************************************//

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

//******************************************************************************************************************************************//


void solve(){
    int n,k;
    cin>>n>>k;
    v(int) a(n);
    int ans = 0;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        ans+=(a[i]>=k);
    }
    cout<<ans<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


Measured memory_bytes: 3884
#include<cstdio>
int n,m;char a[200],b[200],c[200];
int main(){scanf("%d%s%s%s",&n,a,b,c);for(int i=0;i<n;++i)m+=(a[i]==b[i]&&b[i]==c[i])?0:(a[i]==b[i]||b[i]==c[i]||a[i]==c[i])?1:2;printf("%d\n",m);return 0;}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int N, M, i, j,keta_tmp;
    int s[10],c[10];
    int suuzi[3] = {-1,-1,-1};

    scanf("%d %d",&N,&M);

    for(i=0; i<M; i++){
        scanf("%d %d",&s[i],&c[i]);
    }

    for(i=0; i<M; i++){//左からs[i]桁目がc[i]である
        keta_tmp = s[i]-1;
        if((keta_tmp == 0) && (c[i] == 0)){//一番上の桁が0の場合は存在しないので-1
            if(N != 1){
                printf("-1\n");
                return 0;
            }
        }
        if((suuzi[keta_tmp] == -1)||(suuzi[keta_tmp] == c[i])){//未入力か一緒の場合
            suuzi[keta_tmp] = c[i];
        } else {//一つの桁に違う数字を指定された場合
            printf("-1\n");
            return 0;
        }
    }

    if(N == 1){
        if(suuzi[0] == -1){
            printf("0");
        } else {
            printf("%d",suuzi[0]);
        }
    } else {
        for(i=0; i<N; i++){
            if(suuzi[i] == -1){
                if(i==0){
                    printf("1");
                } else {
                    printf("0");
                }
            } else {
                printf("%d",suuzi[i]);
            }
            //-1の時は0を代入するっていうのを後で書く
            //一番上の桁が指定されてない時は1
        }
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
int ans[3][3],a[3][3],b[3][3],d[3][3],o[3][3]; int x[maxn],sta[80]; int i,j,k,l,t,n,m,now,num,top;
void mult(int a[3][3],int b[3][3],int c[3][3]){
    int i,j,k;
    fo(i,0,2) fo(j,0,2) o[i][j]=0;
    fo(k,0,2) fo(i,0,2) fo(j,0,2) o[i][j]=(o[i][j]+(ll)a[i][k]*b[k][j]%mo)%mo;
    fo(i,0,2) fo(j,0,2) c[i][j]=o[i][j];
}
void work(int n){ int i,j; fo(i,0,2) fo(j,0,2) d[i][j]=(i==j); top=0; while (n){ sta[++top]=n%2; n/=2; } while (top){ mult(d,d,d); if (sta[top--]) mult(d,a,d); } }
int main(){
    scanf("%d%d",&n,&m); fo(i,1,m) scanf("%d",&x[i]); x[++m]=n;
    ans[0][0]=ans[0][2]=1; ans[0][1]=2; a[0][0]=a[0][2]=a[1][1]=a[1][2]=a[2][0]=1; a[0][1]=a[2][1]=a[2][2]=2;
    fo(i,0,2) fo(j,0,2) b[i][j]=a[i][j]; b[2][0]--; b[2][1]-=2; b[2][2]--;
    now=1; fo(i,1,m){ work(x[i]-now); mult(ans,d,ans); if (i==m) break; mult(ans,b,ans); now=x[i]+1; } num=ans[0][2]; (num+=mo)%=mo;
    printf("%d\n",num);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}

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

int main(){
    int X;
    cin >> X;
    
    int kakudo=X;
    int ans=1;
    while(kakudo % 360 !=0){
        ans++;
        kakudo += X;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3632
import heapq

l=list(map(int, input().split()))
N, M = l

A=list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A)

for _ in range(M):
    temp_min = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-temp_min//2))
print(-sum(A))


Measured memory_bytes: 14180
import java.util.Scanner;

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

        while(true)
        {
            String input = sc.next();
            String[] binput = input.split("");
            int iinput[] = new int[binput.length];
            int sum=0;

            if(input.equals("0")) break;

            int i;
            for(i=0; i<binput.length; i++)
            {
                iinput[i] = Integer.parseInt(binput[i]);
                sum += iinput[i];
            }

            System.out.println(sum);
        }
        sc.close();
    }
}


Measured memory_bytes: 27320
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        if(n==0&&m==0)break;
        vector<int> member;
        int temp;
        rep(i,n)
        {

            member.push_back(i+1);
        }
        vector<int>::iterator it = member.begin();

        rep(i,n-1)
        {
            rep(j,m-1)
            {
                ++it;
                if(it==member.end())it = member.begin();
            }
            member.erase(it);
            if(it==member.end())it = member.begin();
        }
        cout << member[0]<< endl;
    }

    return 0;
}

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

int main()
{
	string s;
	cin>>s;
	int a=(s[0]%48);
	int b=(a*10)+(s[1]%48);
	int c=((s[2]%48)*10)+(s[3]%48);
	
	 if(((b>=1)&&(b<=12))&&((c>=1)&&(c<=12)))
    {
        cout<<"AMBIGUOUS";
    }
    else if((b>=1)&&(b<=12))
        {
            cout<<"MMYY";
        }
    else if((c>=1)&&(c<=12))

        {
            cout<<"YYMM";
        }
        else
        {
            cout<<"NA";
        }
}

Measured memory_bytes: 3620
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n+1];
        for (int i=0; i < n; i++) a[i] = sc.nextInt();
        a[n] = k;

        Arrays.sort(a);

        int left = 0;
        int right = n;
        while (true) {
            int i = (left+right)/2;
            boolean[][] dp = new boolean[n+1][k+1];
            dp[0][0] = true;

            for (int j = 0; j < n; j++) {
                for (int l = 0; l <= k; l++) {
                    if (dp[j][l]) {
                        dp[j+1][l] = true;
                        if (i != j && l+a[j] <= k) {
                            dp[j+1][l+a[j]] = true;
                        }
                    }
                }
            }

            boolean f = false;
            for (int j = Math.max(k-a[i], 0); j < k; j++) {
                if (dp[n][j]) f = true;
            }

            if (right == left + 1) {
                if (f) System.out.println(i);
                else System.out.println(i+1);
                break;
            }

            if (f) right = i;
            else left = i;
        }
    }
}

Measured memory_bytes: 233000
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()

dp = [[[[0 for _ in  range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
for i in range(4):
    for j in range(4):
        for k in range(4):
            if i == 0 and j == 2 and k == 1 or \
                i == 0 and j == 1 and k == 2 or \
                i == 2 and j == 0 and k == 1:
                dp[3][i][j][k] = 0
            else:
                dp[3][i][j][k] = 1

for x in range(4,N+1):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if dp[x-1][i][j][k] == 0: continue
                    if j == 0 and k == 2 and l == 1 or \
                        j == 0 and k == 1 and l == 2 or \
                        j == 2 and k == 0 and l == 1: continue
                    if i == 0 and k == 2 and l == 1 or \
                        i == 0 and j == 2 and l == 1: continue
                    dp[x][j][k][l] = (dp[x][j][k][l] + dp[x-1][i][j][k]) % MOD

ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[-1][i][j][k]

print (ans % MOD)

Measured memory_bytes: 47724
def do(x, c):
    if len(x) == 1 or x.count(c) == len(x):return 0
    res = ""
    for i in range(len(x) - 1):
        if(x[i] == c or x[i+1] == c):res += c
        else: res += x[i]
    return 1 + do(res, c)

s = raw_input()

ans = 100
for c in "abcdefghijklmnopqrstuvwxyz":
    ans = min(ans, do(s, c))

print ans

Measured memory_bytes: 2692
N,M = map(int,input().split())
DP = [[float('inf')]*N for _ in range(N)]
B = []
for i in range(N):
  DP[i][i] = 0
for _ in range(M):
  a,b,c = map(int,input().split())
  DP[a-1][b-1] = c
  DP[b-1][a-1] = c
  B.append([a-1,b-1,c])
for k in range(N):
  for i in range(N):
    for j in range(N):
      DP[i][j] = min(DP[i][j],DP[i][k]+DP[k][j])   
ans = 0
for i in range(M):
    a,b,c = B[i]
    for j in range(N):
        if DP[j][b] == DP[j][a] + c:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9324
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
typedef pair<int,char> P;
int main(void)
{
	int n,i,j,x;
	P pp[10];
	int kati[10],make[10],zyun[10];
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			scanf(" %c",&pp[i].second);
			zyun[i]=n-i;
			kati[i]=0;
			make[i]=0;
			for(j=0;j<n-1;j++)	{
				scanf("%d",&x);
				if(x==0)	kati[i]++;
				if(x==1)	make[i]++;
			}
			pp[i].first=kati[i]*10000+(1000-make[i])*100+zyun[i];
		}
		sort(pp,pp+n,greater<P>() );
		for(i=0;i<n;i++)	{
			printf("%c\n",pp[i].second);
		}
	}
	return 0;
}


Measured memory_bytes: 1032
import sys
A,B,C,K = map(int,input().split())
if K%2 == 0:
    if abs(A-B) >10**18:
        print("Unfair")
    else: 
        print(A-B)
elif K % 2 == 1:
    if abs(B-A) > 10**18:
        print("Unfair")
    else:
        print(B-A)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
#define ll long long 
#define pb push_back 
#define vec vector<int> 
#define fo(i,n) for (ll i = 0; i < n; i++)
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second 
using namespace std;  
int main()
{ 
  ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll a =min(K, X / D);
    K -=a;
    X -=a* D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int k,n;
int a[1000010],f[1000010],maxn=-1e7;
int main()
{
	scanf("%d %d",&k,&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(i!=n) f[i]=a[i+1]-a[i];
		else f[i]=k-a[i]+a[1];
		maxn=max(f[i],maxn);
	}
	k-=maxn;
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
int main(){

  int a,n,i;

  for(i = 0; i < 4; i++){

    scanf("%d %d",&a,&n);

    if(a == 1) printf("%d\n",6000*n);
    if(a == 2) printf("%d\n",4000*n);
    if(a == 3) printf("%d\n",3000*n);
    if(a == 4) printf("%d\n",2000*n);

  }

  return 0;

}

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

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

}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+1;
const ll INF=4e18;
vector<ll> adj_list[maxn];
ll parent[maxn],height[maxn];
ll dfs(ll s,ll p)	// to compute height and the parent of each node
{
	ll h=0;
	parent[s]=p;
	for(ll i=0;i<adj_list[s].size();i++)
	{
		if(adj_list[s][i]!=p)
		{
			h=max(h,1+dfs(adj_list[s][i],s));
		}
	}
	height[s]=h;
	return h;
}
void solve()
{
	ll N,A,T;
	cin>>N>>T>>A;
	for(ll i=0;i<N-1;i++)
	{
		ll u,v;
		cin>>u>>v;
		adj_list[u].push_back(v);
		adj_list[v].push_back(u);
	}
	dfs(A,-1);	// fix A as the root of the tree
	ll cur=T,ans=0,dist=0;
	while(cur!=A)	// to find the distance between T and A 
	{
		cur=parent[cur];
		dist++;
	}
	if(height[T]>0) ans=height[T]+dist-1;
	cur=parent[T];
	ll moved=0;
	while(dist>=0&&cur!=A)
	{
		dist--;	// movement of T
		if(dist==1) ans=max(ans,moved+1LL);
		else if(dist==0) ans=max(ans,moved);
		else if(dist>0) ans=max(ans,moved+dist+height[cur]-1);
		dist--;	// movement of A
		moved++;
		cur=parent[cur];
	}
	/*cout<<"Parent\n";
	for(ll i=1;i<=N;i++)
	{
		cout<<i<<" "<<parent[i]<<"\n";
	}
	cout<<"Height\n";
	for(ll i=1;i<=N;i++)
	{
		cout<<i<<" "<<height[i]<<"\n";
	}*/
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 12544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 3 || x == 5 || x == 7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

                   Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140