akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        Fscan sc = new Fscan();
        int a = sc.nextInt();
        int p = sc.nextInt();
        p += a*3;
        System.out.println(p/2);

    }
}

class Fscan {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    ll che;
    cin >> che;
    ll ans = pow(che,3);
    cout << ans << endl;
}



Measured memory_bytes: 3240
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

const int NMAX = 100110;
typedef long long i64;

i64 rucsac[NMAX];
int W;
int DIM;

void add(int w, int c)
{
    for (int i = DIM; i >= c; i--)
        rucsac[i] = min(rucsac[i], rucsac[i - c] + w);
}

int main()
{
    int n;
    scanf("%d%d", &n, &W);
    DIM = n * 1000;
    fill(rucsac + 1, rucsac + DIM + 1, 1e18);

    for (int i = 1; i <= n; i++) {
        int w, c;
        scanf("%d%d", &w, &c);
        add(w, c);
    }

    int ans = 0;
    for (int i = 1; i <= DIM; i++)
        if (rucsac[i] <= W)
            ans = i;

    printf("%d\n", ans); /// mereu optim ;)

    return 0;
}


Measured memory_bytes: 896
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let helix = read_as_string();
    match &*helix{
        "A" => println!("T"),
        "T" => println!("A"),
        "C" => println!("G"),
        "G" => println!("C"),
        _ => println!("C"),
    }
}


Measured memory_bytes: 4352
n=int(input())
a=[int(i) for i in input().split()]
count=0

for j in range(1000):
    count_are=0
    for i in range(n):
        if a[i]%2==0:
            count_are=count_are+1
    if count_are==n:
        count=count+1
        for i in range(n):
            a[i]=a[i]/2
    else:
        break

print(count)

Measured memory_bytes: 3060
#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 x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
var N,i,j:Longint;
x,p,ans,now:int64;
A:Array[1..2000]of int64;
begin
read(N,x);
for i:=1 to N do read(A[i]);
ans:=10000000000000000;
for j:=0 to N do begin
p:=A[1];
now:=j*x;
for i:=1 to N do begin
inc(now,A[i]);
if(i<N)and(A[i]>A[i+1])then A[i]:=A[i+1];
end;
if ans>now then ans:=now;
if A[N]>p then A[N]:=p;
end;
writeln(ans);
end.

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
using namespace std;
const int maxn = 1e2 + 10;

struct Res{
    string city;
    int score, whe;
}res[maxn];

bool com(Res &a, Res &b){
    if(a.city == b.city){
        return a.score > b.score;
    }
    for(int i = 0; i < a.city.length() && i < b.city.length(); i++){
        if(a.city[i] != b.city[i]){
            return a.city[i] < b.city[i];
        }
    }
    return a.city.length() < b.city.length();
}

