akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll K;

ll sum(ll x) {
    int z = 0;
    while (x) {
        z += (x%10);
        x /= 10;
    }
    return z;
}

ld eval(ll x) {
    return (ld)x/sum(x);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    vl tri;
    FOR(i,1,1000) {
        ll z = i;
        while (z <= 1e18) {
            tri.pb(z);
            z = 10*z+9;
        }
    }
    sort(all(tri)); tri.erase(unique(all(tri)),tri.end());
    vl ans;
    ld mn = INF;
    F0Rd(i,sz(tri)) {
        mn = min(mn,eval(tri[i]));
        if (eval(tri[i]) <= mn) ans.pb(tri[i]);
    }
    reverse(all(ans));
    cin >> K;
    F0R(i,K) cout << ans[i] << "\n";
    /*ll po10 = 0;
    F0R(i,18) {
        FOR(j,1,10) ans.pb(j*(po10+1)+po10);
        po10 = 10*po10+9;
    }*/
    //for (auto a: ans) cout << a << "\n";
    cin >> K;
    /*ld mn = INF;
    FORd(i,1,10000000) {
        mn = min(mn,eval(i));
        if (eval(i) <= mn) cout << i << "\n";
    }*/
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 512
def run_length_compress(S):
  l = []
  left = 0
  for right in range(1,len(S)):
    if right != len(S) - 1:
      if S[right] != S[right - 1]:
        l.append([S[right - 1], right - left])
        left = right
      else:
        pass
    else:
      if S[right] != S[right - 1]:
        l.append([S[right - 1], right - left])
        l.append([S[right], 1])
      else:
        l.append([S[right], right - left + 1])
  return l

def main():
  n,k = map(int,input().split())
  s = input()
  l = run_length_compress(s)
  if len(l) > 1:
    count = 0
    for i in range(1, len(l), 2):
      l[i][0] = l[i-1][0]
      count += 1
      if count >= k: break
  t = ''
  for j in range(len(l)):
    t += l[j][0]*l[j][1]
  
  res = 0
  for k in range(1,n):
    if t[k-1] == t[k]:
      res += 1
  print(res)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 13428
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a;
    cin>>x>>a;
    if(x<a) cout<<0<<endl;
    else cout<<10<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int c = 0;
		for(int i = 0; i < n; i++) {
			p[i] = in.nextInt();
			if(p[i] != i+1)
				c++;
		}

		String ans = (c <= 2) ? "YES" : "NO";
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N;
    cin >> M;
    int ai[N+1];
    for(int i = 0; i <= N; ++i){
        ai[i] = 1;
    }
    for(int i = 0; i < M; ++i){
        int a;
        cin >> a;
        ai[a] = 0;
    }

    int dp[N+1];
    dp[0] = 1;
    if(ai[1] == 0) dp[1] = 0;
    else dp[1] = 1;

    for(int i = 2; i < N+1; ++i){
        if(ai[i] == 0){
            dp[i] = 0;
        }
        else{
            dp[i] = (dp[i-1] + dp[i-2])%1000000007;
        }
    }

    cout << dp[N];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
char s[N]; int n,m;
int main(){
    scanf("%s",s); n=strlen(s);
    int l=0,r=n-1;
    while(l<r){
        if(s[l]!=s[r]) m++;
        l++; r--;
    }
    printf("%d\n",m);
}

Measured memory_bytes: 256
s = input()
n = len(s) - 1

sum = 0
for i in range(2 ** n):
    tmp = s[0]
    for j in range(n):
        if (i >> j) & 1:
            
            tmp += "+"

        tmp += s[j+1]

    list_tmp = tmp.split("+")

    for j in list_tmp:
        sum += int(j)

print(sum)

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

using namespace std;
using ll = long long;
int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    ll kane=1000;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if(a[i]>=a[j])i=j;
            else {
                ll kabu=kane/a[i];
                kane=kane%a[i] + kabu*a[j];
                i = j-1;
                break;
            }
        }
    }
    cout<<kane<<endl;
    return 0;
}

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

int main(){
    int x,y,cnt=1;
    while(1){
      cin>>x>>y;
      if(x==0 && y==0){
          break;
      }else{
          if(x<y){
          cout<<x<<" "<<y<<endl;
          }else{
          cout<<y<<" "<<x<<endl;
          }
      }
      cnt++;
    }

    return 0;
}


Measured memory_bytes: 3092
N = int(input())
res = []

for i in range(N):
  S, P = input().split()
  P = int(P)
  res.append([i, S, P])
  
res.sort(key=lambda x: x[1])
buf = []

for e in res:
  if len(buf) == 0 or buf[-1][1] == e[1]:
    buf.append(e)
  else:
    buf.sort(key=lambda x: -x[2])
    for f in buf:
      print(f[0] + 1)
    buf = [e]

