akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 2e9;
// const ll INF = 1e12;
const int MAX = 1e6;

ll gcd(ll a, ll b) { // aとbの最大公約数（ユークリッドの互除法）
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { // aとbの最小公倍数
    return a / gcd(a, b) * b;
}

ll lcm(vl &a) { // 3つ以上の整数の最小公倍数
    ll r = 1;
    rep(i, (int)a.size()) {
        r = lcm(r, a[i]);
    }
    return r;
}

int main() {
    // input
    int n;
    cin >> n;
    vl t(n);
    rep(i, n) {
        cin >> t[i];
    }
    // solve
    ll ans = lcm(t);
    // output
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
const int INF = 1<<29;

int overlap2(string a, string b) {
  int n = a.size(), m = b.size();
  REP(i, n+1)
    if (a.substr(i, min(m, n-i)) == b.substr(0, min(m, n-i)))
      return min(m,n-i);
}

int table[14][14];
int dp[1<<14][14];

int main() {
  int n;
  while(cin>>n,n) {
    string s[n];
    REP(i,n)
      cin >> s[i];
    REP(i, n)
      REP(j, n)
        table[i][j] = overlap2(s[i], s[j]);
    REP(S, 1<<n) REP(j, n) dp[S][j] = INF;
    REP(i, n) dp[1<<i][i] = s[i].size();
    REP(S, 1<<n) REP(i, n) {
      if (S>>i&1) REP(j, n) {
          if (!(S>>j&1)) {
            if (table[i][j] == s[j].size())
              dp[S|1<<j][i] = min(dp[S|1<<j][i], dp[S][i]);
            else
              dp[S|1<<j][j] = min(dp[S|1<<j][j], dp[S][i] + (int)s[j].size() - table[i][j]);
          }
        }
    }
    cout << *min_element(dp[(1<<n)-1], dp[(1<<n)-1]+n) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define pi 3.14159265358979323846
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--)
  
long long fact(long long a, long long b){
    int r= max(a, b);
    int v= min(a, b);
    int l=1;
    // if(v==0)
    for(int i=r+1; i<=a+b; i++){
        l*=i;
    }
    for(int i=v; i>=2; i--){
        l/=i;
    }
    return l;
}

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

int powr(int a) { 
    int var=1;
    for(int i=0; i<a; i++){
        var*=2;
    }
    return var;
}

signed main(){   
    fast;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int c=0, d=0;
    for(int i=0; i<n; i++){
        if(s[i]=='R')
            c++;
    }
    rep(i,0,c){
        if(s[i]=='R')
            d++;
    }
    cout << min(c, c-d);
}

Measured memory_bytes: 3744
class Dice:
        def __init__(self, strList):
                self.label = strList[:]
                self.label[0] = int(self.label[0])
                self.label[1] = int(self.label[1])
                self.label[2] = int(self.label[2])
                self.label[3] = int(self.label[3])
                self.label[4] = int(self.label[4])
                self.label[5] = int(self.label[5])
        def reset(self, strList):
                self.label = strList[:]
                self.label[0] = int(self.label[0])
                self.label[1] = int(self.label[1])
                self.label[2] = int(self.label[2])
                self.label[3] = int(self.label[3])
                self.label[4] = int(self.label[4])
                self.label[5] = int(self.label[5])
        def rollE(self):
                temp = self.label[3]
                self.label[3] = self.label[5]
                self.label[5] = self.label[2]
                self.label[2] = self.label[0]
                self.label[0] = temp
        def rollN(self):
                temp = self.label[0]
                self.label[0] = self.label[1]
                self.label[1] = self.label[5]
                self.label[5] = self.label[4]
                self.label[4] = temp
        def rollA(self):
                temp = self.label[3]
                self.label[3] = self.label[4]
                self.label[4] = self.label[2]
                self.label[2] = self.label[1]
                self.label[1] = temp
        def printDice(self):
                print(self.label)

def check(d1, d2):
        for i in range(6):
                if d1.label[i] != d2.label[i]:
                        return False
        return True

strDice = input()
diceList = strDice.split()
dice1 = Dice(diceList)

strDice = input()
diceList = strDice.split()
dice2 = Dice(diceList)
isEqual = False

for j in range(6):
        for k in range(4):
                dice1.rollA()
                if check(dice1, dice2):
                        isEqual = True
        if j % 2 == 0:
                dice1.rollE()
        else:
                dice1.rollN()

if isEqual:
        print('Yes')
else:
        print('No')


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

using namespace std;
typedef long long ll;


string ss[200050],ans[200050];
map<string,int>mp;
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=0; i<n; i++)
    {
        string s;
        cin>>s;
        if(!mp[s])
            ss[sum++]=s;
        mp[s]++;
    }
    int m=-1;
    for(int i=0; i<sum; i++)
        if(m<mp[ss[i]])
            m=mp[ss[i]];
    int k=0;
    for(int i=0; i<sum; i++)
        if(m==mp[ss[i]])
            ans[k++]=ss[i];
    sort(ans,ans+k);
    for(int i=0; i<k; i++)
        cout<<ans[i]<<endl;;
    return 0;
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  string s;
  cin>>s;
  cout << s.substr(0,3) << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> a(n);
  rep(i,n) a[i] = i+1;
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(), a.end()));
  cout << abs(mp[p]-mp[q]) << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int m; cin>>m;
   cout << 48 - m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    vector<int> v(100);
    int cnt=1;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            v[cnt++]=i*j;
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=81;i++){
        if(v[i]==n) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld a, b, c; cin >> a >> b >> c;

	bool ok = false;

	for4 (i, 1ll, 10001ll, 1ll) {
		if (((a * i) % b) == c) {
			ok = true;
			break;
		}
	}

	puts(ok ? "YES" : "NO");
	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3612
def A():
    S = list(input())
    cnt = 0
    p = 3
    keyence = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
    for i in range(7):
        if S[i] != keyence[i]:
            cnt = i
            break
    ans = 0
    if S[:7:] == keyence:
        ans = 1
    elif S[len(S) - 7::] == keyence:
        ans = 1
    elif S[len(S) - (7 - cnt)::] == keyence[cnt::]:
        ans = 1
    else:
        ans = -1
    if ans == 1:
        print("YES")
    else:
        print("NO")
    #print(cnt, S[len(S) - (7 - cnt)::], keyence[cnt::])
A()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <cstdlib>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  string S;
  cin >> S;
  int res = 1e9;

  for (int i=0; i<S.size()-2; ++i) {
    int val = stoi(S.substr(i, 3));
    if (res > abs(val-753)) res = abs(val-753);
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 384
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), k = sc.nextInt();
        long[] h = new long[n];
        long[] dp = new long[n];
        for(int i=0;i<n;i++) {
            h[i] = sc.nextLong();
            dp[i] = Long.MAX_VALUE;
        }

        dp[0] = 0;
        for(int i=1;i<n;i++) {
            for(int j=Math.max(0, i-k);j<i;j++) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i] - h[j]));
            }
        }
        pw.println(dp[n-1]);
        pw.close();
	}

}

