akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <string.h>

#define MAX_N 100

using namespace std;

char form[MAX_N];
char str[MAX_N];

int calc_form(int l, int r){ //l-r???????????????????¨????
	int former, latter;
	int count = 0;
	int i;
	if(str[l] == '0') return 0;
	if(str[l] == '1') return 1;
	if(str[l] == '2') return 2;
	if(str[l] == '-'){
		i = l;
		while(str[i] == '-') i++;
		int res = calc_form(i, r);
		if((i-l)%2 == 0){
			return res;
		}else{
			if(res == 2) return 0;
			else if(res == 1) return 1;
			else return 2;
		}
	}
	for (i = l+1; i < r; i++)
	{
		if((str[i] == '+' || str[i] == '*') && count == 0) break;
		if(str[i] == '(') count++;
		if(str[i] == ')') count--;
	}
	former = calc_form(l+1, i-1);
	latter = calc_form(i+1, r-1);
	if(str[i] == '*'){
		if(former == 2 && latter == 2) return 2;
		if(former == 0 || latter == 0) return 0;
		else return 1;
	}else if(str[i] == '+'){
		if(former == 2 || latter == 2) return 2;
		if(former == 0 && latter == 0) return 0;
		else return 1;
	}
}

int main(){
	while(1){
		cin >> form;
		if(form[0] == '.') break;
		strcpy(str, form);
		int ans = 0;
		for (int p = 0; p <= 2; p++)
		{
			for (int q = 0; q <= 2; q++)
			{
				for (int r = 0; r <= 2 ; r++)
				{
					for (int i = 0; i < strlen(str); i++)
					{
						if(str[i] == 'P') str[i] = p+'0';
						if(str[i] == 'Q') str[i] = q+'0';
						if(str[i] == 'R') str[i] = r+'0';
					}
					if(calc_form(0, strlen(str)-1) == 2) ans++;
					strcpy(str, form);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1148
N, K=(int(i) for i in input().split())
A=[int(i) for i in input().split()]
A= sorted(A)

from math import factorial

inf=10**9+7
ans=0

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


for i in range(K, N+1):
    #(N-1)C(K-1)
    ans+=(A[i-1]*cmb(i-1, K-1,p))%inf
for i in range(1, N-K+2):
    #(N-i)C(K-1)
    ans-=(A[i-1]*cmb(N-i, K-1,p))%inf
print(ans%inf)


Measured memory_bytes: 78248
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int main() {
	int s, w;
	scanf("%d%d", &s, &w);
	if (w >= s) {
		puts("unsafe");
	}
	else {
		puts("safe");
	}
	return 0;
}

Measured memory_bytes: 1660
import numpy as np
h, w = map(int, input().rstrip("\n").split())

array = np.array([[" "] * (w + 2)] + [list(" " + input().rstrip("\n") + " ") for _ in range(h)] + [[" "] * (w + 2)])

list_ = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if array[i][j] == "#":
            list_.append("#")
        else:
            list_.append(str(sum(sum(array[i - 1:i + 2, j - 1:j + 2] == "#"))))
    list_.append("\n")
list_.pop()

print("".join(list_))


Measured memory_bytes: 12460
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const ll N = 1e7 + 5;
int cnt[N];
void mark(ll x){
        cnt[x]++;
        for(ll i = 2; x*i<N; i++){
            cnt[i*x]++;
        }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    for(int i = 1; i<N; i++){
        cnt[i]++;
    }
    ll ans = 0;
    for(ll i = 2; i<=n ;i++){
        mark(i);
        ans+=(cnt[i]*i);
    }
    cout<<ans + 1;
}

Measured memory_bytes: 42708
n = int(input())
min_r = int(input())
max_val = 1 - min_r
for _ in range(n - 1):
    r = int(input())
    diff_r = r - min_r
    if diff_r >= max_val:
        max_val = diff_r
    if r <= min_r:
        min_r = r
print(max_val)



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

int N;
string alphabet;

void output(char msg, deque <char> d) {
	printf("%c ", msg);
	for (auto it : d)
		printf("%c" , it);
	puts("");
	fflush(stdout);
}

int ask(deque <char> d) {
	output('?', d);
	int dist;
	scanf("%d", &dist);
	return dist;
}

bool subsequence(deque <char> d) {
	return d.size() + ask(d) == N;		
}

void add_range(char l, char r) {
	for (char c = l; c <= r; c++)
		alphabet += c;
}

deque <char> multiple(int k, char c) {
	return deque <char> (k, c);
}

deque <char> solve(int lo, int hi) {
	if (hi - lo == 1) 
		return multiple(N - ask(multiple(N, alphabet[lo])), alphabet[lo]);
	int mid = (lo + hi) / 2;
	deque <char> lft = solve(lo, mid);
	deque <char> rig = solve(mid, hi);
	deque <char> sofar;
	while (!rig.empty()) {
		deque <char> tmp = sofar;
		tmp.push_back(rig.front());
		for (auto it : lft)
			tmp.push_back(it);
		if (lft.empty() || subsequence(tmp)) {
			sofar.push_back(rig.front());
			rig.pop_front();
		}
		else {
			sofar.push_back(lft.front());
			lft.pop_front();
		}
	}
	for (auto it : lft)
		sofar.push_back(it);
	return sofar;
}

void find_length() {
	N = 128;
	for (auto it : alphabet)
		N = min(N, ask({it}) + 1);
}

int main() {
	add_range('a', 'z');
	add_range('A', 'Z');
	add_range('0', '9');
	find_length(); 
	output('!', solve(0, alphabet.size()));
	return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>

int main(void) {
  int d,i;
  while (scanf("%d",&d) != EOF){
  int sum = 0;
  for(i = 1;d * (i+1) <= 600; i++){
    sum += (d*(d*i)*(d*i));
    }
  printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++) 
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int n,book[maxn];
int cal(int x) {
	int sum=0;
	rep(i,1,n) {
		sum+=(book[i]-x)*(book[i]-x);
	} 
	return sum;
}
int main() 
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	int ans=inf;
	rep(i,1,n) cin>>book[i];
	rep(i,1,100) ans=min(ans,cal(i));
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {

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

		ArrayList<String> array = new ArrayList<String>();

		try {
			String str = null;
			while ((str = br.readLine()) != null) {
				array.add(str);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		for(String s : array) {
			String[] data = s.split("[, .]");
			String answer = null;
			for(String word : data) {
				if(word.length() <= 6 && word.length() >= 3) {
					if(answer == null) {
						answer = word;
					} else {
						answer += " " + word;
					}
				}
			}
			System.out.println(answer);
		}
	}

}

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

int main(void){
    int ans=0,h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    h1*=60;
    h2*=60;
    h1+=m1;
    h2+=m2;
    ans = h2-h1;
    ans -= k;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
K = int(input())

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    while n % k > 0:
        n = n % k
        n = n * 10 + 7
        res += 1

    print(res)

calculate(K)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int D,N; cin >> D >> N;
    if(N!=100) cout << N;
    else cout << 101;
    REP(i,D) cout << "00";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3552
object Main {
  def main(args: Array[String]): Unit = {
    val factors = io.StdIn.readLine.split(" ").map{_.toInt}
    var str     = 0
    var count   = 0

    if( factors( 0 ) < factors( 1 ) ) {
      str   = factors( 0 )
      count = factors( 1 )
    }
    else {
      str   = factors( 1 )
      count = factors( 0 )
    }

    println( str.toString*count )
  }
}

Measured memory_bytes: 25396
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main(){
	string s;
	int a[100000];
	long long int k;
	cin >> s;
	cin >> k;
	for (int i = 0; i < s.length(); i++){
		if (s[i] == 'a'){
			a[i] = 1;
		}
		else if (s[i] == 'b'){
			a[i] = 2;
		}
		else if (s[i] == 'c'){
			a[i] = 3;
		}
		else if (s[i] == 'd'){
			a[i] = 4;
		}
		else if (s[i] == 'e'){
			a[i] = 5;
		}
		else if (s[i] == 'f'){
			a[i] = 6;
		}
		else if (s[i] == 'g'){
			a[i] = 7;
		}
		else if (s[i] == 'h'){
			a[i] = 8;
		}
		else if (s[i] == 'i'){
			a[i] = 9;
		}
		else if (s[i] == 'j'){
			a[i] = 10;
		}
		else if (s[i] == 'k'){
			a[i] = 11;
		}
		else if (s[i] == 'l'){
			a[i] = 12;
		}
		else if (s[i] == 'm'){
			a[i] = 13;
		}
		else if (s[i] == 'n'){
			a[i] = 14;
		}
		else if (s[i] == 'o'){
			a[i] = 15;
		}
		else if (s[i] == 'p'){
			a[i] = 16;
		}
		else if (s[i] == 'q'){
			a[i] = 17;
		}
		else if (s[i] == 'r'){
			a[i] = 18;
		}
		else if (s[i] == 's'){
			a[i] = 19;
		}
		else if (s[i] == 't'){
			a[i] = 20;
		}
		else if (s[i] == 'u'){
			a[i] = 21;
		}
		else if (s[i] == 'v'){
			a[i] = 22;
		}
		else if (s[i] == 'w'){
			a[i] = 23;
		}
		else if (s[i] == 'x'){
			a[i] = 24;
		}
		else if (s[i] == 'y'){
			a[i] = 25;
		}
		else if (s[i] == 'z'){
			a[i] = 26;
		}

	}
	int c = 0;
	int n = s.length();
	while (c < n){
		if (27 - a[c] <= k&&a[c]!=1){
			
			
			k -= (27 - a[c]);
			a[c] = 1;
		}
		 if (k>0 && c == (n - 1)){
			a[c] += k;
			if (a[c]>26){
				a[c] %= 26;
				if (a[c] == 0){
					a[c] = 26;
				}
			}
		 } else if(k == 0){
			 break;
		 }
		
		c++;
	}
	
	for (int i = 0; i < s.length(); i++){
		if (a[i] == 1){
			s[i] = 'a';
		}
		else if (a[i] == 2){
			s[i] = 'b';
		}
		else if (a[i] == 3){
			s[i] = 'c';
		}
		else if (a[i] == 4){
			s[i] = 'd';
		}
		else if (a[i] == 5){
			s[i] = 'e';
		}
		else if (a[i] == 6){
			s[i] = 'f';
		}
		else if (a[i] == 7){
			s[i] = 'g';
		}
		else if (a[i] == 8){
			s[i] = 'h';
		}
		else if (a[i] == 9){
			s[i] = 'i';
		}
		else if (a[i] == 10){
			s[i] = 'j';
		}
		else if (a[i] == 11){
			s[i] = 'k';
		}
		else if (a[i] == 12){
			s[i] = 'l';
		}
		else if (a[i] == 13){
			s[i] = 'm';
		}
		else if (a[i] == 14){
			s[i] = 'n';
		}
		else if (a[i] == 15){
			s[i] = 'o';
		}
		else if (a[i] == 16){
			s[i] = 'p';
		}
		else if (a[i] == 17){
			s[i] = 'q';
		}
		else if (a[i] == 18){
			s[i] = 'r';
		}
		else if (a[i] == 19){
			s[i] = 's';
		}
		else if (a[i] == 20){
			s[i] = 't';
		}
		else if (a[i] == 21){
			s[i] = 'u';
		}
		else if (a[i] == 22){
			s[i] = 'v';
		}
		else if (a[i] == 23){
			s[i] = 'w';
		}
		else if (a[i] == 24){
			s[i] = 'x';
		}
		else if (a[i] == 25){
			s[i] = 'y';
		}
		else if (a[i] == 26){
			s[i] = 'z';
		}
	}

	cout << s << endl;
	return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  unordered_map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto&& [_, c] : mp) {
    mx = max(mx, c);
  }
  vector<string> ans;
  for (auto&& [s, c] : mp) {
    if (c == mx) ans.emplace_back(s);
  }
  sort(ans.begin(), ans.end());
  for (auto&& s : ans) {
    cout << s << '\n';
  }
  return 0;
}

Measured memory_bytes: 27008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
ll mod = 1000000007;

int main(){
    ios::sync_with_stdio(false);

    ll n, x, m;
    cin >> n >> x >> m;
    vector<pair<ll,ll>> c(100005);
    vector<int> A(100005);
    ll a = x;

    ll k = 0;
    while(k < 100005){
        if(c[a].first) break;
        c[a].first++;
        c[a].second = k; //何番目か
        A[k] = a;
        a = a * a % m;
        k++;
    }


    ll ans = 0,temp = 0;
    if(n <= k) {
        rep(i,n) ans += A[i];
        cout << ans << endl;
        return 0;
    }

    for(int i = 0; i < c[a].second; ++i) ans += A[i];
    for(int i = c[a].second; i < k; ++i) temp += A[i];

    temp *= ((n-c[a].second) / (k-c[a].second));
    for(int i = c[a].second; i < c[a].second - 1 + (n-c[a].second+1) % (k-c[a].second); ++i) ans += A[i];

    cout << ans + temp << endl;

}

Measured memory_bytes: 5340
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[2][5]={0};
    long i;
    for(i=0; i<2; i++) {
        scanf("%s", str[i]);
    }
    if(str[0][0]==str[1][2] && str[0][1]==str[1][1] && str[0][2]==str[1][0]) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
 
    return 0;
}


Measured memory_bytes: 128
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final String S = sc.next();

        // final int N = sc.nextInt();
        // final int A = sc.nextInt();
        // final long B = sc.nextLong();
        // final String s = sc.next();
        // final String b = sc.next();

        // 条件
        // 1. Sは回文
        // 2. 1文字目から( N-1 )/2文字までが回文になる(N = 7の場合: 1文字目から3文字目が回文)
        // 3. ( N+3 ) / 2文字目からN文字目までが回文
        // -----
        // akasakaの場合
        // 1.の回文はパスしている
        // 2.の1文字目から(7 - 1) / 2 ＝＞ 3文字目までは akaなのでパス
        // 3.の(7+3) / 2 => 5文字目から7文字目まではakaなのでおｋ

        boolean result = true;

        // 1.回文チェック
        StringBuffer sb = new StringBuffer(S);
        if (!sb.reverse().toString().equals(S)) {
            result = false;
        }
        // 2. 1文字目から(N-1) / 2文字目までが回文チェック
        String startHalfStr = S.substring(0, (S.length() - 1) / 2);
        sb.setLength(0);
        sb.append(startHalfStr);
        if (!sb.reverse().toString().equals(startHalfStr)) {
            result = false;
        }
        sb.setLength(0);
        String endHalfStr = S.substring((S.length() + 3) / 2 - 1, S.length());
        sb.append(endHalfStr);
        if (!sb.reverse().toString().equals(endHalfStr)) {
            result = false;
        }

        System.out.println(result ? "Yes" : "No");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 23764
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

ULL N;
V<ULL> t;

ULL gcd(ULL a, ULL b) {
    if(a < b) swap(a,b);
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    INIT;
    cin >> N;
    t.resize(N);
    REP(i,N) cin >> t[i];
    ULL ans = t[0];
    FOR(i,1,N) ans = ans*(t[i]/gcd(ans,t[i]));
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi * r * r;
        double length = 2 * r * pi;
        System.out.printf("%f %f", area, length);
    }
}



Measured memory_bytes: 28276
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

int main() {
  int n,m;cin >> n >> m;
  if(n==1 && m==0){cout << 1;return 0;}
  ll x=1;
  ll y;
  ll ans=0;
  queue<int> as;
  int a1;cin >> a1;
  if(a1==1)y=0;
  else{y=1;as.push(a1);}

  rep(i,m-1) {int a;cin >> a; as.push(a);}

  for(int i=2;i<=n;i++){
  	int b=as.front();
  	if(b==i){ans=0;as.pop();}
  	else {ans=(x+y)%mod;}
  	x=y;y=ans;
  }
  cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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



signed main(){
  ll n,k,ans=0;cin>>n>>k;
  vector<ll> a(n),b(n);
  rep(i,0,n)cin>>a[i]>>b[i];

  
  rep(i,0,32){
    ll res=0,tar=k;

    if((k&mpow(2ll,i))>0){
      tar^=(mpow(2ll,i));
      tar|=(mpow(2ll,i))-1;
      cerr<<tar<<endl;
    }else if(i==31){
      tar=k;
    }else{
      continue;
    }

    rep(j,0,n){
      if((tar|a[j])<=tar)res+=b[j];
    }
    ans=max(ans,res);
    cerr<<ans<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
//最大値を求める関数//
#include <stdio.h>
int max(int a,int b)
{
  int max = a;
  if (b > a)	max =b;
  return max;
}
int main(void)
{
  //入力//
  int n;
  scanf("%d",&n);
  int l[n];
  int i;
  for (i =0; i < n; i++ )	{
    scanf("%d",&l[i]);
  }
  //出力//
  //まず最大の数を探し出す．//
  int maxi = 0;
  int place = 0;
  for(i =0; i< n; i++)	{
    maxi = max(maxi,l[i]);
    if(maxi == l[i]) place =i; 
  }
  //ここで，maxiは最大の数,placeは最大値をとっている辺の場所になっている．//
  int sum = 0;
  for(i = 0; i <n; i++)	{
    sum = sum + l[i];
  }
  sum = sum - l[place];
  //ここでsumは最長の辺以外の辺の長さの合計//
  if(sum > maxi)	printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll R;cin>>R;
    
	// 解法
	double ans = R * 2 *M_PI;
	//出力
	printf("%.10f\n", ans);
}


Measured memory_bytes: 3720
(let* ((s (read-line))
       (k (read))
       (x (make-array (list (length s)) :adjustable t :fill-pointer 0)))
  ;;
  (loop :with d := #\*
        :for c :across s
        :if (char/= c d)
        :do (progn
              (vector-push-extend 1 x)
              (setf d c))
        :else
        :do (incf (aref x (1- (length x)))))
  (cond ((= (length x) 1)
         (format t "~A~%" (floor (* k (aref x 0)) 2)))
        ((char/= (aref s 0) (aref s (1- (length s))))
         (format t "~A~%" (loop :for n :across x
                                :sum (* k (floor n 2)))))
        (t
         (format t "~A~%" (+ (loop :for i :from 1 :to (- (length x) 2)
                                   :sum (* k (floor (aref x i) 2)))
                             (floor (aref x 0) 2)
                             (floor (aref x (1- (length x))) 2)
                             (* (1- k) (floor (+ (aref x 0) (aref x (1- (length x)))) 2)))))))


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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  int ans = 0, i = 0;
  while (i < n) {
    int j = i + 1;
    while (j < n && a[j] <= a[j - 1])
      j++;
    ans = max(ans, j - i - 1);
    i = j;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, a[20], k;
bool b[20];
void f(int i, int p) {
	if (i < 0) {
		if (p != k)return;
		int r = 0;
		for (int p = 0; p < n; p++) if (b[p]) r += a[p];
		cout << r << ':';
		for (int p = 0; p < n; p++)if (b[p])cout << ' ' << p;
		cout << endl;
		return;
	}
	b[i] = 0;
	f(i - 1, p);
	b[i] = 1;
	f(i - 1, p + 1);
	return;
}
signed main() {
	cin >> n >> k;
	a[0] = 1;
	for (int i = 1; i < n; i++)a[i] = a[i - 1] * 2;
	f(n - 1, 0);
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
	*this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

int main(void){
  int n, m;
  std::cin >> n >> m;

  static int MAX_VAL = std::pow(10, n)-1;
  static int MIN_VAL = n==1 ? 0 : std::pow(10, n-1);

  std::set<std::pair<int, int> > s_c;
  for(int i=0; i<m; i++){
    int s, c;
    std::cin >> s >> c;
    s_c.insert(std::make_pair(s, c));
  }
  
  for(int i=MIN_VAL; i<=MAX_VAL; i++){
    int keta = i==0 ? 1 : (std::log10(i)+1);
    bool flag = true;
    for(const auto& elem: s_c){
      int s = elem.first;
      int c = elem.second;

      if(keta < s) flag = false;
      int tmp = i;
      for(int j=keta; j>s; j--){
	tmp /= 10;
      }
      //std::cout << i << " " << tmp << " " << s << " " << c << std::endl;
      //std::cout << (tmp%10 != c) << std::endl;
      if(tmp%10 != c) flag = false;

      if(flag==false) break;
    }
    //std::cout << flag << std::endl;
    if(flag){
      std::cout << i << std::endl;
      return 0;
    }
  }

  
  std::cout << -1 << std::endl;
  return 0;
}


Measured memory_bytes: 512
(n,q)=gets.split.map(&:to_i)

parent = (0...n-1).map{gets.split.map(&:to_i)}.sort_by{|a,b|b}.map{|a,b|a}
px = (0...q).map{gets.split.map(&:to_i)}.group_by{|p,x|p}.map{|p,v| [p,v.map{|p,x|x}.reduce(:+)] }.to_h


tmp=(0...n).map{0}

(0...n).each{|i|
    tmp[i]+=tmp[parent[i-1]-1] if i>0
    tmp[i]+=px[i+1] if px[i+1] != nil
}

print tmp.join(" ")

Measured memory_bytes: 88328
#include <stdio.h>
int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a==b)printf("%d\n", c);
	else{
		if(a==c)printf("%d\n", b);
		else printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

  int A, B, C;
  cin >> A >> B >> C;

  int ans = 0;
  while (!(A % 2 || B % 2 || C % 2)) {
    ans++;
    int at = (B + 1) / 2 + C / 2;
    int bt = A / 2 + (C + 1) / 2;
    int ct = (A + 1) / 2 + B / 2;

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

    A = at;
    B = bt;
    C = ct;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,mas[300005],dp[300005],rez;
char c;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n;
    i=0;
    while (i<n)
    {
        cin >> c;
        if (c=='W')
        {
            mas[i]=1;
        }
        i++;
    }
    i=n-1;
    while (i>=0)
    {
        dp[i]=dp[i+1]+1-mas[i];
        i--;
    }
    i=0;
    rez=n;
    while (i<n)
    {
        //cout << m << " " << dp[i+1] << "\n";
        rez=min(rez,m+dp[i+1]);
        m+=mas[i];
        i++;
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int C[3][3], B[3];

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int sm = 0;
  int a = 0;
  rep(i, 3){
    rep(j, 3){
      cin >> a;
      C[i][j] = a;
      sm += a;
    }
  }
  if (sm%3>0) {
    cout << "No" << endl;
    return 0;
  }
  // a1を固定して考える
  bool flag = false;
  rep(a1, 101){
    rep(i, 3){
      if (C[i][0] - a1 < 0){
        flag = true;
        break;
      }
      B[i] = C[i][0] - a1;
    }
    if (flag) continue;
    int a2 = C[0][1] - B[0];
    if (a2 < 0) continue;
    rep(i, 3){
      if (a2 != C[i][1] - B[i]){
        flag = true;
        break;
      }
    }
    if (flag) continue;
    int a3 = C[0][2] - B[0];
    if (a3 < 0) continue;
    rep(i, 3){
      if (a3 != C[i][2] - B[i]){
        flag = true;
        break;
      }
    }
    if (flag) continue;
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 892
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n;cin>>n;
  vector<P> red(n), blue(n);
  rep(i, n){
    int a, b;cin>>a>>b;
    red[i] = P(a, b);
  }
  rep(i, n){
    int c, d;cin>>c>>d;
    blue[i] = P(d, c);
  }
  sort(red.begin(), red.end(), greater<P>());
  sort(blue.begin(), blue.end());
  vector<bool> visit(n, false);
  int ans=0;
  rep(i, n){
    P rp = red[i];
    rep(j, n){
      if(visit[j])continue;
      P bp = blue[j];
      if(bp.second>rp.first && bp.first>rp.second){
        ans++;
        visit[j]=true;
        // printf("red(%d, %d)-blue(%d, %d)\n", rp.first, rp.second, bp.second, bp.first);
        break;
      }
    }
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

const int maxn=2e5+10;
int n,done[1000];
long long tot;
char s[maxn];
vector<int> vec[1000];

int f(int x){
	return n-1-x;
}
int st[maxn<<2];

void build(int rt,int l,int r){
	st[rt]=r-l+1;
	if(l==r)return;
	int mid=l+r>>1;
	build(rt<<1,l,mid);
	build(rt<<1|1,mid+1,r);
}
void del(int rt,int l,int r,int pos){
	--st[rt];
	if(l==r)return;
	int mid=l+r>>1;
	if(pos<=mid)del(rt<<1,l,mid,pos);
	else del(rt<<1|1,mid+1,r,pos);
}
int query(int rt,int l,int r,int x,int y){
	if(l==x&&r==y)
		return st[rt];
	int mid=l+r>>1;
	if(y<=mid)return query(rt<<1,l,mid,x,y);
	else if(x>mid)return query(rt<<1|1,mid+1,r,x,y);
	else
		return query(rt<<1,l,mid,x,mid)+query(rt<<1|1,mid+1,r,mid+1,y);
}

int main(){
	cin>>s;
	n=strlen(s);
	for(int i=0;s[i];++i)
		vec[s[i]].push_back(i);
	if(n&1){
		char odd=0;
		for(int i='a';i<='z';++i)
			if(vec[i].size()&1)
				if(!odd)
					odd=i;
				else{
					puts("-1");
					return 0;
				}
	}
	else{
		for(int i='a';i<='z';++i)
			if(vec[i].size()&1){
				puts("-1");
				return 0;
			}
	}
	build(1,0,n);
	del(1,0,n,n);
	for(int i=0;i<n;++i){
		if(query(1,0,n,i,i)==0)continue;
		if(vec[s[i]].size()%2==1&&vec[s[i]][vec[s[i]].size()/2]==i){
			tot+=abs(query(1,0,n,0,n)/2);
			del(1,0,n,i);
		}
		else{
			tot+=query(1,0,n,vec[s[i]][vec[s[i]].size()-1-done[s[i]]]+1,n);
			del(1,0,n,i);
			del(1,0,n,vec[s[i]][vec[s[i]].size()-1-done[s[i]]]);
			++done[s[i]];
		}
	}
	printf("%lld\n",tot);
	return 0;
}

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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////
string a;

int main(){
    cin>>a;
    ll bit =0;
    ll n = 0;
    for(bit = 0;bit<(1<<4);bit++){
        n = a[0]-'0';
        rep(i,3){
            //cout<<n<<endl;
           if( (bit & (1<<i)) != 0){
               n+=a[i+1]-'0';
           }else{
               n-=a[i+1]-'0';
           }
        }
        if(n==7){break;}
    }
    rep(i,3){
        cout<<a[i];
        if((bit & (1<<i)) !=0){
            cout<<"+";
        }else{
            cout<<"-";
        }
    }
    cout<<a[3];
    cout<<"=7"<<endl;
    return 0;
}

Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    rep(i, 5)
    {
        int a;
        cin >> a;
        if(a == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int l[q], r[q];
    for(int i = 0; i < q; i++){
        cin >> l[i] >> r[i];
    }

    int che[n];
    for(int i = 0; i < n; i++){
        che[i] = 0;
    }
    for(int i = 0; i < n; i++){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            if(i == 0){
                che[i] = 1;
                che[i + 1] = 1;
            }else{
                che[i] = che[i - 1] + 1;
                che[i + 1] = che[i];
            }
        }else{
            if(i == 0){
                che[i] = 0;
            }else{
                che[i]= che[i - 1];
            }
        }
    }


    for(int i = 0; i < q; i++){
        int ans = 0;
        if(l[i] == 1){
            ans = che[r[i] - 2];
        }else{
            ans = che[r[i] - 2] - che[l[i] - 2];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

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(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;

int main(){

    FASTIO;
    PRECISION; 
    
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++){
        int nxt = r*x-d;
        cout<<nxt<<"\n";
        x = nxt;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a[n];
    ll b[n];

    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 0, n){
        cin >> b[i];
    }

    ll m = 0;
    ll p = 0;
    rep(i, 0, n){
        if(a[i] > b[i]){
            m += a[i] - b[i];
        }else{
            p += (b[i] - a[i]) / 2;
        }
    }

    if(p >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

namespace _3_A
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack<int> number = new Stack<int>();
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < s.Count(); i++)
            {
                switch (s[i])
                {
                    case ("+"):
                        {
                            number.Push(number.Pop() + number.Pop());
                            break;
                        }
                    case ("-"):
                        {
                            int a = number.Pop();
                            number.Push(number.Pop() - a);
                            break;
                        }
                    case ("*"):
                        {
                            number.Push(number.Pop() * number.Pop());
                            break;
                        }
                    default:
                        {
                            number.Push(int.Parse(s[i]));
                            break;
                        }
                }
            }
            Console.WriteLine(number.Pop());
        }
    }
}

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

int main() {
  string s;
  cin >> s;
  
  if((s.size() % 2 == 0) ^ (s.at(0) == s.at(s.size() - 1))) cout << "Second" << endl;
  else cout << "First" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200010
typedef long long ll;
using namespace std;
int n,num,t,t2;
int main(){
	cin>>n,t2=n;
	while(n)t=t*10+n%10,n/=10;
	puts(t2==t?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
#重複要素を削除して要素数でLがすべて一緒か判断
def set_list(es):
    return len(list(set(es))) == 1

if set_list(L) != 1:
    print(0)
    exit()

#div内の最小子公倍数ansを求める

ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])

S = m//ans
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)


Measured memory_bytes: 16316
#include <stdio.h>



int main(void){
	int number;
	int length[200] = {};
	int i, j;
	int min, tmp;
	int sum = 0;
	
	scanf("%d", &number);
	number *= 2;
	for(i = 0; i < number; i++){
		scanf("%d", &length[i]);
	}
	for(i = 0; i < number; i++){
		min = i;
		for(j = i + 1; j < number; j++){
			if(length[j] < length[min]){
				min = j;
			}
		}
		tmp = length[i];
		length[i] = length[min];
		length[min] = tmp;
	}
	for(i = 0; i < number; i+=2){
		sum += length[i];
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define cases long long int t;cin>>t;while(t--)
#define fio ios::sync_with_stdio(false); cin.tie(0)
#define ALL(v) (v).begin(), (v).end() 
#define twod(n,m) vector<vector<int> > arr( n , vector<int> (m, 0))
#define prs(s,n) for(ll i=0;i<n;i++)cout<<s[i];
#define pra(arr,n) for(ll i=0;i<n;i++)cout<<arr[i]<<" ";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;
using namespace std;
int main() 
{
	fio;
    ll n;
    cin>>n;
    vector<ll> arr(n);
    unsigned int x = 0;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        unsigned int q = arr[i];
        x = x ^ q;
    }
    for(ll i=0;i<n;i++)
    {
        unsigned int q = arr[i];
        cout<<(x ^ q)<<" ";
    }
}


Measured memory_bytes: 4776
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    long long int h[n+1];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int a[m+1];
    int b[m+1];
    int cnt[n+1];
    for(int i=0;i<n;i++){
        cnt[i] = 0;
    }
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=1;i<=m;i++){
        if(h[a[i-1]-1]>h[b[i-1]-1]){
            cnt[b[i-1]-1] += 1;
        }
        else if(h[a[i-1]-1]==h[b[i-1]-1]){
            cnt[a[i-1]-1] += 1;
            cnt[b[i-1]-1] += 1;
        }
        else{
            cnt[a[i-1]-1] += 1;
        }
      //  cout << h[a[i-1]-1] ;
    }
   /* for(int i=0;i<n;i++){
        cout << cnt[i] << endl;
    }*/
    int ans=0;
    for(int i=0;i<n;i++){
        if(cnt[i]==0){
            ans += 1;
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 5552
package main

import (
	"fmt"
)

func main() {
	var n string
	fmt.Scan(&n)
	if n[0] == n[1] && n[1] == n[2] {
		fmt.Println("Yes")
		return
	}
	if n[2] == n[1] && n[3] == n[2] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) != s.at(s.size()-i-1)){
      cout << "No" << endl;
      break;
    }
    if(i == s.size()-1){
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 256
function main(arg) {
	arg = Number(arg.split("\n")[0])
	var arr = [111,222,333,444,555,666,777,888,999]

	for (var i = 0; i < arr.length; i++) {
		if (arg <= arr[i]) {
			console.log(arr[i])
			break
		}
	}
	
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
N, M = map(int, input().split())
A = list(map(int, input().split()))
p = [(A[i], 1) for i in range(N)]
for j in range(M):
    B, C = map(int, input().split())
    p.append((C, B))

p.sort(reverse=True)
ans, cnt = 0, N
for (v, c) in p:
    use = min(c, cnt)
    ans += use * v
    cnt -= use
print(ans)

Measured memory_bytes: 28792
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 i: i32 = read();
    if i == 1 {
        println!("Hello World");
    } else {
        let j: i32 = read();
        let k: i32 = read();
        println!("{}", j + k);
    }
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry; 
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    ll p[n];
    for(ll i=0;i<n;i++){
        cin >> p[i];
        p[i]--;
    }
    UnionFind tree(n);
    for(ll i=0;i<m;i++){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        tree.unite(x,y);
    }
    ll res=0;
    for(ll i=0;i<n;i++){
        if(tree.same(i,p[i])) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 4552