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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;

const ll nax = 302;
ll n, freq[4];
double dp[nax][nax][nax];

double ans(ll x, ll y, ll z) {
  if (x == 0 && y == 0 && z == 0) return 0;
  if (x < 0 || y < 0 || z < 0) return 0;
  if (dp[x][y][z] > -0.9) {
    return dp[x][y][z];
  }
  double e = n + x * ans(x - 1, y, z) + y * ans(x + 1, y - 1, z) +
             z * ans(x, y + 1, z - 1);
  dp[x][y][z] = e / (x + y + z);
  return dp[x][y][z];
}

void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int sus;
    cin >> sus;
    freq[sus]++;
  }

  memset(dp, -1, sizeof(dp));
  cout << fixed << setprecision(11) << ans(freq[1], freq[2], freq[3]);
}

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

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 215552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s, t;
  cin >> s >> t;
  if (SZ(s) + 1 == SZ(t) && t.substr(0, SZ(s)) == s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int n, m; cin >> n >> m;
  
  int a[1005];
  int count =0;
  double ans =0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  double sum = ans/(4*m);
  
  for (int i=0; i<n; i++) {
    if (a[i] >= sum)	count++;
  }
  if (count >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>

using namespace std;

int id[15];

void print(const int path[1<<15][15],int stat,int last){
	if(stat==0)	return;

	int befstat=path[stat][last]&((1<<20)-1);
	int beflast=path[stat][last]>>20;
	print(path,befstat,beflast);

	if(befstat>0)	putchar(' ');
	printf("%d",id[last]);
}

int main(){
	int n;	scanf("%d",&n);
	int d[15],m[15];
	for(int i=0;i<n;i++)	scanf("%d%d%d",id+i,d+i,m+i);
	int adj[15][15];
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)	adj[i][j]=abs(d[i]-d[j]);

	static int w[1<<15];
	for(int i=0;i<(1<<n);i++){
		int cnt=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j))	cnt+=m[j];
		}
		w[i]=20*cnt;
	}

	static int path[1<<15][15];
	static double tmin[1<<15][15];	// [visited state][last visited]
	for(int i=0;i<(1<<n);i++)for(int j=0;j<n;j++)	tmin[i][j]=1e30;
	for(int i=0;i<n;i++)	tmin[1<<i][i]=0;

	for(int i=0;i<(1<<n);i++)for(int j=0;j<n;j++){
		if(!(i&(1<<j)))	continue;
		for(int k=0;k<n;k++){
			int nextstat=i|(1<<k);
			if(i<nextstat){
				double nextt=tmin[i][j]+adj[j][k]/(2000./(70+w[i]));
				if(nextt<tmin[nextstat][k]){
					tmin[nextstat][k]=nextt;
					path[nextstat][k]=i|(j<<20);
				}
			}
		}
	}

	int k=0;
	for(int i=0;i<n;i++){
		if(tmin[(1<<n)-1][i]<tmin[(1<<n)-1][k])	k=i;
	}

	print(path,(1<<n)-1,k);
	putchar('\n');

	return 0;
}

Measured memory_bytes: 6600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x/GCD(x,y)*y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{

int N;
cin>>N;

vector<int> V(N),C(N);

rep(i,N) cin>>V[i];
rep(i,N) cin>>C[i];

int S=0;

rep(i,N) if(V[i]-C[i]>0) S+=V[i]-C[i];

cout << S << endl;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE-10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] h = in.ni(n);
        int[] c = new int[n];
        Arrays.fill(c, inf);
        c[0]= 0;
        for (int i = 0; i < n-1; i++) {
            c[i+1] = Math.min(c[i+1], c[i]+Math.abs(h[i+1]-h[i]));
            if(i+2<n) c[i+2] = Math.min(c[i+2], c[i]+Math.abs(h[i+2]-h[i]));
        }
        out.println(c[n-1]);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 31324
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

const int length = 100001;
int par[length]={};
int sz[length]={};
void init(int n){
  for(int i=1;i<=n;i++){
    par[i] = i,sz[i]=1;
  }
}
int find(int x){
  if(par[x] == x)return x;
  else return par[x] = find(par[x]);
}
void unite(int x,int y){
  x = find(x),
  y = find(y);
  if(x==y)return;
  if(sz[x] < sz[y]){
    par[x] = y;
    sz[y] += sz[x];
  }else{
    par[y] = x;
    sz[x] += sz[y];
  }
  return;
}