Measured memory_bytes: 34332
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

char N, M;

void input() {
  cin>>N>>M;
}
void solve() {
  debug(N);
  debug(M);
  int k=N,l=M;
  debug(k);
  debug(l);
  rep(i,0,10000)debug(k);
  cout<<(k<l ? "<" : (k==l ? "=" : ">"))<<endl; 
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N_MAX 100000

int parse(char *text);

int main(void)
{
	int n, i, p_idx, count;
	int perm[N_MAX+1];
	char buf[7];

	scanf("%d%*c", &n);

	i = 0;
	p_idx = 1;
	while(1) {
		int flag = 0;
		scanf("%c", &buf[i]);
		if(buf[i] == ' ' || buf[i] == '\n') {
			if(buf[i] == '\n') flag = 1;
			buf[i] = '\0';
			perm[p_idx++] = parse(buf);
			//printf("%d,%d\n", p_idx-1, perm[p_idx-1]);
			if(flag) break;
			i = 0;
			continue;
		}
		i++;
	}

	count = 0;
	for(i=1;i<n;i++) {
		if(i == perm[i]) {
			count++;
			if(i+1 == perm[i+1]) {
				i++;
			}
		}
	}

	if(i == perm[i]) count++;

	printf("%d\n", count);
	
	return 0;
}

int parse(char *text)
{
	int i, ret, len;

	i = 0;
	while(1) {
		if(text[i] == '\0') {
			len = i;
			break;
		}
		i++;
	}

	ret = 0;
	for(i=len-1;i>=0;i--) {
		int a = 1, j;
		for(j=0;j<len-i-1;j++) a *= 10;
		ret += (int)(text[i] - '0') * a;
	}

	return ret;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){

    int N,T,i,minc=inf,ans;
    cin >> N >> T;
    int c[N],t[N];
    for(i=0 ; i<N ; i++){
        cin >> c[i] >> t[i];
    }

    for(i=0 ; i<N ; i++){
        if(T-t[i] >= 0){
            minc = min(minc,c[i]);
            if(minc == c[i]){
            }
        }
    }

    if(minc == inf){
        cout << "TLE" << endl;
    }else{
        cout << minc << endl;
    }
}


Measured memory_bytes: 256
import sys
import math

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    
    n = 0
    for i in range(1, len(A)):
        if A[i-1] > A[i]:
            n += A[i-1] - A[i]
            A[i] = A[i-1]
    print(n)

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

int main(){
	// sengen
	int k,a,b;
	// nyuryoku
	cin >> k >> a >> b;
	// keisan
	int sum = 0;
	for(int i=a;i<=b;i++){
		if(i % k == 0){
			sum++;
		}
	}
	// syutsuryoku
	if(sum == 0){
		cout << "NG";
	}else{
		cout << "OK";
	}
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
num_odd = sum([1 for i in a if i % 2 == 1])
num_4 = len([1 for i in a if i % 4 == 0])
#print(a,num_odd,num_4)
if num_4 >= num_odd:
    print("Yes")
else: 
    if num_odd == (n+1)/2:
        if num_4 == (n-1)/2:
            print("Yes")
            exit(0)
    print("No")


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

typedef uint32_t u32;
typedef int64_t s64;

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		for (int i = 0; i <= n; i++) {
			a[i].resize(i+1, 1);
			for (int j = 1; j < i; j++) a[i][j] = a[i-1][j] + a[i-1][j - 1];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

int64_t gu(int m, int k, const std::vector<int> &revised) {
	int n = revised.size();
	assert(n <= 25);
	int cnt = 0;
	for (int i = 1; i < 1 << n; i++) {
		u32 tmp0 = 0, tmp1 = ~0;
		for (int j = 0; j < n; j++) if (i >> j & 1) tmp0 |= revised[j], tmp1 &= revised[j];
		if (__builtin_popcount(i) <= k && tmp0 == (1U << m) - 1 && !tmp1) cnt++;
	}
	return cnt;
}
int64_t fast(int m, int k, const std::vector<int> &revised) {
	int n = revised.size();
	k = std::min(k, n);
	int64_t ncrsum[n + 1][n + 1];
	memset(ncrsum, 0, sizeof(ncrsum));
	for (int i = 0; i <= n; i++) {
		ncrsum[i][0] = ncrsum[i][i] = 1;
		for (int j = 1; j < i; j++) ncrsum[i][j] = ncrsum[i - 1][j - 1] + ncrsum[i - 1][j];
	}
	for (int i = 0; i <= n; i++) for (int j = 0; j < n; j++) ncrsum[i][j + 1] += ncrsum[i][j];
	uint64_t res = 0;
	for (int i = 0; i < 1 << m; i++) {
		std::map<int, int> ma;
		for (auto j : revised) ma[j & i]++;
		uint64_t cur = 0;
		for (auto j : ma) cur += ncrsum[j.second][k] - 1;
		if (__builtin_popcount(i) & 1) res -= cur;
		else res += cur;
	}
	return res;
}

std::mt19937 rnd;
bool random_check(int m, int n) {
	int k = std::uniform_int_distribution<>(1, n)(rnd);
	std::vector<int> revised(n);
	for (auto &i : revised) i = std::uniform_int_distribution<>(0, (1 << m) - 1)(rnd);
	auto r0 = gu(m, k, revised);
	auto r1 = fast(m, k, revised);
	if (r0 != r1) {
		std::cerr << "FAILED" << std::endl;
		std::cerr << m << " " << k << std::endl;
		for (auto i : revised) std::cerr << i << " ";
		std::cerr << std::endl;
		std::cerr << r0 << " " << r1 << std::endl;
		return false;
	}
	return true;
}

int main() {
	int n = ri(), k = ri();
	
	u32 s = ri(); // and
	u32 t = ri(); // or
	if ((s & t) != s) {
		puts("0");
		return 0;
	}
	u32 a[n];
	for (auto &i : a) i = ri();
	
	u32 mask = ~s & t;
	std::vector<int> all;
	
	std::vector<int> revised;
	for (int i = 0; i < 18; i++) if (mask >> i & 1) all.push_back(i);
	int m = all.size();
	for (auto i : a) {
		if ((i & s) != s) continue;
		if (~t & i) continue;
		int cur = 0;
		for (int j = 0; j < (int) all.size(); j++) if (i >> all[j] & 1) cur |= 1 << j;
		revised.push_back(cur);
	}
	n = revised.size();
	printf("%" PRId64 "\n", revised.size() <= 0 ? gu(m, k, revised) : fast(m, k, revised));
	
	return 0;
}


Measured memory_bytes: 3736
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int a,c=0,d=0,e,max,min,ji=0;
    scanf("%d",&a);
    int b[a];
    for(c=0;c<a;c++)
    {scanf("%d",&b[c]);
    d=d+(b[c]-a)*(b[c]-a);}
    max=b[0]; min=b[0];
    for(c=1;c<a;c++)
    {
        max=max>b[c]? max:b[c];
        min=min<b[c]? min:b[c];
    }
    for(;min<=max;min++)
    {
        ji=0;
        for(e=0;e<a;e++)
            ji=ji+(b[e]-min)*(b[e]-min);
        d=d<ji? d:ji;
    }
    printf("%d",d);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,f[200009],pas;
map <long long, long long> m;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    for(i=1; i<=a; i++) cin>>f[i];
    for(i=1; i<=a; i++){
        pas+=m[f[i]-i];
        m[-i-f[i]]++;
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 27896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int ta,aa;
    if(C%B==0){
        ta=C/B;
    }else{
        ta=C/B+1;
    }
    if(A%D==0){
        aa=A/D;
    }else{
        aa=A/D+1;
    }
    if(ta<=aa){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var nm = n + m;
            if (n == 0 && m == 0) break;
            var a = new int[nm];
            if (n == 0 | m == 0)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int i = 0; i < nm; i++)
                    a[i] = int.Parse(line[i]);
            }
            else
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int i = 0; i < n; i++)
                    a[i] = int.Parse(line[i]);
                line = Console.ReadLine().Trim().Split(' ');
                for (int i = 0; i < m; i++)
                    a[n + i] = int.Parse(line[i]);
            }
            if (nm == 1) { Console.WriteLine(a[0]); goto end; }
            Array.Sort(a);
            var pre = 0;
            var res = 0;
            for (int i = 0; i < nm; i++)
            {
                res = Math.Max(res, a[i] - pre);
                pre = a[i];
            }
            Console.WriteLine(res);
            end:;
        }
    }
}