int main(){
    int n, Score;
    cin >> n;
    string a;
    for(int i = 0; i < n; i++){
        cin >> a >> Score;
        res[i].city = a;
        res[i].score = Score;
        res[i].whe = i + 1;
    }
    sort(res, res + n, com);
    for(int i = 0; i < n; i++){
        cout << res[i].whe << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
const ll max_n = 1e3+5;
const ll max_h = 1e4+5;
const ll inf = 1e12;

int main() {
    // your code goes here
    ll h, n, a[max_n], b[max_n], dp[max_h];
    cin >> h >> n;
    rep(i,1,n) cin >> a[i] >> b[i];
    dp[0] = 0;
  	rep(i,1,h) dp[i] = inf;
    rep(i,1,n) rep(j,0,h) dp[j] = min(dp[j], dp[max(0ll, j-a[i])] + b[i]);
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        long A = sc.nextLong();
        long B = sc.nextLong();
        sc.close();
      
        System.out.println( calc(A-1) ^ calc(B) );
    }

    static long calc(long val){
        if( val <= 0L ){
            return 0L;
        }
        
        String str = Long.toBinaryString(val);
        boolean[] odd = new boolean[41];
        long base = 1L;
        
        for(int i = 0; i < str.length(); i++){
            
            if(i == 0){
                long x = val % 4;
                if( x == 1 || x == 2 ) odd[0] = true;
                continue;
            }
            
            base *= 2;
            if( str.charAt(str.length()-1-i) == '0' ){
                continue;
            }
            
            long cnt1 = (val % base) + 1;
            if( cnt1 % 2 == 1) odd[i] = true;
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = str.length()-1; i >= 0; i--){
            if(odd[i]){
                sb.append("1");
                
            }else{
                sb.append("0");
            }
        }
        
        return Long.parseLong(sb.toString(), 2);
        
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int sum = 0;
        int c = 0;
        String ans = "Yes";
        int[] A = new int[n];
        for(int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(sc.next());
            sum += A[i];
        }
        Arrays.sort(A);
        double bd = sum / (4.0 * m);
        for(int i = n-1; i >= 0 ; i--) {
            if(A[i] < bd) break;
            c++;
        }
        if(c < m) ans = "No";
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int N, T, L, B;

int next(int cur, int dice) {
    int ret = cur + dice;
    if (N < ret) ret = N - (ret - N);
    return ret;
}

int main() {
    ios::sync_with_stdio(false);

    while (cin >> N >> T >> L >> B && ( N || T || L || B )) {
        string LB(101, ' ');
        int k;
        for (int i=0; i<L; ++i) {
            cin >> k;
            LB[k] = 'L';
        }
        for (int i=0; i<B; ++i) {
            cin >> k;
            LB[k] = 'B';
        }

        double p[101][101][2] = {0};
        p[0][0][0] = 1.0;
        for (int i=0; i<T; ++i) {
            for (int j=0; j<N; ++j) {
                for (int k=1; k<=6; ++k) {
                    int ne = next(j, k);
                    if (LB[ne] == 'B') ne = 0;
                    p[i+1][ne][LB[ne] == 'L'] += p[i][j][0] / 6.0;
                }
                p[i+1][j][0] += p[i][j][1];
            }
        }

        double ans = 0;
        for (int i=0; i<=T; ++i) ans += p[i][N][1] + p[i][N][0];
        cout << setprecision(6) << fixed << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

bitset<57> bit[27],bit_ST,bit_tmp;

struct edge{
    int id,to;
    edge(int id=0,int to=0):id(id),to(to){}
};
vector<edge> vp[52];
vector<int> sto;

pi fa[57];

void dfs(int u,int par) {
    for(edge to:vp[u]) {
        int v = to.to;
        int id = to.id;
        if (v == par) continue;
        fa[v] = make_pair(u,id);
        dfs(v,u);
    }
}

void getpath(int s,int t) {
    sto.clear();
    dfs(s,-1);
    int ff = t;
    while (ff != s) {
        sto.pb(fa[ff].second);
        ff = fa[ff].first;
    }
}

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

    rep(i,0,56) bit_ST.set(i);

    int n,m;
    cin >> n;
    rep(i,1,n-1) {
        int u,v;
        cin >> u >> v;
        vp[u].pb(edge(i,v));
        vp[v].pb(edge(i,u));
    }
    cin >> m;
    rep(i,1,m) {
        int u,v;
        cin >> u >> v;
        getpath(u,v);
        for(int x:sto) {
            bit[i].set(x);
        }
    }

    n --;
    ll ans = 1LL<<n;
    rep(i,1,(1<<m)-1) {
        bit_tmp.reset();
        int bel = 0,num = 0;
        rep(j,1,m) {
            if ((i>>(j-1)) & 1) {
                bel ++;
                bit_tmp |= bit[j];
            }
        }
        num = bit_tmp.count();
        if (bel&1) {
            ans -= 1LL<<(n-num);
        }else {
            ans += 1LL<<(n-num);
        }
        //debug((1<<(n-num)));
    }
    cout << ans << endl;
}

/*
3
1 2
2 3
2
1 3
1 2
*/


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

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

    float odd = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 == 1) odd++;
    }

    cout << odd / N << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e;
    //int f=0;
    string st,tt,nt;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    a=0;
    cin>>st;
    if(st[0]=='-')a--;
    if(st[1]=='-')a--;
    if(st[2]=='-')a--;
    if(st[3]=='-')a--;
    if(st[0]=='+')a++;
    if(st[1]=='+')a++;
    if(st[2]=='+')a++;
    if(st[3]=='+')a++;
    printa(a);
    return 0;
}

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

N = int(input())
testimony = [[] for _ in range(N)]
for i in range(N):
    for j in range(int(input())):
        xy = tuple(map(int, input().split(' ')))
        testimony[i].append(xy)

def judge(is_honest):
    res = True
    for i in range(N):
        if is_honest[i]:
            for t in testimony[i]:
                x = t[0]-1
                y = t[1]
                if is_honest[x] == True and y == 0:
                    res = False
                if is_honest[x] == False and y == 1:
                    res = False
    return res

ans = 0
for bit in range(2**N):
    is_honest = [False] * N
    for i in range(N):
        if bit & 1<<i:
            is_honest[i] = True
    if judge(is_honest) == True:
        ans = max(ans, is_honest.count(True))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  ll w0 = -1;

  // key: w0 との diff value: vi の プライオリティキュー
  map<ll, priority_queue<ll> > vm;
  priority_queue<ll> q0;
  vm.insert(make_pair(0, q0));
  priority_queue<ll> q1;
  vm.insert(make_pair(1, q1));
  priority_queue<ll> q2;
  vm.insert(make_pair(2, q2));
  priority_queue<ll> q3;
  vm.insert(make_pair(3, q3));

  rep(i, N) {
    ll wi, vi;
    cin >> wi >> vi;
    if(w0 == -1) {
      w0 = wi;
    }
    ll diff = wi - w0;

    // DEBUG(diff);
    // DEBUG(vi);
    vm.at(diff).push(vi);
  }

  ll maxValue = 0;
  repto(i0, vm.at(0).size()) {
    repto(i1, vm.at(1).size()) { 
      repto(i2, vm.at(2).size()) {
        repto(i3, vm.at(3).size()) {

          // DEBUG(i0);
          // DEBUG(i1);
          // DEBUG(i2);
          // DEBUG(i3);

          ll wsum = i0 * w0 + i1 * w0 + i2 * w0 + i3 * w0;
          wsum += i1 * 1 + i2 * 2 + i3 * 3;
          if(wsum <= W) {
            ll vsum = 0;

            priority_queue<ll> cq0 = vm.at(0);
            rep(i, i0) {
              vsum += cq0.top();
              cq0.pop();
            }

            priority_queue<ll> cq1 = vm.at(1);
            rep(i, i1) {
              vsum += cq1.top();
              cq1.pop();
            }

            priority_queue<ll> cq2 = vm.at(2);
            rep(i, i2) {
              vsum += cq2.top();
              cq2.pop();
            }

            priority_queue<ll> cq3 = vm.at(3);
            rep(i, i3) {
              vsum += cq3.top();
              cq3.pop();
            }

            maxValue = max(maxValue, vsum);
          }
        }
        // DEBUG(maxValue);
      }
    }
  }
  cout << maxValue << endl;
}