int get_size(int n){
  return sz[find(n)];
}
int main(){
  int n,m;cin>>n>>m;
  P p[m];
  int a,b;
  fol(i,m){
    cin>>a>>b;
    p[m-1-i] = make_pair(a,b);
  }
  init(n);
  ll ans[m+1] = {};
  ans[m] = 1LL * n * (n-1) /2;
  for(int i=0;i<m;i++){
    a = p[i].first,
    b = p[i].second;
    ans[m-i-1] = ans[m-i];
    if(find(a)!=find(b)){
      ans[m-i-1] -= (1LL*get_size(a)*get_size(b));
    }
    unite(a,b);
  }
  for(int i=1;i<=m;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
	string str;
	cin >> str;
	str.replace(5, 1, " ");
	str.replace(13, 1, " ");
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,k = map(int, input().split())
ns = defaultdict(set)
for _ in range(n-1):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add(v)
    ns[v].add(u)
def bfs(start):
    from queue import deque
    q = deque([start])
    seen = [None] * n
    seen[start] = 0
    dist = defaultdict(list)
    dist[0].append(start)
    while q:
        u = q.pop()
        d = seen[u]
        for v in ns[u]:
            if seen[v] is None and v not in done:
                seen[v] = d + 1
                dist[d+1].append(v)
                q.appendleft(v)
    return seen, dist
ans = 0
done = set()
while True:
    start = 0
    while start in done:
        start += 1
    seen, dist1 = bfs(start)
    m = max(item for item in seen if item is not None)
    u = dist1[m][0]
    seen, dist1 = bfs(u)
    mm = max(item for item in seen if item is not None)
    if mm<=k:
        break
    ans += 1
    v = dist1[mm][0]
    seen, dist2 = bfs(v)
    v1 = sum(len(dist1[u]) for u in range(k+1, mm+1))
    v2 = sum(len(dist2[u]) for u in range(k+1, mm+1))
    if v1<v2:
        done.add(v)
    else:
        done.add(u)
print(ans)

Measured memory_bytes: 151620
#include <iostream>

using namespace std;

int main() {
    int A,B,C,D,E,F;
    std::cin>>A>>B>>C>>D>>E>>F;
    A*=100;
    B*=100;
    const static int N = 3000;
    int water[N + 5] = {0};
    water[0] = 1;
    for(int i = 0; i <= F; ++ i) {
        if (water[i] <= 0)
            continue;
        if (i + A <= F)
            water[i+A] = 1;
        if (i + B <= F)
            water[i+B] = 1;
    }

    int sugar[N + 5] = {0};
    sugar[0] = 1;
    for(int i = 0; i <= F; ++ i) {
        if (sugar[i] <= 0)
            continue;
        if (i + C <= F)
            sugar[i+C] = 1;
        if (i + D <= F)
            sugar[i+D] = 1;
    }

    int max_water = 0;
    int max_sugar = 0;
    double max_density = -1;

    for (int w = 0; w <= F; ++ w) {
        for (int s = 0; s <= F; ++ s) {
            if (water[w] + sugar[s] >= 2 && w + s <= F) {
                if (s*(100+E) <= (w+s) * E) {
                    double density = 1.0* s / (w+s);
                    if (density > max_density) {
                        max_density = density;
                        max_water = w;
                        max_sugar = s;
                    }
                }
            }
        }
    }

    printf("%d %d\n", max_water + max_sugar, max_sugar);
//    std::cout<<(max_water+max_sugar)<<" "<<max_sugar<<std::end;

    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()
r=[0]*h
c=[0]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            r[i]=1
            c[j]=1
for i in range(h):
    if r[i]:
        for j in range(w):
            if c[j]:
                print(a[i][j],end='')
        print()

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

int main(){
  int A[5][4][11], n;
  for(int i=1; i<=4; i++)
    for(int j=1; j<=3; j++)
      for(int k =1; k<=10; k++)A[i][j][k]=0;

  cin>>n;
  for(int i=0; i<n; i++){
    int b, f, r, v;
    cin >> b>>f>>r>>v;
    A[b][f][r]+=v;
  }
  for(int f=1; f<=4; f++){
    if(f>1)cout<<"####################\n";
    for(int b=1; b<=3; b++){
      for(int r=1; r<=10; r++){
        cout<<" "<<A[f][b][r];
      }
      cout<<endl;
    }
  }
  return 0;
  }


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  rep(i,n) cin>>x[i];
  sort(all(x));
  int cnt=0;
  int ans=INF;
  for(int i=x[0];i<=x[n-1];i++){
    cnt=0;
    rep(j,n){
      cnt+=(i-x[j])*(i-x[j]);
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}


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

int main() {
  int n; cin >> n;
  int answer = 0;
  
  for (int i = 0; i < 100000; i++) {
    if (i * i > n) break;
    else answer = i * i;
  }
  
  cout << answer << endl;
}

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

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 100010
#define MOD 1000000007


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s, t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


Measured memory_bytes: 256
def main():
	n = int(input())
	a = list(map(int,input().split()))

	
	ansl = []
	ansl.append(a[0])
	i = 1
	if n == 1:
		pass
	elif a[0] >= a[1]:
		ansl.append(a[1])

	while i < n:
		if ansl[-1] > a[i]:
			ansl.append(a[i])
		i += 1
	print(len(ansl))


	

if __name__ == '__main__':
	main()

Measured memory_bytes: 85428
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string S;
  cin >> N >> S;
  int l = 0, r = S.size() - 1;
  int result = 0;
  while (true) {
    while (l < S.size() && S[l] == 'R') l++;
    while (r >= 0 && S[r] == 'W') r--;
    if (l <= r) {
      result++;
      l++;
      r--;
    }
    else {
      break;
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 3768
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      for(;;){
        String str[] = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[2]);
        // str[1] : operation

        if(str[1].equals("?")) break; // finish

        switch(str[1]){
          case "+":
            System.out.println(a + b);
            break;
          case "-":
            System.out.println(a - b);
            break;
          case "*":
            System.out.println(a * b);
            break;
          case "/":
            System.out.println(a / b);
            break;
          default:
            break;
        }
      }
      br.close();
    }catch(Exception e){
      System.exit(-1);
    }
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int>w(n);
	for (int i = 0; i < n; i++)cin >> w.at(i);
	ll l = 0;
	ll r = 0;
	for (int i = 0; i < n; i++)r += w.at(i);
	ll ans = r;
	for (int i = 0; i < n; i++) {
		l += w.at(i);
		r -= w.at(i);
		ans = min(ans, abs(r - l));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)){
        if(s.at(1)!=s.at(2)){
            cout <<"Yes"<<endl;
        }
    else if (s.at(1)==s.at(2)){
        cout <<"No"<<endl;
    }
    }

    else {
        cout << "No" <<endl;
    }
    
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        s: String,
    }

    solve(s);
}

fn solve(s: String) {
    let s = s.chars().collect::<Vec<char>>();
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2132
import java.util.Scanner;
import java.io.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int sum = 0, min = 100000, tmp, ans = 0;
		for(int i = 0;i < N; i++){
			tmp = sc.nextInt();
			if(tmp < min) min = tmp;
			sum += tmp;
		}
		ans = (int)(X - sum)/min + N;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main(){
  int N,K;
  scanf("%d",&N);
  char S[N],ans[N];
  scanf("%s",S);
  scanf("%d",&K);

  strcpy(ans,S);

  for(int i = 0; i < N; i ++){
    if(S[i] != S[K - 1]){
      ans[i] = '*';
    }
  }

  printf("%s",ans);

  return 0;
}


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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main(){
    int N;
    cin >> N;
    vi a(1e5+10,0);
    int maxa=0;
    for(int i=0;i<N;i++){
        int temp;
        cin >> temp;
        a[temp]++; 
        maxa=max(maxa,temp);       
    }
    long long ans=0;
    for(int i=1;i<=maxa;i++){
        ans+=(i)*a[i];
    }
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        int b,c;
        cin >> b >> c;
        ans+=(c-b)*a[b];
        a[c]+=a[b];
        a[b]=0;
        cout << ans << endl;
    }
    return 0;    
}

Measured memory_bytes: 3792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();
		out.println(s.charAt(0) + "" +(s.length()-2) + "" + s.charAt(s.length()-1));
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
// A - Shiritori
#include <bits/stdc++.h>
using namespace std;

int main(){
	string a,b,c; cin>>a>>b>>c;
	string ans = a[a.size()-1]==b[0] && b[b.size()-1]==c[0]? "YES": "NO";
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    
int k;
cin>>k;
int even=k/2;
int odd=k/2;
if(k%2==1){
    odd++;
}
cout<<odd*even<<endl;



return 0;
}


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

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

  vector<int> d(N);
  for (int i=0; i<N; i++) {
  cin >> d.at(i);
  }

  int count=0;
  for (int j=1; j<=100; j++) {
   for (int k=0; k<N; k++) {
    if (d.at(k) == j) {
     count++;
     break;
    }
   }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int H,W;
  
  while(cin >> H >> W){
    if(H==0&&W==0){
      break;}
    for(int i=0; i<H; i++){
      
      for(int j=0; j<W; j++){
	if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){
	  cout <<"#";
	}
	else if ((i%2==0&&j%2==1)||(i%2==1&&j%2==0)){
	    cout << ".";
	  }
	  }
	cout << endl;
      }
      cout << endl;
  }
}

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

