akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        do{
            int a = scan.nextInt();
            String s = scan.next();
            int b = scan.nextInt();
            
            if(s.equals("?"))
            break;
            
            int ans = 0;
            
            switch(s){
                case "+": 
                    ans = a+b; break;
                case "-":
                    ans = a-b; break;
                case "*":
                    ans = a*b; break;
                case "/": 
                    ans = a/b; break;
            }
            System.out.println(ans);
        }while(true);
    }
}


Measured memory_bytes: 26152
#include<stdio.h>
#include<math.h>
int main(void){
	int a,b;
	char op[4];
	scanf("%d %c %d",&a,&op[0],&b);
	while(1){
		if(op[0]=='+'){
			printf("%d\n",a+b);
		}
		else if(op[0]=='-'){
			printf("%d\n",a-b);
		}
		else if(op[0]=='*'){
			printf("%d\n",a*b);
		}
		else if(op[0]=='/'){
			printf("%d\n",a/b);
		}
		else if(op[0]=='?'){
			break;
		}
		scanf("%d %c %d",&a,&op[0],&b);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

string s;

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

  	cin >> s;
  	int n = sz(s);

  	for (int i = 0; i + 1 < n; ++i) {
  		if (s[i] == s[i + 1]) {
  			cout << i + 1 << " " << i + 2 << endl;
  			return 0;
  		}
  	}

  	for (int i = 0; i + 2 < n; ++i) {
  		if (s[i] == s[i + 2]) {
  			cout << i + 1 << " " << i + 3 << endl;
  			return 0;
  		}
  	}

  	cout << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#include <iomanip>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int mul(int x, int y) {
	return int((1LL * x * y) % MOD);
}
int add(int x, int y) {
	x += y;
	if (x > MOD) x -= MOD;
	return x;
}
int power(int a, int b) {
	int res = 1;
	while(b != 0) {
		if (b & 1)
			res = mul(res, a);
		a = mul(a, a);
		b /= 2;
	}
	return res;
}
int inv(int x) {
	return power(x, MOD - 2);
}
int C(int n, int r) {
	if (n < r)
		return 0;
	if (r > n - r)
		r = n - r;
	int res = 1;
	for (int i = 1; i <= r; i++) {
		res = mul(res, n - i + 1);
		res = mul(res, inv(i));
	}
	return res;
}
int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	vector <int> pre(w + 1);
	pre[b] = C((h - a) - 1 + b - 1, b - 1);
	for (int y = b + 1; y <= w; y++) {
		int n = (h - a) - 1 + y - 1;
		int r = y - 1;
		int val = 1;
		if (n != 0 && r != 0) {
			val = mul(val, n);
			val = mul(val, inv(r));
		}
		pre[y] = mul(pre[y - 1], val);
	}
	int ans = 0; 
	int res = 1;
	for (int y = w; y >= b + 1; y--) {
		int n = a - 1 + (w - y + 1) - 1;
		int r = (w - y + 1) - 1;
		if (n != 0 && r != 0) { 
			res = mul(res, n);
			res = mul(res, inv(r));
		}
		ans = add(ans, mul(pre[y], res));
	}
	cout << ans;
}
		


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

map<char, int> cnt;
char S[114514];
bool allowed[256];
string A = "AKIHABARA";

int main() {
  scanf("%s", S);

  int lim = 1 << 4;
  for (int st=0; st<lim; st++) {
    string T;
    int idx = 0;
    for (int i=0; i<9; i++) {
      if (A[i] == 'A') {
        if (st >> idx & 1) T += 'A';
        idx++;
      } else {
        T += A[i];
      }
    }

    if (T == S) {
      puts("YES");
      return 0;
    }
  }

  puts("NO");
}


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