if len(buf) > 0:
  buf.sort(key=lambda x: -x[2])
  for f in buf:
    print(f[0] + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B; std::cin >> A >> B;
  std::cout << (A+B) % 24 << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    s = readline().strip()
    t = readline().strip()

    s = sorted(s)
    t = sorted(t, reverse=True)

    if s < t:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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(){
	ll n; cin>>n;
	vector<ll> a(n+1);
	ll res=0;
	rep(i,0,n+1){
		cin>>a[i];
		res+=a[i];
	}
	if(n==0){
		if(a[0]==1){
			cout<<1<<endl;
			return 0;
		}else{
			cout<<-1<<endl;
			return 0;
		}
	}
	if(a[0]!=0){
		cout<<-1<<endl;
		return 0;
	}

	ll ans=res;
	ll cand=2;
	rep(i,0,n){
		// debug(cand);
		// debug(res);
		ans+=cand/2;
		cand=(min(cand,res)-a[i+1])*2;
		res-=a[i+1];
		if(cand<0){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, d, a;
	cin >> n >> d >> a;
	d = 2 * d;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(all(p));
	ll ans = 0;
	ll tot = 0;
	queue<pair<ll, ll>> que;
	rep(i, n) {
		ll x = p[i].first;
		ll h = p[i].second;
		while (que.size() && que.front().second < x) {
			tot -= que.front().first;
			que.pop();
		}
		h -= tot;
		if (h > 0) {
			ll num = (h + a - 1) / a;
			ans += num;
			ll damage = num * a;
			tot += damage;
			que.emplace(damage, x + d);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int H,A;
    cin >> H>>A;
    if(H%A==0)cout << H/A << endl;
    else cout << H/A +1 << endl;
}

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

typedef long long ll;

int n,m,am,sm,hp[110],maxhp;
ll amp[110],adm[110],smp[110],sdm[110];
ll dpa[100100], dps[100100];
string name;
ll tmp;
const ll INF = (ll)(1e15);

int main(){
  while(cin >> n,n){
    maxhp = 0;
    for(int i=0;i<n;i++){
      cin >> hp[i];
      maxhp = max(maxhp,hp[i]);
    }

    cin >> m;
    am = sm = 0;

    for(int i=0;i<m;i++){
      cin >> name >> tmp;
      cin >> name;
      if(name == "All")amp[am] = tmp;
      else smp[sm] = tmp;
      cin >> tmp;
      if(name == "All")adm[am++] = tmp;
      else sdm[sm++] = tmp;
    }


    for(int i=0;i<=maxhp;i++)dpa[i] = INF;
    dpa[0] = 0;

    for(int i=0;i<am;i++){
      for(int j=0;j<=maxhp;j++){
	if(dpa[j]<INF){
	  if(j+adm[i]<=maxhp){
	    dpa[j+adm[i]] = min(dpa[j+adm[i]],dpa[j] + amp[i]);
	  }else{
	    dpa[maxhp] = min(dpa[maxhp],dpa[j]+amp[i]);
	  }
	}
      }
    }

    tmp = INF;
    for(int i=maxhp;i>=0;i--){
      if(tmp<dpa[i])dpa[i] = tmp;
      else tmp = dpa[i];
    }

    for(int i=0;i<=maxhp;i++)dps[i] = INF;
    dps[0] = 0;

    for(int i=0;i<sm;i++){
      for(int j=0;j<=maxhp;j++){
	if(dps[j]<INF){
	  if(j+sdm[i]<=maxhp){
	    dps[j+sdm[i]] = min(dps[j+sdm[i]],dps[j] + smp[i]);
	  }else{
	    dps[maxhp] = min(dps[maxhp],dps[j]+smp[i]);
	  }
	}
      }
    }

    tmp = INF;
    for(int i=maxhp;i>=0;i--){
      if(tmp<dps[i])dps[i] = tmp;
      else tmp = dps[i];
    }

    ll ans = INF;
    for(int i=0;i<=maxhp;i++){
      tmp = dpa[i];
      for(int j=0;j<n;j++){
	int rem = hp[j] - i;
	if(rem<=0)continue;
	tmp += dps[rem];
      }
      ans = min(ans,tmp);
    }
    cout << ans << endl;
  }
}

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

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

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;

    cin >> x;

    int result = x;
    for (int i=x; i<1000000; i++) {
        bool isSosu = true;
        for (int j=i-1; j>1; j--) {
            if (i % j == 0) {
                isSosu = false;
                break;
            }
        }
        if (isSosu) {
            result = i;
            break;
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 888
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)

  n = int(input())
  h = list(map(int,input().split()))+[10**9+7]
  
  i=0
  s=0
  ans=0
  p=10**9+7
  while i < len(h):
    if p < h[i]:
      if ans < i-s:
        ans = i-s
      s=i
    p=h[i]
    i += 1

  print(ans-1)


if __name__ == '__main__':
  solve()

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

using namespace std;

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

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

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

    Int(n);
    vector<int> data(n);
    int s = 0;
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        s += data[i];
    }

    int ans = INF;
    Rep(i, n) {
        int tmp1 = 0;
        rep(j, i+1) {
            tmp1 += data[j];
        }
        ans = min(ans, abs(s - tmp1 - tmp1));
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
d, n, b = map(int, input().split())
O = [list(map(int, input().split())) for i in range(n)]

def solve(b):
    l = d / (b + 1)
    idx = 0
    vx2 = 10**9
    for i in range(b + 1):
        while idx < n and O[idx][0]*(b+1) <= d*(i+1):
            p, h = O[idx]
            p -= l*i
            vx2 = min(vx2, p*(l - p) / (2 * h))
            idx += 1
    if vx2 == 0:
        return 10**9
    if l <= vx2 * 2:
        return l
    return vx2 + l**2 / (4*vx2)
ans = 10**9
for i in range(0, b+1):
    ans = min(ans, solve(i))
import math
print(math.sqrt(ans))

Measured memory_bytes: 5684
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] in = sc.nextLine().split(" ");

		int cut = Integer.parseInt(in[1]);
		Queue<Integer> qu = new LinkedList<Integer>();
		Queue<String> quname = new LinkedList<String>();
		for (int n = 0; n <Integer.parseInt(in[0]); n++) {
			String[] in2 = sc.nextLine().split(" ");
			quname.offer(in2[0]);
			qu.offer(Integer.parseInt(in2[1]));
			
		}
		
		int time = 0;
		while (!qu.isEmpty()) {
			String name=quname.poll();
			int n = qu.poll();
			if (n-cut > 0) {
				quname.offer(name);
				qu.offer(n-cut);
				
				time += cut;
			} else {				
				time += n;
				System.out.println(name+" "+time);
			}
		}
	}

}



Measured memory_bytes: 103776
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

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

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/

int isprime(lint x) {
	//xが素数:1,xが素数でない:0
	if (x == 2) {
		return 1;
	}
	else if (x == 1 || x % 2 == 0) {
		return 0;
	}
	else {
		lint i = 3;
		while (i * i <= x) {
			if (x % i == 0) {
				return 0;
			}
			i += 2;
		}
		return 1;
	}
}

int main() {
	lint X;
	cin >> X;
	while (1) {
		if (isprime(X)) {
			cout << X << endl;
			return 0;
		}
		X++;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int table[8][8];

int confilm(int x,int y){
	int i,j;
	
	for(i=0;i<8;i++){
		if(i!=y && table[x][i]==1){
			return 0;
		}
	}
	for(i=0;i<8;i++){
		if(i!=x && table[i][y]==1){
			return 0;
		}
	}
	
	i=x+1;
	j=y+1;
	while(i<8 && j<8){
		if(table[i++][j++]==1){
			return 0;
		}
	}
	
	
	i=x+1;
	j=y-1;
	while(i<8 && j>=0){
		if(table[i++][j--]==1){
			return 0;
		}
	}
	
	i=x-1;
	j=y-1;
	while(j>=0 && i>=0){
		if(table[i--][j--]==1){
			return 0;
		}
	}
	i=x-1;
	j=y+1;
	while(i>=0 && j<8){
		if(table[i--][j++]==1){
			return 0;
		}
	}
}

int conclusion(int c){
	int i,j;
	
	for(i=0;i<8;i++){
		if(table[c][i]==1){
			if(conclusion(c+1) != 1) return 0; 
		}
	}
	
	if(c==8){
		/* printer*/
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(table[i][j] == 1){ 
				printf("Q");
				}
				else printf(".");	
			}
			printf("\n");
		}
		/*printer end*/
		return 1;
	}
	else{
		for(i=0;i<8;i++){
			if(table[c][i]==0 && confilm(c,i)){
				table[c][i]=1;
				if(!conclusion(c+1)){
					table[c][i]=0;
				}
			}
			
		}
	}
	return 0;
}


int main(void) {
	// your code goes here
	
	int n,i,j,x,y,c=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		table[x][y]=1;
	}
	
	i=conclusion(c);
	
	return 0;
}



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

const int64_t MAX_N = 100001;
vector<bool> is_prime;
bool Sieve_of_Eratosthenes() {
    is_prime.resize(MAX_N+1, true);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for (int64_t i = 2; i <= MAX_N; i++) {
        if (is_prime[i]) {
            for (int64_t j = 2*i; j <= MAX_N; j+= i) {
                is_prime[j] = 0;
            }
        }
    }
}

bool like_2017(int n) {
    return is_prime[n] && is_prime[(n+1)/2];
}


int main() {
    Sieve_of_Eratosthenes();
    int q;
    cin >> q;
    int sumcnt[MAX_N] = {};
    for (int i = 1; i < MAX_N; i++) {
        if (like_2017(i)) {
            sumcnt[i] = sumcnt[i-1] + 1;
        }
        else {
            sumcnt[i] = sumcnt[i-1];
        }
    }
    int ans[q];
    rep(i,q) {
        int lef, rig;
        cin >> lef >> rig;
        ans[i] = sumcnt[rig] - sumcnt[lef-1];
    }
    rep(i,q) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1408
#include <cstddef>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
namespace loquat {
using vertex_t = size_t;
}
namespace loquat {
namespace edge_param {
struct to_ {
	vertex_t to;
	explicit to_(vertex_t t = 0)
		: to(t)
	{ }
};
template <typename T>
struct weight_ {
	using weight_type = T;
	weight_type weight;
	explicit weight_(const weight_type& w = weight_type())
		: weight(w)
	{ }
};
template <typename T>
using weight = weight_<T>;
}
namespace detail {
template <typename T, typename... Params>
struct edge_param_wrapper : public T, edge_param_wrapper<Params...> {
	template <typename U, typename... Args>
	explicit edge_param_wrapper(U&& x, Args&&... args)
		: T(std::forward<U>(x))
		, edge_param_wrapper<Params...>(std::forward<Args>(args)...)
	{ }
};
template <typename T>
struct edge_param_wrapper<T> : public T {
	template <typename U>
	explicit edge_param_wrapper(U&& x)
		: T(std::forward<U>(x))
	{ }
};
}
template <typename... Params>
struct edge : public detail::edge_param_wrapper<edge_param::to_, Params...> {
	template <typename... Args>
	explicit edge(Args&&... args)
		: detail::edge_param_wrapper<edge_param::to_, Params...>(
			std::forward<Args>(args)...)
	{ }
};
}
namespace loquat {
template <typename EdgeType>
class adjacency_list {
public:
	using edge_type = EdgeType;
	using edge_list = std::vector<edge_type>;
private:
	std::vector<std::vector<EdgeType>> m_edges;
public:
	explicit adjacency_list(size_t n)
		: m_edges(n)
	{ }
	edge_list& operator[](vertex_t u){
		return m_edges[u];
	}
	template <typename... Args>
	void add_edge(vertex_t from, Args&&... args){
		m_edges[from].emplace_back(std::forward<Args>(args)...);
	}
};
}
using namespace std;
using ll = long long;
using edge = loquat::edge<loquat::edge_param::weight<ll>>;
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	loquat::adjacency_list<edge> g(n);
	for(int i = 0; i < m; ++i){
		int l, r, d;
		cin >> l >> r >> d;
		--l; --r;
		g.add_edge(l, r,  d);
		g.add_edge(r, l, -d);
	}
	vector<bool> done(n, false);
	vector<ll> pos(n);
	for(int r = 0; r < n; ++r){
		if(done[r]){ continue; }
		done[r] = true;
		pos[r] = 0;
		queue<int> q;
		q.push(r);
		while(!q.empty()){
			const int u = q.front();
			q.pop();
			for(const auto& e : g[u]){
				const int v = e.to;
				if(done[v]){ continue; }
				done[v] = true;
				pos[v] = pos[u] + e.weight;
				q.push(v);
			}
		}
	}
	bool answer = true;
	for(int u = 0; u < n; ++u){
		for(const auto& e : g[u]){
			const int v = e.to, w = e.weight;
			if(pos[v] - pos[u] != w){ answer = false; }
		}
	}
	cout << (answer ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vector<vi> t(n);
  vpi in(m);

  rep(i, m) {
    cin >> in[i].fi >> in[i].se;
    t[in[i].fi-1].eb(in[i].se);
  }

  auto f = [&](int p, int x) {
    string left, right;

    left = to_string(p);
    right = to_string(x);

    while (si(left) < 6) left = '0' + left;
    while (si(right) < 6) right = '0' + right;

    return left + right;
  };

  rep(i, n) sort(all(t[i]));

  rep(i, m) {
    int p = in[i].fi, y = in[i].se;

    int x = lower_bound(all(t[p-1]),y) - t[p-1].begin();

    cout << f(p, x+1) << endl;
  }

  return (0);
}


Measured memory_bytes: 9504
N = int(input())
S = input()
count=0
mylist=[]
for i in range(N):
    if "I" in S[i]:
        count = count+1
        mylist.append(count)
    else:
        count= count-1
        mylist.append(count)

if max(mylist) < 0:
    print(0)    
else:
    print(max(mylist))

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

int main(){
  int n,t[100000],mx=-1;
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i],mx=max(mx,t[i]);
  vector<int> v;
  for(int i=1;i*i<=mx;i++)
    if(mx%i==0){
      v.push_back(i);
      v.push_back(mx/i);
    }
  int ans=0;
  for(int i=0;i<n;i++){
    int mn=1e9;
    for(int j=0;j<v.size();j++)
      if(v[j]>=t[i])mn=min(mn,v[j]-t[i]);
    ans+=mn;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3528
N,M = list(map(int,input().split()))
X = []
for i in range(M):
  tmp = [i for i in input().split()]
  X.append(tmp)

WAs = [0]*(N+1)
flags = [0]*(N+1)

AC = 0
WA = 0

for i in range(M):
  if X[i][1] == 'AC':
    if flags[int(X[i][0])] == 0:
      AC += 1
      WA += WAs[int(X[i][0])]
      flags[int(X[i][0])] = 1
  if X[i][1] == 'WA':
    if flags[int(X[i][0])] == 0:
      WAs[int(X[i][0])] += 1
      
print(AC,WA,sep=' ')
  

Measured memory_bytes: 27408
var lines = []; var result = Infinity;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var K = Number(lines[0].split(" ")[1]);
    lines.shift();

    var h = lines.map(value => Number(value));

    h.sort((a, b) => a - b);

    for (var i = 0; i + K - 1 < N; i++) {
        result = Math.min(result, h[i + K - 1] - h[i]);
    }
    console.log(result);
});

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

int main() {
  int H,W,N,r,c,Z=0;
  string S,T;
  cin>>H>>W>>N>>r>>c>>T>>S;
  reverse(S.begin(),S.end());
  reverse(T.begin(),T.end());
  int A=1,B=H,C=1,D=W;
  for(int i=0;i<N;i++){
    if(S.at(i)=='D'){
      A=max(A-1,1);
    }
    if(S.at(i)=='U'){
      B=min(B+1,H);
    }
    if(S.at(i)=='L'){
      D=min(D+1,W);
    }
    if(S.at(i)=='R'){
      C=max(C-1,1);
    }
    if(T.at(i)=='D'){
      B--;
    }
    if(T.at(i)=='U'){
      A++;
    }
    if(T.at(i)=='L'){
      C++;
    }
    if(T.at(i)=='R'){
      D--;
    }
    if(C>D||A>B){
      Z++;
      break;
    }
    
  }
  if(!(A<=r&&r<=B&&C<=c&&c<=D)){
    Z++;
  }
  if(Z==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  
    
}

Measured memory_bytes: 776
#include<stdio.h>

int main()
{
    int h1, h2, h3;
    h1 = 0; h2 = 0; h3 = 0;
    int height;
    while (scanf("%d", &height) != EOF) {
        if (height > h1) {
            h3 = h2;
            h2 = h1;
            h1 = height;
        } else if (h1 >= height && height > h2) {
            h3 = h2;
            h2 = height;
        } else if (h2 >= height && height > h3) {
            h3 = height;
        }
    }
    printf("%d\n%d\n%d\n", h1, h2, h3);
    return 0;
}

Measured memory_bytes: 1028
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        String s = sc.next();

        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
	}
}


Measured memory_bytes: 21716
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        char[] c1 = str1.toCharArray();
        Arrays.sort(c1);
        String str2 = sc.next();
        char[] c2 = str2.toCharArray();
        Arrays.sort(c2);
        
        int i = 0;
        int j = c2.length - 1;
        while (true) {
            int a = c1[i] - 'a'; // 'b' -> 1
            int b = c2[j] - 'a'; // 'b' -> 1
            if (a < b) {
                System.out.println("Yes");
                return;
            } else if (a > b) {
                System.out.println("No");
                return;
            }
            
            i++;
            j--;
            
            if (j == -1) {
                System.out.println("No");
                return;
            } else if (i == c1.length) {
                System.out.println("Yes");
                return;
            }
        }
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  string s,t;
  cin>>s>>t;
  for(int i=N;i<=2*N;i++){
    string r=s;
    reverse(r.begin(),r.end());
    string p=r.substr(0,2*N-i);
    reverse(p.begin(),p.end());
    if(p==t.substr(0,2*N-i)){
      cout<<i<<endl;return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3616
'use strict'
function main(inp) {
  inp = inp.trim().split('\n');
  let N = inp[0]*1;
  let nums = inp[1].split(' ').map(x=> x*1);
  // 平均を出す、そして四捨五入
  let ava = Math.round(nums.reduce((x,a) => a+=x)/N);
  let ans = 0;
  // 平均値をそれぞれの値から引いて答えを出す
  for(let i = 0; i < N; i++){
  	ans += (nums[i] - ava)*(nums[i] - ava);
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n,t,s,e;
    cin >> n >> t >> s >> e;
    vector<vector<pair<int,int>>> ed(n+1,vector<pair<int,int>>(0));
    rep(i,n-1){
        int f,g,h;
        cin >> f >> g >> h;
        ed.at(f).push_back(mk(g,h));
        ed.at(g).push_back(mk(f,h));
    }
    vector<int> c(n+1,0),r(n+1,-1);
    vector<pp> ra(n+1);
    queue<int> q;
    ra.at(0)=mk(-4,0);
    q.push(s);
    r[s]=0;
    ra[s]=mk(0,s);
    while(!q.empty()){
        int p=q.front();
        q.pop();
        rep(i,ed.at(p).size()){
            int d=ed.at(p).at(i).first;
            if (r.at(d)==-1){
                r.at(d)=r.at(p)+1;
                ra.at(d)=mk(r.at(p)+1,d);
                q.push(d);
                c.at(p)++;
            }
        }
    }
    sort(all(ra));
    reverse(all(ra));
    rep(i,n){
        int f=ra.at(i).second;
        vector<int> g(0);
        bool w=false;
        int h;
        rep(j,ed.at(f).size()){
            int k=ed.at(f).at(j).first,l=ed.at(f).at(j).second;
            if (r.at(f)<r.at(k)){
            if (k==e) {w=true;h=l-c.at(k);continue;}
            g.push_back(l-c.at(k));}
        }
        sort(all(g));
        int o=2;
        if (f==s) o--;
        rep(j,g.size()){
            if ((o+j)*t>=g.at(j)) {cout << "No" << endl;return 0;}
        }
        if (w){
            if ((o+g.size()-1)*t>=h) {cout << "No" << endl;return 0;}
        }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 10584
#include<stdio.h>
int main(){
	int m,f,r,a[100],c,x;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		x=m+f;
		if(m==-1&&f==-1&&r==-1)break;
		else if(m==-1||f==-1)printf("F\n");
		else if(x>79)printf("A\n");
		else if(80>x&&x>64)printf("B\n");
		else if(65>x&&x>49)printf("C\n");
		else if(50>x&&x>29){
			if(r>49)printf("C\n");
			else printf("D\n");
		}
		else if(30>x)printf("F\n");
		}
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<vector<int>> v(n+1, vector<int>(n+1));
        for (int i = 0; i < n; ++i) {
            int s = 0;
            for (int j = 0; j < n; ++j) {
                cin >> v[i][j];
                s += v[i][j];
            }
            v[i].back() = s;
        }
        for (int i = 0; i < n+1; ++i) {
            int s = 0;
            for (int j = 0; j < n; ++j) {
                s += v[j][i];
            }
            v.back()[i] = s;
        }
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= n; ++j) {
                printf("%5d", v[i][j]);
            }
            puts("");
        }
    }
    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
	int n,k,m;
	vector<int>::iterator it;
	while(1){
		cin>>n>>k>>m;
		if(n+k+m==0) break;

		vector<int> s;
		for(int i1=0;i1<n;i1++){
			s.push_back(i1+1);
		}
		it=s.begin();
		advance(it,m-1);
		it=s.erase(it);
		if(it==s.end()) it=s.begin();

		while(s.size()!=1){
			for(int i1=0;i1<k-1;i1++){

				it++;
				if(it==s.end()) it=s.begin();
			}
			
			it=s.erase(it);
			if(it==s.end()) it=s.begin();
		}
		cout<<(*s.begin())<<endl;

	}
	return 0;
}

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

using namespace std;

int numbit(int j){
    unsigned int i = static_cast<unsigned int>(j);
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return static_cast<int>(i & 0x3f);
}

int main(){
    int H,W,K;
    cin >> H >> W >> K;

    string data_s;
    vector<int> data(H);

    for (int i = 0; i < H;i++){
        cin >> data_s;
        for (int j = 0; j < W;j++){
            data[i] |= (data_s.at(j) == '#');
            data[i] <<= 1;
        }
        data[i] >>= 1;
    }

    int ans = 0, numb;
    for (int i = 0; i < (1 << (H)); i++)
    {
        for (int j = 0; j < (1 << (W)); j++)
        {
            numb = 0;

            for (int k = 0; k < H;k++){
                if(!(i&(1<<k))){
                    numb += numbit((data[k] & (j^((1<<W)-1))));
                }
            }

            if(numb==K){

                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3552
using System;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC136.UnevenNumbers();
        }
    }

    class ABC136
    {

        public static void UnevenNumbers()
        {
            int n = Input.getInt();
            int cnt = 0;
            if(n<10) cnt = n%10;
            if(10<= n && n < 100)
            {                
                cnt = 9;
            }
            if(100<= n && n <1000)
            {
                cnt = n- 99 + 9;
            } 
            if(1000<= n && n<10000)
            {
                cnt = 999 - 99 + 9;
            }
            if(10000<=n && n<100000)
            {
                cnt = n - 9999 + 999 - 99 + 9;
            }
            if(n==100000) cnt = 99999-9999+999-99+9;
            Console.WriteLine(cnt);
        }

    }
  
    class Input
    {
        public static int getInt()
        {
            int i = int.Parse(Console.ReadLine());
            return i;
        }

        public static string getString()
        {
            string s = Console.ReadLine();
            return s;
        }
        public static int[] getIntArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] num = s.Select(x=>int.Parse(x)).ToArray();
            return num;
        }
        public static long[] getLongArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            long[] num = s.Select(x=>long.Parse(x)).ToArray();
            return num;
        }
    }

}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll h, w;