using namespace std;

int main()
{
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(k<e-a)
		cout<<":("<<endl;
	else
		cout<<"Yay!"<<endl;

	return 0;
}


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

#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)			    for(int i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh						while
#define mp						make_pair
#define le						length()
#define M						1000000007


void solve()
{
	float ans=6.28318530717958623200
;
float r;

cin>>r;
precise(6)<<ans*r<<endl;

}


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

Measured memory_bytes: 3796
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public struct AB
        {
            public int A;
            public int B;
        }
        public void Calc()
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            Console.WriteLine(T.StartsWith(S) ? "Yes" : "No") ;

        }


    }

}


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

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

int main(){
  ll h,a; cin >> h >> a;
  if(h%a==0){
    cout << h/a << endl;
  }else{
    cout << h/a+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
def prime():
    a = np.ones(110000)
    t = []
    for i in range(2,110000):
        if a[i] == 0:
            continue
        t.append(i)
        j=i+i
        while j < 110000:
            a[j] = 0
            j = j + i

    for i in range(int(input()),110000):
        if i in t:
            print(i)
            break

prime()


Measured memory_bytes: 13404
import itertools

while True:
	n, m, a = map(int, input().split())
	if (n,m,a) == (0,0,0):
		break
	hpq = [list(map(int, input().split())) for i in range(m)]
	hpq = sorted(hpq, reverse=True)
	for k, g in itertools.groupby(hpq, key=lambda x:x[0]):
		for gg in g:
			if a == gg[1]:
				a = gg[2]
				break
			elif a == gg[2]:
				a = gg[1]
				break
	print(a)

Measured memory_bytes: 8088
import sys


def solve(inp):
    (W, H, N) = map(int, inp.readline().split(' '))
    XYA = [list(map(int, inp.readline().split(' '))) for i in range(N)]

    sx = sy = 0
    ex = W
    ey = H
    for (x, y, a) in XYA:
        if a == 1:
            sx = max(sx, x)
        elif a == 2:
            ex = min(ex, x)
        elif a == 3:
            sy = max(sy, y)
        else:
            ey = min(ey, y)

    dx = max(0, ex - sx)
    dy = max(0, ey - sy)

    return str(dx * dy)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A<B){
    if(B-A<=X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
  }
  else cout << "delicious" << endl;
  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> K(M);
    rep(i,M) {
        int k; cin >> k;
        K.at(i) = vector<int>(k);
        rep(j,k) {
            cin >> K.at(i).at(j);
        }
    }
    vector<int> P(M);
    rep(i,M) cin >> P.at(i);

    int res = 0;
    for (int i = 0; i < 1 << N; i++) {
        int bulb = 0;
        rep(j,M) {
            int cnt = 0;
            for (int x : K.at(j)) {
                if (i & 1 << (x - 1)) cnt++;
            }
            if (cnt % 2 == P[j]) bulb++;
        }
        if (bulb == M) res++;
    }
    cout << res  << endl;
}

Measured memory_bytes: 256
s = gets.strip.split("/").map(&:to_i)
if s[0] < 2019
  puts "Heisei"
elsif s[0] > 2019
  puts "TBD"
else
  if s[1]==01 || s[1]==02 || s[1]==03 || s[1]==04
    puts "Heisei"
  else
    puts "TBD"
  end
end

Measured memory_bytes: 14328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class APluralForm {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        if (s[s.size()-1] == 's') {
            cout << s + "es" << endl;
        } else {
            cout << s + "s" << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    APluralForm solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

int num(char c)
{
    return c - '0';
}

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

    int n;
    string s;
    cin >> n >> s;
    s.push_back('a');

    int ans = 0;

    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            for (int k = 0; k < 10; k++)
            {
                int l = -1;
                for (l++; l < n + 1; l++)
                {
                    if (num(s[l]) == i)
                        break;
                }
                for (l++; l < n + 1; l++)
                {
                    if (num(s[l]) == j)
                        break;
                }
                for (l++; l < n + 1; l++)
                {
                    if (num(s[l]) == k)
                        break;
                }
                if (l < n)
                    ans++;
            }

    cout << ans << endl;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def I(): return int(sys.stdin.readline())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input()
    b = input()
    if a[2] == b[0] and a[1] == b[1] and a[0] == b[2]:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    n = I()
    n = int(math.sqrt(n))
    print(n**2)
    return

#C
def C():
    n = I()
    a = LI()
    a.sort()
    b = LI()
    b.sort()
    c = LI()
    c.sort()
    ans = 0
    for i in b:
        x = bisect_left(a, i)
        x = x * (n - bisect_right(c, i))
        ans += x
    print(ans)
    return

# D
# 解説AC
# 俺は正数問題を解いていたと思ったらいつのまにかグラフ問題を解いていた
# 何を言ってるかわからねーと思うが自分もわからねぇ(ｒｙ)
# 変態
# 全部の数字は足す1もしくは×10で考えられて前者なら全体の和が1増えて後者なら
# 変わらないということに気づいたらいけるんだと思う（いけるとは言ってない）
# 倍数の下で何かをするというよりはそのKのmod下にて最小な桁和がいくつになるのか
# という考えに至るとほぼ勝ち
def D():
    k = II()
    dp = [inf] * k
    q = deque()
    q.append(1)
    dp[1] = 1
    while q:
        i = q.pop()
        if dp[(i * 10) % k] > dp[i]:
            dp[(i * 10) % k] = dp[i]
            q.appendleft((i * 10) % k)
        if dp[(i + 1) % k] > dp[i] + 1:
            dp[(i + 1) % k] = dp[i] + 1
            q.append((i + 1) % k)
    print(dp[0])
    return


#Solve
if __name__ == '__main__':
    D()


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;
typedef pair<int, int> pii;
typedef vector<int> Array;
typedef vector<Array> Matrix;

int n;
bool emp[55][33];

lint dp[2][55];

void solve() {
	minit(dp, -1);
	
	for_(i,0,n) dp[0][i] = (1LL << i);
	
	for_(i,0,30) {
		int nw = i % 2, nx = (i + 1) % 2;
		//for_(j,0,n) cout << dp[nw][j] << " ";
		//cout << endl;
		
		for_(j,0,n) {
			dp[nx][j] = dp[nw][j];
			
			if (emp[j][i]) {
				for_(k,0,n) {
					if (j == k) continue;
					if (emp[k][i]) {
						dp[nx][j] |= dp[nw][k];
					}
				}
			}
			
			if (dp[nx][j] == (1LL << n) - 1) {
				cout << i + 1 << endl;
				return;
			}
		}
	}
	
	cout << -1 << endl;
}

int main() {
	while (cin >> n, n) {
		minit(emp, 0);
		for_(i,0,n) {
			int f; cin >> f;
			for_(j,0,f) {
				int d; cin >> d;
				--d;
				emp[i][d] = true;
			}
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int n = Integer.parseInt(r.readLine());

    Set<Integer> set = new HashSet<Integer>();

    for(int i = 0; i < n; i++)
    {
      set.add(Integer.parseInt(r.readLine()));
    }

    System.out.println(set.size());

  }

}


Measured memory_bytes: 22612
#include<stdio.h>
#define HeapSize 500000

void MaxHeapify(int * ,int ,int );
void BuildMaxHeap(int *,int );
int left(int );
int right(int );

int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i + 1);
}
void MaxHeapify(int *A,int i,int n){
  int l,r,largest,temp;
 l = left(i);
 r = right(i);
 if(l <= n && A[l] > A[i]){
   largest = l;
 }
 else largest = i;
 if(r <=  n && A[r] > A[largest]){
   largest = r;
 }
 if(largest != i){
   temp = A[i];
   A[i] = A[largest];
   A[largest] = temp;
   MaxHeapify(A,largest,n);
 }
}
void BuildMaxHeap(int *A,int n){
  int i;
  for(i = n/2; i >= 1;i--){
    MaxHeapify(A,i,n);
  }
} 
 int main( ){
  int i,n;
  int A[HeapSize];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
    BuildMaxHeap(A,n);
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
 }

Measured memory_bytes: 2552
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2;
	int u = x2 - x1, v = y2 -y1;
	cout<<x2-v<<" "<<y2+ u<<" "<<x1 - v<<" "<<y1 + u;
	
	return 0;
}


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

using namespace std;
typedef long long ll;

const long long int MOD = 1000000007;
const int N = 100001;
int n, m;
int arr[N];
int in = 1;
int comp[N];
vector<int> adj[N];
void dfs(int u, int cm){
  comp[u] = cm;
  for(auto el : adj[u])
    if(!comp[el])
      dfs(el, cm);
}
int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n >> m;
  int a, b;
  for(int i = 0;i < n;i++)
    scanf("%d", arr + i), arr[i]--;
  for(int i = 0;i < m;i++){
    scanf("%d %d", &a, &b);
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(int i = 0;i < n;i++){
    if(!comp[i]){
      dfs(i, in++);
    }
  }
  int res = 0;
  for(int i = 0;i < n;i++){
    if(comp[i] == comp[arr[i]])
      res++;
  }
  cout << res;
}



Measured memory_bytes: 8576
import java.util.*;
import java.util.Arrays;
import java.util.Comparator;
public class Main {    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();        
		int m = sc.nextInt();       
        Data [] d = new Data [n];
        for(int i=0;i<n;i++){int A = sc.nextInt();
                             int B = sc.nextInt();
                             d[i] = new Data(A,B);                            
                            }
        Arrays.sort(d, new Comparator<Data>() {
            public int compare(Data d1, Data d2) {
                return d1.getA() - d2.getA();
            }
        }); 
        long ans = 0;
        int count1 = 0;
        int count2 = 0;
        int point = 0;
        while(count1<m){ans+=d[point].getA();
                        count1++;
                        count2++;
                        if(count2==d[point].getB()){count2=0;
                                                    point++;}
                      }
        System.out.println(ans);
	}
}
class Data{
    private int a;
    private int b;
    public Data(int a, int b) {
        this.a = a;
        this.b = b;
    }
    public int getA() {
        return a;
    }
    public int getB() {
        return b;
    }
}


