akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <string>    // useful for reading and writing
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream

using namespace std;

int main()
{
    int i=1;
    while(1)
    {
    int x;
    cin >> x;

    if(x==0) break;
    cout << "Case "<<i<<": "<<x<<endl;
    i += 1;
    }

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a == 1 || b == 1)
    {
        if(a == 1)
            a += 13;
        if(b == 1)
            b += 13;
        if(a > b)
            cout << "Alice" << endl;
        else if(a < b)
            cout << "Bob" << endl;
        else
            cout << "Draw" << endl;
    }
    else
    {
        if(a > b)
            cout << "Alice" << endl;
        else if(a < b)
            cout << "Bob" << endl;
        else
            cout << "Draw" << endl;
    }
}

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

using namespace std;

int main() {
    int n[5];
    int n2[5];
    int minn2=1,ans=0;
    int i,j;
    for(i=0;i<5;i++){
        cin>>n[i];
        n2[i]=n[i]%10;
    }
    for(i=0;i<5;i++){
        ans+=n[i]-n2[i];
        if(n2[i]==0)n2[i]=11;
        minn2=min(minn2,n2[i]);
    }
    sort(n2,n2+5);
    for(i=1;i<5;i++){
        if(n2[i]!=11)ans+=10;
    }
    if(n2[0]==11)n2[0]=0;
    ans+=n2[0];
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
h, w = list(map(int, input().split()))

while h != 0 or w != 0 :

    judgeChange = 0

    for i in range(h) :
        for j in range(w) :
            if j % 2 == judgeChange:
                print('#', end = '')
            else :
                print('.', end = '')
        print()
        
        if judgeChange == 1 :
            judgeChange = 0
        else :
            judgeChange = 1
    print()
    h, w = list(map(int, input().split()))

Measured memory_bytes: 9128
#include<cstdio>

int n;
double point[4][2];

int main()
{
	scanf("%d",&n);
	for(int k=0;k<n;k++)
	{
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<2;j++)
		{
			scanf("%lf",&point[i][j]);
		}
	}

	if((point[0][0]-point[1][0])*(point[2][1]-point[3][1])==(point[0][1]-point[1][1])*(point[2][0]-point[3][0])||(point[0][0]-point[1][0])*(point[2][1]-point[3][1])==(point[0][1]-point[1][1])*(point[2][0]-point[3][0]))
	{
		printf("YES\n");
	}
	else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <stack>
#include <map>
#include <set>
#if __cplusplus > 199711L
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//	tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name;
//	order_of_key
//	find_by_order
#endif

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, pair<string, bool> > useinout();

void initialization() {
#ifdef SOL
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(time(0));
	const string file = useinout().sc.fs;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
	if(useinout().sc.sc) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
}

int solve();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\nexit value: %d\ntime: %.3lf ms\n", exitval, 1000. * clock() / CLOCKS_PER_SEC);
#endif
}

