akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define x first
#define y second

using namespace std;

const string FILENAME = "input";

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		if (a[i] == a[i + 1])
		{
			ans++;
			if (i != n - 2) a[i + 1] = a[i] + a[i + 2];
		}
	}
	cout << ans << endl;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------


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

	map<string, int> mp;
	rep (i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}

	int Max = 0;
	for (auto x : mp) {
		chmax(Max, x.second);
	}

	vector<string> ans;
	for (auto x : mp) {
		if (x.second == Max) {
			ans.push_back(x.first);
		}
	}

	sort(all(ans));

	rep (i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 26868
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    double a,b,c,d,x{0},y{0};
    cin>>a>>b>>c>>d;
    while(a>0)
    {
        a-=d;
        x++;
    }
    while(c>0)
    {
        c-=b;
        y++;
    }
    //cout<<x<<endl;
    //cout<<y<<endl;
    if(x<y)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//

ll calc(ll a)
{
        ll cnt1 = (a + 1) / 2;
        ll ans = cnt1 % 2;
        if(a % 2 == 0) ans ^= a;
        return ans;
}

int main(){
        ll a,b;
        cin >> a >> b;
        ll ans = calc(b) ^ calc(a-1);
        cout << ans << endl;
        return 0;
}





























Measured memory_bytes: 256
import sys
import collections as col
input=sys.stdin.readline

def mainA():
	N,R=map(int,input().split())
	#N=input().rstrip()
	#N=int(input())
	#vA=list(map(int,input().split()))
	
	if N >= 10:
		res = R
	else:
		res = R + 100*(10-N)
	
	print(res)

def mainB():
	N,K=map(int,input().split())
	#N=input().rstrip()
	#N=int(input())
	#vA=list(map(int,input().split()))
	
	res = 0
	while N:
		N //= K
		res += 1
	
	print(res)

def mainC():
	#N,K=map(int,input().split())
	N=input().rstrip()
	#N=int(input())
	vA=list(map(int,input().split()))
	
	res = float("inf")
	for i in range(1, 101):
		t = sum((x-i)**2 for x in vA)
		res = min(res, t)
	
	print(res)


#mainA()
mainB()
#mainC()


Measured memory_bytes: 38256
import math
a, b, x = map(int, input().split())

men = x/a
ans = 0

if men >= 0.5*a*b:
    ans = math.degrees(math.atan(2*(a*b-men)/(a*a)))
else:
    ans = 90 - math.degrees(math.atan(2*men/(b*b)))

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    ll n, m; cin >> n >> m;

    if(n == 1 && m == 1){
        cout << 1;
    }
    else if(n == 1){
        cout << max(0LL, m - 2);
    }
    else if(m == 1){
        cout << max(0LL, n - 2);
    } 
    else if(n == 2 || m == 2){
        cout << 0;
    }
    else{
        cout << n*m - 2*(n+m) + 4;
    }
    

    return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int x;
    cin >> x;
    cout << x*x*x << endl;
}



Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i,n) for (int i=0; i < int(n); i++)
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num) {
	return floor(num) == num;
}

Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	IOS;
	int a,b,c;cin>>a>>b>>c;
	int left=a-b;
	if (c-left>0)cout<<c-left;
	else cout<<0;



	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
/**
 * @param {String} raw_input 入力
 */
function Main(raw_input) {
	const [line] = raw_input.split("\n");
	const [ d, t, s ] = toNumArray(line);
	
	let isYes = t * s >= d;
	console.log(isYes ? 'Yes': 'No');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

////////// ユーティリティ関数

/**
 * 文字列を数値配列
 * @param {String} str 文字列
 */
function toNumArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => parseInt(s, 10));
}

/**
 * 文字列をVigInt配列に変換する
 * @param {String} str 文字列
 */
function toBitIntArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => BigInt(s));
}

/**
 * 2次元配列を返す
 * @param {Array<String>} array 1次元の文字列配列
 * @param {String} delimitor デリミタ
 */
function toMatrix(array, delimitor = ' ') {
	const result = array.map(v => v.split(delimitor));
	return result;
}