Measured memory_bytes: 89632
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(NULL); cout.tie(NULL)
using namespace std;                            
                                                
void yes() {cout << "Yes" << endl;}                                               
void no() {cout << "No" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);

long long g[102][102];
set<pair<int, int> > setik;

void dijkstra(int s, int n) {
    vector<int> d(n + 1, INF);
    d[s] = 0;
    vector<bool> used(n + 1);
    vector<int> p(n + 1);
    for (int i = 1; i <= n; i++) {
        int v = -1;
        for (int j = 1; j <= n; j++) {
            if (!used[j] and (v == -1 or d[j] < d[v])) {
                v = j;
            }
        }
        if (d[v] == INF) break;
        used[v] = true;
        for (int to = 1; to <= n; to++) {
            if (g[v][to] == 0) continue;
            if (d[v] + g[v][to] < d[to]) {
                d[to] = d[v] + g[v][to];
                p[to] = v;
            } 
        }
    }
    for (int i = 1; i <= n; i++) {
        int j = i;
        if (j == s) continue;
        while (p[j] != 0) {
            int mn = min(j, p[j]);
            int mx = max(j, p[j]);
            setik.insert(mp(mn, mx));
            j = p[j];
        }
    }
}   

void solve() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        g[a][b] = c;
        g[b][a] = c;
    }
    for (int i = 1; i <= n; i++) {
        dijkstra(i, n);
    }
    cout << m - setik.size() << endl;
}