Measured memory_bytes: 18360
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
	int w=0,f=1;
	char c=' ';
	while(c<'0'||c>'9')c=getchar(),f=c=='-'?-1:f;
	while(c>='0'&&c<='9')w=w*10+c-48,c=getchar();
	return w*f;
}
const long long p=1e9+7;
int a[10003];
signed main(){
	int n=read();
	if(n<3) puts("0"),exit(0);
	if(n==3) puts("1"),exit(0);
	a[3]=a[4]=a[5]=1,a[6]=2;
	for(int i=7; i<=n; i++) { a[i]=1; for(int j=3; j+3<=i; j++) a[i]+=a[j],a[i]%=p; }
	printf("%lld\n",a[n]);
	return 0;
}

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

int main(){
  int N,Y;
  cin>>N>>Y;
  bool t=1;
  for(int i=0;i<=N;i++){
    if (t!=1){
      break;
    }
    for(int j=0;j<=N-i;j++){
      int k=N-i-j;
      int sum=10000*i+5000*j+1000*k;
      if(sum==Y){
        cout<<i<<" "<<j<<" "<<k<<endl;
        t=0;
        break;
      }
    }
  }
  if(t){
    cout<<"-1 -1 -1"<<endl;
  }
}

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

const int MAXV = 100005;

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


    int oddarr[MAXV] = {}, evenarr[MAXV] = {};
    rep(i, n) {
        int c;
        cin >> c;
        if ((i + 1) % 2 == 1) oddarr[c]++;
        else evenarr[c]++;
    }

    int maxodd = 0, secondodd = 0;
    int maxeven = 0, secondeven = 0;
    int x, y;

    rep(i, MAXV) {
        if (maxodd < oddarr[i]) x = i;
        if (maxeven < evenarr[i]) y = i;
        maxodd = max(maxodd, oddarr[i]);
        maxeven = max(maxeven, evenarr[i]);
    }

    int ans = 0;
    
    sort(oddarr, oddarr + MAXV, greater<int>());
    sort(evenarr, evenarr + MAXV, greater<int>());

    if (x != y) ans = n - maxodd - maxeven;
    else ans = min(n - maxodd - evenarr[1], n - oddarr[1] - maxeven);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