/**
 * 合計を出す
 * @param {Array<Number>} n 数値配列
 */
function sum(n) {
	return n.reduce((a, b) => a + b);
}

Measured memory_bytes: 29672
import sys

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

sc.sort()
ans = ['0' for _ in range(n)]
if n > 1:
	ans[0] = '1'
d = {}
for i in range(m):
	if sc[i] == [1,0]:
		if n > 1:
			print(-1)
			sys.exit()
	if sc[i][0] not in d:
		d[sc[i][0]] = sc[i][1]
	else:
		if d[sc[i][0]] != sc[i][1]:
			print(-1)
			sys.exit()

for i,v in d.items():
	ans[i-1] = str(v)

print("".join(ans))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(2);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 15;
const ll bits = 63;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;



int main(){
    // FASTIO;

    ll n;
    cin>>n;

    ll ans=0;
    ll cntr=1;
    vector<ll>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i];

        if(arr[i]!=cntr){
            ans++;
        }else{
            cntr++;
        }
    }

    if(cntr==1){
        cout<<-1<<"\n";
    }else
    cout<<ans<<"\n";

    


    

}


Measured memory_bytes: 1792
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

import copy
MAX_SCORE = -float('inf')
MAX_ANS = -1
for K in range(26):
    v = 0
    ans = [0]*D
    L = [0]*26
    for i in range(1, D+1):
        max_score = -float('inf')
        max_idx = 0
        for j in range(26):
            temp = v
            temp += S[i-1][j]
            L_ = copy.copy(L)
            L_[j] = i
            for k in range(26):
                for l in range(i, min(i+K+1, D+1)):
                    temp -= C[k]*(l-L_[k])
            if temp >= max_score:
                max_score = temp
                max_idx = j
        v = max_score
        L[max_idx] = i
        ans[i-1] = max_idx+1
    if v >= MAX_SCORE:
        MAX_SCORE = v
        MAX_ANS = ans
print(*MAX_ANS, sep='\n')


Measured memory_bytes: 76604
#include <stdio.h>

int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(1)
	{
		c -= b;
		if(c<=0)
		{
			printf("Yes");
			return 0;
		}
		a -= d;
		if(a<=0)
		{
			printf("No");
			return 0;
		}
	}
}

Measured memory_bytes: 1732
// C++ 14
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>

#define ll long long
#define loop(x, start, end) for(ll x = start; x < end; x++)

using namespace std;

int n, pos;
vector<int> in, pre, post;
    

void rec(int l, int r) {
    if (l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0, pre.size());
    int i;
    loop(i, 0, n) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}


int main(void) {
    int x;
    cin >> n;
    loop(i, 0, n) {
        cin >> x;
        pre.push_back(x);
    }
    
    loop(i, 0, n) {
        cin >> x;
        in.push_back(x);
    }
    
    solve();
}


Measured memory_bytes: 3148
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    std::cin >> n;
    ll result = 0;
    for (int i = 1; i <= n; i++) {
        ll count = 0;
        if(i %2 == 0)continue;
        for (int j = 1; j <= i; j++) {
            if(i%j == 0){
                count++;
            }
        }
        if( count == 8){
            result++;
        }
        
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,i;
	int sum,j=0;
	
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		sum=j=0;
		sum=a+b;
		
		while(sum>0)
		{
			sum=sum/10;
			j++;
		}
		printf("%d\n",j);
	}
	return 0;
}