int main() {
    // freopen("bbreeds.in", "r", stdin);
    // freopen("bbreeds.out", "w", stdout);
    jonathan; 
    livingston;
    solve();
    return 0;
}

Measured memory_bytes: 3748
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ds = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var ans = 0
    if (ds[n/2-1] != ds[n/2]) {
        ans = ds[n/2] - ds[n/2-1]
    }
    print(ans)
}

Measured memory_bytes: 54656
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

int64_t euler_phi(int64_t n) {
  int64_t ret = n;
  ret%=MOD;
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      ret = (ret - (ret/i) + MOD)%MOD;
      while(n % i == 0) n /= i;
    }
  }
  if(n > 1){ret = (ret - (ret/n) + MOD)%MOD;}
  return ret;
}
/*
https://ei1333.github.io/luzhiled/snippets/math/euler-phi.html
*/

long long power(long long b,long long e){
    long long r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}

signed main(void){
    int N,K;
    cin >> N >> K;
    int Ans=0;
    for(int i=1;i<=K;i++){
        int b = power(K/i,N);
        int phi = euler_phi(i);
        int r = (b*phi)%MOD;
        //cout << b MM phi MM r << endl;
        Ans=(Ans+r)%MOD;
    }
    cout << Ans << endl;
    
    /*REP(i,5){
        cout << euler_phi(i+1) << " ";
    }*/
    
    return 0;
}



Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
dflag = 0