# -*-coding:utf-8

import fileinput
import math

def main():
    offiHouse = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]   #y, x, z

    n = int(input())

    for i in range(n):
        a, b, c, d = map(int, input().split())

        offiHouse[a-1][b-1][c-1] += d

    for i in range(4):
        for j in range(3):
            for k in range(10):
                print('', offiHouse[i][j][k], end='')
            print()
        if(i != 3):
            print('#' * 20)

if __name__ == '__main__':
    main()

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

int main()
{
  int k;
  cin >> k;
  queue<int64_t> q({1, 2, 3, 4, 5, 6, 7, 8, 9});
  for (int i = 0; i < k - 1; i++)
  {
    auto x = q.front();
    auto mod = x % 10;
    q.pop();
    if (mod != 0)
    {
      q.push(x * 10 + mod - 1);
    }
    q.push(x * 10 + mod);
    if (mod != 9)
    {
      q.push(x * 10 + mod + 1);
    }
  }
  cout << q.front() << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;

class Main {
  public static void main(String args[]) {

    Scanner scan = new Scanner(System.in);
    int num = scan.nextInt();
    int skill = scan.nextInt();
    long count = 0;
    int[] mon = new int[num];

    for(int i = 0; i < num; i++){
      mon[i] = scan.nextInt();
    }

    Arrays.sort(mon);
    for(int i = num - 1; i >= 0; i--){
      if (skill == 0){
        break;
      }
      mon[i] = 0;
      skill--;
    }

    for(int i = 0; i < num; i++){
      count += mon[i];
    }
    //for(int i = 0; i < num; i++){
      //System.out.println(mon[i]);
    //}

    System.out.println(count);
  }
}


Measured memory_bytes: 66284
import sys
input = sys.stdin.readline


def compress_coordinate(x: list, key=None, reverse=False):
    zipped = {}
    unzipped = {}
    for i, xi in enumerate(sorted(x, key=None, reverse=reverse)):
        zipped[xi] = i + 1
        unzipped[i + 1] = xi
    return zipped, unzipped


class BIT1():
    """
    Binary Indexed Tree (1-indexed)
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)

    def add(self, idx, x):
        # add x to idx-th element
        # idx: 1-indexed
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        # get sum of [1, idx]
        # idx: 1-indexed
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s

    def bisect_left(self, w):
        # condition : always all element is not minus
        # return minimum idx where bit.sum(idx) >= w
        if w <= 0:
            return 0
        idx = 0  # self.bit[idx] < w
        k = 1 << ((self.n).bit_length() - 1)
        while k > 0:
            if idx + k <= self.n and self.bit[idx + k] < w:
                w -= self.bit[idx + k]
                idx += k
            k = k >> 1
        return idx + 1


q = int(input())
query = []
coord = set()
for _ in range(q):
    s = input()
    if s[0] == '1':
        # update query
        _, a, b = map(int, s.split())
        coord.add(a)
        query.append((1, a, b))
    else:
        # evaluation query
        query.append((2, ))

zipped, unzipped = compress_coordinate(list(coord))
a_sum = b_sum = 0
bit = BIT1(len(coord))
for i in range(q):
    if query[i][0] == 1:
        a = query[i][1]
        b = query[i][2]

        if i > 0:
            n = bit.sum(len(coord))
            idx1 = bit.bisect_left(n // 2)
            idx2 = bit.bisect_left(n // 2 + 1)
            if a < unzipped[idx1]:
                a_sum += unzipped[idx1] - a
            elif a > unzipped[idx2]:
                a_sum += a - unzipped[idx2]

        b_sum += b
        bit.add(zipped[a], 2)
    else:
        n = bit.sum(len(coord))
        idx1 = bit.bisect_left(n // 2)
        print(unzipped[idx1], b_sum + a_sum)


Measured memory_bytes: 102100
#include <stdio.h>

int F[45];
int N;
/*

  int fibonacci(int n){
  if (n == 0 || n == 1)return F[n] = 1;
  if(F[n] != NULL)return F[n];

  return F[n] = fibonacci(n - 2) + fibonacci(n -1);
  } 
*/
void makeFibonacci(void){
  int i;
  F[0] = 1;
  F[1] = 1;
  //printf("F[0] = %d\n", F[0]);
  //printf("F[1] = %d\n", F[1]);
 
  // printf("N = %d\n",N);




  for(i = 2 ; i <= N ; i++){

    F[i] = F[i - 2] + F[i - 1];

    //printf("F[%d] = %d\n", i,F[i]);
  }

  printf("%d\n",F[N]);

}

int main(){

  int num;

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

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int lim=3005;
const ll mod=1000000007;

ll dp[100005][102];//cuksy i bachory

int t[102];

int n,k;
ll ret;
ll pr(int x, int y,int n2){
   
	if(x) {
      ret=dp[y][n2]-dp[x-1][n2];
      if(ret<0) ret+=mod;
      return ret;
	}
	return dp[y][n2];
}


inline void wc(int *n23) //tylko dodatnie
{
    register char c23 = 0;
    while (c23 < 33) c23=getc_unlocked(stdin);
    (*n23) = 0;
    while (c23>32) {(*n23)=(*n23)*10LL + (c23-48); c23=getc_unlocked(stdin);}
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	//cin>>n>>k;
	wc(&n); wc(&k);

	for(int i=1;i<=n;i++) wc(&t[i]);//cin>>t[i];
	for(int i=0;i<=n;i++) dp[0][i]=1;
	for(int i=0;i<=k;i++) dp[i][0]=1;

	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[j][i]=pr(max(0,j-t[i]),j,i-1)+pr(0,j-1,i);
			dp[j][i]%=mod;
		}
	}

	//wypisz();
	cout<<pr(k,k,n)%mod;
	return 0;
}


Measured memory_bytes: 80000
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

const int mod = 1000000007;

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<int> > dp(H+1, vector<int>(W,0));
  dp[0][0] = 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      for (int k = 0; k < 1 << (W - 1); k++) {
        // 2本の横線が繋がっていないか調べる
        bool ok = true;
        for (int l = 0; l < W - 2; l++) {
          if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
            ok = false;
          }
        }
        if (ok) {
          if (j >= 1 && ((k >> (j-1)) & 1)) {
            // 左方向に横線をたどるケース
            dp[i+1][j - 1] += dp[i][j];
            dp[i+1][j-1] %= mod;
          } else if (j <= W -2 && ((k >> j) & 1)) {
            // 右方向に横線をたどるケース
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= mod;
          } else {
            // 横線を辿らないケース
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
          }
        }
      }
    }
  }
  cout << dp[H][K - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int flag = 0;
  for(int i = 0; i < N; i++){
    if(A[i] % 2 == 0){
      if(A[i]%3 != 0 && A[i]%5 != 0){
        flag = 1;
        break;
      }
    }
  }
  if(flag == 0){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  for(auto&& e:a)cin>>e;
  bitset<4000001> dp;
  dp.set(0, true);
  int sum=0;
  for(auto&& e:a){
    dp |= dp<<e;
    sum += e;
  }
  for(int i=(sum+1)/2;i<=sum;++i) {
    if(dp.test(i)) {
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


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

int main()
{
  int a,b,c;
  int max;
  cin >> a >> b >> c;

  if( a > b )
    {swap(a , b);}
  if( b > c )
    {swap(b , c);}
  if( a > b )
    {swap(a , b);}

  cout << a << " " << b << " " << c << endl;

  return 0;
}



Measured memory_bytes: 3108
#include <iostream>

using namespace std;
 
int main(void){
	
	int A,B;
	
	cin>>A>>B;
	
	if(A<=5)
		cout<<0;
	else if(A>=6 && A<=12)
		cout<<B/2;
	else
		cout<<B;
	
	return 0;
}

Measured memory_bytes: 256
s = gets
if s.length == 2
	if s[0] == s[1]
		printf '%d %d',1,2
		exit
	else
		printf '%d %d',-1,-1
		exit
	end
end
(s.length-2).times do |index|
	if s[index] == s[index + 1]
		printf '%d %d',index+1,index+2
		exit
	elsif s[index] == s[index + 2]
		printf '%d %d',index+1,index+3
		exit
	end
end
printf '%d %d',-1,-1
exit

Measured memory_bytes: 1916
#include<stdio.h>
int main(){
  double w;
  int f;
  char *p[11]={"light fly","fly","bantam","feather","light","light welter",
	       "welter","light middle","middle","light heavy","heavy"};
  
  while(scanf("%lf",&w)!=EOF){
    f=w>48?w>51?w>54?w>57?w>60?w>64?w>69?w>75?w>81?w>91?10:9:8:7:6:5:4:3:2:1:0;
    puts(p[f]);
  }
  return 0;
}

Measured memory_bytes: 0
n, q = map(int, input().split(' '))
s = input()
l_r = []
for _ in range(q):
    l_r.append(tuple(map(int, input().split(' '))))

n = [0]
c = 0
for i in range(1, len(s)):
    if s[i-1:i+1] == 'AC':
        c += 1
    n.append(c)

for (l, r) in l_r:
    print(n[r - 1] - n[l - 1])

Measured memory_bytes: 19772
#include<stdio.h>
int isPrime(int x){
  int i;
  if(x==2) return 1;
  if(x<2 || x%2==0) return 0;
  for(i=3;i*i<=x;i=i+2){
    if(x%i==0) return 0;
  }
  return 1;
}
int main(){
  int n,i,count=0,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    isPrime(a);
    if(isPrime(a)) count++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;

int main() {
  long long H; cin >> H;
  
  int i = 1;
  while (true) {
    long long target = pow(2, i);
    if (target > H) {
      cout << (target - 1) << endl;
      return 0;
    }
    i++;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
vector<int> vec;
vector<int>::iterator it;
int n, x, num;
signed main(){
	while (~scanf("%d", &n))
	{
		vec.clear();
		num = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &x);
			x = 1e9 + 7 - x;
			if (vec.empty())
			{
				vec.push_back(x);
				num++;
			}
			else
			{
				it = upper_bound(vec.begin(), vec.end(), x);
				if (it == vec.end())
				{
					vec.push_back(x);
					num++;	
				}
				else
				{
					*it = x;
				}	
			}
		}
		printf("%d\n", num);
	}
}


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

int popCount(int x) {
  int cnt = 0;
  while (x != 0) {
    x &= x - 1;
    cnt++;
  }
  return cnt;
}

int main(void) {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S[i];

  int ans = (H - 1) + (W - 1);
  for (int tateComb = 0; tateComb < (1 << (H - 1)); tateComb++) {
    int vdiv = 0;
    int hdiv = popCount(tateComb);
    int prevVdiv = -1;
    vector<bool> hPartitions;
    int x = tateComb;
    for (int i = 0; i < H - 1; i++) {
      hPartitions.push_back(x % 2);
      x /= 2;
    }
    vector<int> cntPerBlock(hdiv + 1, 0);
    bool hFail = false;
    for (int w = 0; w < W; w++) {
      int curBlock = 0;
      bool fail = false;
      for (int h = 0; h < H; h++) {
        if (S[h][w] == '1') cntPerBlock[curBlock]++;
        if (cntPerBlock[curBlock] > K) {
          fail = true;
          break;
        }
        if (h < H - 1 && hPartitions[h]) curBlock++;
      }
      if (fail) {
        if (prevVdiv == w - 1) {
          hFail = true;
          break;
        }
        prevVdiv = w - 1;
        vdiv++;
        w--;
        fill(cntPerBlock.begin(), cntPerBlock.end(), 0);
      }
    }
    if (!hFail) ans = min(ans, vdiv + hdiv);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag=true;
    rep(i, (n-1)/2){
        if(s[i]!=s[(n-1)/2-1-i]||s[n-1-i]!=s[(n+3)/2-1+i]||s[i]!=s[n-1-i]){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
    return 0;
}

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

int N, K;
int g[5050];
ll C[5050];
int vis[5050];
ll S[5050]; // 사이클 구간 합을 찾아내기 위해

int main()
{
	scanf("%d %d", &N, &K);
	for(int i=1; i<=N; i++)
		scanf("%d", &g[i]);
	for(int i=1; i<=N; i++)
		scanf("%lld", &C[i]);
	ll res = -INF;
	for(int i=1; i<=N; i++) // n에서 출발했을 때
	{
		memset(vis, -1, sizeof(vis));
		ll sum = 0;
		int n = i, k = K, p = 1;
		vis[0] = 0; S[0] = 0;
		while(1)
		{
			n = g[n];
			sum += C[n];
			k--;

			res = max(res, sum);
			if (k == 0) break;

			if (vis[n] != -1) // 사이클 처리
			{
				ll s = sum - S[n], c = p - vis[n];
				if (s > 0) // 최대한 이동
				{
					ll cnt = k / c;
					sum += s*cnt;
					k %= c;

					res = max(res, sum);
					while(k--)
					{
						n = g[n];
						sum += C[n];
						res = max(res, sum);
					}
				}
				else // 한 바퀴 내에서만 결정
				{
					k = min(k, (int)c);
					res = max(res, sum);
					while(k--)
					{
						n = g[n];
						sum += C[n];
						res = max(res, sum);
					}
				}
				break;
			}
			vis[n] = p++; S[n] = sum;
		}
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 3924
#include <stdio.h>


int main (void){
int Y, N, y, r, a, b, c, A[100], B[100], C[100], i = 1;
scanf("%d %d", &N, &Y);
A[1] = -1;
if(Y % 1000 != 0){
	printf("-1 -1 -1\n");
}
else{
	y = Y / 1000;
	r = y % 5;
    for(c = r; c <= N; c = c + 5){
    	a = (y + 4 * c) / 5 - N;
    	b = 2 * N - (y + 9 * c) / 5;
    	if(a >= 0 && b >= 0){
    		A[i] = a;
    		B[i] = b;
    		C[i] = c;
    	}
    }
    if(A[1] == -1){
    	printf("-1 -1 -1\n");
    }
    else{
    	printf("%d %d %d", A[1], B[1], C[1]);
    }
}
return 0;
}

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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    string S;
    cin >> S;
    if(S == "AAA" || S=="BBB") cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// 枝定義
struct Edge
{
	int from;
	int	to;
	int	dist;
	Edge(){}
	Edge(int from, int to, int dist): from(from), to(to), dist(dist){}
};

// ワーシャルフロイド
template<class T>
class WarshallFloyd
{
public:
	// distList[i][j] = iからjまでの最短距離
	vector<vector<T>> distList;

public:
	WarshallFloyd(int nodeNum, const vector<Edge> &edgeList)
	{
		distList.resize(nodeNum, vector<T>(edgeList.size(), (T)1e9));
		for (auto edgeOne : edgeList) {
			distList[edgeOne.from][edgeOne.to] = edgeOne.dist;
			distList[edgeOne.to][edgeOne.from] = edgeOne.dist;
		}

		for (int nodeCnt = 0; nodeCnt < nodeNum; nodeCnt++) {
			for (int i = 0; i < nodeNum; i++) {
				for (int j = 0; j < nodeNum; j++) {
					distList[i][j] = min(distList[i][j], distList[i][nodeCnt] + distList[nodeCnt][j]);
				}
			}
		}
	}
};


int main()
{
	// 入力
	int N, M, R;
	cin >> N >> M >> R;
	
	vector<int> pathList;
	REP(i, R) {
		int r;
		cin >> r;
		r--;
		pathList.emplace_back(r);
	}

	vector<Edge> edgeList;
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		edgeList.emplace_back(Edge(a, b, c));
		edgeList.emplace_back(Edge(b, a, c));
	}

	// ワーシャルフロイド
	WarshallFloyd<int> res(N, edgeList);

	// 順列
	ll ans = INF;
	sort(pathList.begin(), pathList.end());
	do {
		ll totalCost = 0;
		int from = pathList[0];
		for (int i = 1; i < pathList.size(); i++) {
			int to = pathList[i];
			totalCost += res.distList[from][to];
			from = to;
		}
		ans = min(ans, totalCost);
	} while (next_permutation(pathList.begin(), pathList.end()));

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31992
N=int(input())
W=list(map(int,input().split()))
import itertools
cs1=list(itertools.accumulate(W))[:-1]
cs2=list(itertools.accumulate(W[::-1]))[::-1]
ans=cs1[-1]
for x,y in zip(cs1,cs2[1:]):
  ans=min(ans,abs(x-y))
print(ans)

Measured memory_bytes: 3064
N=int(input())
a,b,c,d=0,0,0,0
for i in range(N):
  s=input()
  if s=='AC': a+=1
  elif s=='WA': b+=1
  elif s=='TLE': c+=1
  elif s=='RE': d+=1
  pass
print('AC x {}'.format(a))
print('WA x {}'.format(b))
print('TLE x {}'.format(c))
print('RE x {}'.format(d))




Measured memory_bytes: 9196
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

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

long long gcd(long long aaa,long long bbb){
    if(bbb==0){
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}
 
long long lcm(long long aaa,long long bbb){
    long long g = gcd(aaa,bbb);
    return aaa/g * bbb;
}

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

    cin>>a>>b>>c>>d;
    if(c==1||d==1)Cout(0);
    else{
    ans=b-a+1;
    ll st,en;
    if(a%c!=0)st=a+(c-a%c);
    else st=a;
    if(b%c!=0)en=b-b%c;
    else en=b;
    if(en>=st)ans=ans-(max((en-st),0LL)/c+1);

    if(a%d!=0)st=a+(d-a%d);
    else st=a;
    if(b%d!=0)en=b-b%d;
    else en=b;
    if(en>=st)ans=ans-(max((en-st),0LL)/d+1);

    tmp=lcm(c,d);
    if(a%tmp!=0)st=a+(tmp-a%tmp);
    else st=a;
    if(b%tmp!=0)en=b-b%tmp;
    else en=b;
    if(en>=st)ans=ans+(max((en-st),0LL)/tmp+1);

    Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
#include <unordered_map>
unordered_map<ll,ll> dp[51];
int a[50];
int main(){
    int n, k;
    int s, t;
    cin >> n >> k >> s >> t;
    dp[0][(1<<18)-1] = 1;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    for(int i = 0; i < n; i++){
        int x =a[i];
        if((s&x)==s and (t|x)==t)for(int j = k - 1; j >= 0; j--){
            for(auto &y : dp[j]){
                dp[j+1][(((y.first >> 18)|x)<<18 )+ (y.first & x)] += y.second;
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= k; i++){
        ans += dp[i][((ll)t<<18) + s];
    }
    cout << ans << endl;
}


Measured memory_bytes: 106836
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();

        int arr[]=new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = scanner.nextInt();

        int mainCount=0;

        for (int i = 1; i < n-1; i++) {

            if(arr[i]>arr[i-1] && arr[i]<arr[i+1])
                mainCount++;
            else if(arr[i]<arr[i-1] && arr[i]>arr[i+1])
                mainCount++;
        }

        System.out.println(mainCount);

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> b(n);
    REP(i, 0, n) {
        cin >> b[i];
    }

    vector<int> ans;
    REP(j, 0, n) {
        for (int i = b.size() - 1; i >= 0; i--) {
            if (i + 1 == b[i]) {
                ans.push_back(i + 1);
                b.erase(b.begin() + i);
                break;
            }
        }
        if (ans.size() != j + 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (auto it = rbegin(ans); it != rend(ans); it++) {
        cout << *it << endl;
    }

    return 0;
}


Measured memory_bytes: 256