Measured memory_bytes: 600
function main(input){
    // 文字列から10進数に変換する　 スペースきたら区切ってそれぞれリストにいれる
    var A = parseInt(input.split(" ")[0], 10);
    var B = parseInt(input.split(" ")[1], 10);
    var H = parseInt(input.split(" ")[2], 10);
    var M = parseInt(input.split(" ")[3], 10);
 
	// 時針のrad　jsはモジュールや定義なしでπ使える
	rad_H = ((360/12) * H + ((360/12)/60)*M) * (Math.PI/180);
	// 分針のrad
	rad_M = (360/60)*M*(Math.PI/180);
 
	// 針間の距離
	console.log(Math.sqrt( (A*A)+(B*B)-2*A*B*Math.cos(rad_H-rad_M)) );
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29992
from itertools import permutations
from math import factorial

N,M = map(int,input().split())
ab = set([tuple(map(int,input().split())) for _ in range(M)])

l = [i+1 for i in range(N)]
P = list(permutations(l))
P = P[:factorial(N-1)]

ans = 0
for p in P:
    path = True
    for i in range(len(p)-1):
        if not ((p[i],p[i+1]) in ab or (p[i+1],p[i]) in ab):
            path = False
            break
    if path:
        ans += 1

print(ans)


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int N,M;
using Graph = vector<vector<int>>;

void bfs(Graph &G, vector<bool> &check,int x) {
  check[x] = true;
  for (int i = 1; i <= N; i++) {
    if (G[x][i] == 1) {
      if (check[i]) continue;
      bfs(G,check,i);
    }
  }
  return;
}

int main() {
  cin >> N >> M;
  Graph G(N+1, vector<int>(N+1));
  
  vector<int> a(M),b(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    G[a[i]][b[i]] = 1;
    G[b[i]][a[i]] = 1;
  }
  
  int count = 0;
  for (int i = 0; i < M; i++) {
    G[a[i]][b[i]] = 0;
    G[b[i]][a[i]] = 0;
    vector<bool> check(N+1,false);
    check[0] = true;
    
    bfs(G,check,1);
    bool can = false;
    for (int i = 1; i <= N; i++) {
      if(!check[i]) can = true;
    }
    if (can) count++;
    G[a[i]][b[i]] = 1;
    G[b[i]][a[i]] = 1;
  }
  
  cout << count << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n;
 	cin>>n;
 	vector<int> nums(n);
 	for(int i = n-1; i>=0;--i)
 	{
 	    cin>>nums[i];
 	}
 	for(int i = 0;i<n-1;++i)
 	{
 	    cout<<nums[i]<<" ";
 	}
 	cout<<nums[n-1]<<endl;
 }


Measured memory_bytes: 3048
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())
common_divisors = set(prime_factorize(a)) & set(prime_factorize(b)) | {1}
print(len(common_divisors))

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

using namespace std;