for i in a:
    if i%2==0:
        if i%3==0 or i%5==0:
            pass
        else:
            dflag += 1
            
if dflag:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<P> A(Q);
  REP(i,Q) cin >> A[i].first >> A[i].second;
  
  int B[N]={0};
  int cnt=0;
  REP(i,N-1){
    if(S.at(i)=='A'&&S.at(i+1)=='C'){
      cnt++;
    }
    B[i+1]=cnt;
  }

  REP(i,Q){
    cout << B[A.at(i).second-1]-B[A.at(i).first-1] << endl;
  }
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
#define inf 2000000001

vector<int> S = {inf};

int parent(int i)
{
    return i / 2;
}

int left(int i)
{
    return 2 * i;
}

int right(int i)
{
    return 2 * i + 1;
}

void maxHeapify(vector<int> &A, int i)
{
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= S.size() - 1 && A[i] < A[l])
        largest = l;
    else
        largest = i;
    if (r <= S.size() - 1 && A[r] > A[largest])
        largest = r;

    if (largest != i)
    {
        swap(A[largest], A[i]);
        maxHeapify(A, largest);
    }
}

void insert(vector<int> &S, int k)
{
    int i = S.size();
    S.push_back(k);
    while (S[i] > S[i / 2])
    {
        swap(S[i], S[i / 2]);
        i /= 2;
    }
}