int main()
{
	int i,N,temp,cheo=1,chee=1;
	cin>>N;
	vector<int> odd,even;
	vector<pair<int,int>> oddn(2),evenn(2);
	for(i=0;i<N/2;i++){
		cin>>temp;
		odd.push_back(temp);
		cin>>temp;
		even.push_back(temp);
	}
	for(i=0;i<2;i++){
		oddn.at(i)=make_pair(0,0);
		evenn.at(i)=make_pair(0,0);
	}
	sort(odd.begin(),odd.end());
	sort(even.begin(),even.end());
	for(i=1;i<N/2;i++){
		if(odd.at(i)==odd.at(i-1)){
			cheo++;
		}else{
			if(cheo>=oddn.at(0).first){
				oddn.at(1)=oddn.at(0);
				oddn.at(0)=make_pair(cheo,odd.at(i-1));
			}else if(cheo>=oddn.at(1).first){
				oddn.at(1)=make_pair(cheo,odd.at(i-1));
			}
			cheo=1;
		}
		
		if(even.at(i)==even.at(i-1)){
			chee++;
		}else{
			if(chee>=evenn.at(0).first){
				evenn.at(1)=evenn.at(0);
			evenn.at(0)=make_pair(chee,even.at(i-1));
			}else if(chee>=evenn.at(1).first){
				evenn.at(1)=make_pair(chee,even.at(i-1));
			}
			chee=1;
		}
	}
	if(cheo>=oddn.at(0).first){
		oddn.at(1)=oddn.at(0);
		oddn.at(0)=make_pair(cheo,odd.at(i-1));
	}else if(cheo>=oddn.at(1).first){
		oddn.at(1)=make_pair(cheo,odd.at(i-1));
	}
	if(chee>=evenn.at(0).first){
		evenn.at(1)=evenn.at(0);
		evenn.at(0)=make_pair(chee,even.at(i-1));
	}else if(chee>=evenn.at(1).first){
		evenn.at(1)=make_pair(chee,even.at(i-1));
	}
	
	if(oddn.at(0).second!=evenn.at(0).second){
		cout<<N-oddn.at(0).first-evenn.at(0).first;
	}else if((oddn.at(1).first==0)&&(evenn.at(1).first==0)){
		cout<<N/2;
	}else if((oddn.at(1).first==0)||(evenn.at(1).first==0)){
		cout<<N-max(oddn.at(0).first,evenn.at(0).first)-max(oddn.at(1).first,evenn.at(1).first);
	}else{
		cout<<N-max(oddn.at(0).first+evenn.at(1).first,oddn.at(1).first+evenn.at(0).first);
	}
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    int n,k;cin >> n >> k;
    if(n/2+n%2>=k) puts("YES");
    else puts("NO");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, M;
map<int,int> a;
bool g(int L) {
	vector<int> c(L);
	int mi = 1<<30, ma = -1;
	for (int i = 0; i < L; ++ i) {
		c[i] = max(i, L-1-i);
		mi = min(mi, c[i]);
		ma = max(ma, c[i]);
	}
	auto b = a;
	for (int x : c) {
		if (b[x] == 0) return false;
		-- b[x];
	}
	for (auto p : b) {
		if (p.second == 0) continue;
		if (!(mi < p.first && p.first <= ma)) return false;
	}
	return true;
}
bool f() {
	for (int l = M+1; l <= N; ++ l) {
		if (g(l)) return true;
	}
	return false;
}
int main() {
	cin >> N;
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		++ a[x];
		M = max(M, x);
	}
	cout << (f() ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int r, c, n;
struct Point {
    int x, y, id;
    int getEid () const {
        if (x == 0) {
            return 0;
        } else if (y == c) {
            return 1;
        } else if (x == r) {
            return 2;
        } else {
            return 3;
        }
    }

    bool operator < (const Point &p) {
        int eid = getEid();
        if (eid != p.getEid()) {
            return eid < p.getEid();
        } else {
            if (eid == 0) {
                return y < p.y;
            } else if (eid == 1) {
                return x < p.x;
            } else if (eid == 2) {
                return y > p.y;
            } else {
                return x > p.x;
            }
        }
    }
};

typedef pair<int, int> pii;
vector<Point> pt;
int prv[MAXN], nxt[MAXN];

pii del (int L) {
    int R = nxt[L];
    int LL = prv[L];
    int RR = nxt[R];
    nxt[LL] = RR;
    prv[RR] = LL;
    if (pt[LL].id == pt[RR].id) {
        return pii(LL, RR);
    } else {
        return pii(-1, -1);
    }
}

bool edge (int x, int y) {
    return x == 0 || x == r || y == 0 || y == c;
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> r >> c >> n;
    REP (i, n) {
        int xf, yf, xs, ys;
        cin >> xf >> yf >> xs >> ys;
        if (edge(xf, yf) && edge(xs, ys)) {
            pt.push_back({xf, yf, i});
            pt.push_back({xs, ys, i});
        }
    }

    sort(pt.begin(), pt.end());

    REP (i, SZ(pt)) {
        nxt[i] = (i+1) % SZ(pt);
        prv[i] = (i-1+SZ(pt)) % SZ(pt);
        debug(pt[i].x, pt[i].y, pt[i].id);
    }

    queue<int> bfs;
    REP (i, SZ(pt)) {
        if (pt[i].id == pt[nxt[i]].id) {
            bfs.emplace(i);
        }
    }

    int cnt = 0;
    while (!bfs.empty()) {
        if (cnt == SZ(pt)/2) {
            break;
        }
        int cur = bfs.front();
        bfs.pop();

        pii ret = del(cur);
        if (ret.first != -1) {
            bfs.emplace(ret.first);
        }
        cnt++;
    }

    if (cnt == SZ(pt)/2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 8176
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    return a.second < b.second;
}
int main(){
  int n;ll k;
  cin >> n >> k;
  pair <int,int>  v[n];
  rep{
    int a,b;
    cin >> a >> b;
    v[i] = make_pair(a,b);
  }
  sort(v,v+n);
  ll sum = 0;
  rep{
    sum += v[i].second;
    if(sum >= k){
      cout << v[i].first << endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
G = [[] for i in range(n)]
enter = [0] * n
for i in range(m):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    enter[y-1] += 1

dp = [0] * n
s = []
for i in range(n):
    if not enter[i]:
        s.append(i)

while(s!=[]):
    v = s.pop(0)
    for i in G[v]:
        enter[i] -= 1
        if not enter[i]:
            s.append(i)
            dp[i] = dp[v]+1

print(max(dp))

Measured memory_bytes: 87168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int a[3];
    rep(i,3)cin >> a[i];

    sort(a,a+3);

    cout << (a[0] * a[1]) /2<< endl;

    return 0;
}

Measured memory_bytes: 3588
n, m = map(int, input().split())
ans = []
tmp = True
for i in range(n): ans.append('a')

for i in range(m):
    s, c = map(int, input().split())

    if s < 1 or s > n:
        tmp = False
        break
    if c < 0 or c > 9:
        tmp = False
        break

    if n != 1 and s == 1 and c == 0:
        tmp = False
        break

    if ans[s - 1] == 'a':
        ans[s - 1] = str(c)
    else:
        if ans[s - 1] != str(c):
            tmp = False
            break

if n != 1 and ans[0] == 'a': ans[0] = '1'
for i in range(n):
    if ans[i] == 'a': ans[i] = '0'

if tmp:
    for i in range(n):
        print(ans[i], end='')
    print()
else:
    print(-1)



Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int n, m, i, j, a[100][100], b[100], c;
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (j = 0; j < m; j++) {
        scanf("%d", &b[j]);
    }
    for (i = 0; i < n; i++) {
        c = 0;
        for (j = 0; j < m; j++) {
            c += a[i][j] * b[j];
        }
        printf("%d\n", c);
    }
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

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

Measured memory_bytes: 3576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRuinedSquare solver = new BRuinedSquare();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRuinedSquare {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] x = new int[4];
            int[] y = new int[4];

            for (int i = 0; i <= 1; i++) {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            for (int i = 2; i <= 3; i++) {
                int dx = x[i - 1] - x[i - 2];
                int dy = y[i - 1] - y[i - 2];

                x[i] = x[i - 1] - dy;
                y[i] = y[i - 1] + dx;
            }

            String answer = String.format("%d %d %d %d", x[2], y[2], x[3], y[3]);

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 200000000;

int dp[2][2][5002];
int n;
int cost[10000];

main(){
  cin >> n;
  for(int i=0;i<n-1;++i){
    cin >> cost[i];
  }
  fill(dp[0][0], dp[2][0], INF);
  dp[0][1][1] = 0;
  dp[0][0][0] = 0;
  for(int i=0;i<n-1;++i){
    int now = i%2;
    int next = (i+1)%2;
    for(int j=0;j<=n/2;++j) dp[next][0][j] = dp[next][1][j] = INF;
    for(int j=0;j<=n/2;++j){
      dp[next][1][j+1] = min(dp[next][1][j+1], min(dp[now][1][j], dp[now][0][j] + cost[i]));
      dp[next][0][j] = min(dp[next][0][j], min(dp[now][0][j], dp[now][1][j] + cost[i]));
    }
  }
  cout << min(dp[1][0][n/2], dp[1][1][n/2]) << endl;
  return 0;
}

Measured memory_bytes: 944
n = int(input())
li = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(1, n):
    ans += li[0]*li[i]

check = ans
for i in range(1, n):
    if li[i-1] == 0:
        continue
    check -= li[i] * li[i-1]
    check //= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(ans)


Measured memory_bytes: 31532
object Main extends App {
    var get = readLine.split(" ")
 var a = get(0).toInt
 var b = get(1).toInt
 var c = get(2).toInt
  var sum = a + b
  sum = math.min(sum,a+b)
  sum = math.min(sum,a+c)
  sum = math.min(sum,b+c)
  println(sum)
}

Measured memory_bytes: 25520
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static String repeat(String str, int n) {
		return String.join("", Collections.nCopies(n, str));
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String line = sc.nextLine();

		int diff = 0;
		String rightAnswer = repeat(".", n);
		int nextDiff = 0;

		for (int i = 0; i < n; i++) {
			if (line.charAt(i) != rightAnswer.charAt(i))
				diff++;
		}

		int best = diff;

		for (int i = n - 1; i > -1; i--) {
			if (line.charAt(i) == '#')
				nextDiff = diff - 1;
			else {
				nextDiff = diff + 1;
			}
			if (nextDiff < best) {
				best = nextDiff;
			}
			diff = nextDiff;
		}

		System.out.println(best);

		sc.close();
	}
}

Measured memory_bytes: 29636
//  Created by conan1024hao on 2019/11/19.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;
    cin>>n>>m;
    int cnt[40][40];
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int d=0;
            cin>>d;
            d--;
            cnt[i][d]++;
        }
    }
    int ans=0;
    for(int i=0;i<m;i++){
        bool abc=1;
        for(int j=0;j<n;j++){
            if(cnt[j][i]==0)
                abc=0;
        }
        if(abc==1)
            ans++;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $H, $N);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $A[$i], $B[$i]);
}

$dp[0] = 0;

for($h = 1; $h < $H + 1; $h++) {
    $dp[$h] = PHP_INT_MAX;
}

for ($h = 1; $h < $H + 1; $h++) {
    for ($n = 0; $n < $N; $n++) {
        $dp[$h] = min($dp[$h], $B[$n] + $dp[max($h - $A[$n], 0)]);
    }
}
printf("%d", $dp[$H]);


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

int main() {
  long long int n, temp, sum = 0, count=1;
  vector<long long int> nums;
  cin >> n;
  for (long long int i=0; i<n; i++) {
    cin >> temp;
    nums.push_back(temp);
  }
  sort(nums.begin(), nums.end());
  for (long long int i=1; i<n; i++) {
    if (nums[i]!=nums[i-1]) {
      if (count%2==1) sum++;
      count=1;
    } else count++;
  }
  if (count%2==1) sum++;
  cout << sum;
  return 0;
}

Measured memory_bytes: 1400
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (A + B >= K) {
        print(min(A, K));
    } else {
        print(A - (K - A - B));
    }
}


Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