int a[123];
int main()
{
    int n,m,x,y;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    int sum;
    cin >> m;
    for(int i = 0; i < m; i++){
        sum = 0;
        int tx,ty;
        cin >> x >> y;
        tx = x;
        ty = a[x];
        a[x] = y;
        for(int j = 1; j <= n; j++)
            sum += a[j];
        cout << sum << endl;
        a[tx] = ty;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	string str; cin >> str;
	int n; cin >> n;
	while (n--){
		string tmp; cin >> tmp;
		if (tmp == "replace"){
			int a, b; string r; cin >> a >> b >> r;
			str=str.replace(a, b-a+1, r);
		}
		else if (tmp == "reverse"){
			int a, b; cin >> a >> b;
			string rev = str.substr(a, b - a + 1);
			reverse(rev.begin(), rev.end());
			str = str.replace(a, b-a+1, rev);
		}
		else if (tmp == "print"){
			int a, b; cin >> a >> b;
			cout << str.substr(a, b - a + 1) << '\n';
		}
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

struct pq2{
    bool operator()(const pair<int,int> &p1,const pair<int,int> &p2) {
        if (p1.second == p2.second) {
            return p1.first < p2.first;
        } else {
            return p1.second < p2.second;
        }
    }
};

int main(void)
{
    int n,m;
    cin >> n >> m;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> v1;
    priority_queue<pair<int,int>,vector<pair<int,int>>,pq2> v2;
    for(int i = 0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        v1.push(make_pair(a,b));
    }

    int ans = 0;
    for(int i = 1;i <= m ; i++) {
        while(!v1.empty() && v1.top().first <= i) {
            v2.push(v1.top());
            v1.pop();
        }
        if (!v2.empty()) {
            ans += v2.top().second;
            v2.pop();
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int BLACK = 1;

int n;
int M[MAX][MAX];

void prim(){
    int minv;
    int d[MAX], color[MAX];
    
    for(int i=0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    
    while(1){
        minv = INFTY;
        int u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1)break;
        color[u] = BLACK;
        for(int i=0; i<n; i++){
            if(M[u][i] != INFTY && color[i] != BLACK){
                if(d[i] > d[u]+M[u][i]){
                    d[i] = d[u]+M[u][i];
                }
            }
        }
    }
    
    for(int i=0; i<n; i++){
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] =INFTY;
        }
    }
    
    int k, c, u, v;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k ;j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    
    prim();
    
    return 0;
}



Measured memory_bytes: 3152
#include "bits/stdc++.h" 
using namespace std;

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

typedef long long unsigned int ll;
typedef pair<int, int> P;

int N, M;
int T[100];
P pt[100];

void solve(){
  int sum=0;
  rep(i, N){
    sum += T[i];
  }
  rep(i, M){
    int index = pt[i].first - 1;
    cout << sum - T[index] + pt[i].second << endl;
  }
}

int main(){
  cin >> N;
  rep(i, N){
    cin >> T[i];
  }
  cin >> M;
  rep(i, M){
    int p, x;
    cin >> p;
    cin >> x;
    pt[i] = P(p, x);
  }
  solve();
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
vector<int> G[100000];
int A[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  priority_queue<P> q;
  cin >> K;
  rep(i, N) A[i] = -INF;
  rep(i, K) {
    int v, k;
    cin >> v >> k;
    v--;
    A[v] = k;
    q.push(P(A[v], v));
  }
  while (!q.empty()) {
    int v = q.top()._2, k = q.top()._1;
    q.pop();

    for (int t : G[v]) {
      if (A[t] == k+1) continue;
      if (A[t] == -INF) {
        A[t] = k-1;
        q.push(P(A[t], t));
      }
      else if (A[t] != k-1) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  rep(i, N) {
    cout << A[i] << "\n";
  }
  return 0;
}


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

int main(){
    vector<int> a,b,c;
    int A,B,C;
    cin >> A >> B >> C;

    if(A%2==1 || B%2==1 || C%2==1){
        cout << 0 << endl;
        return 0;
    }

    if(A==B && B==C){
        cout << -1 << endl;
        return 0;
    }
    
    a.push_back(A);
    b.push_back(B);
    c.push_back(C);

    int i;
    for(i=0;;i++){
        if(a[i]%2==1 || b[i]%2==1 || c[i]%2==1){
            break;
        }

        a.push_back(b[i]/2 + c[i]/2);
        b.push_back(a[i]/2 + c[i]/2);
        c.push_back(a[i]/2+b[i]/2);
    }

    cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <math.h>
#include <stack>
#include <tuple>
#include <cstring>
#include <chrono>
#include <bitset>
#include <list>
#include <stdlib.h>
#include <iomanip>
#include <bitset>
#include <chrono>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
 
bool comparator(const pair<ll, ll> &x, const pair<ll, ll> &y)
{
    return x.second - x.first < y.second - y.first;
}
 
ll gcd(ll x, ll y)
{
    return y == 0LL ? x : gcd(y, x % y);
}
 
struct interval {
    int len;
    ll value;
};

 
int main()
{
    std::ios::sync_with_stdio(false);
 
    int n, m;
    cin >> n >> m;
    
    int no_value = -1;
    // problem, pair<last ac, all wa>
    vector< pair<int, vector<int> > > ns(n, make_pair(no_value, vector<int>()));
    int pr;
    string status;
    
    forn (i, m) {
        cin >> pr >> status;
        pr--;
        if (status == "AC") {
            if (ns[pr].first == no_value) {
                ns[pr].first = max(ns[pr].first, i);
            }
        } else {
            ns[pr].second.push_back(i);
        }
    }
    
    int ac = 0;
    int pen = 0;
    forn (i, n) {
        if (ns[i].first != -1) {
            ac++;
            
            for (int j = 0; j < ns[i].second.size() && ns[i].second[j] < ns[i].first; j++) {
                pen++;
            }
        }
    }
    
    cout << ac << ' ' << pen << endl;
    
    return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<math.h>

int main(){
  int i,n,d,c=0;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&d);
    c+=isPrime(d);
  }
  
  printf("%d\n",c);
  
  return 0;
}

int isPrime(int d){
  int i;
  if(d==2)return 1;
  if(d<2||d%2==0)return 0;
  i=3;
  while(i<=sqrt(d)){
    if(d%i==0)return 0;
    i=i+2;
  }
  return 1;
}



Measured memory_bytes: 2124
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nm = IO.RSLong;
            var abs = new List<KeyValuePair<long, long>>();
            for (int i = 0; i < nm[0]; i++)
            {
                var tmp = IO.RSLong;
                var kv = new KeyValuePair<long, long>(tmp[0], tmp[1]);
                abs.Add(kv);
            }

            abs.Sort((a, b) => (int)a.Key - (int)b.Key);
            long ans = 0;
            var n = abs[0].Value;
            abs.Reverse();
            for (int i = 0; i < nm[1]; i++)
            {
                if (n > 0)
                {
                    ans += abs[abs.Count - 1].Key;
                    n--;
                }
                else
                {
                    abs.RemoveAt(abs.Count - 1);
                    n = abs[abs.Count - 1].Value;
                    ans += abs[abs.Count - 1].Key;
                    n--;
                }
            }
            WriteLine(ans);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }
    }
}

Measured memory_bytes: 21304
program lamps
  implicit none
  integer :: n, k, i, j, l, r
  integer, dimension(200001) :: a = 0, b = 0
  read(*,*) n, k
  read(*,*) a(1:n)
  do i = 1, k
    b(1:n) = 0
    do j = 1, n
      l = max(j-a(j),1)
      r = min(j+a(j),n)+1
      b(l) = b(l)+1
      b(r) = b(r)-1
    end do
    do j = 1, n
      b(j+1) = b(j+1)+b(j)
    end do
    if (all(b(1:n) == a(1:n))) exit
    a(1:n) = b(1:n)
  end do
  write(*,'(i0)',advance='no') a(1)
  do i = 2, n
    write(*,'(x,i0)',advance='no') a(i)
  end do
  write(*,*) 
end program lamps

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

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        Tuple<string, int, int>[] tuple = new Tuple<string, int, int>[N];

        for(int i = 0; i < N; i ++)
        {
            var line = Console.ReadLine().Split(' ').ToArray();
            tuple[i] = new Tuple<string, int, int>(line[0],int.Parse(line[1]),i + 1);
        }

        var a = tuple.OrderBy(x => x.Item1).ThenByDescending(x => x.Item2);

        foreach (var t in a)
        {
            Console.WriteLine(t.Item3);
        }
    }

}

Measured memory_bytes: 11616
/**
 *   Author: praveen_ojha
 *   Created: 17 January 2019
 *   Time: 11:50:41
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
int n,a[100005],dp[100005],k;
int solve(int ind){
	if(ind==n-1){
		return 0;
	}
	if(dp[ind]!=-1)
		return dp[ind];
	int mini=INT_MAX;
	for(int i=1;i<=k;i++){
		if(ind+i<n){
		dp[ind+i]=solve(ind+i);
		mini=min(mini,dp[ind+i]+abs(a[ind]-a[ind+i]));
		}
	}
	dp[ind]=mini;
	return dp[ind];

}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    cout<<solve(0);
return 0;
}

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

int main(){
  ll A, B;
  cin >> A >> B;
  
  cout << 6 - A - B << endl;
  return 0;
}

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

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

    int pre = 0;
    for (int i = 0; i < N; i++) {
        if (pre <= H[i] - 1) {
            pre = H[i] - 1;
        } else if (pre <= H[i]) {
            pre = H[i];
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
//#include <map>
#include<string>
using namespace std;
int main() {
	int t;
	cin >> t;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while (t){
		string s;
		cin >> s;
		if (s == "AC")ac++;
		else if (s == "WA")wa++;
		else if (s == "TLE")tle++;
		else re++;
		t--;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}


Measured memory_bytes: 3624
#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.at(i);
}
int sum=0;  
vector<int> B(N);
for (int i = 0; i < N; i++) {
  cin >> B.at(i);
  sum+=B.at(i);
}
vector<int> C(N);
for (int i = 0; i < N-1; i++) {
  cin >> C.at(i);
}
for (int i = 0; i < N-1; i++) {
  if(A.at(i+1)-A.at(i)==1) sum+=C.at(A.at(i)-1);
}
  cout << sum << endl;  
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    int k,x;
    cin >> k >> x;
    for(int i = x - k + 1; i < x + k - 1; i++){
        cout << i << " ";
    }
    cout << x+k-1 <<endl;
}

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

using namespace std;
typedef pair<int,int> ii;

static vector<int> white[2005];
static vector<int> black[2005];
static int whitePos[2005];
static int blackPos[2005];
static ii arr[4005];

static int memo[2005][2005];

int dp(int w, int b){ ///first a white and first b black sorted
	if(w == 0 && b == 0) return 0;
	if(memo[w][b] != -1) return memo[w][b];
	
	int ans = 1023456789;
	if(b != 0){
		int bb = b - 1;
		int oPos = blackPos[bb];
		int bRight = bb - (lower_bound(black[bb].begin(),black[bb].end(),oPos) - black[bb].begin());
		int wRight = w - (lower_bound(white[w].begin(),white[w].end(),oPos) - white[w].begin());
		if(w == 0) wRight = 0;
		
		oPos += bRight;
		oPos += wRight;
		ans = min(ans, dp(w,bb) + oPos - w - bb);
	}
	if(w != 0){
		int ww = w - 1;
		int oPos = whitePos[ww];
		int bRight = b - (lower_bound(black[b].begin(),black[b].end(),oPos) - black[b].begin());
		int wRight = ww - (lower_bound(white[ww].begin(),white[ww].end(),oPos) - white[ww].begin());
		if(b == 0) bRight = 0;
		
		oPos += bRight;
		oPos += wRight;
		ans = min(ans, dp(ww,b) + oPos - ww - b);
	}
	//cout << w << " " << b << " " << ans << "\n";
	memo[w][b] = ans;
	return ans;
}

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	for(int i = 0;i < 2 * n;i++){
		char c;
		cin >> c;
		int x;
		cin >> x;
		x--;
		
		if(c == 'B'){
			arr[i] = ii(x,0);
			blackPos[x] = i;
			for(int j = n;j > x;j--) black[j].push_back(i);
		}
		else{
			arr[i] = ii(x,1);
			whitePos[x] = i;
			for(int j = n;j > x;j--) white[j].push_back(i);
		}
	}
	for(int i = 0;i <= n;i++){
		sort(white[i].begin(),white[i].end());
		sort(black[i].begin(),black[i].end());
	}
		
	for(int i = 0;i <= n;i++) fill(memo[i],memo[i]+(n+1),-1);
	
	cout << dp(n,n);
}


Measured memory_bytes: 40320
#include<iostream>
#include<cstring>
#include<string.h>
#include<cstdio>
using namespace std;
typedef long long ll;


int main(){
    char s[12345];
    scanf("%s", s);
    int len = strlen(s);
    ll ans = 0;
    // 2^(len-1) 回す
    for(int t = 0; t < (1<<(len-1)); t++){
        ll num = s[0] - '0';  //先頭の文字を数字に変換
        for(int i=0;i<len-1;i++){
            // i bit目が立ってた時+が入る
            // 立っていなかったら10倍して次の数字が加えられる
            if( t & (1 << i)){
                ans += num;
                num = 0;
            }
            num = num * 10 + s[i+1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int a, b;
    cin >> a >> b;
    if(a>b){
        cout << 2*a-1 << endl;
    }else if(a==b){
        cout << 2*a << endl;
    }else{
        cout << 2*b-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>

int main()
{
    int h, w;
    char s[20][20 + 1];
    std::cin >> h >> w;
    for (int i = 0; i < h; ++i)
    {
        std::cin >> s[i];
    }
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
    int max = 0;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            std::queue<std::pair<int, int>> q;
            int d[20][20];
            for (int k = 0; k < h; ++k)
            {
                for (int l = 0; l < w; ++l)
                {
                    d[k][l] = -1;
                }
            }
            if (s[i][j] == '.')
            {
                q.push(std::pair<int, int>(i, j));
                d[i][j] = 0;
                while (q.size())
                {
                    std::pair<int, int> p = q.front();
                    q.pop();
                    for (int k = 0; k < 4; ++k)
                    {
                        int x = p.first + dx[k];
                        int y = p.second + dy[k];
                        if (0 <= x && x < h && 0 <= y && y < w && d[x][y] == -1 && s[x][y] == '.')
                        {
                            q.push(std::pair<int, int>(x, y));
                            d[x][y] = d[p.first][p.second] + 1;
                        }
                    }
                }
                for (int k = 0; k < h; ++k)
                {
                    for (int l = 0; l < w; ++l)
                    {
                        if (d[k][l] > max)
                        {
                            max = d[k][l];
                        }
                    }
                }
            }
        }
    }

    std::cout << max;

    return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int>A(n,0);
    fol(i,n)cin>>A[i];
    vector<int>B=A;
    sort(A.begin(),A.end());
    int r = n/2,l=r-1;
    fol(i,n){
        if(B[i]<=A[l]) printf("%d\n",A[r]);
        else printf("%d\n",A[l]);
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define i64 unsigned long long
int main ()
{
    i64 i,j,n,t,c=1;
    cin >> n;
    if(n%2==0)
    {
        cout << n << endl;
    }
    else
    {
        cout << (n*2) << endl;
    }
//cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
L = []
for _ in range(N) :
  L.append(list(map(str, input().split())))
X = str(input())
#print (L)

sum = 0
Xt = 0
for i in range(N) :
  if Xt == 1 :
    sum += int(L[i][1])
  if L[i][0] == X :
    Xt = 1
print (sum)

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

int main() {
    string s;
    cin >> s;
    int ans = 700;
    rep(i,3) {
        if(s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}

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

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

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

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

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

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

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

// ---- ----

LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }

#define bit(b, i) (((b) >> (i)) & 1)

int n, x[1000], y[1000], t[2], d[32];

pair<int, int> f(int m, string s) {
	assert(m == s.size());
	
	auto p = MP(0, 0);
	inc(i, m) {
		if(s[i] == 'R') { p.FI += d[i]; }
		if(s[i] == 'L') { p.FI -= d[i]; }
		if(s[i] == 'U') { p.SE += d[i]; }
		if(s[i] == 'D') { p.SE -= d[i]; }
	}
	return p;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i]; }
	
	inc(i, n) { t[(x[i] + y[i]) % 2] = 1; }
	if(t[0] && t[1]) {
		cout << -1 << endl;
		return 0;
	}
	
	incII(i, 0, 30) { d[i] = 1 << (30 - i); }
	d[31] = 1;
	int m = (t[0] ? 32 : 31);
	
	cout << m << endl;
	inc(i, m) { cout << d[i] << (i == m - 1 ? "\n" : " "); }
	inc(i, n) {
		int X = y[i] + x[i];
		int Y = y[i] - x[i];
		
		int xp = 0, yp = 0, z;
		string s;
		inc(j, m) {
			z = 0;
			if(xp < X) { xp += d[j]; z |= 1; } else { xp -= d[j]; }
			if(yp < Y) { yp += d[j]; z |= 2; } else { yp -= d[j]; }
			s += "DRLU"[z];
		}
		
		cout << s << "\n";
		
		auto p = f(m, s);
		assert(p == MP(x[i], y[i]));
		// cout << "in: " << x[i] << " " << y[i] << endl;
		// cout << "ou: " << p.FI << " " << p.SE << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n;
    cin >> n;
    map<string, int> ma;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        ma[s]++;
    }
    cout << ma.size() << endl;
}

Measured memory_bytes: 19248
import math
from functools import reduce

def gcd(*numbers):
  return reduce(math.gcd, numbers)

K = int(input())
sum = 0
for a in range(1, K+1):
  for b in range(a, K+1):
    for c in range(b, K+1):
      l = len(set([a, b, c]))
      if l==1:
        num = 1
      elif l==2:
        num = 3
      elif l==3:
        num = 6
      sum += gcd(a, b, c)*num
print(sum)

Measured memory_bytes: 9628
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	int H, W;
	string a[101];
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		cin >> a[i];
	}
	int four = (H/2) * (W/2);
	int two, one;
	if(H%2 == 0 && W%2 == 1){
		two = H/2;
	}else if(H%2 == 1 && W%2 == 0){
		two = W/2;
	}else{
		two = 0;
	}
	if(H%2 == 1 && W%2 == 1){
		one = 1;
	}else{
		one = 0;
	}
	
	int letterCount[26];
	fill(letterCount, letterCount+26, 0);
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			letterCount[((int)a[i][j]-97)]++;
		}
	}
	
	int four_ = 0;
	int two_ = 0;
	int one_ = 0;
	for(int i = 0; i < 26; i++){
		four_ += letterCount[i]/4;
		two_ += (letterCount[i] % 4) /2;
		one_ += letterCount[i] % 2;
	}
	
	bool isYes = true;
	if(four_ < four){
		isYes = false;
	}
	else{
		four -= four_;
		if(two_ < four*2 + two){
			isYes = false;
		}
		else if(one_ != one){
			isYes = false;
		}
	}
	
	cout << (isYes ? "Yes" : "No") << endl;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int w[n];
  int l = 0, r = 0;
  int i;
  for (i = 0; i < n; i++) {
    cin >> w[i];
    l += w[i];
  }
  int result = 1000000;
  for (i = 0; i < n; i++) {
    result = min(result, abs(l - r));
    l -= w[i];
    r += w[i];
  }
  result = min(result, abs(l - r));
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [''] * M
P = [[] for _ in range(N)]
for i in range(M):
    pi, yi = map(int, input().split())
    P[pi-1].append((yi, i))

for j, pref in enumerate(P):
    pref = sorted(pref, key=lambda x: x[0])
    for k, (yi, i) in enumerate(pref):
        A[i] += str(j+1).zfill(6) + str(k+1).zfill(6)
        
for a in A:
    print(a)

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

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}

//経路復元なしDijkstra法
template<class T> 
vector<T> dijkstra(int start, const vector<vector<pair<int,T>>>& Hen){
	T INF = numeric_limits<T>::max();
	int N = Hen.size();
	vector<T> dist(N, INF);
	dist[start] = 0;
	priority_queue<pair<T,int>, vector<pair<T,int>>, greater<pair<T,int>>> que;
	que.push({0, start});
	while(que.size()) {
		int ver = que.top().second;
		T cost = que.top().first; que.pop();
		if(cost != dist[ver])continue;
		for(auto i : Hen[ver]) {
			if(dist[i.first] > cost + i.second) {
				dist[i.first] = cost + i.second;
				que.push({dist[i.first], i.first});
			}
		}
	}
	return dist;
}


int main()
{
    vector<tuple<double, double, double>> pos;
    {
        double xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb;
        pos.push_back({xa, ya, 0}), pos.push_back({xb, yb, 0});
    }
    int n; cin >> n;
 
    for(int i = 0; i < n; i++) {
        double x, y, r; cin >> x >> y >> r;
        pos.push_back({x, y, r});
    }
 
    vector<vector<pair<int,double>>> hen(n + 2);
    for(int i = 0; i < n + 2; i++) {
        for(int j = i + 1; j < n + 2; j++) {
            double xa, ya, ra, xb, yb, rb, dist;
            tie(xa, ya, ra) = pos[i], tie(xb, yb, rb) = pos[j];
            dist =  sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) - (ra + rb);
            dist = max(dist, 0.0);
            hen[i].push_back({j, dist});
            hen[j].push_back({i, dist});
        }
    }
 
    cout << fixed <<setprecision(12) << dijkstra(0,hen)[1] << '\n';
 
 
}

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


int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (A >= K) cout << K << endl;
    else if (A+B>=K) cout << A << endl;
    else cout << A - (K-A-B) << endl;
    
    return 0;
}

Measured memory_bytes: 3672