int extractMax(vector<int> &S)
{
    if (S.size() > 1)
    {
        int r = S[1];
        S[1] = S[S.size() - 1];
        S.pop_back();
        maxHeapify(S,1);
        return r;
    }
    else
    {
        return -1;
    }
}
int main()
{
    string str;
    int k;
    while (true)
    {
        cin >> str;
        if (str[0] == 'i')
        {
            cin >> k;
            insert(S, k);
        }
        else if (str[1] == 'x')
            printf("%d\n", extractMax(S));
        else if (str[1] == 'n')
            break;
    }

    return 0;
}


Measured memory_bytes: 6996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

//入力
int x,a,b ;

int main() {

	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b)) COUT('A');

	else COUT('B');

	return 0;
}


Measured memory_bytes: 256
N,H=map(int,input().split())
ab=[[0]*2 for i in range(N)]
for i in range(N):
  ab[i]=list(map(int,input().split()))
ab.sort(key=lambda x:x[0])
max_katana=ab[-1]
ab.sort(reverse=True,key=lambda x:x[1])
count=0
for i in range(N):
  if H > 0:
    if ab[i][1] >= max_katana[0]:
      H -= ab[i][1]
      count+=1
    else:
      break
if H > 0:
  if H % max_katana[0]==0:
    count+= H // max_katana[0]
  else:
    count+= (H // max_katana[0]) + 1
print(count)

Measured memory_bytes: 28968
/////////////////////////////////TEST CASES////////////////////////////////////
/*
4
C D C D
C C D C
D D D D
C D D D
7
C D D C D D D
C D D C D D D
D D D D D D C
D C D C D D D
D D D C D C D
C D D C D C C
C D C D C C C
5
D C D C C
D D C C D
D D C C D
D D D C C
C D C C D
5
D C D C D
C C C D D
D D C C D
C D D D C
D C D C C
*/
/////////////////////////////////////CODE/////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 1000000000;
ll MOD = 1000000007;
void solve()
{
	IN(x)IN(k)IN(d);
	x = abs(x);
	ll m = 0;
	if (x / d < k)
	{
		ll t = x % d;
		k -= x / d;
		if (k % 2 == 0)
			m = t;
		else
			m = abs(t - d);
	}
	if (x / d == k)
	{
		m = x % d;
	}
	if (x / d > k)
	{
		m = x - k * d;
	}
	cout << m;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 3648
N = int(input())
a = []
if N == 0:
    a = ["0"]
while N != 0:
    a.append(str(N % 2)) # N mod 2
    N = -(N - N % 2) // 2 # (N − (N mod 2)) // 2
print("".join(list(reversed(a))))

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

struct dice{
  int x[6];
  void roll_x(){roll(0,4,5,1);}
  void roll_y(){roll(0,2,5,3);}
  void roll_z(){roll(1,3,4,2);}

  vector<dice> all_rolls(){
    vector<dice> res;
    for(int k=0; k<6; (k&1 ? roll_y() : roll_x()), k++){
      for(int i=0; i<4; roll_z(),i++){
        res.push_back(*this);
      }
    }
    return res;
  }

  void roll(int a,int b,int c,int d){
    int tmp = x[a];
    x[a] = x[b];
    x[b] = x[c];
    x[c] = x[d];
    x[d] = tmp;
  }
};

vector<dice> a[4];
int n,ans;

void solve(vector<int> z) {
  if(z.size()==n) {
    int sum=0;
    dice v[n];
    for(int i=0; i<n; i++) v[i]=a[i][z[i]];
    for(int i=0; i<6; i++) {
      int c[30];
      memset(c,0,sizeof(c));
      for(int j=0; j<n; j++) c[v[j].x[i]]++;
      int ma=0;
      for(int i=0; i<30; i++) ma=max(ma,c[i]);
      sum+=n-ma;
    }
    ans=min(ans,sum);
    return;
  }
  for(int i=0; i<a[z.size()].size(); i++) {
    vector<int> y=z;
    y.push_back(i);
    solve(y);
  }
}

int main() {
  while(cin >> n && n) {
    for(int i=0; i<n; i++) a[i].clear();
    ans=1000000007;

    map<string, int> m;m.clear();
    for(int i=0; i<n; i++) {
      dice b;
      for(int j=0; j<6; j++) {
	string s;
	cin >> s;
	if(!m[s]) {
	  int q=m.size()+1;
	  m[s]=q;
	}
	b.x[j]=m[s];
      }
      a[i]=b.all_rolls();
    }
    vector<int> y;
    solve(y);
    cout << ans << endl;
  }
  return 0;
}

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

int main()
{
  int H, W;
  cin >> H >> W;
  
  string A_Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  int ansH;
  char ansW;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      string S;
      cin >> S;
      if (S == "snuke")
      {
        ansH = i + 1;
        ansW = A_Z.at(j);
        break;
      }
    }
  }
  
  cout << ansW << ansH << endl;
}

Measured memory_bytes: 256