int main() {
	initialization();
	int exitval = solve();
	finish(exitval);
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 100100;

map<int, int> ma;
map<int, int>::iterator itm;
set<pair<int, int> > st;

int solve() {

	int k, t;
	scanf("%d%d", &k, &t);
	for (int i = 0; i < t; i++) {
		int x;
		scanf("%d", &x);
		st.insert(mp(x, i));
	}

	int lst = -1;
	while (st.size() > 1) {
		pair<int, int> p1 = *(st.rbegin());
		st.erase(--(st.end()));
		pair<int, int> p2 = *(st.rbegin());
		st.erase(--(st.end()));
		p1.fs--, p2.fs--;
		lst = p2.sc;
		if (p1.fs) {
			st.insert(p1);
		}
		if (p2.fs) {
			st.insert(p2);
		}
	}

	int cnt = 0;
	if (st.size() == 1) {
		pair<int, int> p = *(st.rbegin());
		while (p.fs) {
			p.fs--;
			if (lst == p.sc) {
				cnt++;
			}
			lst = p.sc;
		}
	}
	printf("%d\n", cnt);

	return (0);
}

inline pair<pair<bool, bool>, pair<string, bool> > useinout() {
	return (mp(mp(0, 0), mp("", 0)));
}

// by Andrey Kim


Measured memory_bytes: 256
from fractions import gcd
A, B = map(int, input().split())
M = gcd(A, B)
primes = {}
i = 2
while(M >= i ** 2):
  if(M % i == 0):
    primes[i] = primes.get(i, 0) + 1
    M //= i
  else:
    i += 2 - (i + 1) % 2
if M > 1: primes[M] = 1

print(len(primes) + 1)

Measured memory_bytes: 5432
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    R = [0]
    for i in range(n):
        R.append(R[-1] + A[i])

    D = Counter(R)
    res = 0
    for v in D.values():
        res += v * (v - 1) // 2

    print(res)


if __name__ == '__main__':
    resolve()


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

int main()
{
    int n,x,i;
    string s;
    while(cin>>n>>s)
    {
        string s1,s2;
        if(n%2==0)
        {
            x=n/2;
            for(i=0;i<x;i++)
            {
                s1+=s[i];
            }
            for(i=x;i<n;i++)
            {
                s2+=s[i];
            }
            if(s1.compare(s2)==0)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;

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

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
students = [list(map(int, input().split())) for _ in range(N)]
points =  [list(map(int, input().split())) for _ in range(M)]
for student in students:
  dis_list = [abs(student[0]-point[0]) + abs(student[1]-point[1]) for point in points]
  min_dis = min(dis_list)
  print(dis_list.index(min_dis)+1)

Measured memory_bytes: 39152
// AOJ 2207: Consistet Unit System
// 2017.12.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define HASHSIZ 607
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table

int lookup(char *s, int w, int id)
{
	HASH *tp = hash + (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	while (tp->s != NULL) {
		if (strcmp(tp->s, s) == 0) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

// <????????????Union Find>
#define MAX 300
int par[MAX], ws[MAX];
int find(int x)
{
	int p;
	if (par[x] < 0) return x;
    p = find(par[x]), ws[x] += ws[par[x]];
    return par[x] = p;
}
    
int weight(int x)
{
    find(x); 
    return ws[x];
}
    
int unite(int x, int y, int w)
{
	int t;
    w += weight(x), w -= weight(y);
    x = find(x), y = find(y);
    if (x == y) return 0;
    if (par[y] < par[x]) t = x, x = y, y = t, w = -w;
    par[x] += par[y], par[y] = x;
    ws[y] = w;
    return 1;
}
// </????????????Union Find>

char unit[MAX][18]; int sz;

int main()
{
	int n, i, j, k, minus, ans;
	char buf[102], *p, *q;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		memset(hash, 0, sizeof(hash));
		memset(par, 0xff, sizeof(par));
		memset(ws, 0, sizeof(ws));
		sz = 0; ans = 1;
		while (n-- > 0) {
			fgets(buf, 100, stdin);
			if (!ans) continue;

			p = buf + 2;		// skip "1 "
			q = p; while (isalpha(*p)) p++;
			*p = 0;	strcpy(unit[sz], q);
			if ((i = lookup(unit[sz], p-q, sz)) < 0) i = sz++;
			
			p += 6;			// skip " = 10^"
			minus = 0; if (*p == '-') minus = 1, p++;
			k = 0; while (isdigit(*p))  k = 10*k + (*p++ & 0xf);
			if (minus) k = -k;
			p++;

			q = p; while (isalpha(*p)) p++;
			*p = 0;	strcpy(unit[sz], q);
			if ((j = lookup(unit[sz], p-q, sz)) < 0) j = sz++;

			// i = k * j ???
			if (find(i) == find(j)) {
				if (ws[i] - ws[j] != k) ans = 0;
			} else unite(j, i, k);
		}
		puts(ans ? "Yes" : "No");
	}
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    for (auto& row : board) {
        cin >> row;
    }
    vector<vector<int>> horizontal(h, vector<int>(w, 0));
    vector<vector<int>> vertical(h, vector<int>(w, 0));
    for (int r = 0; r < h; ++r) {
        for (int i = 0; i < w; ++i) {
            if (board[r][i] == '#') {
                horizontal[r][i] = 0;
                continue;
            }
            int j = i;
            while (j+1 < w && board[r][j+1] == '.') ++j;
            for (int k = i; k <= j; ++k) {
                horizontal[r][k] = j-i+1;
            }
            i = j;
        }
    }
    for (int c = 0; c < w; ++c) {
        for (int i = 0; i < h; ++i) {
            if (board[i][c] == '#') {
                vertical[i][c] = 0;
                continue;
            }
            int j = i;
            while (j+1 < h && board[j+1][c] == '.') ++j;
            for (int k = i; k <= j; ++k) {
                vertical[k][c] = j-i+1;
            }
            i = j;
        }
    }
    int best = 0;
    for (int r = 0; r < h; ++r) {
        for (int c = 0; c < w; ++c) {
            best = max(best, horizontal[r][c] + vertical[r][c] - 1);
        }
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 35968
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

Max = 0
for i in set(s):
    C = 0
    C = s.count(i) - t.count(i)
    if Max < C:
        Max = C
print(Max)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin>>N>>M;
    int g=(M+1)/2;
    int k=M/2;
    int co=0;
    int c=1;
    while(0<g){
        cout<<c<<" ";
        cout<<c+g*2-1<<endl;
        g--;
        c++;
    }
    c=N;
    while(0<k){
        cout << c << " ";
        cout << c-k*2<<endl;
        c--;
        k--;
    }



    



}


Measured memory_bytes: 3640
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var output = 1;
  var mod = 1000000007;
  var r = 0;
  var g = 0;
  var b = 0;
  for(var i = 0; i < N; i++){
    var count = 0;
    var isAdd = false;
    if(list[i] == r){
      count++;
      if(!isAdd){
        r++;
        isAdd = true;
      }
    }
    if(list[i] == g){
      count++;
      if(!isAdd){
        g++;
        isAdd = true;
      }
    }
    if(list[i] == b){
      count++;
      if(!isAdd){
        b++;
        isAdd = true;
      }
    }
    output *= count;
    output %= mod;
  }
  myout(output);
}


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

int main(){
  int a[12]={1,2,1,3,1,3,1,1,3,1,3,1};
  int b,c;
  cin >> b >> c;
  if(a[b-1]==a[c-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j;
  string s;
  while(cin>>s,s[0]!='#'){
    int lx=-1,ly=0,rx=3,ry=0;
    int a=0,b=0;
    int ln=s.length();
    j=0;
    for(i=0;i<ln;i++){
      if((i+j)%2){
	if(0){
	}else if(rx==(s[i]-'1')%3&&ry==(s[i]-'1')/3){
	  a++;
	  j=(j+1)%2;
	}else if((s[i]-'1')%3>rx){
	  rx=(s[i]-'1')%3;
	  ry=(s[i]-'1')/3;
	  a++;
	  j=(j+1)%2;
	}else{
	  lx=(s[i]-'1')%3;
	  ly=(s[i]-'1')/3;
	}
      }else{
	if(0){
	}else if(lx==(s[i]-'1')%3&&ly==(s[i]-'1')/3){
	  a++;
	  j=(j+1)%2;
	}else if((s[i]-'1')%3<lx){
	  lx=(s[i]-'1')%3;
	  ly=(s[i]-'1')/3;
	  a++;
	  j=(j+1)%2;
	}else{
	  rx=(s[i]-'1')%3;
	  ry=(s[i]-'1')/3;
	}
      }
    }
    lx=-1;
    ly=0;
    rx=3;
    ry=0;
    j=0;
    for(i=0;i<ln;i++){
      if((i+j)%2){
	if(0){
	}else if(lx==(s[i]-'1')%3&&ly==(s[i]-'1')/3){
	  b++;
	  j=(j+1)%2;
	}else if((s[i]-'1')%3<lx){
	  lx=(s[i]-'1')%3;
	  ly=(s[i]-'1')/3;
	  b++;
	  j=(j+1)%2;
	}else{
	  rx=(s[i]-'1')%3;
	  ry=(s[i]-'1')/3;
	}
      }else{
	if(0){
	}else if(rx==(s[i]-'1')%3&&ry==(s[i]-'1')/3){
	  b++;
	  j=(j+1)%2;
	}else if((s[i]-'1')%3>rx){
	  rx=(s[i]-'1')%3;
	  ry=(s[i]-'1')/3;
	  b++;
	  j=(j+1)%2;
	}else{
	  lx=(s[i]-'1')%3;
	  ly=(s[i]-'1')/3;
	}
      }
    }
    cout<<min(a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1144
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm>  
using namespace std; 
const int MAX_N = 205; 
void chkmax(int &x, int y) { if (y > x) x = y; } 
void chkmin(int &x, int y) { if (x > y) x = y; } 
char a[MAX_N][MAX_N]; 
int N, M; 
int f[MAX_N][MAX_N][MAX_N], g[MAX_N][MAX_N][MAX_N]; 
void prepare() { 
	static int r[MAX_N][MAX_N], c[MAX_N][MAX_N]; 
	for (int i = 1; i <= N; i++) 
		for (int j = M; j; j--) 
			r[i][j] = (a[i][j] == a[i][j + 1] ? r[i][j + 1] : 0) + 1; 
	for (int i = N; i; i--) 
		for (int j = 1; j <= M; j++) 
			c[i][j] = (a[i + 1][j] == a[i][j] ? c[i + 1][j] : 0) + 1; 
	for (int i = 1; i <= N; i++) 
		for (int j = 1; j <= M; j++) { 
			f[i][j][j] = c[i][j]; 
			for (int k = j + 1; k <= M; k++) 
				f[i][j][k] = min(f[i][j][k - 1], a[i][k] == a[i][k - 1] ? c[i][k] : 0); 
		}
	for (int i = 1; i <= M; i++)
		for (int j = 1; j <= N; j++) { 
			g[i][j][j] = r[j][i]; 
			for (int k = j + 1; k <= N; k++) 
				g[i][j][k] = min(g[i][j][k - 1], a[k][i] == a[k - 1][i] ? r[k][i] : 0); 
		} 
} 
void solve() { 
	static int F[MAX_N][MAX_N][MAX_N], G[MAX_N][MAX_N][MAX_N]; 
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++) 
			for (int k = j; k <= M; k++) { 
				f[i][j][k] += f[i + f[i][j][k]][j][k]; 
				if (f[i][j][k]) chkmax(F[j][i][i + f[i][j][k] - 1], k - j + 1); 
			} 
	for (int i = 1; i <= M; i++)
		for (int j = 1; j <= N; j++)
			for (int k = j; k <= N; k++) { 
				g[i][j][k] += g[i + g[i][j][k]][j][k]; 
				if (g[i][j][k]) chkmax(G[j][i][i + g[i][j][k] - 1], k - j + 1); 
			} 
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++) 
			for (int k = M; k >= j; k--) 
				chkmax(f[i][j][k], max(f[i][j][k + 1], G[i][j][k])); 
	for (int i = 1; i <= M; i++)
		for (int j = 1; j <= N; j++) 
			for (int k = N; k >= j; k--) 
				chkmax(g[i][j][k], max(g[i][j][k + 1], F[i][j][k])); 
} 
int main () { 
	scanf("%d %d", &N, &M); 
	for (int i = 1; i <= N; i++) scanf("%s", a[i] + 1); 
	prepare(); 
	int ans = 0; 
	for (; f[1][1][M] < N; ++ans) solve(); 
	printf("%d\n", ans); 
    return 0;  
} 

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

	int n, m;
	cin >> n >> m;

	priority_queue<ll> q;

	REP(i, n) {
		ll a;
		cin >> a;
		q.push(a);
	}
	REP(i, m) {
		ll b;
		b = q.top();
		q.pop();
		b /= 2;
		q.push(b);
	}

	ll ans = 0;
	REP(i, n) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;

}

Measured memory_bytes: 1400
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func partseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()

	if n%111 == 0 {
		fmt.Println(111 * (n / 111))
	} else {
		t := n / 111
		fmt.Println(111 * (t + 1))
	}
}


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

int main() {
  double a, b, C;
  cin >> a >> b >> C;
  double c = sqrt(a * a + b * b - 2 * a * b * cos(C / 180.0 * acos(-1)));
  double s = (a + b + c) / 2;
  double S = sqrt(s * (s - a) * (s - b) * (s - c));
  double L = a + b + c;
  double h = S * 2 / a;
  cout << fixed << setprecision(8) << S << endl << L << endl << h << endl;
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N);
  int a, b;
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    road.at(a-1)++;
    road.at(b-1)++;
  }
  for (int i=0; i<N; i++) {
    cout << road.at(i) << endl;
  }
}

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

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    
    vector<ll> ab;
    rep(i, x) rep(j, y) ab.push_back(a[i] + b[j]);
    sort(ab.begin(), ab.end(), greater<ll>());
    
    vector<ll> abc;
    rep(i, min(k, x*y)) rep(j, z) abc.push_back(ab[i] + c[j]);
    sort(abc.begin(), abc.end(), greater<ll>());

    rep(i, k) cout << abc[i] << endl; 
    return 0;
}

Measured memory_bytes: 44056
<?php
	$n = trim( fgets( STDIN ) );
	$nums = [];
	for( $i=0; $i<$n; $i++ ) {
		array_push( $nums, intval( trim( fgets( STDIN ) ) ) );
	}
	$cnt = $n;
	$end = max( $nums );
	
	for( $i=2; $i*$i<=$end; $i++ ) {
		$nums2 = [];
		$size = count( $nums );
		for( $j=0; $j<$size; $j++ ) {
			if( 0 == $nums[$j]%$i )  {
				if( $nums[$j] != $i ) {
					$cnt--;
				}
			} else {
				array_push( $nums2, $nums[$j] );
			}
		}
		$nums = $nums2;
	}
	print $cnt;
?>

Measured memory_bytes: 17328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll x=b;
ll y=d;
ll ans=x*y;
if(ans<a*c){ans=a*c;}
if(ans<a*d){ans=a*d;}
if(ans<b*c){ans=b*c;}
cout<<ans;
}






Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    while(1){
        int h,w;cin>>h>>w;
        if(h==0&&w==0)return 0;
        rep(i,h){
            rep(j,w){
                if(i==0||i==h-1||j==0||j==w-1)cout<<"#";
                else cout<<".";
            } 
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
    }
    int mn = 1e9;
    vi ret;
    for (int i = 0; i < n; ++i) {
        queue<int> q;
        vi dist(n, -1), prev(n, -1);
        q.push(i);
        dist[i] = 0;
        [&] {
            while (!q.empty()) {
                int c = q.front();
                q.pop();
                for (auto &ne : edges[c]) {
                    if (dist[ne] == -1) {
                        dist[ne] = dist[c] + 1;
                        prev[ne] = c;
                        q.push(ne);
                    } else if (ne == i and dist[c] + 1 < mn) {
                        mn = dist[c] + 1;
                        vi().swap(ret);
                        int x = c;
                        while (true) {
                            ret.push_back(x);
                            if (x == ne)
                                return;
                            x = prev[x];
                        }
                    }
                }
            }
        }();
    }
    if (ret.size() == 0)
        cout << -1 << "\n";
    else {
        cout << ret.size() << "\n";
        for (auto &r : ret) {
            cout << r + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-05-18 19:56:42
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , k , val[MAXN] , Real[MAXN] , mark[MAXN];
vector<int> adj[MAXN];
set<pii> st;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    fill(Real , Real + MAXN , -1);

    cin >> n;
    for(int i = 1 , v , u ; i < n ; i++){
        cin >> v >> u;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    cin >> k;
    for(int i = 0 , v , p ; i < k ; i++){
        cin >> v >> p;
        Real[v] = p;
        val[v] = p;
        st.insert({p , v});
    }

    while(SZ(st)){
        pll A = *st.begin();
        st.erase(st.begin());
        int v = A.Y;
        if(mark[v]) continue;
        mark[v] = 1;
        for(int u : adj[v]){
            if(mark[u]) continue;
            val[u] = val[v] + 1;
            st.insert({val[u] , u});
        }
    }
    for(int i = 1 ; i <= n ; i++)   if(Real[i] != -1 && val[i] != Real[i])  return cout << "No" << endl , 0;
    for(int i = 1 ; i <= n ; i++)   for(int j : adj[i]) if(abs(val[i] - val[j]) != 1)   return cout << "No" << endl , 0;
    cout << "Yes" << endl;
    for(int i = 1 ; i <= n ; i++)   cout << val[i] << endl;


    return 0;
}
/*

*/


Measured memory_bytes: 39552
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int x[6][6]={{1,2,3,4,5,6},
			 {2,6,3,4,1,5},
			 {3,2,6,1,5,4},
			 {4,2,1,6,5,3},
			 {5,1,3,4,6,2},
			 {6,2,4,3,5,1}};
int y[4][6]={{1,2,3,4,5,6},
			 {1,4,2,5,3,6},
			 {1,5,4,3,2,6},
			 {1,3,5,2,4,6}};
int c[33][6],d[6];
int func(char *s){
	if(strcmp(s,"Red")==0)return 0;
	if(strcmp(s,"Yellow")==0)return 1;
	if(strcmp(s,"Blue")==0)return 2;
	if(strcmp(s,"Magenta")==0)return 3;
	if(strcmp(s,"Green")==0)return 4;
	if(strcmp(s,"Cyan")==0)return 5;
}
int main(){
	int i,j,k,l,n,ans,f[33],r[33];
	char t[15];
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(f,0,sizeof(f));
		ans=0;
		for(i=0;i<n;i++){
			for(j=0;j<6;j++){
				scanf("%s",t);
				c[i][j]=func(t);
				//printf("%d ",func(t));
				if(func(t)==0)r[i]=j;
			}
			for(j=0;j<6;j++)d[j]=c[i][x[r[i]][j]-1];
			memcpy(c[i],d,sizeof(int)*6);
			/*
			for(k=0;k<4;k++){
				for(j=0;j<6;j++)printf("%d ",c[i][y[k][j]-1]);
				printf("\n");
			}
			printf("\n");
			*/
			for(j=0;j<i;j++){
				if(f[j]==1)continue;
				for(k=0;k<4;k++){
					for(l=0;l<6;l++)if(c[i][y[k][l]-1]!=c[j][l])break;
					if(l==6){
						ans++;f[j]=1;
						break;
					}
				}
			}
			//printf("  ::%d\n\n",ans);
		}
		printf("%d\n",ans);
	}
	
	return 0;
}

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

int main() {
	int a, b;
	char op;
	cin >>a>>op>>b;
	if (op == '+') {
		a += b;
	}
	else if (op == '-') {
		a -= b;
	}
	cout << a << endl;

	

	

	//system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
string N;
int main() {
	cin >> N;
	if(N[0]=='7'||N[1]=='7'||N[2]=='7'){
		cout << "Yes" << el;
	}else{
		cout << "No" << el;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <string>

using namespace std;

int main() {
	string S;
	
	cin >> S;
	
	if (S[0] != 'A') {
		cout << "WA" <<endl;
		return 0;
	}
	
	int count=0;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == 'C' && (i < 2 || i > S.size()-2)) {
			cout << "WA" << endl;
			return 0;
		}
		if (S[i] == 'C') {
			count++;
		}
	}
	if (count != 1) {
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 0; i < S.size(); i++) {
		if (S[i] >= 'B' && S[i] <= 'Z' && S[i] != 'C') {
			cout << "WA" << endl;
			return 0;
		}
	}
	
	cout << "AC" << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np
h, w = list(map(int, input().split()))
ss = []
for _ in range(h):
    s = input()
#     s = s.replace(".", "0").replace("#", "1")
#     s = list(map(int, list(s)))
    ss.append(s)
# ss = np.array(ss)
    

from collections import deque
def find(now_h, now_w):
    dp = np.zeros([h, w], dtype = np.int32) + 9999
    dp[now_h, now_w] = 0
    que = deque()
    que.append((now_h, now_w))
    while len(que) > 0:
        now_h, now_w = que.popleft()
        if (now_h, now_w) in que:
            continue
        for mh, mw in ([0,1], [0,-1], [1,0], [-1,0]):
            next_h = now_h + mh
            next_w = now_w + mw
            if next_h < 0 or next_h >= h or next_w < 0 or next_w >= w:
                continue
            if ss[next_h][next_w] == "#":
                continue
            a = dp[now_h, now_w] + 1
            if dp[next_h, next_w] > a:
                dp[next_h, next_w] = a
                que.append((next_h, next_w))
#             print(que)
    score = np.max(dp[dp != 9999])
    return score

maximum = 0
for sh in range(h):
    for sw in range(w):
        if ss[sh][sw] == ".":
            if sh > 0 and sh < h - 1 and sw > 0 and sw < w - 1:
                if 0 + (ss[sh + 1][sw] == ".") + (ss[sh - 1][sw] == ".") + (ss[sh][sw + 1] == ".") + (ss[sh][sw - 1] == ".") >= 3:
                    continue
            score = find(sh, sw)
            if maximum < score:
                maximum = score

print(maximum)

Measured memory_bytes: 14508
N,K=map(int, input().split())
H=list(map(int, input().split()))

if N-1<=K:
    print(abs(H[N-1]-H[0]))
    exit()

inf=10**4+1
dp=[inf]*N
dp[0]=0

for i,h in enumerate(H):
    if i == 0:continue
    m=inf
    M=max(0,i-K)
    dp[i]=min([dpt+abs(h-ht) for ht,dpt in zip(H[M:i],dp[M:i])])
print(dp[N-1])

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

int main(void){
    int a,b,x,y;
    cin >> a >> b >> x >> y;
    int c[100],d[100];
    for(int i = 0;i < a;i++)cin >> c[i];
    for(int i = 0;i < b;i++)cin >> d[i];
    sort(c,c+a,greater<int>());
    sort(d,d+b);
    if(c[0] < d[0] && x < d[0] && d[0] <= y)cout << "No ";
    cout << "War";
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll n,k;
  cin >> n >> k;
  VLL a(n);
  rep(i,n){
    cin >> a[i];
  }
  VLL pa(n,0);
  rep(i,n){
    if(a[i] > 0) pa[i] = a[i];
  }
  rep(i,n-1) pa[i+1] += pa[i];
  rep(i,n-1) a[i+1] += a[i];
  ll ans = 0;
  FOR(i,k-1,n){

    if(i != k-1) ans = max(ans, pa[n-1] - (pa[i] - pa[i-k]) + max(a[i]-a[i-k],0LL) );
    else ans = max(ans, pa[n-1] - (pa[i]) + max(a[i],0LL) );
    //cout << i << " , " << i-k << ","<<ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys

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


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


def is_nth_bit_set(x, n):
    if x & (1 << n):
        return 1
    else:
        return 0


def main():
    N = int(input())
    F = []
    for _ in range(N):
        f = list(map(int, input().split()))
        F.append(f)

    P = []
    for _ in range(N):
        p = list(map(int, input().split()))
        P.append(p)

    ans = -INF
    total = 2 ** 10
    for pattern in range(1, total):
        joisino = [is_nth_bit_set(pattern, i) for i in range(10)]
        benefit = 0
        for f, p in zip(F, P):
            cnt = 0
            for i, j in zip(joisino, f):
                if i and j:
                    cnt += 1

            benefit += p[cnt]

        if ans < benefit:
            ans = benefit

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, d[101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	
	sort(d, d+n);
	
	int c = 0;
	for(int i = 1; i < n; i++){
		if(d[i-1] != d[i]) c++;
	}
	cout << c+1 << endl;
	
	return 0;
}

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

int main(){
  int N, L;
  string S[105], ret;
  cin >> N >> L;

  for(int i = 0; i<N; i++)cin >> S[i];
  sort(S, S+N);
  for(int i = 0; i<N; i++)ret+= S[i];
  cout << ret<< endl;
}


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

int main(){
    int a;
    cin >> a;
    int amari10 = a % 10;
    int amari100 = a % 100;
    int amari1000 = a % 1000;
    int ichi = amari10;
    int juu = ( amari100 - amari10 ) / 10;
    int hyaku = ( amari1000 - amari100 ) / 100;

    if ( ichi == 7 || juu == 7 || hyaku == 7 ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

const int INF = 1001001001;

int main() {
  int n, m, x;
  cin >> n >> m >> x;

  int a[n][m];
  int c[n];

  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s, 1 << n) {
    int sum = 0;
    int score[m];
    rep(i, m) score[i] = 0;

    rep(i, n) {
      if (s >> i & 1) {
        sum += c[i];
        rep(j, m) score[j] += a[i][j];
      }

      bool ok = true;
      rep(i, m) if (score[i] < x) ok = false;

      if (ok) ans = min(ans, sum);
    }
  }

  if (ans == INF)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
  return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> v(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int tmp;
            cin >> tmp;
            tmp--;
            v[i].push_back(tmp);
        }
    }

    vector<int> p(M);
    rep(i, M) cin >> p[i];

    int ans = 0;
    for (int i=0; i<(1<<N); ++i) {
        bool ok = true;
        rep(j, M) {
            int c = 0;
            for (int id : v[j]) {
                if ((i >> id) & 1) {
                    c++;
                }
            }
            if (c%2 != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int crmean(int a, int b){
  int sum, mean;
  sum = a + b;
  mean = sum/2 + sum%2;
  return mean;
}

int main() {
  // 一年の秒数
  int a, b;
  int mean;
  cin >> a >> b;
  
  mean = crmean(a,b);
  cout << mean << endl;
}

Measured memory_bytes: 256
/// https://github.com/hatoo/competitive-rust-snippets
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules !get {([$t:ty]) => {{let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace().map(|t| t.parse::<$t>() .unwrap () ) .collect ::<Vec <_ >>() } } ;([$t :ty ] ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !([$t ] ) ) .collect ::<Vec <_ >>() } ;($t :ty ) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;line .trim () .parse ::<$t >() .unwrap () } } ;($($t :ty ) ,*) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;let mut iter =line .split_whitespace () ;($(iter .next () .unwrap () .parse ::<$t >() .unwrap () ,) *) } } ;($t :ty ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($t ) ) .collect ::<Vec <_ >>() } ;($($t :ty ) ,*;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($($t ) ,*) ) .collect ::<Vec <_ >>() } ;}
#[allow(unused_macros)]
macro_rules !debug {($($a :expr ) ,*) =>{eprintln !(concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) ;} }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let mut input: Vec<u8> = get!([u8]);
    input.sort();
    if input == [5, 5, 7] {
        println!("YES");
    }else{
        println!("NO");
    }
}

Measured memory_bytes: 8572
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
  Console.ReadLine().Split([|' '; '.'|])
  |> fun xs -> int64 xs.[0] * ((int64 xs.[1]) * 100L + int64 xs.[2]) / 100L
  |> Console.WriteLine  
  0 // return an integer exit code


Measured memory_bytes: 27904
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
from bisect import bisect_left
b = [list(map(int, input().split())) for i in range(m)]
b.sort(key=lambda x: x[1], reverse=True)
cur = 0
ans = 0
for e in b:
  t = bisect_left(a, e[1])
  if t>=cur:
    ans += min(t-cur, e[0])*e[1]
    cur += min(t-cur, e[0])
while cur<len(a):
  ans += a[cur]
  cur += 1
print(ans)

Measured memory_bytes: 82284
from collections import Counter
def main():
    n = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    mod = 1000000007
    if n % 2 == 0:
        if any([a % 2 == 0 for a in A]) or any([v != 2 for v in c.values()]):
            print(0)
            exit()

    else:
        if any([a % 2 != 0 for a in A]) or any([v != 2 if k != 0 else v != 1 for k, v in c.items()]):
            print(0)
            exit()
    print(pow(2, n // 2, mod))    


if __name__ == '__main__':
    main()


Measured memory_bytes: 61420
class Dice(object):

    def __init__(self, num):
        self.num = num

    def rotate_S(self):
        self.num = [self.num[4], self.num[0], self.num[2], self.num[3], self.num[5], self.num[1]]

    def rotate_N(self):
        self.num = [self.num[1], self.num[5], self.num[2], self.num[3], self.num[0], self.num[4]]

    def rotate_W(self):
        self.num = [self.num[2], self.num[1], self.num[5], self.num[0], self.num[4], self.num[3]]

    def rotate_E(self):
        self.num = [self.num[3], self.num[1], self.num[0], self.num[5], self.num[4], self.num[2]]


dice = Dice(map(int, raw_input().split()))
order = raw_input()
for i in range(len(order)):
    if order[i] == 'S':
        dice.rotate_S()
    elif order[i] == 'N':
        dice.rotate_N()
    elif order[i] == 'W':
        dice.rotate_W()
    elif order[i] == 'E':
        dice.rotate_E()

print dice.num[0]

Measured memory_bytes: 6484
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fi first
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
 
int32_t main() 
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	fastIO;
	ll t,n,i,j,a,c,d,k,q,l,r,x,y;
	//cin>>t;
	t=1;
	while(t--)
	{
		string s;
		cin>>s;
		n=s.size();
		if(s[n-1]=='s')
		{
			cout<<s<<"es";
		}
		else
		{
			cout<<s<<"s";
		}
		
	}
	return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    int d = 0;
    int ans = 1;
    for (int i = 0; i < N; i++) {
        // cout << "d: " << d << endl;
        d = d + L[i];
        if (d <= X) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    string ans = "";
    for (char c = 'a'; c <= 'z'; ++c)
    {
        bool found = false;
        if (S.find(c) == string::npos)
        {
            ans = c;
            break;
        }
    }
    if (ans == "")
    {
        cout << "None" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}


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

int main(void){
    int n;
    cin >> n;
    
    int l[200];
    int i;
    for(i = 0; i < n * 2; i++){
        cin >> l[i];
    }
    
    sort(l, l + n * 2);
    
    int ans = 0;
    for(i = 0; i < n * 2; i++){
        if(i % 2 == 0){
            ans += l[i];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <cmath>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;



lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,w,x,y,z;

string s;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;
    cin >> s;

    if(s == "SUN")
    {
        a = 7;
    }
    else     if(s == "MON")
    {
        a = 6;
    }
    else     if(s == "TUE")
    {
        a = 5;
    }
    else     if(s == "WED")
    {
        a = 4;
    }
    else     if(s == "THU")
    {
        a = 3;
    }
    else     if(s == "FRI")
    {
        a = 2;
    }
    else     if(s == "SAT")
    {
        a = 1;
    } 


    cout <<  a    << endl;


//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int maxn=1e5+5;
char a[maxn],b[maxn];
int n;

int get()
{
	for(int i=1;i<n;i++)
	{
		if(i<n-2)
		{
			if(a[i]=='o')
			{
				if(b[i]=='S')
				    b[i+1]=b[i-1];
				else
				{
					if(b[i-1]=='S')
					    b[i+1]='W';
					else
					    b[i+1]='S';
			    }
			}
			else
			{
				if(b[i]=='W')
				    b[i+1]=b[i-1];
				else
				{
					if(b[i-1]=='S')
					    b[i+1]='W';
					else
					    b[i+1]='S';
			    }
			}
		}
		    else if(i==n-2)
			{
				if(a[i]=='o')
				{
					if(b[i]=='W'){
					    if(b[i-1]==b[i+1])
					        return 0;
					    }
					else{
						if(b[i-1]!=b[i+1])
						    return 0;
					}
				}
				else
				{
					if(b[i]=='W'){
					    if(b[i-1]!=b[i+1])
					        return 0;
					    }
					else{
						if(b[i-1]==b[i+1])
						    return 0;
					}
				}
			}
			else
			{
				if(a[i]=='o')
				{
					if(b[i]=='S')
					{
						if(b[i-1]!=b[0])
						    return 0;
					}
					else
					{
						if(b[i-1]==b[0])
						    return 0;
					}
				}
				else
				{
					if(b[i]=='S')
					{
						if(b[i-1]==b[0])
						    return 0;
					}
					else
					{
						if(b[i-1]!=b[0])
						    return 0;
					}
				}
			}
		}
	return 1;
}

int main()
{
	int flag;
	scanf("%d",&n);
	scanf("%s",a);
	if(a[0]=='o')
	{
		memset(b,0,sizeof(b));
		b[0]='S';
		b[n-1]='S'; 
		b[1]='S';
		flag=get();
		if(flag)
		{
			printf("%s\n",b);
			return 0;
		 } 
		else
		{
			memset(b,0,sizeof(b));
			b[0]='W';
			b[n-1]='S';
			b[1]='W';
			flag=get();
			if(flag)
			{
				printf("%s\n",b);
				return 0;
			 } 
		}
	}
	else
	{
		memset(b,0,sizeof(b));
		b[0]='S';
		b[n-1]='S'; 
		b[1]='W';
		flag=get();
		if(flag)
		{
			printf("%s\n",b);
			return 0;
		 } 
		else
		{
			memset(b,0,sizeof(b));
			b[0]='W';
			b[n-1]='W';
			b[1]='W';
			flag=get();
			if(flag)
			{
				printf("%s\n",b);
				return 0;
			 } 
		}
	}
	if(a[0]=='o')
	{
		memset(b,0,sizeof(b));
		b[0]='S';
		b[n-1]='W'; 
		b[1]='W';
		flag=get();
		if(flag)
		{
			printf("%s\n",b);
			return 0;
		 } 
		else
		{
			memset(b,0,sizeof(b));
			b[0]='W';
			b[n-1]='W';
			b[1]='S';
			flag=get();
			if(flag)
			{
				printf("%s\n",b);
				return 0;
			 } 
		}
	}
	else
	{
		memset(b,0,sizeof(b));
		b[0]='S';
		b[n-1]='W'; 
		b[1]='S';
		flag=get();
		if(flag)
		{
			printf("%s\n",b);
			return 0;
		 } 
		else
		{
			memset(b,0,sizeof(b));
			b[0]='W';
			b[n-1]='S';
			b[1]='S';
			flag=get();
			if(flag)
			{
				printf("%s\n",b);
				return 0;
			 } 
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[100005];
int q[200005];
int dp[100005];
int head,tail;
int main(){
	memset(dp,0x3f3f3f3f,sizeof(dp));
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	head=tail=1;
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
		for(int j=max(1,i-k);j<i;j++)
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
	printf("%d\n",dp[n]);
	return 0; 
}  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define INF 1e9 + 5
#define in scanf
using namespace std;
 
int main() {
	// your code goes here
		int n;
		cin >> n;
		vector<int> a(n), d(n,INF);
		for(int& x : a){
			in("%d",&x);
		}
		d[0] = 0;
		for(int i = 0;i < n;++i)
		for(int j :{i + 1, i + 2}){
			if(j<n){
				d[j]  = min(d[i] + abs(a[i]-a[j]) , d[j]);
			}
		}
		cout << d[n-1] << endl;
	return 0;
}

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

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

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

    ll ans=0;
    rep(i,N){
        ans+=a[3*N-2-2*i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2560