Measured memory_bytes: 256
import sys
import math
import bisect

def solve(x, y, z):
    max_val = 0
    for i in range(10 ** 18):
        if y * i + z * (i + 1) <= x:
            max_val = i
        else:
            break
    return max_val

def main():
    x, y, z = map(int, input().split())
    print(solve(x, y, z))
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b;
	cin>> a >> b;
	vector<int> c(3);
	c[0]=a+b;
	c[1]=a-b;
	c[2]=a*b;
	sort(c.begin(),c.end());
	cout << c[2]<< endl;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int d[11] = {0};

  d[a]++;
  d[b]++;
  d[c]++;
  d[e]++;

  if (d[1] == 1 && d[9] == 1 && d[7] == 1 && d[4] == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		char[] body = s.toCharArray();
		int n = s.length();
		long k = in.nextLong();
		in.close();

		// sが1文字
		if ( n == 1 ) {
			System.out.println(k / 2);
			return;
		}

		long cnt = 0;
		int temp = 1;
		int kind = 1;
		for ( int i = 1; i < n; i++ ) {
			if ( body[i - 1] == body[i] ) {
				temp++;
			} else {
				cnt += (temp / 2);
				temp = 1;
				kind++;
			}
		}
		cnt += (temp / 2);

		// 先頭と末尾が別文字 or 繰り返しが1回のみ
		if ( body[0] != body[n - 1] || k == 1) {
			System.out.println(cnt * k);
			return;
		}
		
		// sが1種類の文字からなる
		if ( kind == 1 ) {
			System.out.println(n * k / 2);
			return;
		}

		// それ以外
		int idx = 1;
		int head = 1;
		while ( idx < n && body[idx - 1] == body[idx] ) {
			head++;
			idx++;
		}

		idx = n - 1;
		int tail = 1;
		while ( 0 <= idx && body[idx - 1] == body[idx] ) {
			tail++;
			idx--;
		}
		
		// System.out.println("h:" + head + " t:" + tail + " c:" + cnt);
		
		long ans = (cnt - head/2 - tail/2 + (head + tail)/2)*k - (head + tail)/2 + head/2 + tail/2;
		System.out.println(ans);

	}
}

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
"""
Created on Sun Jan  6 21:36:22 2019

@author: Yamazaki Kenichi
"""

