akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// graph template
template<typename T>
class Edge{
	public:
		int src, to; T cost;

		Edge(int to, T cost): src(-1), to(to), cost(cost){}
		Edge(int src, int to, T cost): src(src), to(to), cost(cost){}

		bool operator==(const Edge &e)const{
			return src==e.src and to==e.to and cost==e.cost;
		}
};
template<typename T>
using Edges = vector<Edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

template<typename T>
vector<T> bellman_ford(Edges<T> &edges, int V, int s){
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(V, INF);
    dist[s] = 0;

    for(int i = 0; i < V - 1; i++){
        for(auto &e: edges){
            if(dist[e.src] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }

	vector<bool> negative_cycle(V, false);
	for(int i = 0; i < V; i++){
    	for(auto &e: edges){
    	    if(dist[e.src] == INF) continue;
    	    if(dist[e.to] > dist[e.src] + e.cost or negative_cycle[e.src]) negative_cycle[e.to] = true;
    	}
	}
	if(negative_cycle[V-1]) return vector<T>();

    return dist;
}

int main(void){
	int N, M, P;
	cin >> N >> M >> P;
	Edges<int> es;
	for(int i = 0; i < M; i++){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--; c = P - c;
		es.push_back(Edge<int>(a, b, c));
	}

	vector<int> vec = bellman_ford(es, N, 0);
	int res;
	if(vec.empty()) res = -1;
	else res = max(0, vec[N-1] * -1);

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>

using namespace std;

int primes[1001];

void facts(int n)
{
    int root=sqrt(n);
    
    for(int i=2;i<=root;i++)
    {
        while(n%i==0)
        {
            primes[i]++;
            n/=i;
        }
    }
    
    if(n!=1)
        primes[n]++;
}

int main()
{
    int n,mod=1e9+7;
    long long ans=1;
    
    scanf("%d",&n);
    
    for(int i=2;i<=n;i++)
        facts(i);
    
    for(int i=2;i<=n;i++)
        ans=(ans*(primes[i]+1))%mod;
    
    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
using namespace std;
int max(int x, int y){
  return (x>y ? x : y);
}

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


Measured memory_bytes: 256
h,w=map(int,input().split())
C=[]
for index1 in range(10):
    C.append(list(map(int,input().split())))
A=[]
for index2 in range(h):
    A.append(list(map(int,input().split())))

def warshall_floyd(G):

    #kがこの位置でなければならない
    for k in range(10):
        for i in range(10):
            for j in range(10):
                G[i][j]=min(G[i][j],G[i][k]+G[k][j])
    
    return G

D=warshall_floyd(C)
magic=[0]*10
for index3 in range(10):
    if index3!=1:
        magic[index3]=D[index3][1]

ans=0
for index4 in range(h):
    for index5 in range(w):
        if A[index4][index5]>-1:
            ans+=magic[A[index4][index5]]

print(ans)

        

Measured memory_bytes: 3444
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*   
*   文件名称：D.cpp
*   创 建 者：YaliKiWi
*   创建日期：2019年07月20日
*   描    述：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define maxn 200000+10
int a[maxn],n,c[maxn];
int cnt;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(register int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(register int i=n;i>=1;i--){
		int sum=0;
		for(register int j=n/i;j>=1;j--){
			if(c[i*j])sum=1-sum;
		}
		if(sum!=a[i])c[i]=1,cnt++;
	}
	cout<<cnt<<endl;
	for(register int i=1;i<=n;i++){
		if(c[i])cout<<i<<" ";
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int cnt=1;
    for(int i=2; i<N+1; i*=2){
        if(i%2!=0) continue;
        if(i>cnt) cnt = i;
    }
    cout << cnt << endl;
    return 0;
}

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

int main()
{
    char s[200002];
    int i,j,a,b;
    cin>>s;
    int n=strlen(s);
    for(i=0;i<n;i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(j=n-1;j>=0;j--){
        if(s[j]=='Z'){
            b=j;
            break;
        }
    }
    cout<<b-a+1;
    return 0;
}


Measured memory_bytes: 3768
import math

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

count = 0

for v in T:
  top = 0
  tail = len(S)
  while top < tail:
    i = math.floor((top + tail)/2)
    if v == S[i]:
      count += 1
      break
    elif v > S[i]:
      top = i + 1
    else :
      tail = i

print (count)


Measured memory_bytes: 16768
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 200+10
    string S;
    ll ans=INF;
    ll ren;
    ll A;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>S;
    A=ans=S.size();

    REP(i,S.size()-1){
        //if(i==0)continue;
        if(S[i]!=S[i+1])ans=min(ans,max((ll)i+1,A-i-1));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace  std;
int fa[100010];
int n,m;
struct edge{
	int x,y,w;
	edge(int x=0,int y=0 ,int w=0 ):x(x),y(y),w(w){
	}
}a[100010];
int getfa(int x){
	if(x==fa[x]) return x;
	else return getfa(fa[x]);
}
bool cmp(edge a,edge b){
	return a.w<b.w;
}
int f(){
	int ans=0;
	sort(a,a+m,cmp);
	int cnt=n;
	for(int i=0;i<n;i++) fa[i]=i;
	for(int i=0;i<m;i++){
		int f1=getfa(a[i].x),
		f2=getfa(a[i].y);
		if(f1!=f2){
			ans+=a[i].w;
			cnt--;
			fa[f1]=f2;
			if(cnt==1) break;
		}
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
	}
	printf("%d\n",f());
	return 0;
}


Measured memory_bytes: 4412
/**
 *      ABC 59 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 23:10:40
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string A, B; cin >> A >> B;

    int sizeA = A.size(); int sizeB = B.size();
    if (sizeA > sizeB){
        cout << "GREATER" << endl;
    }
    else if (sizeA < sizeB){
        cout << "LESS" << endl;
    }
    else {
        if (A.compare(B) > 0){
            cout << "GREATER" << endl;
        }
        else if (A.compare(B) < 0){
            cout << "LESS" << endl;
        }
        else {
            cout << "EQUAL" << endl;
        }
    }

    return 0;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n); 
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int max = k - (a.at(n-1) - a.at(0));
  for (int i = 1; i < n; i++) {
    if (a.at(i) - a.at(i-1) > max) {
      max = a.at(i) - a.at(i-1);
    }
  }
  cout << k - max << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
int main(){
    ll h,w;
    cin>>h>>w;
    ll ans=h*w/2;
    if(h%2==1&&w%2==1)ans++;
    if(h==1||w==1)ans=1;
	cout<<ans<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

vector<ll> divisor;
void find_divisor(ll N) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}

int main() {
  ll S;
  cin >> S;
  ll x1, x2, y1, y2;
  x1 = y2 = ceil(sqrt(S));
  ll T = x1 * y2 - S;
  if(T != 0) {
    find_divisor(T);
    x2 = divisor.back();
    y1 = T / x2;
  } else {
    x2 = y1 = 0;
  }
  cout << 0 << ' ' << 0 << ' '
       << x1 << ' ' << y1 << ' '
       << x2 << ' ' << y2 << endl;
  return 0;
}


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

using namespace std;

const int mod = 998244353, proot = 3;

int n, m, ans;
vector<int> fac, ifac, dp, f;

int pow_mod(int x, int n) {
	int y = 1;
	while(n) {
		if(n & 1) {
			y = (long long) y * x % mod;
		}
		x = (long long) x * x % mod;
		n >>= 1;
	}
	return y;
}

int inv(int x) {
	return pow_mod(x, mod - 2);
}

int C(int n, int m) {
	return m < 0 || n < m ? 0 : (long long) fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

void prepare() {
	fac.resize(n + 3);
	ifac.resize(n + 3);
	fac[0] = 1;
	for (int i = 1; i <= n + 2; ++i) {
		fac[i] = (long long) fac[i - 1] * i % mod;
	}
	ifac[n + 2] = inv(fac[n + 2]);
	for (int i = n + 2; i; --i) {
		ifac[i - 1] = (long long) ifac[i] * i % mod;
	}
	return;
}

int lowbit(int x) {
	return x & (-x);
}

int getpw2(int x) {
	while(x != lowbit(x)) {
		x += lowbit(x);
	}
	return x;
}

void dft(vector<int> &a, bool rev) {
	int n = a.size();
	for (int i = 0, j = 0; i < n; ++i) {
		if(i < j) {
			swap(a[i], a[j]);
		}
		for (int k = n >> 1; (j ^= k) < k; k >>= 1);
	}
	vector<int> w(n, 0);
	w[0] = 1;
	for (int hl = 1, l = 2; l <= n; hl = l, l <<= 1) {
		int wn = pow_mod(proot, (mod - 1) / l);
		if(rev) {
			wn = inv(wn);
		}
		for (register int i = hl - 1; ~i; --i) {
			w[i << 1] = w[i];
			w[(i << 1) | 1] = (long long) w[i] * wn % mod;
		}
		for (int i = 0; i < n; i += l) {
			for (register int j = 0, x; j < hl; ++j) {
				int &t = a[i + hl + j];
				x = (long long) w[j] * t % mod;
				t = (a[i + j] - x) % mod;
				a[i + j] = (a[i + j] + x) % mod;
			}
		}
	}
	if(rev) {
		int inv_n = inv(n);
		for (int i = 0; i < n; ++i) {
			a[i] = (long long) inv_n * a[i] % mod;
		}
	}
	return;
}

void mul(vector<int> &a, vector<int> &b, vector<int> &c) {
	int M = a.size() + b.size() - 1, N = getpw2(M);
	vector<int> A(N, 0), B(N, 0);
	for (int i = 0; i < a.size(); ++i) {
		A[i] = a[i];
	}
	for (int i = 0; i < b.size(); ++i) {
		B[i] = b[i];
	}
	dft(A, 0);
	dft(B, 0);
	for (int i = 0; i < N; ++i) {
		A[i] = (long long) A[i] * B[i] % mod;
	}
	dft(A, 1);
	c.clear();
	for (int i = 0; i < M; ++i) {
		c.push_back(A[i] < 0 ? A[i] + mod : A[i]);
	}
	return;
}

void transfer() {
	vector<int> g(n + 1, 0);
	for (int i = 0; i <= n; ++i) {
		g[i] = (long long) dp[i] * ifac[i] % mod;
	}
	mul(f, g, g);
	for (int i = 0; i <= n; ++i) {
		dp[i] = ((long long) dp[i] * (C(i + 1, 2) + 1) + (long long) g[i] * fac[i + 2]) % mod;
	}
	return;
}

int main() {
	cin >> n >> m;
	prepare();
	dp.assign(n + 1, 1);
	f.assign(ifac.begin() + 2, ifac.end());
	f[0] = 0;
	for (int i = 2; i <= m; ++i) {
		transfer();
	}
	for (int i = 0; i <= n; ++i) {
		ans = ((long long) dp[i] * C(n, i) + ans) % mod;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 644
#include <stdio.h>

int main()
{
  int N,i,j,minj,flag,tmp,swap_times=0;

  scanf("%d",&N);

  int a[N];

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

  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    tmp=a[i];
    a[i]=a[minj];
    a[minj]=tmp;
    if(i!=minj)swap_times++;
  }
  
  for(i=0;i<N;i++){
    printf("%d",a[i]);
    if(i!=N-1) printf(" ");
  }

  printf("\n%d\n",swap_times);

  return 0;
}



Measured memory_bytes: 2128
import sys
readline = sys.stdin.readline

N,Q = map(int,readline().split())
G = [[] for i in range(N)]
for i in range(N - 1):
  a,b = map(int,readline().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)

P = [0 for i in range(N)]
for i in range(Q):
  p,x = map(int,readline().split())
  P[p - 1] += x
  
stack = [[0, 0, -1]]
while stack:
  v,point,parent = stack.pop()
  P[v] += point
  for child in G[v]:
    if child == parent:
      continue
    stack.append([child,P[v],v])
  
print(*P)

Measured memory_bytes: 65932
H, W, D = gets.split.map(&:to_i)
px = []
py = []
H.times do |i|
  gets.split.map(&:to_i).each_with_index do |x, j|
    px[x] = i
    py[x] = j
  end
end

d = []
(1..D).each do |i|
  d[i] = 0
end
(D+1..H*W).each do |i|
  d[i] = d[i-D] + (px[i] - px[i-D]).abs + (py[i] - py[i-D]).abs
end

gets.to_i.times do
  l, r = gets.split.map(&:to_i)
  puts d[r] - d[l]
end

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

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a == 1 && b == 1) {
		cout << "Draw";
		return 0;
	}
	if (a == 1) {
		cout << "Alice";
		return 0;
	}
	if (b == 1) {
		cout << "Bob";
		return 0;
	}
	if (a > b) {
		cout << "Alice";
	}
	else if (a < b) {
		cout << "Bob";
	}
	else {
		cout << "Draw";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int cnt = 1;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int q;
		scanf("%d", &q);
		sum += q;
		if (sum <= m)cnt++;
		else
			break;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 128
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var X = parseInt(lines[0],10);
    var A = parseInt(lines[1],10);
    var B = parseInt(lines[2],10);
    
    var pass_time = B - A;
//    console.log(pass_time);
    if(pass_time <=  0){
        console.log("delicious");
    }else if (pass_time <= X){
        console.log("safe");
    }else{
        console.log("dangerous");
    }

});

Measured memory_bytes: 21320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}





int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;

    priority_queue<ll> a;
    rep(i,n){
        ll x;
        cin >> x;
        a.push(x);
    }

    rep(i,m){
        ll k = a.top();
        a.pop();
        k /= 2;
        a.push(k);
    }
    ll ans = 0;

    rep(i,n){
        ll k = a.top();
        a.pop();
        ans += k;
    }

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


Measured memory_bytes: 4268
def east(dice):
    buff = [d for d in dice]
    dice[0] = buff[3]
    dice[2] = buff[0]
    dice[5] = buff[2]
    dice[3] = buff[5]


def west(dice):
    buff = [d for d in dice]
    dice[0] = buff[2]
    dice[2] = buff[5]
    dice[5] = buff[3]
    dice[3] = buff[0]


def north(dice):
    buff = [d for d in dice]
    dice[0] = buff[1]
    dice[1] = buff[5]
    dice[5] = buff[4]
    dice[4] = buff[0]


def south(dice):
    buff = [d for d in dice]
    dice[0] = buff[4]
    dice[1] = buff[0]
    dice[5] = buff[1]
    dice[4] = buff[5]


dice = list(map(int, input().split()))
commands = input()

for c in commands:
    if c == "E":
        east(dice)
    elif c == "W":
        west(dice)
    elif c == "N":
        north(dice)
    elif c == "S":
        south(dice)
    else:
        break

print(dice[0])

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,k; cin >> n >> k;

  vector<pair<int,int>> ans;
  int cnt = 0;
  for(int i = 2; i <= n; i++){
    cnt += ans.size();
    ans.push_back({1,i});
  }
  if(cnt < k){
    cout << -1 << endl;
    return 0;
  }

  for(int q = 1; q < 100; q++){
    if(cnt > k){
      int l = 2;
      for(int i = 0; i < n; i++){
        if(l+q > n || cnt == k) break;
        ans.push_back({l,l+q});
        cnt--;
        l++;
      }
    }
  }
  cout << ans.size() << endl;
  for(auto p : ans){
    cout << p.first << " " << p.second << endl;
  }

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		sc.close();

		int total = 0;

		for(int second = 1; second <= T ; second++) {
			if(second % A == 0) {
				total +=  B;
//				System.out.println("Second:" +second);
//				System.out.println("Total:"+total);
			}
		}

		System.out.println(total);

	}

}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<int>> num(62, vector<int>(2, 0));
  rep(i, 62) {
    rep(j, n) {
      if(a[j] & 1ll << i) ++num[i][1];
      else ++num[i][0];
    }
  }
  //for(int i = 0; i < 5; ++i) cout << i << " " << num[i][1] << ":" << num[i][0] << endl;
  mint ans = 0;
  rep(i, n) {
    rep(j, 62) {
      mint mask = 1ll<<j;
      if(a[i] & 1ll<<j) ans += mask*num[j][0];
      else ans += mask*num[j][1];
    }
  }
  ans /= 2;
  cout << ans.x << endl;
}

Measured memory_bytes: 2560
const Main = (input) => {
  const line = input.split('\n')
  const weathers = line[0].split('')
  let current = 0
  let result = 0

  weathers.forEach(weather => {
    current = (weather === 'R') ? ++current : 0
    result = Math.max(result, current)
  })

  console.log(result)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 30680
import sys
from collections import deque

readline = sys.stdin.readline
N = int(readline())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, readline().split())
    E[a-1].append((b-1, c))
    E[b-1].append((a-1, c))

Q, K = map(int, readline().split())
dist = [-1] * N
dist[K-1] = 0
q = deque([K-1])
while q:
    x = q.pop()
    d = dist[x]
    for i, j in E[x]:
        if dist[i] == -1:
            dist[i] = d + j
            q.append(i)
for _ in range(Q):
    x, y = map(int, readline().split())
    print(dist[x-1] + dist[y-1])


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int cnt = 0;
  vector<int> dist(n, -1);
  rep(sv,n) {
    if(dist[sv] != -1) continue;
    queue<int> q;
    dist[sv] = 0;
    q.push(sv);
    while(!q.empty()) {
      int v = q.front(); q.pop();
      for(int nv : G[v]) {
        if(dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        q.push(nv);
      }
    }
    cnt++;
  }
  int ans = cnt-1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8724
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	cin >> a >> s;
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

std::map<long long, long long> prime_factor(long long n) {
  std::map<long long, long long> ret;
  for(long long i = 2; i * i <= n; ++i) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1; // if n is prime number.
  return ret;
}

int main() {
  ll N;
  cin >> N;

  map<ll, ll> primes;
  for (ll i=1; i<=N; ++i) {
    map<ll, ll> p_i = prime_factor(i);
    for (const auto p : p_i) {
      primes[p.first] += p.second;
    }
  }
  ll five_count = 0;
  ll three_count = 0;
  ll fifteen_count = 0;
  ll twentyfive_count = 0;
  ll seventyfive_count = 0;
  for (const auto p : primes) {
    // cerr << p.second << endl;
    if (p.second >= 4) {
      five_count++;
    }
    if (p.second >= 2) {
      three_count++;
    }
    if (p.second >=14 ) {
      fifteen_count++;
    }
    if (p.second >=24 ) {
      twentyfive_count++;
    }
    if (p.second >=74 ) {
      seventyfive_count++;
    }
  }
  ll ans = 0;
  if (five_count < 2 || three_count < 3) {
    cout << ans << endl;
    return 0;
  }
  ll five_five_three = 0;
  five_five_three = five_count * (five_count-1) / 2;
  five_five_three *= three_count -2;
  ans += five_five_three;
  ll fifteen_five = fifteen_count * (five_count-1);
  ans += fifteen_five;
  ll twentyfive_three = twentyfive_count * (three_count-1);
  ans += twentyfive_three;
  ll seventyfive = seventyfive_count;
  ans += seventyfive;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<queue>
using namespace std;
int h,w;
int sz,used[444][444];
long ans;
string s[444];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(used[i][j])continue;
			sz++;
			queue<pair<pair<int,int>,bool> >P;
			P.push(make_pair(make_pair(i,j),s[i][j]=='#'));
			used[i][j]=sz;
			long cw=0,cb=0;
			(s[i][j]=='.'?cb:cw)++;
			while(!P.empty())
			{
				int x=P.front().first.first,y=P.front().first.second;
				bool b=P.front().second;
				P.pop();
				for(int r=0;r<4;r++)
				{
					int tx=x+dx[r],ty=y+dy[r];
					if(tx<0||ty<0||tx>=h||ty>=w||used[tx][ty]||(b==(s[tx][ty]=='#')))continue;
					(b?cb:cw)++;
					used[tx][ty]=sz;
					P.push(make_pair(make_pair(tx,ty),!b));
				}
			}
			ans+=cb*cw;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<set>
#define read(a) scanf("%d",&a)
using namespace std;
const int N=1e5+1;
int num[2][N];
int n;
typedef pair<int,int> Pr;
priority_queue<Pr> Q;
priority_queue<Pr> P;
int main()
{
	read(n);int x;
	for(int i=1;i<=n;++i){read(x);++num[i&1][x];}
	for(int i=1;i<N;++i) {
		if(num[0][i]) Q.push(Pr(num[0][i],i));
		if(num[1][i]) P.push(Pr(num[1][i],i));
	}
	if(n<=1) return puts("0");
	int ans=2147483647;
	Pr u,v;
	u=Q.top();v=P.top();Q.pop();P.pop();
	if(u.second!=v.second) {ans=n-u.first-v.first;}
	else{
		if(!Q.empty()) ans=min(ans,n-Q.top().first-v.first);
		if(!P.empty()) ans=min(ans,n-P.top().first-u.first);
		if(Q.empty()&&P.empty()) ans=n-max(u.first,v.first);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2044
MOD = 10**9 + 7

MOD_t_MAX = 5*10**5+10

fac  = [None] * MOD_t_MAX
finv = [None] * MOD_t_MAX
inv  = [None] * MOD_t_MAX
def MOD_COM_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MOD_t_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
def MOD_COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def MOD_perm(n, r):
    rtn = 1
    for _ in range(r):
        rtn *= n
        rtn %= MOD
        n -= 1
    return rtn

def main():
    n, m = map(int, input().split())
    ans = 0
    perm = MOD_perm(m, n)
    MOD_COM_init()
    for i in range(n+1):
        tmp = perm * MOD_COM(n, i) % MOD
        ans += (-1)**i * tmp
        ans %= MOD
        if i < n:
            perm *= inv[m-i]
            perm %= MOD
    print(ans*MOD_perm(m, n)%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 68264
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


int A[5];
void solve() {
	map<int, int>odd, even;
	int N; cin >> N;
	vector<int>v(N);
	REP(i, N) {
		cin >> v[i];
		if (i & 1)odd[v[i]]++;
		else even[v[i]]++;
	}
	vector<P>v0, v1;
	v0.push_back({ 0,1e9 });
	v1.push_back({ 0,1e9 });
	for (auto x : even) {
		v0.push_back({ x.second,x.first });
	}
	for (auto x : odd) {
		v1.push_back({ x.second,x.first });
	}
	VSORT(v0); VREVERSE(v0);
	VSORT(v1); VREVERSE(v1);
	int c0 = (N+1) / 2, c1 = N / 2;
	if (v0[0].second == v1[0].second) {
		ll ans = min(c0 - v0[0].first + c1 - v1[1].first, c0 - v0[1].first + c1 - v1[0].first);
		print(ans);
	}
	else {
		ll ans = c0 - v0[0].first+ c1 - v1[0].first;
		print(ans);
	}
}




signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



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

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

    int ans=0;
    while(n>0)
    {
        n=n-x;
        ans+=t;
    }
    cout<<ans<<endl;
     return 0;

}



Measured memory_bytes: 3632
from collections import deque
N, Q = map(int, input().split())

tree = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

X = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    X[p - 1] += x

d = deque([0])
ans = X
visited = [False] * N 

while d:
    q = d.pop()
    visited[q] = True

    for t in tree[q]:
        if not visited[t]:
            ans[t] += X[q]
            d.append(t)

print(*ans)

Measured memory_bytes: 105236
#include <stdio.h> 
int main(void)
{ 
    int h, w; 
    int i, j; 
    while(1){ 
        scanf("%d %d ", &h, &w); 
        if(h==0&&w==0)break; 
        for(i=0;i<h;i++){ 
            for(j=0;j<w;j++){ 
                if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){ 
                    printf("#"); 
                }else{
                    printf(".");
                }
            } 
            printf("\n"); 
        } 
        printf("\n"); 
    }
    return 0; 
} 


Measured memory_bytes: 2044
import java.util.*;
import java.util.regex.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final String S = sc.next();
        sc.close();

        Pattern p = Pattern.compile("^(dream|dreamer|erase|eraser)*");
        Matcher m = p.matcher(S);
        if (m.matches()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

double dp[3001];

int main()
{
    int n;
    cin >> n;
    vector<double> p(n + 1);
    for(int i = 1; i <= n; i++)
        scanf(" %lf", &p[i]);
    dp[0] = 1;
    for(int i = 1; i <= n; i++)
        for(int x = i; x >= 0; x--)
            if(!x) dp[x] = (1 - p[i]) * dp[x];
            else dp[x] = (1 - p[i]) * dp[x] + p[i] * dp[x - 1];
    double ans = 0;
    for(int x = 1; x <= n; x++) 
        if(x + x > n)
            ans += dp[x];

    printf("%.9lf\n", ans);


    return 0;
}

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

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N,X;
  cin>>N>>X;
  int m[N];
  int ans=N,min_m=1000;
  for (int i=0; i<N; i++) {
    cin>>m[i];
    X-=m[i];
    min_m=min(min_m,m[i]);
  }
  ans+=X/min_m;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <queue>
using namespace std;

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

int dis[512][512];
int occ[512][512];

int per[512*512];
int n;

void do_relax_loop(queue<pair<int, int>> &q) {
  while (q.size()) {
    int x, y;
    x = q.front().first, y = q.front().second;
    q.pop();
    #define RELAX(i,j,cost) if (i >= 0 && j >= 0 && i < n && j < n && cost < dis[i][j]) dis[i][j] = cost, q.push(make_pair(i, j));
    RELAX(x-1,y,dis[x][y]+occ[x-1][y]);
    RELAX(x+1,y,dis[x][y]+occ[x+1][y]);
    RELAX(x,y-1,dis[x][y]+occ[x][y-1]);
    RELAX(x,y+1,dis[x][y]+occ[x][y+1]);
    #undef RELAX
  }
}

void relax_dis() {
  FOR(i,n) {
    if (dis[i][0] > occ[i][0]) dis[i][0] = occ[i][0];
    if (dis[i][n-1] > occ[i][n-1]) dis[i][n-1] = occ[i][n-1];
    if (dis[0][i] > occ[0][i]) dis[0][i] = occ[0][i];
    if (dis[n-1][i] > occ[n-1][i]) dis[n-1][i] = occ[n-1][i];
  }
  queue<pair<int, int>> q;
  FOR(i,n) FOR(j,n) if (dis[i][j] == 0) q.push(make_pair(i, j));
  FOR(i,n) FOR(j,n) if (dis[i][j] == 1) q.push(make_pair(i, j));
  do_relax_loop(q);
}

void relax_dis_near(int x, int y) {
  queue<pair<int, int>> q;
  if ((x == 0 || y == 0 || x == n-1 || y == n-1) && dis[x][y]) dis[x][y] = 0, q.push(make_pair(x, y));
  if (x > 0 && dis[x-1][y] < dis[x][y]) dis[x][y] = dis[x-1][y], q.push(make_pair(x, y));
  if (x+1<n && dis[x+1][y] < dis[x][y]) dis[x][y] = dis[x+1][y], q.push(make_pair(x, y));
  if (y > 0 && dis[x][y-1] < dis[x][y]) dis[x][y] = dis[x][y-1], q.push(make_pair(x, y));
  if (y+1<n && dis[x][y+1] < dis[x][y]) dis[x][y] = dis[x][y+1], q.push(make_pair(x, y));
  do_relax_loop(q);
}

int main() {
  scanf("%i", &n);
  FOR(i,n*n) scanf("%i", per+i), per[i]--;
  memset(dis, 1, sizeof(dis));
  FOR(i,n) FOR(j,n) occ[i][j] = 1;
  relax_dis();
  long long ans = 0;
  FOR(i,n*n) {
    int x = per[i] % n;
    int y = per[i] / n;
    ans += dis[x][y];
    occ[x][y] = 0;
    relax_dis_near(x, y);
  }
  printf("%lli\n", ans-n*n);
}


Measured memory_bytes: 6236
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = [0]*n
z = [ [] for i in range(n) ]
for i in range(n):
    aa = inn()
    a[i] = aa
    for j in range(aa):
        x,y = inm()
        x -= 1
        z[i].append((x,y))

mx = 0
for i in range(2**n):
    honest = [ ((i>>j)&1 == 1) for j in range(n) ]
    nbits = sum([ ((i>>j)&1) for j in range(n) ])
    ok = True
    for j in range(n):
        if not honest[j]:
            continue
        for u in z[j]:
            x,y = u
            if honest[x] and y==0 or not honest[x] and y==1:
                ok = False
                break
        if not ok:
            break
    #print("i {} honest {} nbits {} ok {}".format(i,honest,nbits,ok))
    if ok and nbits>mx:
        mx = nbits

print(mx)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	
	private static long commonDivisor(long a, long b){
		long r = a%b;
		if(r==0) return b;
		else return commonDivisor(Math.max(r, b), Math.min(r, b));
	}

	private static long commonMultiple(long a, long b){
		long max = Math.max(a, b);
		long min = Math.min(a, b);
		long i = 1;
		while(true){
			if(max*i%min==0)
				break;
			i++;
		}
		return max*i;
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a, b, c;
		while(scan.hasNext()){
			a = scan.nextInt();
			b = scan.nextInt();
			if(b>a){
				c = a;
				a = b;
				b = c;
			}
			System.out.print(commonDivisor(a,b)+" "+commonMultiple(a,b)+"\n");
		}
	}
}

Measured memory_bytes: 11000
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ll>a(n),b(n),c(n);
    ll suma=0,sumb=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0;i<n;++i)
    {
        cin>>b[i];
        sumb+=b[i];
    }
    if(suma<sumb)
    {
        cout<<"-1\n";
        return 0;
    }
    ll am=0;
    vector<ll>ex;
    int ans=0;
    for(int i=0;i<n;++i)
    {
        if(a[i]<b[i])
        {
            am+=b[i]-a[i];
            ans++;
        }
        if(a[i]>b[i])
        {
            ex.pb(a[i]-b[i]);
        }
    }
    sort(all(ex));
    int ind=(int)ex.size()-1;
    while(am>0)
    {
        am-=ex[ind];
        ind--;
        ans++;
    }
    cout<<ans<<'\n';
}







Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll a,b,c; cin >> a >> b >> c;
	map<ll,ll> mp;
	mp[a]++; mp[b]++; mp[c]++;
	if(mp.size()==2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

long long gcd(long long a, long long b) {
	if (b == 0LL) return a;
	a %= b;
	return gcd(b, a);
}

int main() {
	int t;
	cin >> t;
	long long ans = 1LL;
	while (t--) {
		long long n;
		cin >> n;
		ans = (ans / gcd(ans, n)) * n;
	}
	cout << ans;
	return 0;
}

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

int main(){
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(a > 0){
		printf("%d\n",e*(b-a));
	}
	else{
		printf("%d\n",e*b+d-c*a);
	}
	
	
	return 0;
}


Measured memory_bytes: 3212
iN ,iX  = map(int,input().split())
aX = tuple(map(int,input().split()))

aCum = [0]*iN
aCum[0] = aX[0]
for i in range(1,iN):
    aCum[i]=aCum[i-1]+aX[i]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[-1 * i * iK -1]
    return iCost

iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
print(iTotalCost)


Measured memory_bytes: 26504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int x;
    cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 3660
def solve(string):
    n, *l = map(int, string.split())
    l.sort(reverse=True)
    nums = 0
    for i, a in enumerate(l[:-2]):
        j, k = i + 1, n - 1
        while (j < k):
            if (a < l[j] + l[k]):
                nums += k - j
                j += 1
            else:
                k -= 1
    return str(nums)
 
 
if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define P(X) cout<<"db "<<X<<endl;
#define P2(X,Y) cout<<"d2 "<<X<<" "<<Y<<endl;
#define ll long long
#define rep(i,n) for(i=1;i<=n;i++)
#define FO freopen("t.txt","w",stdout);
#define MS(XX,YY) memset(XX,YY,sizeof(XX));
#define pii pair<int,int>
using namespace std;
int ar[100009],mx,mn,cd;
int main()
{
    int i,j,a,b,ts,f=1,x,cn=0,n;
    //freopen("test.txt","r",stdin);
    scanf("%d",&n);
    scanf("%d",&mn);
    mx=-mn;
    for(i=1;i<n;i++){
        scanf("%d",&x);
        cd=x-mn;
        mn=min(mn,x);
        mx=max(cd,mx);

    }

    printf("%d\n",mx);
    return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define ll long long
const int N = 3e5 + 7;

using namespace std;

ll n , m;
ll ans , sum  , a , b , c;
string s , s1;
ll used[N];
int main()
{
        ios_base::sync_with_stdio(false);
   ll T;
   ll arr[3];
   cin >> arr[0] >> arr[1] >> arr[2];
   if( arr[0] % 2 == 0 or arr[1] % 2 == 0 or arr[2] % 2 == 0)
        return cout << 0 , 0;
        sort( arr , arr + 3 );
   cout << arr[1] * arr[0];
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();

    System.out.printf("%d %d %.5f\n", a / b, a % b, (double)a / (double)b);
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<tuple<string,int,int>> v(n);
  for (int i=0;i<n;++i) {
    string a;
    int b;
    cin >> a >> b;
    v[i] = make_tuple(a, -b, i);
  }
  sort(v.begin(), v.end());
  for (int i=0;i<n;++i) {
    int a = get<2>(v[i]);
    cout << a+1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<27;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n;
    vector<vector<int>> dp;
    vector<pair<int,int>> hp;
    Problem(LL n):n(n),dp (n,vector<int>(n+1,INF)){};

    void solve(){
        for(int i=0; i<n; ++i){
            int h,p;
            cin>> h >> p;
            hp.push_back({h,p});
        }
        sort(hp.begin(),hp.end(),[](pair<int,int> &a, pair<int,int> &b){
            return a.first+a.second<b.first+b.second;
        });
        dp[0][1]=hp[0].second;
        dp[0][0]=0;
        for(int i=1; i<n; ++i){
            for(int j=0; j<=n; ++j){
                dp[i][j]=min(dp[i][j],dp[i-1][j]);
                if(j>0 and dp[i-1][j-1]<=hp[i].first){
                    dp[i][j]=min(dp[i][j],dp[i-1][j-1]+hp[i].second);
                }
            }
        }
        cout << lower_bound(dp[n-1].begin(),dp[n-1].end(),INF)-dp[n-1].begin()-1 <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



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

#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)<(b)?(a):(b))

int skyline[41];

double calc(int x, int y, int r){
	return y+r-sqrt((double)(r*r-x*x));
}

int main(void){
	int n,r;
	while(scanf("%d %d", &r, &n),r||n){
		int i,j,xl,xr,h;
		for(i=0;i<41;i++) skyline[i]=0;

		for(i=0;i<n;i++){
			scanf("%d %d %d", &xl, &xr, &h);
			for(j=xl;j<xr;j++){
				if(skyline[j+20]<h)skyline[j+20]=h;
			}
		}
		double t=calc(0,min(skyline[19],skyline[20]),r);
		double tt;
		int tx,ty;
		tx=0;
		ty=min(skyline[19],skyline[20]);
		for(j=0;j<r-1;j++){
			if(skyline[j+20]>skyline[j+1+20]){
				tt=calc(j+1,skyline[j+1+20],r);
				if(tt<t){
					tx=j+1;
					ty=skyline[j+21];
				}
				t=min(t,tt);
			}
		}
		for(j=-1;j>0-r;j--){
			if(skyline[j+20]>skyline[j-1+20]){
				tt=calc(j,skyline[j-1+20],r);
				if(tt<t){
					tx=j;
					ty=skyline[j+19];
				}
				t=min(t,tt);
			}
		}
		printf("%0.4f\n",t);
	}

	return 0;
}

Measured memory_bytes: 640
import numpy as np

ncity, nlines = map(int, input().rstrip("\n").split())
matrix = np.zeros((ncity, ncity), dtype=int)
for _ in range(nlines):
    l, c = map(lambda x: int(x) - 1, input().rstrip("\n").split())
    matrix[l][c] += 1
    matrix[c][l] += 1

for list_ in matrix:
    print(sum(list_))

Measured memory_bytes: 12500
#include<iostream>
#include<limits>
#include<string>
#include<vector>
using namespace std;

int main()
{
	int num;
	cin >> num;
	vector<int> a(num + 1);
	for (int idx = 1; idx < num + 1; ++idx)
	{
		uint32_t ret = 0;
		cin >> a[idx];
	}

	vector<int> b(num + 1, 0);
	vector<int> c;

	for (int idx = num; idx >= 1; --idx)
	{
		// 倍数の個数を取得
		int tmp = 0;
		for (int idx2 = 1; idx2 <= num && idx * idx2 <= num; ++idx2)
		{
			tmp += b[idx * idx2];
		}

		// 違っていれば入れる
		if (tmp % 2 != a[idx])
		{
			c.push_back(idx);
			b[idx] = 1;
		}
	}

	// 結果
	cout << c.size() << endl;
	for (auto i : c)
	{
		cout << i << " ";
		cout << endl;
	}
}

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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int main(){
	int n, k;
	double ans = 0;
	std::cin >> n >> k;
	RC(i, n){
		double tmp = 1. / n;
		if(i + 1 >= k){
			ans += tmp;
		}else{
			tmp /= 1 << (int)log2((k - 1.) / (i + 1.)) + 1;
			ans += tmp;
		}
	}
	printf("%.12f\n", ans);
}


Measured memory_bytes: 384
/*
*
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#define CLR(ARR,NUM) memset(ARR,NUM,sizeof(ARR))
#define GETNUM(NUM) scanf("%d",&NUM)
#define faster_io() ios_base::sync_with_stdio(false)
using namespace std;
const int MAXN = 110;
char map[MAXN][MAXN];
bool vis[MAXN][MAXN];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

void dfs(int x,int y,char ch)
{
	for(int i=0;i<4;i++){
		int tx=x+dx[i];
		int ty=y+dy[i];
		if(map[tx][ty]==ch&&!vis[tx][ty]){
			vis[tx][ty]=true;
			dfs(tx,ty,ch);
		}
	}
}

int main()
{
	int h,w;
	while(cin >> h >> w){
		if(h==0&&w==0)	break;
		getchar();
		CLR(vis,false);
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				map[i][j]=getchar();
			}
			getchar();
		}
		int ans=0;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(!vis[i][j]){
					ans++;
					vis[i][j]=true;
					dfs(i,j,map[i][j]);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1652