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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int j;
        cin>>j;
        a[i] = j;
    }
    // dp[i] -> whether current player can win given there are i stones remaining
    vector<bool> dp(k+1);
    for(int stones = 0;stones<=k;stones++){
        for(int x: a){
            if(stones>=x&&!dp[stones-x])
                dp[stones] = true;
        }
    }
    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[4][13]={0};//これで全てゼロクリアされます
  int i, j, k, x, n;
  char m;

  scanf("%d", &n);

  for(k = 0; k < n; k++){
    scanf(" %c %d", &m, &x);//先頭にスペースを入れておくと、スペースや改行をパスできる
    if(m == 'S')
      a[0][x - 1] = 1;
    else if(m == 'H')
      a[1][x - 1] = 1;
    else if(m == 'C')
      a[2][x - 1] = 1;
    else if(m == 'D')
      a[3][x - 1] = 1;
  }

  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(a[i][j] == 0){
	if(i == 0)
	  printf("S %d\n", j + 1);
	else if(i == 1)
	  printf("H %d\n", j + 1);
	else if(i == 2)
	  printf("C %d\n", j + 1);
	else if(i == 3)
	  printf("D %d\n", j + 1);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include<iostream>
    
using namespace std;
     
int main()
    {
        int n;
        cin>>n;
        int dp[3]={0};
        for(int d=0;d<n;d++){
            int arr[3];
            for(int i=0;i<3;i++) scanf("%d", &arr[i]);
            int curr[3] = {0};
            for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                    if(i==j)continue;
                    curr[j] = max(curr[j], dp[i] + arr[j]);
                }
            }
     
            for(int z = 0;z<3;z++){
                dp[z] = curr[z];
            }
        }
        printf("%d", max({dp[0], dp[1], dp[2]}));
       return 0;
    }

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, n; cin >> h >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  cout << (accumulate(ALL(a), 0) >= h ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

char map[111][111];

int main()
{
	int A,B; scanf ("%d %d",&A,&B);

	if (A >= 2 && B >= 2){
		A--; B--;
		for (int i=0;i<50;i++) for (int j=0;j<100;j++){
			if (((i+1) & 1) && (j & 1)) map[i][j] = '#';
			else map[i][j] = '.';
		}
		for (int i=50;i<100;i++) for (int j=0;j<100;j++){
			if ((i & 1) && (j & 1)) map[i][j] = '.';
			else map[i][j] = '#';
		}
		for (int i=0;i<50;i+=2) for (int j=1;j<100;j+=2){
			if (B > 0) B--;
			else map[i][j] = '.';
		}
		for (int i=51;i<100;i+=2) for (int j=1;j<100;j+=2){
			if (A > 0) A--;
			else map[i][j] = '#';
		}
	}
	else if (A == 1){
		for (int i=0;i<100;i++) for (int j=0;j<100;j++){
			if ((i & 1) && (j & 1)) map[i][j] = '#';
			else map[i][j] = '.';
		}
		for (int i=1;i<100;i+=2) for (int j=1;j<100;j+=2){
			if (B > 0) B--;
			else map[i][j] = '.';
		}
	}
	else if (B == 1){
		for (int i=0;i<100;i++) for (int j=0;j<100;j++){
			if ((i & 1) && (j & 1)) map[i][j] = '.';
			else map[i][j] = '#';
		}
		for (int i=1;i<100;i+=2) for (int j=1;j<100;j+=2){
			if (A > 0) A--;
			else map[i][j] = '#';
		}
	}

	printf ("100 100\n");
	for (int i=0;i<100;i++) puts(map[i]);

	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  auto dp = Make2DVector<FiniteField>(c + 1, d + 1, 0);
  dp[a][b] = 1;
  for (int x = a; x <= c; x++) {
    for (int y = b; y <= d; y++) {
      if (x == a && y == b) continue;
      dp[x][y] += dp[x][y - 1] * x;
      dp[x][y] += dp[x - 1][y] * y;
      dp[x][y] -= dp[x - 1][y - 1] * (x - 1) * (y - 1);
    }
  }
  cout << dp[c][d].Value() << endl;
}

Measured memory_bytes: 73664
n = input()
n = int(n)

total = 0

lst_a = input().split()
lst_b = input().split()

for i in range(0, n ,1):
    a = lst_a[i]
    b = lst_b[i]
    a = int(a)
    b = int(b)
    if a > b:
        total += (a - b)

print(total)

Measured memory_bytes: 3064
// DSL_1_A.cpp
// Set - Disjoint Set???Union Find Tree

#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

class UF {
public:
    vector<int> id, rank;
    UF() {}
    UF(int size) {
        id.resize(size, 0);
        rank.resize(size, 0);
        for (int i = 0; i < size; i++) {
            id[i] = i;
        }
    }

    int root(int x) {
        if (x != id[x]) {
            id[x] = root(id[x]);
        }
        return id[x];
    }

    void same(int x, int y)
    {
        if (root(x) == root(y)) {
            printf("%d\n", 1);
        }
        else printf("%d\n", 0);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] <= rank[ry]) {
            id[rx] = ry;
            if (rank[rx] == rank[ry]) {
                rank[ry]++;
            }
        }
        else {
            id[ry] = rx;
        }
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    UF uf = UF(n);
    int cmd, x, y;
    while (q--) {
        cin >> cmd >> x >> y;
        if(cmd) {
            uf.same(x, y);
        }
        else uf.unite(x, y);
    }
    return 0;
}