H,W = map(int,input().split())
a = [input() for i in range(H)]

r =[[0]*W for i in range(H)]
r[0][0]=1


for i in range(1,W):
    if a[0][i]== '.':
        r[0][i] = r[0][i-1]

for j in range(1,H):
    if a[j][0] =='.':
        r[j][0] = r[j-1][0]
            
for j in range(1,H):
    for i in range(1,W):
        if a[j][i] == '.':
            r[j][i] = r[j-1][i]+r[j][i-1]

print(r[H-1][W-1]%1000000007)
        

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

using namespace std;

int main() {
    int n; cin >> n;
    double arr[n];
    for (int i  = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    long double res = (arr[0] + arr[1])/2;
    for (int i = 2; i < n; i++) {
        res = (res + arr[i])/2;
    }
    cout << fixed << setprecision(10) << res;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <set>
#include <iterator>

using namespace std;

set<string> &num_of_member(
	string const& name,
	unordered_map<string, set<string>> &member_dp,
	unordered_map<string, vector<string>> const& member) {
	if (member_dp.find(name) != member_dp.end()) {
		return member_dp[name];
	}
	set<string> ret;
	auto it = member.find(name);
	if (it == member.end()) {
		ret.insert(name);
	}
	else {
		for (auto const& n : it->second) {
			auto v = num_of_member(n, member_dp, member);
			set_union(ret.begin(), ret.end(), v.begin(), v.end(), inserter(ret, ret.end()));
			//ret.insert(v.begin(), v.end());
		}
	}
	member_dp[name] = ret;
	return member_dp[name];
}

void solve(int n) {
	unordered_map<string, vector<string>> member;
	string line, first;
	for (int i = 0; i < n; i++) {
		cin >> line;
		auto colon = line.find(':');
		auto name = line.substr(0, colon);
		if (i == 0) {
			first = name;
		}
		auto start = colon + 1;
		bool end = false;
		while (!end) {
			auto comma = line.find(',', start);
			if (comma == string::npos) {
				comma = line.size() - 1;
				end = true;
			}
			auto mem_name = line.substr(start, comma - start);
			member[name].push_back(mem_name);
			start = comma + 1;
		}
	}
	unordered_map<string, set<string>> member_dp;
	cout << num_of_member(first, member_dp, member).size() << endl;
}

int main() {
	int n;
	while (cin >> n && n) {
		solve(n);
	}
}

Measured memory_bytes: 3444
//1:10
#include <stdio.h>
#include <string.h>
#include <algorithm>

typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abs(ll a){return(a<0)?-a:a;}

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

//int a[200000];
//int b[200000];
int a, b;
#define MAXI 2000001
int c[MAXI];
int main(){
        int N,M;
        scanf("%d %d",&N,&M);
        memset(c,0,sizeof(c));

        for(int i = 0; i < M; i ++){
                scanf("%d %d",&a,&b);
                if(a == 1 || a == N){
                        c[b]++;
                }
                if(b == 1 || b == N){
                        c[a]++;
                }
        }

        for(int i = 1; i <= MAXI-1; i++){
                if(c[i] == 2){
                        puts("POSSIBLE");
                        return 0;
                }
        }
        puts("IMPOSSIBLE");
}

Measured memory_bytes: 7936
#include <iostream>
#include <cmath>

using namespace std;

int main() {

    int N = 0;
    cin >> N;

    int num = 0;
    int lastHeight = 0;
    int currentHeight = 0;
    int step = 0;
    int maxStep = 0;

    while (num < N) {
        cin >> currentHeight;
        if (lastHeight >= currentHeight) {
            step++;
            maxStep = max(step, maxStep);
        } else {
            step = 0;
        }
        lastHeight = currentHeight;
        num++;
    }

    cout << maxStep << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){

	ll n;
	cin>>n;
	vector<ll> a;
	a.resize(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(a.begin(),a.end(),greater<ll>() );
	ll m[2]={0,0};
	ll j=0;
	ll b=0;
	rep(i,n){
		if(a[i]==b){
			m[j]=a[i];
			j++;
			b=0;
			if(j==2)break;
		}else{
			b=a[i];
		}
	}
	cout<<m[0]*m[1]<<endl;
}



Measured memory_bytes: 1024
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  multiset<ll> as;
  rep(i, N) {
    ll a;
    cin >> a;
    as.insert(a);
  }

  ll res = 0;

  while (!as.empty()) {
    auto num_it = --as.end();
    ll num = *num_it;

    ll sum = 1;
    while (sum <= num) sum *= 2;

    ll pair = sum - num;
    auto pair_it = as.find(pair);

    if (pair_it != as.end() && !(num_it == pair_it && as.count(num) == 1)) {
      res++;
      as.erase(pair_it);
    }

    as.erase(num_it);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 9600
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll X, Y, Z;
  cin >> X >> Y >> Z;
  cout << (X - Z)/(Z + Y);
 
  return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 105;
const int INF = 1000;

vector<int> to[MAX_N];
int d[MAX_N], f[MAX_N]; // d：発見時刻、f：完了時刻
int t = 0; int n; 

void init(){
    rep(i,MAX_N){
        d[i] = INF, f[i] = INF;
    }
}

void dfs(int u){
    if(d[u] == INF) d[u] = ++t;
    for(auto v: to[u]){
        if(d[v] == INF) dfs(v); // *もう訪問が完了している頂点には不要に寄らない
    }
    if(f[u] == INF) f[u] = ++t;
}

void dfs_init(){
    rep(i,n){
        if(d[i] == INF) dfs(i);
    }
}

int main()
{
    cin >> n;
    init();
    rep(i,n){
        int u, k; cin >> u >> k; --u;
        rep(_,k){
            int v; cin >> v; --v;
            to[u].push_back(v);
        }
    }
    dfs_init();
    rep(i,n){
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
}


Measured memory_bytes: 3252
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        if(i%3==0){
            cout<<" "<<i;
        }
        else{
            int x=i;
            while(x){
                if(x%10==3){
                    cout<<" "<<i;
                    break;
                }
                x/=10;
            }
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3108
s=list(input())
t=list(input())
flag=False
ata=0
for i in range(len(s)-len(t)+1):
  if flag==True:
    break
  for j in range(len(t)):
    if s[len(s)-1-(i+j)]!="?" and s[len(s)-1-(i+j)]!=t[len(t)-1-j]:
      break
    if j==(len(t)-1):
      flag=True
      ata=i
if flag==True:
  for i in range(len(t)):
    s[len(s)-1-(ata+i)]=t[len(t)-1-i]
  for i in range(len(s)):
    if s[i]=="?":
      s[i]="a"
  print("".join(s))
else:
  print("UNRESTORABLE")



Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n;
        String result = "No";
        
        n = sc.nextInt();
        
        for(int i = 1; i < 10; i++){
            if((n / i < 10) && (n % i == 0)){
                result = "Yes";
                break;
            }else{
                result = "No";
            }
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,t;cin>>n>>t;
    vin a(n);rep(i,n)cin>>a[i];
    vin maximum(n),minimum(n);
    minimum[0]=a[0];maximum[n-1]=a[n-1];
    rep(i,n-1){
        minimum[i+1]=min(a[i+1],minimum[i]);
        maximum[n-2-i]=max(a[n-2-i],maximum[n-1-i]);
    }
    int m=0;
    rep(i,n)m=max(m,maximum[i]-minimum[i]);
    set<int> ans;
    rep(i,n)if(maximum[i]-minimum[i]==m)ans.insert(minimum[i]);
    cout<<ans.size()<<endl;
}

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

#define rep(i, a, b) for (int i = (a); i < (b); i++)

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

  cout << s;
  if (s[s.size() - 1] == 's')
    cout << "es";
  else
    cout << "s";
  cout << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, n, sum = 0;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	if (sum >= h)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

char s[500001];
char t[500001];

int main(void) {
    scanf("%s\n%s",s,t);
    int n=strlen(s);
    int ret=0;
    for(int i=0;i<n;i++) {
        if(s[i]!=t[i]) {
            ret++;
        }
    }
    printf("%d",ret);
}

Measured memory_bytes: 4176
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int F = sc.nextInt();
		boolean[] b1 = new boolean[F + 1];
		boolean[] b2 = new boolean[F + 1];
		b1[0] = true;
		b2[0] = true;
		for (int i = 0; i < F; ++i) {
			if (i + 100 * A < b1.length)
				b1[i + 100 * A] |= b1[i];
		}
		for (int i = 0; i < F; ++i) {
			if (i + 100 * B < b1.length)
				b1[i + 100 * B] |= b1[i];
		}
		for (int i = 0; i < F; ++i) {
			if (i + C < b1.length)
				b2[i + C] |= b2[i];
		}
		for (int i = 0; i < F; ++i) {
			if (i + D < b1.length)
				b2[i + D] |= b2[i];
		}
		int a = 0;
		int b = 0;
		for (int i = 100; i <= F; i += 100) {
			if (!b1[i])
				continue;
			for (int j = 0; i + j <= F; ++j) {
				if (!b2[j])
					continue;
				if (E * i < j * 100)
					continue;
				if ((a == 0 && b == 0) || b * (i + j) < j * (a + b)) {
					a = i;
					b = j;
				}
			}
		}
		System.out.println((int) (a + b) + " " + (int) b);

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 21844
n,m = map(int,input().split())
l = [int(x) for x in input().split()]

if(n>=m):
  print('0')
  exit(0)
l.sort()
 
gap = [l[i+1]-l[i] for i in range(m-1)]
 
gap.sort()

print(sum(gap[:m-n]))


Measured memory_bytes: 13832
import sys

datasetnum=[]
n=-1

def calculatebillionare(n):
    global datasetnum
    scores={}
    billionares=[]
    if n==-1:
        return None
    else:
        for salesdata in datasetnum:
            if not salesdata[0] in billionares:
                if salesdata[0] in scores:
                    scores[salesdata[0]]=scores[salesdata[0]]+salesdata[1]*salesdata[2]
                else:
                    scores[salesdata[0]]=salesdata[1]*salesdata[2]
                if scores[salesdata[0]]>=1000000:
                    billionares.append(salesdata[0])
                    del(scores[salesdata[0]])
        if len(billionares)==0:
            print "NA"
        else:
            for people in billionares:
                print people
        datasetnum=[]
        return None
                    
for line in sys.stdin:
    line=line.strip()
    line=line.split(" ")
    lineelement=map(int,line)
    if len(lineelement)==1:
        calculatebillionare(n)
        if lineelement[0]==0:
            break
        else:
            n=lineelement[0]
    else:
        datasetnum.append(lineelement)

    

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


int main()
{
	ios_base::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	multiset<int> mt;
	int x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		mt.insert(x);
	}
	while(m--)
	{
		int last = *(--mt.end());
		mt.erase(mt.find(last));
		last>>=1;
		mt.insert(last);
	}
	long long ans=0;
	for(auto i:mt)
		ans+=i;
	cout<<ans;	
}

Measured memory_bytes: 4992
import sys
import math

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B, H, M = map(int, input().split())

    deg_a = H * 30 + M * (30 / 60)
    deg_b = M * (360 / 60)
    deg = min(abs(deg_a - deg_b), 360 - abs(deg_a - deg_b))
    deg = deg / 360 * 2 * math.pi

    ans = A * A + B * B - 2 * A * B * math.cos(deg)
    print(math.sqrt(ans))


if __name__ == "__main__":
    main()


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<string> G(2); cin >> G;
        ll ans = 1;
        bool flg = false;
        rep(i, N) {
            if(G[0][i] == G[1][i]) {
                ans *= i == 0 ? 3 : flg ? 1 : 2;
                flg = false;
            } else {
                assert(G[0][i] == G[0][i + 1] and G[1][i] == G[1][i + 1]);
                ans *= i == 0 ? 6 : flg ? 3 : 2;
                flg = true;
                i++;
            }
            ans %=  1000000007;
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
i=input("")
y=len(i)
i=int(i)
j = []
while i > 0:
    j.append(i%10)
    i //= 10
j.reverse()
k=[]
if y==4:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    k.append(x1)
    k.append(x2)
    print(min(k))
if y==5:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    x3=abs(100*j[2]+10*j[3]+j[4]-753)
    k.append(x1)
    k.append(x2)
    k.append(x3)
    print(min(k))
if y==6:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    x3=abs(100*j[2]+10*j[3]+j[4]-753)
    x4=abs(100*j[3]+10*j[4]+j[5]-753)
    k.append(x1)
    k.append(x2)
    k.append(x3)
    k.append(x4)
    print(min(k))
if y==7:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    x3=abs(100*j[2]+10*j[3]+j[4]-753)
    x4=abs(100*j[3]+10*j[4]+j[5]-753)
    x5=abs(100*j[4]+10*j[5]+j[6]-753)
    k.append(x1)
    k.append(x2)
    k.append(x3)
    k.append(x4)
    k.append(x5)
    print(min(k))
if y==8:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    x3=abs(100*j[2]+10*j[3]+j[4]-753)
    x4=abs(100*j[3]+10*j[4]+j[5]-753)
    x5=abs(100*j[4]+10*j[5]+j[6]-753)
    x6=abs(100*j[5]+10*j[6]+j[7]-753)
    k.append(x1)
    k.append(x2)
    k.append(x3)
    k.append(x4)
    k.append(x5)
    k.append(x6)
    print(min(k))
if y==9:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    x3=abs(100*j[2]+10*j[3]+j[4]-753)
    x4=abs(100*j[3]+10*j[4]+j[5]-753)
    x5=abs(100*j[4]+10*j[5]+j[6]-753)
    x6=abs(100*j[5]+10*j[6]+j[7]-753)
    x7=abs(100*j[6]+10*j[7]+j[8]-753)
    k.append(x1)
    k.append(x2)
    k.append(x3)
    k.append(x4)
    k.append(x5)
    k.append(x6)
    k.append(x7)
    print(min(k))
if y==10:
    x1=abs(100*j[0]+10*j[1]+j[2]-753)
    x2=abs(100*j[1]+10*j[2]+j[3]-753)
    x3=abs(100*j[2]+10*j[3]+j[4]-753)
    x4=abs(100*j[3]+10*j[4]+j[5]-753)
    x5=abs(100*j[4]+10*j[5]+j[6]-753)
    x6=abs(100*j[5]+10*j[6]+j[7]-753)
    x7=abs(100*j[6]+10*j[7]+j[8]-753)
    x8=abs(100*j[7]+10*j[8]+j[9]-753)
    k.append(x1)
    k.append(x2)
    k.append(x3)
    k.append(x4)
    k.append(x5)
    k.append(x6)
    k.append(x7)
    k.append(x8)
    print(min(k))


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

int main(){
  string S,T;
  cin >> S >> T;
  int count=0;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3600
n,k = map(int,input().split())
h_list = [int(input()) for nesya in range(n)]
h = sorted(h_list)
s = 10**9
for i in range(n-k+1):
  t = h[i+k-1] - h[i]
  if s > t:
    s = t
print(s)

Measured memory_bytes: 8280
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define ll long long int
#define ld long double
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define fore(a, v, n) for(ll a=v; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)
//cout<<flush;

using namespace std;

#define MUCHO 9999999

ll n;
map<ll, ll> cants;
ll ns[400000];

int main() {
	IOS;
	cin >> n;
	forn (i) {
		cin >> ns[i];
		cants[ns[i]]++;
	}

	ll count = 0;
	for (auto v = cants.rbegin(); v != cants.rend(); v++) {
		if (!v->second)
			continue;
		assert(v->second > 0);

		{
			ll count = 0;

			fore (e, 1, 31) {
				int sum = 1 << e;
				auto pair = cants.find(sum - v->first);

				if (pair != cants.end() && pair->second)
					count++;
			}

			assert(0 <= count && count <= 1);
		}

		fore (e, 1, 31) {
			ll sum = 1 << e;
			auto pair = cants.find(sum - v->first);
			assert(0 <= pair->second);

			if (pair != cants.end() && pair->second) {
				ll matches = min(pair->second, v->second);

				if (pair->first == v->first)
					matches /= 2;
				pair->second -= matches;
				v->second -= matches;
				count += matches;
				break;
			}
		}
	}

	cout << count << endl;
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define UQns(v) v.erase(unique(ALL(v)), v.end())
#define UQ(v) sort(ALL(v)); UQns(v)

int n;
vector<int> v;
int a[2][8] = {
	{ 2, 10, 3, 9, 4, 8, 6, 0 }, 
	{ 6, 2, 10, 3, 9, 4, 8, 0 }
};

int main() {
	cin >> n;
	
	if(n == 3) { v = { 2, 3, 25 }; }
	else {
		inc(i, (n + 7) / 8) {
			inc(j, 8) {
				v.PB(12 * i + a[n % 2][j]);
				if(v.size() == n) { break; }
			}
		}
	}
	
	if(n >= 8) { v[7] = 30000; }
	
	inc(i, v.size()) { cout << (i == 0 ? "" : " ") << v[i]; }
	cout << endl;
	
	// assert
	UQ(v);
	assert(v.size() == n);
	for(auto && e: v) { assert(inII(e, 1, 30000)); }
	
	int s = 0;
	for(auto && e: v) { s += e; }
	for(auto && e: v) { assert(gcd(e, s - e) > 1); }
	
	int g = v[0];
	for(auto && e: v) { g = gcd(g, e); }
	assert(g == 1);
	
	return 0;
}


Measured memory_bytes: 512
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] DR = { 1, 0, -1, 0 };
	static int[] DC = { 0, 1, 0, -1 };
	static int H, W;

	public static void main(String[] arg) {
		while (true) {
			W = sc.nextInt();
			H = sc.nextInt();
			if (W == 0) break;
			char[][] m = new char[H][];
			for (int i = 0; i < H; ++i) {
				m[i] = sc.next().toCharArray();
			}
			int[][] st = new int[H][W];
			bfs('B', 1, m, st);
			bfs('W', 2, m, st);
			System.out.println(count(1, st) + " " + count(2, st));
		}
	}

	static int count(int v, int[][] st) {
		int c = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (st[i][j] == v) ++c;
			}
		}
		return c;
	}

	static void bfs(char ch, int v, char[][] m, int[][] st) {
		Queue<Point> q = new ArrayDeque<Point>();
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (m[i][j] == ch) {
					q.add(new Point(i, j));
				}
			}
		}
		boolean[][] visited = new boolean[H][W];
		while (!q.isEmpty()) {
			Point p = q.poll();
			int r = p.x;
			int c = p.y;
			for (int i = 0; i < 4; ++i) {
				int nr = r + DR[i];
				int nc = c + DC[i];
				if (0 <= nr && nr < H && 0 <= nc && nc < W && !visited[nr][nc] && m[nr][nc] == '.') {
					q.add(new Point(nr, nc));
					visited[nr][nc] = true;
					st[nr][nc] |= v;
				}
			}
		}
	}

}

Measured memory_bytes: 27916
#include <iostream>

using namespace std;

int main()
{
    int a,h,n,nr,s=0;
    cin>>h>>n;
    for(int i=1; i<=n; ++i)
    {
        cin>>nr;
        s+=nr;
    }
    if(s>=h) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

int main() {
    long long n,m;
    cin >> n >> m;
    long long A[n][m];
    long long B[m];
    vector<long long> C(n, 0);

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> B[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            C.at(i) = C.at(i) + A[i][j]*B[j];
        }
    }
    for(int i=0; i<n; i++){
        cout << C.at(i) << endl;
    }
}


Measured memory_bytes: 3140