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

using namespace std;
typedef long long ll;
const int N = 2e5 + 10;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }
ll lcm(int a, int b) { return 1LL*a / gcd(a, b)*b; }

int main() {
	int a, b; cin >> a >> b;
	cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
import sys

P=str(input()).upper()#大文字小文字を区別しないので大文字で考える
line=[]

#文章を一文にまとめる
while True:
    tmp_line = str(input())
    if tmp_line == 'END_OF_TEXT':
        break
    line += tmp_line.upper().split()

ans = 0

for tmp_word in line:
    if tmp_word == P:
        ans += 1

print("%d"%(ans))



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

int main() {
  int N, cnte = 0, cnto = 0;
  cin >> N;
  if (N == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }
  if (N == 4) {
    cout << "2 5 20 63" << endl;
    return 0;
  }
  if (N == 5) {
    cout << "2 4 6 3 9" << endl;
    return 0;
  }

  vector<int> ans;
  set<int> se, so;
  for (int n = 2; cnte + cnto < N; n++) {
    if (n % 2 == 0) {
      ans.push_back(n);
      se.insert(n);
      cnte++;
    }
    if (n % 2 == 1 && n % 3 == 0) {
      ans.push_back(n);
      so.insert(n);
      cnto++;
    }
  }

  if (cnto % 2 == 1) {
    for (int i = N - 1; i >= 0; i--) {
      if (ans[i] % 2 == 1) {
        int tmp = ans[i] + 1;
        while (se.find(tmp) != se.end()) tmp += 2;
        ans[i] = tmp;
        se.insert(tmp);
        cnte += tmp / 2;
        break;
      }
    }
  }

  if (cnte % 3 == 1) {
    for (int i = N - 1; i >= 0; i--) {
      if (ans[i] % 2 == 0) {
        int tmp = ans[i] + 4;
        while (se.find(tmp) != se.end()) tmp += 6;
        ans[i] = tmp;
        break;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,d,a;
    cin>>n>>d>>a;

    vector<pair<long long, long long> > inp(n);

    vector<long long> cum(n + 5);

    for(int i = 0; i < n; i++) {
        cin>>inp[i].first>>inp[i].second;
    }

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

    ll cnt = 0;

    for(int i = 0; i < n; i++) {

        if(inp[i].second <= 0) {
            i++;
            if(i < n) {
                cum[i] = cum[i] + cum[i-1];
                inp[i].second -= cum[i]*a;
            }
            i--;
            continue;
        }

        ll extra = (inp[i].second + a - 1) / a;
        cnt = cnt + extra;

        ll next = inp[i].first + 2*d;

        int idx = (int)(upper_bound(inp.begin(), inp.end(), make_pair(next, 1ll<<60)) - inp.begin());
        cum[i] += extra;
        cum[idx] -= extra;

        i++;
        while(i < n && inp[i].first <= next) {

            cum[i] = cum[i] + cum[i-1];

            inp[i].second -= cum[i]*a;
            if(inp[i].second <= 0) i++;
            else break;
        }

        if(i < n && inp[i].first > next) {
            cum[i] = cum[i] + cum[i-1];
            inp[i].second -= cum[i]*a;
        }

        i--;

    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 4992
import sys
range = xrange
input = raw_input

class segtree:
    def __init__(self, n):
        m = 1
        while m < n:
            m *= 2
        self.m = m
        self.data = [0]*(m + m)
    def add(self, i, x):
        i += self.m
        while i:
            self.data[i] += x
            i >>= 1

    def summer(self, l ,r):
        l += self.m
        r += self.m
        while l < r:
            if l & 1:
                if self.data[l]:
                    return True
                l += 1
            if r & 1:
                r -= 1
                if self.data[r]:
                    return True
            l >>= 1
            r >>= 1
        return False

orda = ord('a')

inp = sys.stdin.read().split(); ii = 0

n = int(inp[ii]); ii += 1
S = [ord(c) - orda for c in inp[ii]]; ii += 1

segs = [segtree(n) for _ in range(26)]
for i in range(n):
    segs[S[i]].add(i, 1)

q = int(inp[ii]); ii += 1
out = []
for _ in range(q):
    case = int(inp[ii]); ii += 1

    if case == 1:
        i = int(inp[ii]) - 1; ii += 1
        c = ord(inp[ii]) - orda; ii += 1

        segs[S[i]].add(i, -1)
        S[i] = c
        segs[S[i]].add(i, 1)
    else:
        l = int(inp[ii]) - 1; ii += 1
        r = int(inp[ii]); ii += 1
        out.append(sum(seg.summer(l,r) for seg in segs))
print '\n'.join(str(x) for x in out)


Measured memory_bytes: 259248
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
struct restraunt {
  string name;
  int id;
  int score;
  bool operator<(const restraunt& right) const {
    return name == right.name ? score > right.score : name < right.name;
  }
};

int main() {
  int N;
  cin >> N;
  vector<restraunt> A(N);
  for (int i = 1; i <= N; i++) {
    cin >> A[i - 1].name >> A[i - 1].score;
    A[i - 1].id = i;
  }
  sort(A.begin(), A.end());
  /*for (int i = 0; i < N; i++) {
    int previd = i;
    int endid = i;
    while (A[previd].name == A[endid].name) {
      endid++;
    }
    for (int j = endid; previd <= j; j--) {
      cout << A[j].score << endl;
    }
    i = endid;
  }*/
  REP(i, N) { cout << A[i].id << endl; }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <limits.h>
#define INIT_H 10000
using namespace std;
struct Data
{
	Data(int i, int h) :index(i), height(h){}
	int index;
	int height;
};
struct DataComp
{
	bool operator()(const Data& d1, const Data& d2){
		if( d1.height == d2.height )
			return (d1.index > d2.index);
		return (d1.height < d2.height);
	}
};

int main(){
	int H[20001] = {};
	int T[20001] = {};
	int i = 0, j, s, b, h = INIT_H;
	priority_queue<Data, vector<Data>, DataComp> pq;
	pq.push(Data(0, INIT_H));
	H[0] = INIT_H;

	char c, p = 0;
	while(cin.get(c)){
		if( c == '\n'){
			b = i;
			pq.push(Data(b, h));
			break;
		}
		if (0 != p && c != p)
			pq.push(Data(i, h));
		++i;
		if( c == '/' ) ++h;
		else if( c == '\\' ) --h;
		H[i] = h;		
		p = c;
	}

	s = pq.size();
	if( 0 == s ){
		cout << 0 << "\n" << 0 << "\n";
		return 0;
	}

	Data d = pq.top();
	pq.pop();
	T[d.index] = H[d.index];

	int i_min = d.index,
		i_max = d.index;

	while(!pq.empty())
	{
		Data d = pq.top();
		pq.pop();
		if(T[d.index] == 0){
			h = H[d.index];
			T[d.index] = h;
			if( d.index < i_min ){
				i = d.index + 1;
				while( (H[i] <= h) && (T[i] == 0) && ( i <= i_max )) {
					T[i] = h;
					++i;
				}
				i_min = d.index;
			}else if( d.index > i_max ){
				i = d.index - 1;
				while ((H[i] <= h) && (T[i] == 0) && (i >= i_min)){
					T[i] = h;
					if (H[i] == h) break;
					--i;
				}
				i_max = d.index;
			}
		}
	}

	int A = 0;
	int t = -1;
	vector<int> v(s, 0);
	for(i = 1; i <= b; ++i){
		if( T[i] == 0 || T[i-1] == 0 )
			continue;
		if( T[i-1] == H[i-1] && T[i] > H[i] )
			++t;
		if(-1 == t)
			continue;
		v[t] += (T[i] - H[i]) + (T[i-1] - H[i-1]);
	}

	for(i = 0; i <= t; ++i)
		A += v[i];
	++t;

	cout << A / 2 << "\n" << t;
	for(i = 0; i < t; ++i)
		cout << " " << v[i] / 2;
	cout << "\n";

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <map>
#include <stack>

using namespace std;

struct Area {
    int ulx, uly, lrx, lry;
    Area(int ulx=0, int uly=0, int lrx=0, int lry=0)
        : ulx(ulx), uly(uly), lrx(lrx), lry(lry) {}
    bool contains(int x, int y) const {
//        cout << x << ',' << y << endl;
        return (ulx <= x && x <= lrx && uly <= y && y <= lry);
    }
};

enum Type {
    START,
    END,
    AREA,
};

struct Token {
    Type type;
    string tagName;
    Area area;
};

string input;
int index;

int getInt() {
    while (!isdigit(input[index])) index++;
    int n = 0;
    while (isdigit(input[index])) {
        n = n * 10 + input[index] - '0';
        index++;
    }
    return n;
}

Token nextToken() {
    string buf;
    Token t;
    if (input[index] == '<') {
        index++;
        if (input[index] == '/') {
            t.type = END;
            index++;
        } else {
            t.type = START;
        }
        while (input[index] != '>') {
            buf.push_back(input[index]);
            index++;
        }
        index++; // ignore '>'
        t.tagName = buf;
    } else {
        t.type = AREA;
        t.area.ulx = getInt();
        t.area.uly = getInt();
        t.area.lrx = getInt();
        t.area.lry = getInt();
    }
    return t;
}

map<string, Area> areaTable;
map<string, vector<string> > children;
void parse() {
    Token t;
    stack<string> st;
    string cur;
    while (index < input.size()) {
        t = nextToken();
        if (t.type == START) {
            cur = t.tagName;
            if (!st.empty()) {
                children[st.top()].push_back(cur);
            }
            st.push(cur);
        } else if (t.type == END) {
            st.pop();
            if (!st.empty()) cur = st.top();
        } else {
            areaTable[cur] = t.area;
        }
    }
}

int main() {
    int n;
    while (cin >> n, n) {
        cin >> input;
        input = "<OUT OF MAIN PANEL>0,0,10000,10000" + input + "</OUT OF MAIN PANEL>";
        index = 0;
        areaTable.clear();
        children.clear();
        parse();
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            int cnt = (1<<28);

            for (map<string, Area>::iterator it = areaTable.begin();
                    it != areaTable.end(); it++) {
                if (it->second.contains(x, y)) {
                    bool top = true;
                    for (int i = 0; i < children[it->first].size(); i++) {
                        if (areaTable[children[it->first][i]].contains(x, y)) {
                            top = false;
                            break;
                        }
                    }
                    if (top) {
                        cout << it->first << ' ' << children[it->first].size() << endl;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}

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

using namespace std;

int n;
int f[11111];

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	f[0] = 1;
	for(int i = 1; i <= n; ++i){
		int x;
		scanf("%d",&x);
		for(int j = 9900; j >= 0; --j){
			f[j + x] |= f[j];
		}
	}
	for(int i = 10000; i > 0; --i) if (i % 10 && f[i]){
		printf("%d",i);
		return 0;
	}
	printf("0");
	return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [(A[i], i) for i in range(N)]
    B.sort(reverse = True)

    DP = [[-1 for j in range(N + 1)] for _ in range(N)] #i番目の幼児まで見た時、左からi番目まで埋まっている時の最大値
    DP[0][0] = B[0][0] * abs(B[0][1] - (N - 1))
    DP[0][1] = B[0][0] * B[0][1]

    for i in range(1, N):
        for j in range(i + 1):
            #右に詰める時はjの値は変わらない
            #左に詰めるときはj += 1
            DP[i][j] = max(DP[i][j], DP[i-1][j] + B[i][0] * abs(B[i][1] - (N - 1 - i + j)))
            DP[i][j+1] = max(DP[i][j+1], DP[i-1][j] + B[i][0] * abs(B[i][1] - j))
    print(max(DP[N-1]))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 107152
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, c = LI()
D = LIR(c)
C = LIR(n)
#　mod_color[mod3][color]
mod_color = [[0] * c for _ in range(3)]
for y in range(n):
    for x in range(n):
        mod_color[(y + x + 2) % 3][C[y][x] - 1] += 1


# 30 * 29 * 28
ans = INF
# もともとmod0のところをiに、mod1のところをjに、mod2のところをkにする。
for i, j, k in permutations(range(c), 3):
    ret = 0
    for l in range(3):
        for m in range(c):
            if l == 0:
                ret += mod_color[l][m] * D[m][i]
            elif l == 1:
                ret += mod_color[l][m] * D[m][j]
            else:
                ret += mod_color[l][m] * D[m][k]
    ans = min(ans, ret)


print(ans)



Measured memory_bytes: 47708
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

vector<ll> Ni, Pi;

ll f(ll N, ll X){
    if(N==0) return X<=0?0:1;
    else if(Ni[N] == X) return Pi[N];
    else if(Ni[N-1]+2 == X) return Pi[N-1] + 1;
    else if(Ni[N-1]+2 < X) return Pi[N-1] + 1 + f(N-1, X - Ni[N-1] - 2);
    else if(Ni[N-1]+2 > X) return f(N-1, X-1);
}

int main(void)
{
    ll N,X;
    cin >> N >> X;
    Ni.assign(N+1,1);
    Pi.assign(N+1,1);
    REP(i, N){
        Ni[i+1] = 2*Ni[i] + 3;
        Pi[i+1] = 2*Pi[i] + 1;
    }
    pr(f(N,X));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";

signed main()
{
	//freopen("input.txt", "r", stdin);
	
	int n; cin>>n;
	int a[n], b[n], c[n-1];
	for(int &i : a) cin>>i;
	for(int &i : b) cin>>i;
	for(int &i : c) cin>>i;
	int ans = 0;
	int p = -2;
	
	for(int i=0; i<n; i++)
	{
		ans += b[a[i] - 1];
		if(i>0) if(a[i] == a[i-1] + 1) ans += c[a[i-1] - 1];
		p = a[i];
	}
	cout<<ans<<"\n";
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    vector<ll> A(3); rep(i, 3){cin >> A.at(i);}
    sort(A.begin(), A.end());
    cout << A.at(2) - A.at(0) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3652
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 110728
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll a,b,c,d,e;
  cin >> a>>b>>c>>d>>e;
  
  ll ans;
  if(min(min(8*a,4*b),min(2*c,d))==8*a) ans=4*a*e;
  else if(min(min(8*a,4*b),min(2*c,d))==4*b) ans=2*b*e;
  else if(min(min(8*a,4*b),min(2*c,d))==2*c) ans=c*e;
  else if(e%2==0) ans=(e/2)*d;
  else if(min(min(4*a,2*b),c)==4*a) ans=(e/2)*d+4*a;
  else if(min(min(4*a,2*b),c)==2*b) ans=(e/2)*d+2*b;    
  else if(min(min(4*a,2*b),c)==c) ans=(e/2)*d+c;  
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

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

Measured memory_bytes: 21844
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1){
        cout<<"No"<<endl;
    }
    else{
        auto tmp =s.substr(0,n/2);
        if(tmp+tmp==s)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int x;
		int i = 0;

		while(true){
			x = scan.nextInt();
			if(x == 0){
				break;
			}else{
				System.out.println("Case " + (i + 1) + ": " + x);
				i++;
			}
		}
	}
}

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

const int Max = 105;
const int INF = (1<<29);
int n, G[Max][Max], Min;
set<int> T;
set<int> V;

void Pime0(int u)
{
    T.insert(u);
    V.erase(u);
    set<int>::iterator i, j;
    while(T.size()<n)
    {
        int minv = INF;
        int index = -1;
        for(i=T.begin(); i!=T.end(); i++)
        {
            for(j=V.begin(); j!=V.end(); j++)
            {
                if(G[*i][*j]!=INF && minv>G[*i][*j])
                {
                    minv = G[*i][*j];
                    index = *j;
                }
            }
        }
        T.insert(index);
        V.erase(index);
        Min += minv;
    }
}
int main()
{
    cin >> n;
    Min = 0;
    for(int i=0; i<n; i++)
    {
        V.insert(i);
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin >> G[i][j];
            if(G[i][j]==-1)
                G[i][j] = INF;
        }
    }
    Pime0(0);
    cout << Min << endl;
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
using ll = long long;
ll mod = 1000000007;
ll power(ll base, ll x)
{
  if (x == 0)
  {
    return 1;
  }
  else
  {
    ll a = power(base, x / 2);
    a = a * a % mod;
    if (x % 2 == 1)
      a *= base;
    return a % mod;
  }
}
ll fact(ll a)
{
  if (a == 0)
    return 1;
  else
    return a * fact(a - 1) % mod;
}
ll fact(ll a, ll until)
{
  if (a == until)
    return 1;
  else
    return a * fact(a - 1, until) % mod;
}
ll inv(ll a)
{
  return power(a, mod - 2);
}
ll combi(ll n, ll a)
{
  return fact(n, n - a) * inv(fact(a)) % mod;
}
int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  // cout << power(2, 3) << endl;
  // cout << power(3, 3) << endl;
  // cout << power(3, 4) << endl;
  // cout << fact(1) << endl;
  // cout << fact(2) << endl;
  // cout << fact(3) << endl;
  // cout << fact(4, 2) << endl;
  // cout << fact(4, 3) << endl;
  // cout << fact(5, 3) << endl;
  ll ans = power(2, n) - combi(n, a) - combi(n, b)-1;
  ans = (ans + mod + mod) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf = 1e9;
typedef pair<ll,mp> mmp;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

vector<ll> bfs(vector<vector<bool> > used,vector<mp> go,int s){
	int n = go.size();
    	vector<ll> res(n,inf);
	int h = used.size();
	int w = used[0].size();
	vector<vector<ll> > cost(h,vector<ll>(w,inf) );
	queue<mmp> q;
	q.push( mmp(0,mp(go[s].first,go[s].second ) ) );
	while(!q.empty() ){
	    mmp now = q.front();
	    q.pop();
	    ll c = now.first;
	    //cout<<c<<endl;
	    ll x = now.second.first;
	    ll y = now.second.second;
	    if(!used[x][y] )continue;
	    used[x][y] = false;
	    cost[x][y] = min(cost[x][y],c);
	    for(int i=0;i<4;i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(!used[nx][ny] ) continue;
		q.push( mmp( c + 1,mp(nx,ny) ) );
	    }
	}
	for(int i=0;i<n;i++) res[i] = min(res[i], cost[ go[i].first ][ go[i].second ] );
	return res;
}

int main(){
    while(1){
	int w,h;
	cin>>w>>h;
	if(w==0)break;
	vector<vector<bool> > used(h+2,vector<bool>(w+2,false) );
	int s;
	vector<mp> go;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			char tmp ;
			cin>>tmp;
			if(tmp=='o'){
				s = go.size();
				go.push_back(mp(i,j) );
				used[i][j] = true;
			}else if(tmp=='*'){
				go.push_back(mp(i,j) );
				used[i][j] = true;
			}else if(tmp=='.'){
				used[i][j] = true;
			}
		}
	}
	swap(go[0],go[s]);//
	s = 0;
	int n = go.size();
	if(n >11){
		cout<<"error"<<endl;
		return 1;
	}	
	vector<vector<ll> > g(n);
	for(int i=0;i<n;i++) g[i] = bfs ( used, go ,i);
	//cout<< "OK"<<endl;
	/*for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout<<g[i][j]<<' ';
		}
		cout<<endl;
	}*/
	vector<vector<ll> > dp( (1<<n),vector<ll>(n,inf) ); // [bit][i] bit 1のとき未訪問, 0 のとき訪問済み i は最後に来た場所
	dp[(1<<n)-1][0] = 0;
	for(int i= (1<<n)-1;i>=0;i--){//TSP
		for(int j = 0;j<n;j++)
		    for(int k=0;k<n;k++)
			if( !( (i>>k) & 1 ) )dp[i][j] = min(dp[i][j] , dp[ i | (1<<k) ][k] + g[j][k] ) ;  
	}
	ll m  = inf ;
	for(int i=0;i<n;i++){
		m = min( m, dp[1<<i][i] );
	}
	//for(int i=0;i<n;i++)for(int j=0;j<n;j++) m = min( m , res[ (1<<n)-1][i][j] );
	if( m == inf){
		cout<<-1<<endl;
	}else{
		cout<<m<<endl;
	}
    }
	return 0;
}



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

int main() {
    int N;
    int d[100100];  // 最大 100 個ですが余裕をもたせます
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];
  
	sort(d, d+N);
    
    cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a=a%b;
    c=c%b;
    for(int i=1;i<=b;i++){
        if((a*i)%b==c){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 128
import sys
import io
import math
import re

datalist = input().split()
data_a = int(datalist[0])
datalist = input().split()
datalist = input().split()
datalist = input().split()
datalist = input().split()
data_b = int(datalist[0])
datalist = input().split()
data_c = int(datalist[0])

if data_b -data_a <= data_c:
  print('Yay!')
else:
  print(':(')

Measured memory_bytes: 3188
N, M = gets.split.map(&:to_i)
X = (1..N).map { gets.split.map(&:to_i) }

def max_positive(xs)
  xs.map {|x, y, z| x+y+z }.sort.reverse.take(M).inject(0, &:+)
end

puts (
  (
    [-1, 1].product([-1, 1], [-1, 1]).map do |s|
      xs = X.map do |x|
        (0...3).map {|i| s[i]*x[i] }
      end

      max_positive(xs)
    end
  ).max
)



Measured memory_bytes: 2296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[i+1])
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    map<int, int> M;
    for (int i = 0; i < N; i++) {
        int A; cin >> A; M[A]++;
    }
    vector<int> B;
    for (auto &p : M) B.push_back(p.second);
    sort(begin(B), end(B));
    vector<int> C(N + 1);
    int j = B.size() - 1;
    int sum = N;
    for (int i = N; i > 0; i--) {
        while (j >= 0 && B[j] > i) j--;
        sum -= (B.size() - 1) - j;
        C[i] = sum / i;
    }
    j = N;
    for (int i = 1; i <= N; i++) {
        while (j > 0 && C[j] < i) j--;
        cout << j << '\n';
    }
    return 0;
}

Measured memory_bytes: 16752
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;



vector<int>a;


bool isOK(int index, int key) {
	if (a[index] > key)return true;//ここの配列名を適宜変えよう！
	else return false;
}


int binary_search(int key,int up) {

	int left = up, right = (int)a.size() - 1;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key))right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	CST(10);
	
	double a, b,x;
	cin >> a >> b >>x;
	double y = a * a*b;
	double k;
	if (x * 2 >= y) {
		k = 2.0 * (y - x) / (a * a);
		double s = atan(a / k)*180.0/pi;
		cout << 90.0 -s << endl;
	}
	else {
		k = 2.0*x / (a*b);
		double s = atan(b / k)*180.0 / pi;
		cout << s << endl;
	}
	

	return 0;
}


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

int main(){
  int n;
  cin >>n;
  vector<int> l(n);
  int sum = 0;
  rep(i,n) {
    cin >>l[i];
    sum += l[i];
  }
  sort(l.begin(),l.end(),greater<int>());
  sum -= l[0];
  if(l[0]<sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
 
int main() {
  int a, b;
  a = (getchar()-'0') * 10;
  a += (getchar()-'0');
  b = (getchar()-'0') * 10;
  b += (getchar()-'0');
  bool ayy = a >= 1 && a <= 12;
  bool byy = b >= 1 && b <= 12;
  if(ayy && !byy) printf("MMYY");
  else if(!ayy && byy) printf("YYMM");
  else if(ayy && byy) printf("AMBIGUOUS");
  else printf("NA");
}

Measured memory_bytes: 256
/* Wall */

#include <bits/stdc++.h>

using namespace std;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);

    int c[10][10];
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            scanf("%d", &c[i][j]);
        }
    }

    int a[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            scanf("%d", &a[i][j]);
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int cost = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] != -1) {
                cost += c[a[i][j]][1];
            }
        }
    }
    printf("%d\n", cost);

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n,i;
  cin>>n;
  vector<long long int> num(n);
  for(i=0;i<n;i++){
    cin>>num[i];
  }
  long long int maxi = INT_MIN;
  for(i=0;i<n;i++){
    if(num[i]>maxi){
      maxi = num[i];
    }
    else{
      if(maxi - num[i]>=2){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

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

    if (n > m / 2){
        cout << (m / 2) << endl;
    }
    else{
        cout << n + (m - 2 * n) / 4 << endl;
    }
}

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

typedef enum {
  WHITE,
  GRAY,
  BLACK,
} color_t;
#define MINIMUM_SPANNING_TREE_GRAPH_SIZE 100

static color_t colors[MINIMUM_SPANNING_TREE_GRAPH_SIZE];
static int32_t minimum_costs[MINIMUM_SPANNING_TREE_GRAPH_SIZE];

bool minimum_spannig_tree(int32_t graph[][MINIMUM_SPANNING_TREE_GRAPH_SIZE], size_t size, size_t *weight)
{
  if (graph == NULL) {
    *weight = 0;
    return false;
  }

  uint32_t i;
  for (i = 0; i < size; i++) {
    colors[i] = WHITE;
    minimum_costs[i] = INT32_MAX;
  }

  minimum_costs[0] = 0;
  *weight = 0;

  while (true) {
    int32_t mincost = INT32_MAX;
    uint32_t minimum_vertex;
    for (i = 0; i < size; i++) {
      if ((colors[i] != BLACK) && (minimum_costs[i] < mincost)) {
        mincost = minimum_costs[i];
        minimum_vertex = i;
      }
    }

    if (mincost == INT32_MAX) break;
    *weight += mincost;
    colors[minimum_vertex] = BLACK;

    for (i = 0; i < size; i++) {
      if ((colors[i] != BLACK) && (graph[minimum_vertex][i] < INT32_MAX)) {
        if (graph[minimum_vertex][i] < minimum_costs[i]) {
          minimum_costs[i] = graph[minimum_vertex][i];
          colors[i] = GRAY;
        }
      }
    }
  }

  return true;
}

#if !defined(TEST)
int32_t graph[MINIMUM_SPANNING_TREE_GRAPH_SIZE][MINIMUM_SPANNING_TREE_GRAPH_SIZE];

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  uint32_t i;
  for (i = 0; i < num; i++) {
    uint32_t j;
    for (j = 0; j < num; j++) {
      int32_t d;
      scanf("%d", &d);
      graph[i][j] = (d == -1) ? INT32_MAX : d;
    }
  }

  size_t weight;
  minimum_spannig_tree(graph, num, &weight);
  printf("%lu\n", weight);

  return 0;
}
#endif

Measured memory_bytes: 640
import Control.Monad
import Data.List

main = do
  [n,m] <- fmap (map read . words) getLine
  mat <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
  let newMat = solve3 mat

  putStr . output $ newMat

solve3 mat = newMat ++ [newLine]
  where
    newMat = map sumAdd mat
    newLine = map sum $ transpose newMat
    -- newLineSum = sum newLine

sumAdd list = list ++ [s]
  where
    s = sum list

output mat = unlines . map unwords . map (map show) $ mat



Measured memory_bytes: 6524
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let d: usize = read();
    let x: usize = read();
    let mut aseq = vec![0 as usize; n];
    for i in 0..n {
        aseq[i] = read();
    }
    let mut sum = 0;
    for day in 0..d {
        for i in 0..n {
            if day % aseq[i] != 0 { continue; }
            sum += 1;
        }
    }
    println!("{}", x + sum);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL MOD = 998244353;
const int MAXN = 123456;
int cnt[MAXN];
int a[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    if (a[0] || cnt[0] > 1) return !printf("0\n");
    LL ans = 1;
    for (int i = 1; i < N; i++) {
        if (cnt[i] && !cnt[i - 1]) return !printf("0\n");
        for (int j = 0; j < cnt[i]; j++) {
            ans = (ans * cnt[i - 1]) % MOD;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    bool card[52];
    for(int i=0;i<52;i++) card[i]=false;

    map<char,int> mark2num;
    mark2num['S']=0;
    mark2num['H']=13;
    mark2num['C']=26;
    mark2num['D']=39;
    char num2mark[4]={'S','H','C','D'};
    
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        char mark;
        int rank;
        cin >> mark >> rank;
        rank=mark2num[mark]+rank-1;
        card[rank]=true;
    }

    for(int i=0;i<52;i++){
        if(!card[i]){
            cout << num2mark[i/13] << ' ' << (i%13)+1 << endl;
        }
    }
    
    return 0;
}


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

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

typedef long long ll;
const ll MOD = 998244353;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const ll NMAX=200005;
using namespace std;

ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll d = pow(a, b / 2);
    return (d * d) % MOD;
  } else {
    ll d = pow(a, b - 1);
    return (a * d) % MOD;
  }
}

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans = 0;


    ll fact[NMAX+1];
    fact[0] = 1;
    fact[1] = 1;
    for(ll i = 2; i <= NMAX; i++){
        fact[i] = fact[i-1]*i;
        fact[i] %= MOD;
    }
    ll invfact[NMAX+1];
    invfact[NMAX] = pow(fact[NMAX], MOD-2);
    invfact[0] = 1;
    for(ll i = NMAX-1; i > 0; i--){
        if(i ==0) exit(1);
        invfact[i] = invfact[i+1]*(i+1)%MOD;
    }


    for(ll i = 0; i <= k; i++){
        ll tmp = m;
        tmp = tmp * pow(m-1,n-1-i) % MOD;
        ll choose = fact[n-1]*invfact[n-1-i]%MOD;
        choose = choose*invfact[i]%MOD;
        tmp = tmp*choose %MOD;
        ans = (ans + tmp) %MOD;
    }

    cout << ans%MOD << endl;
    return 0;
}

Measured memory_bytes: 6700
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string a;
  string b;
  cin>>a;
  cin>>b;
  int count=0;
  for(int i=0;i<3;i++)
  {
    if(a[i]==b[i])
      count++;
  }
  cout<<count;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int a[7]={64,32,16,8,4,2,1},k;
int main()
{
  cin>>k;
  for(int i=0;i<7;i++)if(a[i]<=k){cout<<a[i]<<endl;return 0;}
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N % 2 == 0:
        print("%.10f" % 0.5)
    else:
        print("%.10f" % ((N+1)/(2*N)))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
   int count[4][3][10] = {{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
                           {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
                           {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
                           {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}}};
   int n,b,f,r,v;
   cin >> n;
 
   for(int i = 0; i < n; i++){
       cin >> b >> f >> r >> v;
       count[b-1][f-1][r-1] += v;
   }
   for(b = 1; b <= 4; b++){
       for(f = 1; f <= 3; f++){
           for(r = 1; r <= 10; r++){
               cout << " " << count[b-1][f-1][r-1];
           }
           cout << endl;
       }
       if(b < 4) cout << "####################" <<endl;
   }
 
}


Measured memory_bytes: 3080
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let num: u32 = read();
    match num % 10 {
        2 | 4 | 5 | 7 | 9 => println!("hon"),
        0 | 1 | 6 | 8 => println!("pon"),
        3 => println!("bon"),
        x => println!("error"),
    }
}


Measured memory_bytes: 2092
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]

t, x, y = 0, 0, 0

flag = True
for ti, xi, yi in d:
  if ti >= xi + yi:
    if (ti - t) % 2 != (abs(xi - x) + abs(yi - y)) % 2:
    	flag = False
    	break
    t = ti
    x = xi
    y = yi
    
  else:
    flag = False
    break
    
print("Yes" if flag else "No")

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

int main(){
  int n;  cin >> n;
  vector<long> a(n);

  long minus = 0, mini = 1e9+3, rui = 0;
  bool iszero = false;
  for(int i=0; i<n; i++){
    cin >> a[i];
    rui += abs(a[i]);
    mini = min(mini, abs(a[i]));
    if(a[i] == 0)  iszero = true;
    else if(a[i] < 0)  minus++;
  }

  if(iszero){
    cout << rui << endl;
    return 0;
  }else if(minus % 2){
    cout << rui - mini*2 << endl;
  }else{
    cout << rui << endl;
  }

  return 0;
}


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

int main() {
  int n; std::cin >> n;
  std::vector<std::string> a(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  // int n = 5;
  // std::vector<std::string> a{"7.5", "2.4", "17.000000001", "17", "16.000000000"};

  /* ピリオドをすべての文字列に加える */
  for (int i = 0; i < n; i++)
    if (a[i].find('.') == std::string::npos) // ピリオドの有無
      a[i].push_back('.');                   // ピリオドを末尾に加える
  
  /* key:val = (c2, c5):cnt */
  std::map<std::pair<int, int>, long long> p;

  /* aの素因数2と5の数を数える */
  for (int i = 0; i < n; i++) {
    // a[i].length() => 文字列の長さ
    // a[i].find('.') => .(ピリオド)が存在すればその位置, なければstd::string::npos

    // std::cout << a[i] << " " <<  a[i].length() - a[i].find('.') - 1 << std::endl;
    /* 小数点以下の数 */
    int d_cnt = a[i].length() - a[i].find('.') - 1;
    int c2 = -d_cnt; // 2の数を-d_cntで初期化
    int c5 = -d_cnt; // 5の数を-d_cntで初期化
    
    /* 文字を数字に変換 */
    a[i].replace(a[i].find('.'), 1, ""); // .(ピリオド)を削除 str.replace(開始位置, 長さ, 置き換え後の新たな文字列)
    long long a_ll = std::stoll(a[i].c_str()); // long longに変換
    
    /* 2の数を取得 */
    while (a_ll%2 == 0) {
      ++c2;
      a_ll /= 2;
    }
    /* 5の数を取得 */
    while (a_ll%5 == 0) {
      ++c5;
      a_ll /= 5;
    }

    /* mapに key:val = (c2, c5):数 保持 */
    p[std::pair<int, int>(c2, c5)]++; // keyが存在しない場合は0が追加される
  }

  /* チェック */
  // for (auto itr = p.begin(); itr != p.end(); ++itr)
  //   // std::cout << "(" << (*itr).first.first << ", " << (*itr).first.second << ")" 
  //   //           <<  " " << (*itr).second << std::endl;
  //   std::cout << "(" << itr->first.first << ", " << itr->first.second << ")" 
  //             <<  " " << (*itr).second << std::endl;
  
  long long cnt = 0;
  for (auto itr_1 = p.begin(); itr_1 != p.end(); ++itr_1) {
    int c2_1 = itr_1->first.first;
    int c5_1 = itr_1->first.second;
    long long cnt_1 = itr_1->second;

    if (c2_1 >= 0 && c5_1 >= 0)
      cnt += cnt_1 * (cnt_1-1)/2;

    // if (itr_1->first.first >= 0 && itr_1->first.second >= 0)
    //   cnt += itr_1->second*(itr_1->second-1)/2;

    for (auto itr_2 = std::next(itr_1, 1); itr_2 != p.end(); ++itr_2) {
    int c2_2 = itr_2->first.first;
    int c5_2 = itr_2->first.second;
    long long cnt_2 = itr_2->second;
      if (c2_1 + c2_2 >= 0 && c5_1 + c5_2 >= 0)
        cnt += cnt_1 * cnt_2;
      // if (itr_1->first.first + itr_2->first.first >= 0 && itr_1->first.second + itr_2->first.second >= 0)
      //   cnt += itr_1->second * itr_2->second;
    }

  }
  std::cout << cnt << std::endl;


  return 0;
}

Measured memory_bytes: 9496
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

/**
 * A - BBQ Easy
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i < 2*n; i++) {
			list.add(sc.nextInt());
		}
		sc.close();
		list.sort(new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o1 - o2;
			}
		});
		int x = 0;
		for (int i = 0; i < n; i++) {
			x += list.get(i*2);
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), a=scan.nextInt(),b=scan.nextInt();
		if(b>a*n){
			b=a*n;
		}
		System.out.println(b);
	}
}


Measured memory_bytes: 22868
import itertools

class UnionFind:
	def __init__(self, n):
		self.par = [-1 for i in range(n + 1)]
		self.rank = [0 for _ in range(n + 1)]

	def find(self, x):
		if self.par[x] < 0:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def same_check(self, x, y):
		return self.find(x) == self.find(y)

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.rank[x] < self.rank[y]:
			self.par[y] += self.par[x]
			self.par[x] = y
		else:
			self.par[x] += self.par[y]
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def size(self, x):
		return -self.par[self.find(x)]


n, m = list(map(int, input().split()))
bridges = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)
inconv = int(n * (n - 1) / 2)
ans = [inconv]

for x, y in reversed(bridges):
	#print(x, y, uf.same_check(x, y), uf.size(x), uf.size(y))
	if not uf.same_check(x, y):
		inconv -= uf.size(x) * uf.size(y)
		uf.unite(x, y)
	ans.append(inconv)

ans.pop(-1)
for x in reversed(ans):
	print(x)

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) {
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(a.begin(),a.end());
  int b=a[n/2];
  long long ans=0;
  for(int i=0;i<n;i++){
    a[i]-=b;
    ans+=abs(a[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  set<int> st;
  int n,a;
  cin >> n;
  REP(i,n){
      cin >> a;
      if (st.count(a)==1){
          st.erase(a);
      }else{
          st.insert(a);
      }

  }
  cout << st.size() << endl;
}


Measured memory_bytes: 4992
s = input()
count = 0
for k,i in enumerate(s):
    if k % 2 == 0:
        if i == '0':
            count += 1
    if k % 2 == 1:
        if i == '1':
            count += 1

count1 = 0
for k, i in enumerate(s):
    if k % 2 == 0:
        if i == '1':
            count1 += 1
    if k % 2 == 1:
        if i == '0':
            count1 += 1

print(min(count, count1))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,m,arr[3]={},s,c;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        arr[i]=-1;
    bool ok=1;
    while(cin>>s>>c){
        if(n!=1&&s==1&&c==0)
            ok=0;
        if(arr[s-1]!=-1&&arr[s-1]!=c)
            ok=0;
        arr[s-1]=c;
    }
    if(!ok)
        cout<<-1<<endl,exit(0);
    int ans=0;
    if(arr[0]<1&&n!=1)
        arr[0]=1;
    int a[]={1,10,100};
    for(int i=0;i<n;i++)
        if(arr[i]!=-1)
            ans+=arr[i]*a[n-1-i];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import numpy as np
data = input().split()
data = [int(d) for d in data]

t = data[2] + data[3]/60

A = data[0] * np.array([np.cos(2*np.pi*t), -np.sin(-2*np.pi*t)])
B = data[1] * np.array([np.cos(np.pi*t/6), -np.sin(-np.pi*t/6)])

d = np.sqrt(np.sum((A-B)**2))

print(d)

Measured memory_bytes: 27132