Measured memory_bytes: 3308
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.nextLine();
    String str = "WA";
    int count = 0;
    boolean f = true;
    int len = a.length();
    if(a.charAt(0) == 'A'){
      for(int i = 2;i < len-1;i++){
        if(a.charAt(i)=='C'){
          count++;
        }else{
          if(Character.isUpperCase(a.charAt(i)))f=false;
        }
      }
    }
    if(Character.isUpperCase(a.charAt(1)))f=false;
    if(Character.isUpperCase(a.charAt(len-1)))f=false;
    if(count == 1 && f)str = "AC";
    System.out.println(str);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a = a + b - c - d;
    if (a > 0) cout << "Left";
    if (a < 0) cout << "Right";
    if (a == 0) cout << "Balanced";
}

Measured memory_bytes: 3632
#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>;

int main() {
    string s;
    cin >> s;
    s.at(5) = ' ';
    s.at(13) = ' ';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	vvi dp(n+1, vi(3, 0));
	
	int a, b, c;
	for(int i=1 ; i<=n ; ++i){
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
	}
	
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s<d) cout<<"No";
    else cout<<"Yes";
    return 0;   
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vi t(n),x(n),y(n);
	rep(i,n){
		cin>>t[i]>>x[i]>>y[i];
	}
	if(t[0]<x[0]+y[0]){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=1;i<n;++i){
		if((t[i]-t[i-1])<(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(t[0]%2!=(x[0]+y[0])%2){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=1;i<n;++i){
		if((t[i]-t[i-1])%2!=(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
class Dice:
  def __init__(self, state):
    self.state = state

  def vertical(self, direction):
    s = self.state
    state = [s[1], s[5], s[0], s[4]]
    if direction < 0:
      s[0], s[1], s[4], s[5] = state
    elif 0 < direction:
      s[0], s[1], s[4], s[5] = reversed(state)
    return self
  
  def lateral(self, direction):
    s = self.state
    state = [s[2], s[5], s[0], s[3]]
    if direction < 0:
      s[0], s[2], s[3], s[5] = state
    elif 0 < direction:
      s[0], s[2], s[3], s[5] = reversed(state)
    return self

  def north(self):
    self.vertical(-1)
    return self

  def south(self):
    self.vertical(1)
    return self
  
  def east(self):
    self.lateral(1)
    return self

  def west(self):
    self.lateral(-1)
    return self

dice1 = Dice(input().split())
dice2 = Dice(input().split())

if dice1.state == dice2.state:
  print('Yes')
else:
  is_eql = False
  for c in list('NNNNWNNNWNNNENNNENNNWNNN'):       
    if c == 'N':
      dice1.north()
    elif c == 'S':
      dice1.south()
    elif c == 'W':
      dice1.west()
    elif c == 'E':
      dice1.east()
    if dice1.state == dice2.state:
      is_eql = True
      break
  print('Yes' if is_eql else 'No')
      
  


Measured memory_bytes: 5572
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            int m = sc.nextInt();
            if(n==0 && m==0) break;

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

            int pos = 1;
            int ans = Integer.MAX_VALUE;
            for(int i=0; i<m; i++){
                pos += sc.nextInt();
                if(pos>=n){
                    ans = Math.min(ans, i+1);
                    continue;
                }
                pos = Math.abs(pos+sugo[pos-1]);
                if(pos>=n) ans = Math.min(ans, i+1);
            }
            System.out.println(ans);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 27644
import math
import heapq
def main():

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    l, r = 1, max(A)
    valid = max(A)

    while l <= r:
        m = (l+r) // 2
        count = 0
        for v in A:
            count += (v-1) // m
        if count <= K:
            r = m-1
            valid = min(valid, m)
        else:
            l = m+1

    ans = max(A)
    for u in [valid+1, valid, max(1,valid-1)]:
        count = 0
        for v in A:
            count += (v-1) // u
        if count <= K:
            ans = u
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 93688
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    ll x;
    cin >> x;
    ll res = 0;
    res += x/11*2;
    x%=11;
    if(x>0){
        if(x<=6)res++;
        else res += 2;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(a == 1 && b != 1){
        print("Alice");
    }else if(a != 1 && b == 1){
        print("Bob");
    }else if(a == b){
        print("Draw");
    }else{
        if(a > b){
            print("Alice");
        }else{
            print("Bob");
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int n,m,k;
vector<int> h1(15);
vector<int> h2(15);

string cmp(string a,string b)
{
  if(a.size()>b.size()) return a;
  if(b.size()>a.size()) return b;
  return max(a,b);
}

int main(int argc,char const* argv[])
{
  while(1)
    {
      cin >> n >> m >> k;
      if(!n) break;
      double dp[2][100005];
      memset(dp,0.0,sizeof(dp));
      dp[0][0]=1.0;
      for(int i=1;i<=n;i++)
	{
	  for(int j=0;j<m*n+1;j++) dp[i%2][j]=0;
	  for(int prev=0;prev<=n*m;prev++)
	    {
	      if(dp[(i+1)%2][prev]==0) continue;
	      for(int k=1;k<=m;k++)
		{
		  int nxt=prev+k;
		  dp[i%2][nxt]+=dp[(i+1)%2][prev]*(double)(1.0/m+0.0);
		}
	    }
	}
      cout << fixed << setprecision(9);
      double ans=0.0;

      for(int j=1;j<=n*m;j++)
	{
	  if(j<=k)
	    {
	      dp[n%2][k+1]+=dp[n%2][j];
	    }
	  else
	    {
	      ans+=dp[n%2][j]*(double)(j-k);
	    }
	}
	
      cout << ans << endl;
    }
  return 0;
}



Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
int ans=0,n,a[100001];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int t=1,z=a[1];
	for (int i=2;i<=n;i++)
	  if (a[i]!=a[i-1])
	  {
	  	if (t>=z) ans+=t-z;
	  	else ans+=t;
	  	z=a[i];
	  	t=1;
	  }
	  else t++;
	if (t>=z) ans+=t-z;
	else ans+=t;
	printf("%d",ans);
	return 0;
}

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

int main(){
    int n, q; cin >> n >> q;
    vector<ll> a(n), x(q);
    rep(i, n) cin >> a[i];
    rep(i, q) {
        ll x; cin >> x;
        ll res = 0;
        int r = 0;
        ll sum = 0;
        rep(l, n) {
            while (r < n && sum + a[r] <= x) {
                sum += a[r];
                r++;
            }
            res += r - l;
            if (l == r) r++;
            else sum -= a[l];
        }
        cout << res << endl;
    }
}
   


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);


int main() {
    cin>>N;
    cout<<10 - (N / 200)<<endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main(void){
    // Your code here!
    int X,N;
    int p[100];
    int tmp;
    
    scanf("%d%d",&X,&N);
    tmp = X;
    
    for(int i = 0; i < N; i++){
        scanf("%d",&p[i]);
    }
    
    for(int i = 0; i <= 51; i++){
        int flag_p = 0;
        int flag_m = 0;
        for(int j = 0; j < N; j++){
            if(p[j] == X-i){
                flag_m = 1;
            }
            if(p[j] == X+i){
                flag_p = 1;
            }
        }
        
        if(flag_m == 0){
            printf("%d\n",X-i);
            return 0;
        }
        else if(flag_p == 0){
            printf("%d\n",X+i);
            return 0;
        }
    }
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll a=x/d;
    ll m=x%d;
    if(a==k)  {
        cout<<m<<endl;
    }
    else if(a<k) {
        if((k-a)%2==0) cout<<m<<endl;
        else {
            k%=2;
            cout<<min(m+d,-(m-d))<<endl;
        }
    }
    else {
        ll b=x-k*d;
        cout<<b<<endl;
    }
    return 0;
}

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

A,B,C,X,Y = map(int, input().split())

ans = 10000 * 10**5
for z in range(10**5+1):
    x = max(X-z, 0)
    y = max(Y-z, 0)
    yen = A*x + B*y + 2*C*z
    if ans > yen:
        ans = yen

print(ans)


Measured memory_bytes: 9128
N, M, C = map(int, input().split())
blist = list(map(int, input().split()))
alist = [list(map(int, input().split())) for _ in range(N)]

print(sum([1 if sum(t[0]*t[1] for t in zip(alist[i], blist)) + C > 0 else 0 for i in range(N)]))

Measured memory_bytes: 3060
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        long[] XY = r.ll();
        long a = XY[0];
        int n;
        for(n = 0; a <= XY[1]; n++)
            a *= 2;
        println(n);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21332
x, y, z = input()
sum=0
if x=='R' and y=='R' and z == 'R':
    print(3)
elif (x=='R' and y=='R') or (y=='R' and z =='R'):
    print(2)
elif x=='R' or y=='R' or z=='R':
    print(1)
else:
    print(0)




Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
 
  // ここにプログラムを追記
  int x = 1;
  for (int i = 0; i < N; i++) {
   
    if (x * 2 < x + K) {
      x *= 2;
    } else {
      x += K; 
    }
  }
  
   
  cout << x << endl;
  
}

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

int main() {
    int a,b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
long long int a,b,c;
scanf("%lld",&b);
for(a=1;a<=sqrt(b);a++)
{
	if(a*a<=b)
	c=a*a;
} 
printf("%lld",c);
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 2000;
const int P = 1e9 + 7;

int f[MAXN], g[MAXN], S, sum[MAXN];

int main() {
    IO::read(S);
    f[0] = 1, sum[0] = sum[1] = sum[2] = sum[3] = 1;
    for (int i = 3; i <= S; ++i) {
        (f[i] += sum[i - 3]) %= P;
        sum[i] = (sum[i - 1] + f[i]) % P;
    }
    printf("%d\n", f[S]);
    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  if (s.size() == 1) {
    std::cout << s << std::endl;
    return 0;
  }

  int64_t ans = 0;
  for (int i = 0; i < (1 << (s.size() - 1)); i++) {
    int64_t sum = 0, tmp = (s[0] - '0');
    for (int j = 1; j < s.size(); j++) {
      if ((i & (1 << (j - 1))) != 0) {
        sum += tmp;
        tmp = (s[j] - '0');
      } else {
        tmp *= 10;
        tmp += (s[j] - '0');
      }
    }
    sum += tmp;
    ans += sum;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  int N,S=0; cin>>N;
  int num=N;

  while(num>0){
    S+=(num%10);
    num/=10;
  }
  cout<<(N%S==0?"Yes":"No")<<endl;

  return 0;
}


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

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int **graph;
  graph = (int**)malloc(sizeof(int*)*(n+22));
  for(int i=0; i<n+22; i++)
    graph[i] = malloc(sizeof(int)*(m+22));
  while(m--){
    int a, b;  scanf("%d %d", &a, &b);
    graph[a][++graph[a][0]] = b;
    graph[b][++graph[b][0]] = a;
  }

  int ans[100005] = {0}, anscount = 0;  ans[1] = 1;
  int queue[100000], front = 0, rear = 0, qsize = 100000;
  queue[rear++] = 1;
  while(front != rear){
    int now = queue[front];  front = (front+1)%qsize;
    for(int i=1; i<=graph[now][0]; i++)
      if(!ans[graph[now][i]]){
	ans[graph[now][i]] = now;
	queue[rear] = graph[now][i];
	rear = (rear+1)%qsize;
	anscount++;
      }
  }

  if(anscount != n-1){
    printf("No\n");
  }else{
    printf("Yes\n");
    for(int i=2; i<=n; i++)
      printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 556644
#include <bits/stdc++.h>
using namespace std;
int dp[100010];
int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;++i) cin >> h[i];
    for(int i=0;i<n-1;++i){
        dp[i+1] = dp[i] + abs(h[i+1]-h[i]);
        for(int j=0;j<k;++j){
            if(i-j<0) continue;
            dp[i+1] = min(dp[i+1],dp[i-j] + abs(h[i+1]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 23104
n = int(input())

MOD = 10 ** 9 + 7

k = len(bin(n)) - 2

dp = [[0, 0, 0] for _ in range(k + 1)]

dp[0][0] = 1

for i in range(k):
    if (n >> (k - 1 - i)) & 1:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = dp[i][0] + dp[i][1]
        dp[i+1][2] = dp[i][1] * 2 + dp[i][2] * 3
    else:
        dp[i+1][0] = dp[i][0] + dp[i][1]
        dp[i+1][1] = dp[i][1]
        dp[i+1][2] = dp[i][1] + dp[i][2] * 3
    map(lambda x:x%MOD, dp[k])

print(sum(dp[k]) % MOD)

Measured memory_bytes: 3064
import sys
n,k=map(int,input().split())
data=[]
for i in range(n):
    t,d=map(int,input().split())
    data.append([d,t])
data.sort(reverse=True)
flag=[0]*(n+1)
eat=[]
lst=[]
count=0
for u in data:
    d,t=u
    if flag[t]==0:
        eat.append(u)
        flag[t]=1
        count+=1
        if count==k:
            break
    else:
        lst.append(u)
else:
    lst.sort(reverse=True)
    sum=0
    for i in range(n-count):
        if i<k-count:
            sum+=lst[i][0]
        else:
            if lst[i][0]>eat[count-1][0]+2*count-1:
                eat[count-1]=lst[i]
                count-=1
            else:
                break
    for u in eat:
        sum+=u[0]
    sum+=count**2
    print(sum)
    sys.exit()
lst.sort(reverse=True)
for u in lst:
    d=u[0]
    if d>eat[count-1][0]+2*count-1:
        eat[count-1]=u
        count-=1
    else:
        break
sum=0
for u in eat:
    sum+=u[0]
sum+=count**2
print(sum)

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

Sd = input()
T = input()
lSd, lT = len(Sd), len(T)

found = []
for i in range(lSd - lT + 1):
    subFound = True
    for j in range(lT):
        if not (Sd[i + j] == T[j] or Sd[i + j] == '?'):
            subFound = False
    if subFound:
        found.append((Sd[0:i] + T + Sd[i + lT:]).replace('?', 'a'))

found.sort()
if len(found) == 0:
    S = "UNRESTORABLE"
else:
    S = found[0]

print(S)


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

int main(int argc, char *argv[])
{
    string s;
    cin>>s;
    const string original = "CODEFESTIVAL2016";
    int count = 0;
    for(int i = 0; original[i]; ++i) if(original[i] != s[i]) count++;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
int N, K;
vector<int> D;
vector<vector<int>>A;
bool F[100] = { false };
int main() {
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			a--;
			F[a] = true;
		}
	}
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		if (!F[i]) ANS++;
	}
	cout << ANS;
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    int K = sc.nextInt();
    int X = sc.nextInt();
    
    if ((K * 500) >= X) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    int count = 0;
    for(int i = h; i <= H; i += h)
    {
        for(int j = w; j <= W; j += w)
        {
            count++;
        }
    }
    ll co = (1e9 - 1) / (h*w-1);
    ll ans = count * (-h*w*co+co-1) + co*(H*W-count);
    if(ans < 0) cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
        vector<vector<int>> tmp(H+1, vector<int>(W+1));
        for(int i = 1; i <= H; i++)
        {
            int x = i;
            for(int j = 1; j <= W; j++)
            {
                if(i % h != 0)
                {
                    cout << co << " ";
                }
                else
                {
                    if(j % w != 0) cout << co << " ";
                    else cout << -h*w*co+co-1 << " ";
                }
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3968
#include<stdio.h>

#define INFTY 1000000001

void merge(int *, int, int, int);
void mergeSort(int *, int, int);

int count;

int main()
{
  int i, n, S[500000];

  scanf("%d", &n);

  for(i=0; i<n; i++)
    {
      scanf("%d", &S[i]);
    }

  mergeSort(S, 0, n);
  for(i=0; i<n; i++)
    {
      printf("%d", S[i]);
      if(i+1 < n) printf(" ");
    }
  printf("\n");
  printf("%d\n", count);
  
  return 0;
}
void merge(int *A, int left, int mid, int right)
{
  int i, j, k;
  int n1 = mid-left;
  int n2 = right-mid;
  int L[n1+1], R[n2+1];

  for(i=0; i<n1; i++)
    {
      L[i] = A[left+i];
    }
  for(i=0; i<n2; i++)
    {
      R[i] = A[mid+i];
    }

  L[n1] = R[n2] = INFTY;
  i = j = 0;

  for(k=left; k<right; k++)
    {
      count++;
      if(L[i] <= R[j])
	{
	  A[k] = L[i];
	  i = i+1;
	}
      else
	{
	  A[k] = R[j];
	  j = j+1;
	}
    }
}
void mergeSort(int *A, int left, int right)
{
  int mid;
  
  if(left+1 < right)
    {
      mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }
}

Measured memory_bytes: 4508
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	s := map[rune]int{}
	for _, v := range S {
		s[v]++
	}

	ans := "No"
	if len(s) == 2 {
		ans = "Yes"
		for _, v := range s {
			if v != 2 {
				ans = "No"
				break
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import product
    n=int(input())
    match=[[0]*n for _ in range(n)]
    V=0 # V=n(n-1)/2
    for i,j in product(range(n),repeat=2):
        if(i>=j): continue
        match[i][j]=V
        V+=1

    def toID(i,j):
        if(i>j): i,j=j,i
        return match[i][j]

    E=[[] for _ in range(V)]
    for i in range(n):
        A=list(map(lambda x:int(x)-1,input().split()))
        for j in range(1,n-1):
            E[toID(i,A[j-1])].append(toID(i,A[j]))
    # 頂点数Vの有向グラフをdfsしてLongest pathの長さを求める
    # -1: unchecked, -2: checked and uncalculated
    dp=[-1]*V
    def dfs(v):
        if(dp[v]>=0): return
        dp[v]=-2
        length=0
        for nv in E[v]:
            if(dp[nv]==-2):
                print(-1)
                exit()
            if(dp[nv]==-1):
                dfs(nv)
            length=max(length,dp[nv]+1)
        dp[v]=length
    # calculate
    for i in range(V): dfs(i)
    print(max(dp)+1)
resolve()

Measured memory_bytes: 131712
#include <iostream>
#include <algorithm>
#define N 100
#define INF 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int n;
int M[N][N],color[N],d[N],p[N];
   //M??????????????????color????¨??????¶???(0,1,2),d????????????????°???????????¨????
   //p???MST???????°???¨?????¨??????????????????????????????

int Prim() {
	for (int i = 0;i < n;i++) d[i] = INF;
	d[0] = 0;  //?????????????????????????????§???????????§????´???????????????????????????????
	/*p[0] = -1;  //?????????????????????????????????????????? (???????????£????????????)*/

	int u;
	while (true) {
		int min = INF;
		for (int i = 0;i < n;i++) {  //MST????§???????????????????????????????????±????
			if(color[i]!=BLACK&&min>d[i]){
				min = d[i];  //??´??°?????????????????°min?????°??????d[i]???????´??????????????????????...
				u = i;
			}
		}

	if (min == INF) break; //????????\?????????d[i]?????´??°??§???????????¨???????????¨

	color[u] = BLACK;

	for (int v = 0;v < n;v++) 
		if(color[v]!=BLACK&&M[u][v]!=-1)
			if (M[u][v] < d[v]) {
				d[v] = M[u][v];  //?????????????????????????±????
				/*p[v] = u;*/
				/*color[v] = GRAY;(????????????bcSSSP??§?????¢?´¢?????????????????????????????§?????????S)*/
			}

	}

	int sum = 0;
	for (int i = 0;i < n;i++) sum += d[i];  //d[i]???????¨????MST???????????????
	return sum;
		
}

int main() {
	cin >> n;
	for (int i = 0;i < n;i++)
		for (int j = 0;j < n;j++) {
			cin >> M[i][j];
			if (M[i][j] == -1) M[i][j] = INF;
		}

	cout<<Prim()<<endl;

}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<double> b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) b[i] = (double)1 / a[i];
    double sum = 0.0;
    rep(i, n) sum += b[i];
    cout << fixed << setprecision(7) << 1.0 / sum << endl;
}

Measured memory_bytes: 256
import math


class SegmentTree:
    __slots__ = ["elem_size", "tree_size", "tree"]

    def __init__(self, a: list, default: int):
        real_size = len(a)
        self.elem_size = 1 << math.ceil(math.log2(real_size))
        self.tree_size = 2 * self.elem_size + 1
        self.tree = [default] * (self.elem_size - 1) + a + [default] * (self.elem_size - real_size)

    def get_range_index(self, x, y, k=0, l_end=0, r_end=None):
        '''[x, y], tree[k], [l_end, r_end)'''
        if r_end is None:
            r_end = self.elem_size

        if l_end == x and y == r_end-1:
            return [k]
        elif not l_end <= x <= y < r_end:
            return []

        mid = (l_end + r_end) // 2
        left_y = y if y < mid-1 else mid-1
        right_x = x if x > mid else mid

        left = self.get_range_index(x, left_y, 2*k+1, l_end, mid)
        right = self.get_range_index(right_x, y, 2*k+2, mid, r_end)
        return left + right

    def get_value(self, x, y):
        tree = self.tree
        index_list = self.get_range_index(x, y)

        return sum(tree[n] for n in index_list)

    def update_tree(self, k: int):
        tree = self.tree

        while k > 0:
            k = (k-1) // 2
            left, right = tree[2*k+1], tree[2*k+2]
            tree[k] = left + right

    def set_value(self, i: int, value: int, op: str):
        k = self.elem_size - 1 + i
        if op == "=":
            self.tree[k] = value
        elif op == "+":
            self.tree[k] += value
        self.update_tree(k)


n, q = map(int, input().split())
rsq = SegmentTree([0]*n, 0)
ans = []
for _ in [0]*q:
    c, x, y = map(int, input().split())
    if c == 0:
        rsq.set_value(x-1, y, "+")
    else:
        ans.append(rsq.get_value(x-1, y-1))
print("\n".join([str(n) for n in ans]))

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

int main(){
  string s,a="abcdefghijklmnopqrstuvwxyz";

  cin>>s;
  int sz=s.size();
  for(int i=0;i<26;i++){
    bool flag=false;
    for(int j=0;j<sz;j++){
      if(a[i]==s[j]) flag=true;
    }
    if(!flag){ cout<<a[i]; return 0; }
  }
  cout<<"None";

}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!

s = list(input())

t = []

for i in range(len(s)):
    if s[i] == '0':
        t.append('0')
    elif s[i] == '1':
        t.append('1')
    else:
        if len(t) != 0:
            del t[-1]

print(''.join(t))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 5e3 + 10;
ll z[MAXN];
ll n; 
void z_function(string s){
    ll nn = s.size();

    FOR(i,0,n+1) z[i] = 0;

    for(ll i=1,l=0,r=0;i<nn;i++){
        if(i<=r) z[i] = min(r-i+1,z[i-l]);
        while(i+z[i]<nn && s[z[i]] == s[i+z[i]]) z[i]++;
        if(i+z[i]-1>r) l=i,r=i+z[i]-1;
    }
}

void solve(){

    cin>>n;
    string s; cin>>s; 
    ll ans = 0;

    FOR(i,0,n-1){
        string temp = "";
        FOR(j,i,n-1){
            temp = temp + s[j];
        }
        z_function(temp);

        FOR(j,0,n){
            ans = max(ans,min(z[j],j));
        }
    }

    cout<<ans<<endl;
}

signed main(){
 
   FastRead;    
 
    
    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    string date;
    cin >> date;
    string correctDate;
    if(date[3] == '7'){
        string odd = date.substr(4);
        correctDate = "2018" + odd;
    }else{
        correctDate = date;
    }
    cout << correctDate << endl;
}

Measured memory_bytes: 256
n = int(input())
hi = list(map(int, input().split()))

dp = [float('INF')] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(hi[i] - hi[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(hi[i] - hi[i-2]))

print(dp[-1])


Measured memory_bytes: 13928
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	string s = readln.chomp;
	auto n = s.length;

	int ans = 0;
	foreach(i; 0 .. n){
		if(i <= n - 1 - i && s[i] != s[n - 1 - i]) ans += 1;
	}

	ans.writeln;
}

Measured memory_bytes: 256