ll ans = INF;

int main(void) {
  // Here your code !
  scanf("%lld %lld\n", &h, &w);

  for (ll i = 1; i < h; ++i) {
    ll mid = (i + h) / 2;

    ll cur_base = w * i;

    for (ll j = max(mid - 2, i); j <= min(mid + 2, h); ++j) {
      ll cur_1 = w * (j - i);
      ll cur_2 = w * (h - j);

      ll cur_diff = max(cur_base, max(cur_1, cur_2)) - min(cur_base, min(cur_1, cur_2));

      ans = min(ans, cur_diff);
    }
  }

  for (ll i = 1; i < h; ++i) {
    ll mid = w / 2;

    ll cur_base = w * i;

    for (ll j = max(mid - 2, 0LL); j <= min(mid + 2, w); ++j) {
      ll cur_1 = (h - i) * j;
      ll cur_2 = (h - i) * (w - j);

      ll cur_diff = max(cur_base, max(cur_1, cur_2)) - min(cur_base, min(cur_1, cur_2));

      ans = min(ans, cur_diff);
    }
  }

  for (ll i = 1; i < w; ++i) {
    ll mid = (i + w) / 2;

    ll cur_base = h * i;

    for (ll j = max(mid - 2, i); j <= min(mid + 2, w); ++j) {
      ll cur_1 = h * (j - i);
      ll cur_2 = h * (w - j);

      ll cur_diff = max(cur_base, max(cur_1, cur_2)) - min(cur_base, min(cur_1, cur_2));

      ans = min(ans, cur_diff);
    }
  }

  for (ll i = 1; i < w; ++i) {
    ll mid = h / 2;

    ll cur_base = h * i;

    for (ll j = max(mid - 2, 0LL); j <= min(mid + 2, h); ++j) {
      ll cur_1 = (w - i) * j;
      ll cur_2 = (w - i) * (h - j);

      ll cur_diff = max(cur_base, max(cur_1, cur_2)) - min(cur_base, min(cur_1, cur_2));

      ans = min(ans, cur_diff);
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        int a,b; cin >> a >> b;
        int ans = 0;
        int sock = 1;
        while(sock<b){
            sock--;
            sock+=a;
            ans++;
        }
        cout<<ans<<endl;


return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

        int s;

        scanf("%d",&s);

        cout << s/60/60 << ":" << s/60%60 << ":" << s % 60 << endl;

        return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

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

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(x) x.begin(), x.end()
#define lp(i, n) for (int i = 0; i < n; i++)
#define mem(a, v) memset(a, v, sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y, a.X))
#define vec(a, b) ((b) - (a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a) / length(a)
#define dotP(a, b) ((conj(a) * b).X)
#define crossP(a, b) ((conj(a) * b).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(a) dotP(a, a)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(v, m) conj(v / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll n, ll x) {
  if (!x)
    return 1;
  if (x % 2)
    return n * fastpow(n, x - 1);
  ll p = fastpow(n, x / 2);
  p %= mod;
  p *= p;
  p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll ret = num % mod;
  while (ret < 0)
    ret += mod;
  return ret;
}

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
long double dist(pair<ll, ll> &a, pair<ll, ll> &b) {
  return sqrt(
      ((a.f - b.f) * (a.f - b.f) * 1.0 + (a.se - b.se) * (a.se - b.se)));
}
/*vector<int> ap;
bool np[MX];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <MX; j+=i) np[j] = 0;
        }
    }
    for(ll i = 2 ; i< MX ; i++) if(np[i]) ap.pb(i);
}*/
const ll MX = 1e5+5;
void add(int &a, int b){
	a +=b;
	if(a>=mod) a-=mod;
}
void sub(int &a, int b){
	a -=b;
	if(a<0) a+=mod;
}
ll p[405];
ll dp[405][405];
ll solve(int l , int r){
	if(l > r) return 1e14;
	if(l == r) return 0;
	ll &ret = dp[l][r];
	if(~ret) return ret;
	ret = 1e14;
	for(int j = l ; j<= r; j++){
		ret = min(ret,solve(l,j) + solve(j+1,r));
	}
	ret += p[r] - p[l-1];
	return ret;
}
int main()
{
    IO;
	int n;
	cin>>n;
	vector<ll> arr(n+1);
	for(int i = 1 ; i <= n ; i++){
		 cin>>arr[i];
		 p[i] = p[i-1] + arr[i];
	}
	mem(dp,-1);
	cout<<solve(1,n)<<"\n";
    return 0;
}



Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(){
	int N, M, X;
	cin >> N >> M >> X;
	int C[N], A[N][M];
	for (int i = 0; i < N; i++){
		cin >> C[i];
		for (int j = 0; j < M; j++){
			cin >> A[i][j];
		}
	}

	int ans = -1;
	long long bits = 0;
	while (bits != (1<<N)){
		int Csum = 0;
		int Asum[M] = {0};
		for (int i = 0; i < N; i++){
			if (bits & (1<<i)){
				Csum += C[i];
				for (int j = 0; j < M; j++){
					Asum[j] += A[i][j];
				}
			}
		}

		bool isOK = true;
		for (int j = 0; j < M; j++){
			if(Asum[j] < X){
				isOK = false;
			}
		}
		if(isOK && (Csum < ans || ans == -1)){
			ans = Csum;
		}
		bits++;
	}

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int N,A,B,C;
vector<int> v(100000);
vector<int> l(100000);
int ans=999999999;
void calc(vector<int> &v){
  //cout<<v[0]<<v[1]<<v[2]<<v[3]<<v[4]<<endl;
  int suma=0,sumb=0,sumc=0;
  int cnta=0,cntb=0,cntc=0;
 for(int i=0;i<N;i++){
   if(v[i]==0){suma+=l[i];cnta++;}
   if(v[i]==1){sumb+=l[i];cntb++;}
   if(v[i]==2){sumc+=l[i];cntc++;}
 }
 if(cnta==0||cntb==0||cntc==0){return;}
 int cu=abs(A-suma)+abs(B-sumb)+abs(C-sumc)+10*(cnta+cntb+cntc-3);
 ans=min(ans,cu);
 return;
}

void dfs(int depth,vector<int> &v){
  if(depth==N){
    calc(v);
    return;
  }
  for(int i=0;i<4;i++){
    v[depth]=i;
    dfs(depth+1,v);
  }
}
int main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++){
    cin>>l[i]; 
  }
  dfs(0,v);
  cout<<ans<<endl;
  return 0;
}

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

const int INF = 1e9+7; 

int main() {
	int n,m; cin>>n>>m;
	vector<vector<int>> adj(n+1,vector<int>(n+1,INF));
	vector<vector<int>> path(n+1,vector<int>(n+1,-1));
	vector<vector<int>> used(n+1,vector<int>(n+1));
	vector<vector<int>> edges(m);
	for (int i=0; i<m; i++) {
		int a,b,c; cin>>a>>b>>c;
		edges[i] = {a,b,c};
		adj[a][b] = c;
		adj[b][a] = c;
		path[a][b] = b;
		path[b][a] = a;
	}
	for (int i=0; i<=n; i++) {
		adj[i][i]=0;
		path[i][i]=i;
	}

	for (int k=0; k<=n; k++) {
		for (int i=0; i<=n; i++) {
			for (int j=0; j<=n; j++) {
				if (adj[i][k]==INF or adj[k][j]==INF) continue;
				if (adj[i][j] > adj[i][k]+adj[k][j])
					path[i][j] = path[i][k];
				adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
			}
		}
	}

	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			int current=i;
			while (current != j) {
				used[current][path[current][j]]=1;
				current = path[current][j];
			}
		}
	}

	int ans=0;
	for (vector<int> v : edges)
		if (!used[v[0]][v[1]]) ans++;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n,k;
int ans;
int main(){
  cin >> n >> k;
  REP(i,n){
    int l;
    cin >> l;
    ans += 2 * min(l,k-l);
  }
  cout << ans <<endl;
  return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    sort(all(a));
    cout << a[a.size()-1]-a[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , M;
  cin >> N >> M;
  vector <int> S(N);
  int wa = 0; 
    for (int i=0; i<N; i++){
        int a; 
        cin >> a;
        S.at(i) = a ;
        wa += a;
    }
  int count=0;
  for (int i=0; i<N; i++){
       if(S.at(i)*4*M >= wa ){
       count ++;
       }
    }
  if (count >= M){
    cout << "Yes" <<endl;
  } 
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

    long double eps = 1.0e-14;

    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 384