ali = 0
bob = 0

a.sort()
# print(a)
while True:
    if(len(a) > 0):
        ali += a.pop()
    else:
        break
    if(len(a) > 0):
        bob += a.pop()
    else:
        break

print(ali - bob)


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

int n;

int sumSatisfy(vector<int> &A, vector<int> &B, vector<int> &C) {
    int sf = 0;
    for (int i = 1; i <= n; i++) {
        sf += B.at(i);
    }
    for (int i = 1; i <= n - 1; i++) {
        if (A.at(i + 1) == A.at(i) + 1) {
            sf += C.at(A.at(i));
        }
    }

    return sf;
}

int main() {
    cin >> n;
    vector<int> A(n + 1);
    vector<int> B(n + 1);
    vector<int> C(n);
    for (int i = 1; i <= n; i++) {
        cin >> A.at(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> B.at(i);
    }
    for (int i = 1; i <= n - 1; i++) {
        cin >> C.at(i);
    }

    int ans = sumSatisfy(A, B, C);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

var a = []int{1, 3, 5, 7, 8, 10, 12}
var b = []int{4, 6, 9, 11}

func main() {
	var x, y int
	fmt.Scan(&x)
	fmt.Scan(&y)

	if check(x) == check(y) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func check(n int) string {
	if inArray(n, a) {
		return "A"
	} else if inArray(n, b) {
		return "B"
	} else {
		return "C"
	}
}

func inArray(n int, list []int) bool {
	for _, v := range list {
		if n == v {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
	int N,i,k;

	while(0==0){
		scanf("%d",&N);
		if(N==0)break;
		for(i=0;i<9;i++){
			scanf("%d",&k);
			N-=k;
		}
		printf("%d\n",N);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

#define deg_to_rad(deg) ((deg)*M_PI / 180.0)

// const int MOD = 998244353;

void Main()
{
    string N;
    cin >> N;
    if ((N.at(0) == N.at(1) && N.at(1) == N.at(2)) || (N.at(1) == N.at(2) && N.at(2) == N.at(3)))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3608
#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++)
typedef int long long ll;
using namespace std;

int main(){
    string s;
    int a,b;
    cin>>a>>b;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i!=a){
            if(s[i]=='-'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(s[i]!='-'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        
    }
    cout<<"Yes"<<endl;
    

    
return 0;
}


Measured memory_bytes: 256
N = int(input())
s1 = input()
s2 = input()
MOD = 1000000007
state = -1
ans = 1
flag = False
for i in range(N):
  if i+1<N:
    if s1[i]==s1[i+1]:
      flag = True
      continue
    if flag:
      if state==1:
        ans *= 2
      elif state==2:
        ans *= 3
      else:
        ans *= 6
      state = 2
    else:
      if state==1:
        ans *= 2
      elif state==2:
        ans *= 1
      else:
        ans *= 3
      state = 1
    flag = False
  else:
    if flag:
      if state==1:
        ans *= 2
      elif state==2:
        ans *= 3
      else:
        ans *= 6
    else:
      if state==1:
        ans *= 2
      elif state==2:
        ans *= 1
      else:
        ans *= 3
  ans %= MOD
print(ans)

Measured memory_bytes: 38400
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> x(n), y(n);
    int i,j;
    for(i=0; i<n; i++) {
        scanf("%d%d", &x[i], &y[i]);
    }
    double sum=0;
    for(i=0; i<n; i++) {
        for(j=i+1; j<n; j++) {
            sum+=sqrt(((double)x[i]-x[j])*((double)x[i]-x[j])+((double)y[i]-y[j])*((double)y[i]-y[j]));
        }
    }
    sum=sum*2/n;
    printf("%.10lf\n", sum);

    return 0;
}


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

int main(void){
    long long n,k;cin>>n>>k;
    long long min=n%k;
    long long tmp=0;
    while(true){
        tmp=abs(min-k);
        if(min>tmp)min=tmp;
        else break;
    }
    cout<<min<<endl;
}



Measured memory_bytes: 256
$%=1e9+7;
$N=<>-3;
@$_=1for@_=glob'{A,C,G,T}'x3;
@AGC=0;@ACG=0;@GAC=0;
for$i(1..$N){
	for$j(@_){
		for(A,C,G,T){
			if("$j$_"!~/ACG|AGC|GAC|AG.C|A.GC/){
				$j=~/./;
				(${$'.$_}[$i]+=$$j[$i-1])%=$%
			}
		}
	}
}
$x=($x+$$_[$N])%$%for@_;
print$x,$/


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

int main(void){
    int n,l;
    cin >> n >> l;
    list<string> dict;
    for (size_t i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        dict.push_back(s);
    }
    dict.sort();
    while (!dict.empty())
    {
        cout << dict.front();
        dict.pop_front();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
require "set"
a_arr = 3.times.map{gets.chomp.split(" ").map(&:to_i)}
n = gets.chomp.to_i
b_arr = n.times.map{gets.to_i}.to_set

a_arr.each_with_index do |arr, i|
  arr.each_with_index do |a, j|
    if b_arr.include?(a) then
      a_arr[i][j] = 0
    end
  end
end

if (a_arr[0][0] == 0 && a_arr[0][1] == 0 && a_arr[0][2]== 0 ) ||
  (a_arr[1][0] == 0 && a_arr[1][1] == 0 && a_arr[1][2]== 0 ) ||
  (a_arr[2][0] == 0 && a_arr[2][1] == 0 && a_arr[2][2]== 0 ) ||
  (a_arr[0][0] == 0 && a_arr[1][0] == 0 && a_arr[2][0]== 0 ) ||
  (a_arr[0][1] == 0 && a_arr[1][1] == 0 && a_arr[2][1]== 0 ) ||
  (a_arr[0][2] == 0 && a_arr[1][2] == 0 && a_arr[2][2]== 0 ) ||
  (a_arr[0][0] == 0 && a_arr[1][1] == 0 && a_arr[2][2]== 0 ) ||
  (a_arr[0][2] == 0 && a_arr[1][1] == 0 && a_arr[2][0]== 0 ) then
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int w, a, b;
    cin >> w >> a >> b;
    if (a > b) swap(a, b);
    cout << max(0, b-(a+w)) << endl;
    return 0;
}


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

long long digit(long long x) {
  long long count=0;
  while (x>0) {
    x = x/10;
    count++;
  }
  return count;
}

long long dig_sum(long long x) {
  long long sum=0;
  while (x>0) {
    sum += x%10;
    x = x/10;
  }
  return sum;
}

int main() {
  long long N;
  cin >> N;
  
  if (N<10) {
    cout << N << endl;
  }
  
  else {
    long long max=0,dig=digit(N),p=pow(10,dig-1);
    for (long long i=p-1;i<=N;i+=p) {
      if (max < dig_sum(i)) {
        max = dig_sum(i);
      }
    }
  cout << max << endl;
  }
}

Measured memory_bytes: 256
mod = 10**9+7


H, W, A, B = map(int, input().split())


class Fact():
    def __init__(self, H, W):
        self.mod = 10**9+7
        self.facts = [1]*(H+W-1)
        for i in range(1, H+W-1):
            self.facts[i] = self.facts[i-1]*i % mod

        self.i = [pow(self.facts[-1], mod-2, mod)]
        for i in range(1, H+W-1)[::-1]:
            self.i.append(self.i[-1]*i % mod)
        self.i.reverse()

    def comb(self, n, r):
        ret = self.facts[n] * self.i[n-r]*self.i[r]
        return ret

    def print_fact(self):
        print(self.facts)


f = Fact(H, W)

all_path = f.comb(H+W-2, H-1)

remove_path = 0
for i in range(B):
    tmp = f.comb(H-A+i-1, i)
    tmp *= f.comb(W-i-1+A-1, A-1)
    remove_path += tmp

remove_path %= mod

print((all_path - remove_path) % mod)


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

int main() {
    int k, a, b;
    scanf("%d%d%d", &k, &a, &b);// don't forget &
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            puts("OK");
            return 0;
        }
    }
    puts("NG");
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std; 
  
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi x(n);
  rep(i, n){
    cin >> x[i];
  }
  vi temp{x};
  int middle = n / 2;
  sort(x.begin(), x.end());
  int middleNum = x[middle - 1];
  rep(i, n){
    if(temp[i] <= middleNum) cout << x[middle] << endl;
    else cout << middleNum << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;
int v[100],c[100];
signed main(){
  int ans=0;
  int n;cin>>n;
  rep(i,n){
    cin>>v[i];
  }
  rep(i,n)cin>>c[i];
  rep(i,n)ans+=max((int)0,v[i]-c[i]);
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n, a;
  
  cin >> n >> a;
  
  int r = n % 500;
  
  if (r > a) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

map<int,int> fr;
int kr;
void add(int x,int p){
  int old=fr[x];
  fr[x]=old+p;
  kr+=abs(fr[x])-abs(old);
}

int main(){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  vi ans;
  rep(i,n){
    add(a[i],1);
    add(a[n-1-i],-1);
    if(kr==0)ans.push_back(i+1);
  }
  rep(i,ans.size()){
    cout<<ans[i]<<(i==(int)ans.size()-1?"\n":" ");
  }
}



Measured memory_bytes: 5520
#include <cstdio>
typedef long long ll;

int n,m,k,Fac[900005],Inv[900005];
const int p=1000000007;

inline ll C(const int n,const int m){return (ll)Fac[n]*Inv[m]%p*Inv[n-m]%p;}
inline ll Pow(ll a,ll b,ll s=1){for(;b;b>>=1,a=a*a%p)if(b&1)s=s*a%p;return s%p;}

int main()
{
    scanf("%d%d%d",&n,&m,&k),--n;
    ll Sum=1,Ans=1;
    for(int i=Fac[0]=1;i<=900000;++i)Fac[i]=(ll)Fac[i-1]*i%p;
    Inv[900000]=Pow(Fac[900000],p-2);
    for(int i=900000;i>=1;--i)Inv[i-1]=(ll)Inv[i]*i%p;
    for(int i=1;i<=m+k;++i)
    {
        Sum=(Sum<<1)%p;
        if(i>m)Sum=(Sum-C(i-1,m)+p)%p;
        if(i>k)Sum=(Sum-C(i-1,k)+p)%p;
        Ans=(Ans*3+C(n+i,i)*Sum)%p;
    }
    printf("%d\n",(int)Ans);
    return 0;
}

Measured memory_bytes: 7168
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    long long N, S, A[1 << 18], B[1 << 18];
    vector<pair<long long, long long>> vec;
     
    int main() {
    	cin >> N;
    	for (int i = 1; i <= N; i++) {
    		cin >> A[i] >> B[i];
    		vec.push_back(make_pair(B[i], A[i]));
    	}
    	sort(vec.begin(), vec.end());
     
    	for (int i = 0; i < vec.size(); i++) {
    		S += vec[i].second;
    		if (S > vec[i].first) {
    			cout << "No" << endl;
    			return 0;
    		}
    	}
    	cout << "Yes" << endl;
    	return 0;
    }

Measured memory_bytes: 9456
#include <stdio.h>
     
    int main() {
      int X, A, B;
      scanf("%d %d %d", &X, &A, &B);
      if(0 <= (A - B) ) {
        printf("delicious");
      } else if (X >= (B - A)) { 
      	printf("safe");
      }else {
      	printf("dangerous");
      }
      return 0;
    }

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

int main(){
  long long k, a, b;
  long long a1;
  cin >> k >> a >> b;
  a1 = k+1;

  if(a >= b){
    cout << 1+k << endl;
    return 0;
  }

  if(a-1 >= k-1){
    cout << 1+k << endl;
    return 0;
  }

  k-=(a-1)+2;

  long long ans = b;

  ans += (b-a)*(k/2);
  if(k % 2 == 1){
    ans++;
  }

  cout << max(ans, a1) << endl;

  return 0;
}






Measured memory_bytes: 256
N = int(input())
F = {}
for n in range(2,N+1):
    _n = n
    f = 2
    while f*f<=_n:
        if n%f==0 and f not in F: F[f] = 0
        while n%f==0:
            n//=f
            F[f]+=1
        f+=1
    if n>1:
        if n not in F: F[n] = 0
        F[n] += 1

ans = 1
mod = 10**9+7
for _, k in F.items():
    ans = ans*(k+1)%mod
print(ans)

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

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

  deque<int> dq;
  while ( n-- ) {
    char cum[12];
    int num;    
    scanf("%s", cum);    
    if ( strcmp(cum, "insert") == 0 ) {      
      scanf("%d", &num);
      dq.push_front(num);      
    } else if ( strcmp(cum, "delete") == 0 ) {
      scanf("%d", &num);
      bool flag = false;
      deque<int> nxt;
      while ( !dq.empty() ) {
	int dat = dq.front(); dq.pop_front();	
	if ( dat == num && !flag ) {
	  //cout << dat << endl;
	  flag = true;
	  continue;
	}
	nxt.push_back(dat);	
      }
      dq = nxt;
    } else if ( strcmp(cum, "deleteFirst") ) {
      dq.pop_back();      
    } else {
      dq.pop_front();      
    }
  }
  
  while ( dq.size() > 1 ) {
    printf("%d ", dq.front());    
    dq.pop_front();
  }
  if ( dq.size() ) cout << dq.front() << endl;
  
  return 0;
}



Measured memory_bytes: 7672
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    deque<int> q;
    REP(i, n) {
        if (i % 2 == 0) {
            q.push_back(a[i]);
        } else {
            q.push_front(a[i]);
        }
    }
    if (n % 2 == 1) {
        REP(i, n - 1) cout << q[n - i - 1] << " ";
        cout << q[0] << endl;
    } else {
        REP(i, n - 1) cout << q[i] << " ";
        cout << q[n - 1] << endl;
    }
}


Measured memory_bytes: 3840
#include <algorithm>
#include <queue>
#include <iostream>
#include <vector>
#include <map>
int main(){
  int k, x;
  std::cin>>k>>x;
  for(int i=x-k+1;i<=x+k-1;++i){
    printf("%d\n", i);
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char A[10],B[10],C[10];
  int con=0;
  
  scanf("%s %s %s",A,B,C);
   
  for(int i=1;i<=10;i++){
    if(A[i]=='\0'&&A[i-1]==B[0]) con++;
    if(B[i]=='\0'&&B[i-1]==C[0]) con++;
  }
  
  if(con==2) printf("YES");
  else printf("NO");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int>v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=n-1;i>=0;i--){
		if(i!=0) cout<<v[i]<<" ";
		else cout<<v[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> vec;
  int sum=0;
  for(int i=1;i<=n;i++){
    vec.push_back(i);
    sum+=i;
    if(sum==n) break;
    if(sum>n){
      vec.erase(vec.begin()+sum-n-1);
      break;
    }
  }
  for(int v:vec){
    cout<<v<<endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,H,W,ans;
char A,B;
int c[10][10];

int main() {
	cin >> A >> B;
	

	if ( A > B) cout << ">";
	else if ( A < B) cout << "<";
	else cout << "=";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin >> s[i];
    int ans=0;
    for(int bith=0;bith<(1<<h);bith++){
        for(int bitw=0;bitw<(1<<w);bitw++){
            int cnt=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(bith>>i&1) continue;
                    if(bitw>>j&1) continue;
                    if(s[i][j]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc =new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Integer [] l = new Integer[N];
        int ans=0;
        for(int i =0; i<N;i++){
        l[i] =sc.nextInt();
        }
        Arrays.sort(l,Comparator.reverseOrder());
        for(int i=0; i<K;i++){
            ans+=l[i];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
import os
import sys
from collections import Counter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

# グラフの最大マッチングだと辺の数多すぎ
# 大きい数から見ていくとまだ見てない数のうちペアになれる数が1つに定まる

A.sort(reverse=True)
counts = Counter(A)
ans = 0
for a in A:
    if counts[a] <= 0:
        continue
    counts[a] -= 1
    b = (1 << a.bit_length()) - a
    if counts[b] > 0:
        ans += 1
        counts[b] -= 1
print(ans)


Measured memory_bytes: 33424
#include<stdio.h>

typedef struct{
  char fig;
  int num;
  }Card;

void bubblesort(Card *,int);
void selectionsort(Card *,int);
void print(Card *,int);
int judge(Card *,Card *,int);
void change1(char *,char *);
void change2(int *,int *);

void bubblesort(Card *A,int N)
{
  int i,j;

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--) {
        if(A[j].num < A[j-1].num) {
       change1(&A[j].fig,&A[j-1].fig);
       change2(&A[j].num,&A[j-1].num);
      }
    }
  }
}


void selectionsort(Card *A,int N)
{
  int minj,i,j;

  for(i=0;i<N;i++) {
    minj = i;
    for(j=i;j<N;j++){
      if(A[j].num < A[minj].num) 
	minj = j;
    }
      change1(&A[i].fig,&A[minj].fig);
      change2(&A[i].num,&A[minj].num);
  }
}

void change1(char *a,char *b)
{
  char ex = *a;
  *a = *b;
  *b = ex;
}

void change2(int *a,int *b)
{
  int ex = *a;
  *a = *b;
  *b = ex;
}

void print (Card *A,int N)
{
  int i;

  for(i=0;i<N;i++) {
    if(i) printf(" ");
    printf("%c%d",A[i].fig,A[i].num);
  }
  printf("\n");
}


int judge (Card *A,Card *B,int N)
{
  int i;
  for(i=0;i<N;i++)
    if(A[i].fig != B[i].fig) {
      return 0;
    }
      return 1;
}
  

int main()
{
  Card A[40],B[40];
  int N,i;
  char ch;
  
  scanf("%d%c",&N,&ch);
  for(i=0;i<N;i++)
    scanf("%c%d%c",&A[i].fig,&A[i].num,&ch);

  for(i=0;i<N;i++) {
    B[i].fig = A[i].fig;
    B[i].num = A[i].num;
  }

  bubblesort(A,N);
  selectionsort(B,N);

  print(A,N);
  printf("Stable\n");
  print(B,N);
  if(judge(A,B,N)) {
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>

int main(){
  int n,i,u,l,j,v,k,adj[120][120];
  scanf("%d",&n);
    for(i=1;i<=n;i++){
      scanf("%d %d",&u,&k);
      for(j=1;j<=k;j++){
	scanf("%d",&v);
	adj[i][v]=1;
      }
      
    }
     for(i=1;i<=n;i++){
       for(j=1;j<n;j++){
	 printf("%d ",adj[i][j]);
       }
       printf("%d\n",adj[i][j]);
     }
       
  return 0;
  }



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

int main() {
    int index[2], N, i, swap=0;
    cin >> N;
    int nums[N];
    for (i=0; i<N; i++) cin >> nums[i];
    for (i=0; i<N; i++) {
        if (nums[i] == i+1) continue;
        else {
            if (swap >= 2) {
                cout << "NO" << endl;
                return 0;
            }
            if (nums[nums[i]-1] == i+1) swap += 1;
            else {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
use proconio::input;
// use num::*;

fn main() {
    input! {
        n: String,
    };
    let ans = match &n[n.len() - 1..] {
        "2" | "4" | "5" | "7" | "9" => "hon",
        "0" | "1" | "6" | "8" => "pon",
        _ => "bon",
    };
    println!("{}", ans);
}


Measured memory_bytes: 2124
require 'set'
require 'pp'
N = gets.chomp.to_i
s = gets.chomp

e_count = 0
w_count = 0
(0..N-1).each do |i|
  e_count += 1 if s[i] == 'E'
end

ans = N

N.times do |i|
  e_count -= 1 if s[i] == 'E'
  w_count += 1 if i > 0 && s[i-1] == 'W'
  ans = e_count + w_count if ans > e_count + w_count
end

puts ans


Measured memory_bytes: 3008
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
    ll n;
    cin >> n;
    vi cnt;
    ll ans = 0;
    for(ll i = 2; i * i <= n; i++){
        if(n % i == 0){
            int cur = 0;
            while(n % i == 0){
                cur++;
                n /= i;
            }
            ans += int((sqrt(8 * cur + 1) - 1) / 2);
        }
    }
    if(n > 1)
        ans++;
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

const int COMB_MAX = 52;
ll comb[COMB_MAX][COMB_MAX];

int main(){
  comb[0][0] = 1;
  FOR(i,1,COMB_MAX)REP(j,i+1){
    if(j==0 || j==i)comb[i][j]=1;
    else comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
  }
  int n,a,b;
  cin>>n>>a>>b;
  vl v(n);
  REP(i,n)cin>>v[i];
  sort(ALL(v));
  reverse(ALL(v));
  printf("%.9f\n", 1.0 * accumulate(v.begin(), v.begin()+a, 0.0) / a);
  ll x = v[a-1];
  int s = count(ALL(v), x);
  int t = count(v.begin(), v.begin()+a, x);
  if(t==a){
    // sum(sCa ~ sCb)
    ll ans = 0;
    FOR(i,a,b+1)ans += comb[s][i];
    cout<<ans<<endl;
  }else{
    // sCt
    cout<<comb[s][t]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256