akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main() {
  int N; cin>>N;
  vector<ll> A(N); REP(i,N) cin>>A[i];
  vector<ll> ans;
  REP(j,N){
    const auto &res = prime_factorize(A[j]);
    for (auto p : res) {
      int last_num = 0;
      for (int i = 0; i < p.second; ++i){
        if(last_num == p.first) continue;
        last_num = p.first;
        ans.push_back(p.first);
      }
    }
  }
  sort(ans.begin(), ans.end());
  bool pair_flag = true;
  int small_sum = 1;
  int max_sum = 0;
  int ans_s = ans.size();
  REP(i,ans_s-1){
    if(ans[i+1] == ans[i]){
      pair_flag = false;
      small_sum++;
      max_sum = max(max_sum, small_sum);
    }
    else small_sum = 1;
  }
  if(pair_flag) cout << "pairwise coprime";
  else if(max_sum < N) cout << "setwise coprime";
  else cout << "not coprime";
}

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

using namespace std;

const int MAXN = 1e5 + 100;
vector <int> g[MAXN];
const int MOD = 1e9 + 7;
int n, k;
typedef long long ll;

int dfs(int v, int p, int start) {
	ll ans = 1;
	for (auto u : g[v]) {
		if (u == p) continue;
		ans *= ((ll)dfs(u, v, k - 2) * start) % MOD;
		ans %= MOD;
		start--;
	}
	if (p == -1) {
		ans *= k;
		ans %= MOD;
	}
	return ans;
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << dfs(1, -1, k - 1);
	return 0;
}


Measured memory_bytes: 11520
<?php
$a=explode(' ',trim(fgets(STDIN)));
$W=(int)$a[0];
$H=(int)$a[1];
$x=(int)$a[2];
$y=(int)$a[3];
$r=(int)$a[4];
if($x-$r<0){echo 'No';}
elseif($y-$r<0){echo 'No';}
elseif($x+$r>$W){echo 'No';}
elseif($y+$r>$H){echo 'No';}
else{echo 'Yes';}
?>

Measured memory_bytes: 15440
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	vector<vector<int>> c;
	for (auto i = 0; i < M; ++i)
	{
		vector<int> temp;
		int k;
		cin >> k;
		for (auto j = 0; j < k; ++j)
		{
			int s;
			cin >> s;
			temp.push_back(s);
		}
		c.push_back(temp);
	}
	vector<int> p;
	for (auto i = 0; i < M; ++i)
	{
		int temp;
		cin >> temp;
		p.push_back(temp);
	}

	auto limit = 1;
	for (auto i = 0; i < N; ++i)
	{
		limit *= 2;
	}

	auto result = 0;
	for (auto i = 0; i < limit; ++i)
	{
		auto on = true;
		for (auto j = 0; j < M; ++j)
		{
			auto count = 0;
			for (auto k = 0; k < c[j].size(); ++k)
			{
				if ((i & (1 << (c[j][k] - 1))) != 0)
				{
					++count;
				}
			}

			if ((count % 2) != p[j])
			{
				on = false;
				break;
			}
		}
		if (on)
		{
			++result;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define N 100010
using namespace std;
int n;
lint a[N], b[N],c[N];

lint pd[N][3];

lint run(int i, int at){
	if(i == n) return 0;
	
	if(at != -1 && pd[i][at] != -1)
		return pd[i][at];
	
	if(at != 0)
		pd[i][at] = max(pd[i][at], a[i] + run(i+1,0));
	if(at != 1)
		pd[i][at] = max(pd[i][at], b[i] + run(i+1,1));
	if(at != 2)
		pd[i][at] = max(pd[i][at], c[i] + run(i+1,2));
	
	return pd[i][at];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(pd, -1, sizeof pd);
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	cout<<run(0,-1)<<"\n";
	
	return 0;	
}


Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int a, b;
	cin >> a >> b;

	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int N;
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll ans = 1;
    cin >> N;
    vector<ll> t(N);
    rep(i, 0, N)
    {
        cin >> t[i];
    }
    rep(i, 0, N)
    {
        ans = lcm(ans, t[i]);
        // cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,a,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;


int main()
{
    scanf("%lld%lld",&n,&m);
    n=n%m;
    c=abs(n-m);
    c=min(c,abs(c-m));
    printf("%lld\n",c);
    return 0;
}
/// empty() lld lld push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3832
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    if((a+b)%2){
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << (a+b)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DP
{
    class D
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]), W = int.Parse(s[1]);
            long[] Value = new long[W + 1];
            for(int i = 0; i < N; i++)
            {
                string[] s0 = Console.ReadLine().Split(' ');
                int w = int.Parse(s0[0]);
                int v = int.Parse(s0[1]);
                
                for(int j = W; j >= 0; j--)
                {
                    if (w <= j)
                    {
                        long vd = Value[j - w] + v;
                        if (vd > Value[j]) Value[j] = vd;
                    }
                }
            }
            Console.WriteLine(Value[W]);
        }

    }
}


Measured memory_bytes: 13248
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

vector<int> bfs(int s, vector<vector<int>> &g) {
    int n = g.size();
    vector<int> d(n, -1);
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while(que.size()) {
        int now = que.front();
        que.pop();
        if(d[now] == -1) {
            continue;
        }
        for(auto next : g[now]) {
            if(d[next] == -1) {
                d[next] = d[now] + 1;
                que.push(next);
            }
        }
    }
    return d;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, u, v;
    cin >> n >> u >> v;
    u--;
    v--;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    auto td = bfs(u, g);
    auto ad = bfs(v, g);
    // 高橋君が青木君より先に到達できる頂点のうち、
    // 最も青木君から遠い頂点をx、その距離をdistとする
    int x = -1;
    int dist = -1;
    for(int i = 0; i < n; i++) {
        if(td[i] <= ad[i]) {
            if(dist < ad[i]) {
                x = i;
                dist = ad[i];
            }
        }
    }
    cout << ad[x] - 1 << endl;
}


Measured memory_bytes: 6656
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	long N, D; cin >> N >> D;

	cout << ((N - 1) / (2 * D + 1)) + 1;

}

Measured memory_bytes: 256
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[n+1];
    pair<ll, ll> bc[m+1];
    ll bigsum = 0;
    for(ll i = 0 ; i < n; i++)
    {
        cin >> a[i];
        bigsum+=a[i];
    }
    for(ll i = 0; i < m; i++)
    {
        cin >> bc[i].sc;
        cin >> bc[i].fr;
    }
    sort(bc, bc+m);
    sort(a, a+n);
    ll lastpos = 0;
    
    for(ll i = m-1; i >= 0; i--)
    {
        ll sum = 0;
        bool stopped = false;
        ll c = 0;
        for(ll j = lastpos; j < lastpos+bc[i].sc; j++)
        {
            if(a[j] >= bc[i].fr)
            {
                stopped = true;
                break;
            }
            sum+=a[j];
            c++;
        }
        lastpos = lastpos+bc[i].sc;
        bigsum+= c*bc[i].fr-sum;
        if(stopped)
        {
            break;
        }
    }
    cout << bigsum << endl;
}


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

int N;
const int MAX = 1.0e5 + 10;
ll X[MAX], L[MAX];

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

    vector<pair<ll, ll> > ts;
    for (int i = 0; i < N; i++) {
        ts.push_back({X[i]+L[i], X[i]-L[i]});
    }

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

    ll ans = 0;
    ll now = -1.0e15;
    for (int i = 0; i < N; ++i) {
        if (now <= ts[i].second) {
            ans++;
            now = ts[i].first;
        }
    }

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


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


int main() {
  string N;
  cin >> N;
  int a = N.size() - 1;
  if(N[a] == '3'){
    cout << "bon" << endl;
  }
  else if(N[a] == '0' || N[a] == '1' ||
          N[a] == '6' || N[a] == '8'){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

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

int a, b;

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

#undef int
int main(){
	#define int long long
	scanf("%lld%lld", &a, &b);
	int c = gcd(a, b);
	int ans = 0;
	for (int i=1; i<=trunc(sqrt(c)); i++) {
		if (c % i != 0) continue;
		if (check(i)) {
			ans ++;
		}
		if (i != c / i && check(c / i)) {
			ans ++;
		}
	}
	printf("%lld\n", ans + 1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  vector<P> mk(n);
  for(int i=0;i<n;i++){
    cin>>mk[i].first>>mk[i].second>>p[i];
  }
  int m;
  cin>>m;
  vector<int> w(m);
  rep(i,m)
    cin>>w[i];
  vector<int> dp(400,-1);
  dp[0]=0;
  rep(i,400){
    rep(j,n){
      for(int k=mk[j].first;k<=mk[j].second;k++){
	if(i-k>=0&&dp[i-k]!=-1){
	  dp[i]=max(dp[i],dp[i-k]+p[j]);
	}
      }

    }

  }
  /*rep(i,100)
    cout<<dp[i]<<" "<<i<<endl;
  */
  vector<int> ans(m);
  rep(i,m){
    ans[i]=dp[w[i]];
    if(ans[i]==-1){
      cout<<"-1"<<endl;
      return 0;
    }
  }
  rep(i,m){
    cout<<ans[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;

		for (int i = 0; i < 3; i++) {
				if (s.charAt(i) == '1') {
				count++;
			}
		}
		System.out.print(count);

	}
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

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

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}


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

  vector<ll> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i] /= 2;
  }

  set<int> s;
  rep(i, N) {
    ll temp = a[i];
    int cnt = 0;
    while (temp % 2 == 0) {
      cnt++;
      temp /= 2;
    }
    s.insert(cnt);
  }

  if (sz(s) > 1) {
    cout << 0 << endl;
    return 0;
  }


  ll LCM = 1;
  rep(i, N) {
    LCM = lcm(LCM, a[i]);

    if (LCM > M) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = M / LCM;
  ans = (ans + 1) / 2;

  cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
a = list(input() for i in range(N)) #0～N-1まである
k = 0
for i in range(N-1): #0～N-2まである
  if a.count(a[i]) != 1:
    print('No')
    break
  elif (a[i+1][0:1]) != (a[i][-1:]): #1～N-1までやりたい　#0～N-2までやりたい
    print('No')
    break
  else:
    k = k + 1

if k == (N-1):
  print('Yes')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
bool can(int i)
{
	if(i==105)
	{
		if(n%105==0)
		{
			return true;
		}
		return false;
	}
	for(int j=0;j<=n;j+=i)
	{
		n-=j;
		if(n==0)
		{
			return true;
		}
		if(can(i+1))
		{
			return true;
		}
		n+=j;
	}
	return false;
}
int main()
{
	cin>>n;
	cout<<(can(100)?"1":"0");
	return 0;
}

Measured memory_bytes: 384
N, C = list(map(int, input().split()))
D = []
for i in range(C):
    D.append(list(map(int, input().split())))
#print(D)
c = []
for i in range(N):
    c.append(list(map(int, input().split())))
#print(c)

A = [[0]*C, [0]*C, [0]*C] # color count
for i in range(N):
    x = 0
    y = i
    j = (x+y)%3
    while y>=0:
        A[j][c[y][x]-1] += 1
        y -= 1
        x += 1
#print(A)
for i in range(1, N):
    x = i
    y = N-1
    j = (x+y)%3
    while x<N:
        A[j][c[y][x]-1] += 1
        y -= 1
        x += 1
#print(A)

from itertools import permutations as p
ans = 1e10
for colors in p(range(C),3):
    tmp = 0
    for i in range(3):
        for j in range(C):
            tmp += A[i][j]*D[j][colors[i]]
    #print(colors, tmp)
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 1e2+7;
int T,n,m;
int x[N],y[N],d[N];
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int L;
    scanf("%d", &L);

    if(L<=2){
        printf("2 %d\n", L);
        rep(i,0,L){
            printf("1 2 %d\n", i);
        }
        return 0;
    }

    int len = 0;
    while(1<<len <= L)
        ++len;

    n = len, m = 0;
    rep(i,0,len-1){
        x[++m] = i + 1;
        y[m] = i + 2;
        d[m] = 0;
        x[++m] = i + 1;
        y[m] = i + 2;
        d[m] = 1<<i;        
    }

    per(i,0,len-1){
        if(L&(1<<i)){
            x[++m] = i + 1;
            y[m] = n;
            d[m] = L >> (i + 1) << (i + 1);
        }
    }

    printf("%d %d\n", n, m);
    rep(i,1,m+1){
        printf("%d %d %d\n", x[i], y[i], d[i]);
    }
    return 0;
}

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

int main() {
       ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    

      long long q,n,k,i,count=0,j=0,l,r,ans=0,p,m,x;
      cin>>n>>k;
      long long a[n];
      for(i=0;i<n;i++)
     { cin>>a[i]; 
     }
     if(k>=n)
     {cout<<0; return 0;}
     sort(a,a+n);
     for(i=0;i<(n-k);i++)
     {
         count+=a[i];
     }
      cout<<count;
      
    
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
 
template<class T>
using Graph = std::vector<std::vector<T>>;
 
bool dfs(Graph<int> &G, int step, int u, int v,
         std::vector<bool> &visited)
{
    int n = G.size();
    int x = (step < n / 2 ? u : v);
    if (step == n - 1) {
        return true;
    }
     
    bool ret = false;
    for (int next : G[x]) {
        if (!visited[next]) {
            visited[next] = true;
 
            if (step < n / 2) {
                ret |= dfs(G, step + 1, next, v, visited);
            } else {
                ret |= dfs(G, step + 1, u, next, visited);
            }           
        }        
    }
 
    return ret;
}
 
bool solve(Graph<int> &G, int u, int v)
{
    int n = G.size();
    if (n & 1) {
        return false;
    }
 
    std::vector<bool> visited(n, false);
    visited[u] = visited[v] = true;
    return dfs(G, 1, u, v, visited);
}
 
int main()
{
    int n, u, v;
    std::cin >> n >> u >> v;
    u--; v--;
     
    Graph<int> G(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;
 
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
 
    std::cout << (solve(G, u, v) ? "Yes" : "No") << std::endl;
     
    return 0;
}

Measured memory_bytes: 17564
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B = lr()

def F(x):
    '''x-1までの排他的論理和の合計を返す'''
    if x%2 == 0:
        y = x >> 1
        return y & 1
    else:
        return (x-1)^F(x-1)

answer = F(A) ^ F(B+1)
print(answer)


Measured memory_bytes: 3060
A = list(input().split() for i in range(3))
n = int(input())
r1 = set(A[0])
r2 = set(A[1])
r3 = set(A[2])
c1 = {A[0][0], A[1][0], A[2][0]}
c2 = {A[0][1], A[1][1], A[2][1]}
c3 = {A[0][2], A[1][2], A[2][2]}
d1 = {A[0][0], A[1][1], A[2][2]}
d2 = {A[0][2], A[1][1], A[2][0]}
b = set(input() for i in range(n))
if r1.issubset(b) or r2.issubset(b) or r3.issubset(b) or c1.issubset(b) or c2.issubset(b) or c3.issubset(b) or d1.issubset(b) or d2.issubset(b):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  if (S.size() % 2 == 1) {
    cout << "No" << endl;
    return;
  }
  for (ll i = 0; i < S.size(); i += 2) {
    if (S[i] != 'h' or S[i+1] != 'i') {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	std::string s, p;
	std::cin >> s >> p;
	if ((s+s).find(p) != std::string::npos) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
using namespace std;  
const int N=105;  
typedef long long ll;  
const ll INF=1000000005;  
int n,v[110],ans,f[110][410];
ll m,w[110],gint;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    gint=w[1]-1;
    for (int i=1;i<=n;i++)
        w[i]-=gint;     
    for (int i=1;i<=n;i++)
        for (int j=i;j>=1;j--)
            for (ll k=min(4LL*n,m-gint*j);k>=w[i];k--)
                    f[j][k]=max(f[j][k],f[j-1][k-w[i]]+v[i]);
    for (int i=0;i<=n;i++)
        for (int j=0;j<=4*n;j++)
            ans=max(ans,f[i][j]);
    cout<<ans;
    return 0;  
}  

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int INF = 1 << 30;
  int64_t N,W;
  cin >> N >> W;
  int64_t w[N];
  int64_t v[N];
  for(int64_t i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  int64_t dp[N+1][100010] = {};
  for(int64_t j=0;j<100010;j++){
    dp[0][j] = INF;
  }
  dp[0][0] = 0;
 
  for(int64_t i=0;i<N;i++){
    for(int64_t j=0;j<100010;j++){
      if(v[i]>j) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = min(dp[i][j-v[i]]+w[i],dp[i][j]);
    }
  }
  
  int ans = 0;
  for(int64_t j=0;j<100010;j++){
    if(dp[N][j]<=W){
      ans = j;
    }
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 82560
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  def pow(a: Int, n: Int, res: Int = 1): Int = {
    if (n == 0) {
      res
    } else if ((n&1) == 0) {
      pow(a*a, n >> 1, res)
    } else {
      pow(a*a, n >> 1, res*a)
    }
  }

  println((100 * (n-m) + 1900 * m) * pow(2, m))
}


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

int main() {
  int64_t n,m;
  cin>>n>>m;
  if(n>1&&m==1){
  cout<<n-2<<endl;
  }
  if(n==1&&m>1){
  cout<<m-2<<endl;
  }
  if(n==1&&m==1){
  cout<<1<<endl;
  }
  if(n>1&&m>1){
  cout<<(n-2)*(m-2)<<endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	fmt.Println(abc049c(s))
}

func abc049c(s string) string {
	for 0 != len(s) {
		if len(s) >= 5 {
			switch s[len(s)-5:] {
			case "dream", "erase":
				s = s[:len(s)-5]
				continue
			}
		}
		if len(s) >= 6 {
			switch s[len(s)-6:] {
			case "eraser":
				s = s[:len(s)-6]
				continue
			}
		}
		if len(s) >= 7 {
			switch s[len(s)-7:] {
			case "dreamer":
				s = s[:len(s)-7]
				continue
			}
		}
		return "NO"
	}
	return "YES"
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  int i,k=0;
  cin>>s>>t;
  if(s[0]==t[0]) k++;
  if(s[1]==t[1]) k++;
  if(s[2]==t[2]) k++;
  cout<<k<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
using P = std::pair<int, int>;


int main() {
    int W, H;
    while(cin >> W >> H, W) {
        vector<vector<char>> tile(W, vector<char>(H));
        vector<vector<int>> ret(W, vector<int>(H));
        queue<P> que;
        for(int i=0; i<H; ++i) {
            for(int j=0; j<W; ++j) {
                cin >> tile[j][i];
                if(tile[j][i] == '@') {
                    que.push(make_pair(j, i));
                    ret[j][i] = 1;
                }
            }
        }
        int dx[4] = {0, 1, 0, -1};
        int dy[4] = {1, 0, -1, 0};
        while(!que.empty()) {
            P p = que.front();
            que.pop();
            for(int i=0; i<4; ++i) {
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];
                if(nx >= 0 && nx < W && ny >= 0 && ny < H && tile[nx][ny] != '#' && ret[nx][ny] == 0) {
                    ret[nx][ny] = ret[p.first][p.second] + 1;
                    que.push(make_pair(nx, ny));
                }
            }
        }
        int ans = 0;
        for(int i=0; i<H; ++i) {
            for(int j=0; j<W; ++j) {
                if(ret[j][i] != 0) {
                    ans += 1;
                }
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;


char s[110];
char s1[100];
char s2[100];
int main()
{
    int n;
    cin >> n;
    cin >> s;
    
    int len = strlen(s);
    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }else{
        for(int i=0;i<len/2;i++){
            s1[i] = s[i];
        }
        for(int i=0;i<len/2;i++){
            s2[i] = s[i + len/2];
        }

         

        for(int i=0;i<len/2;i++){
            if(s1[i] != s2[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;


    }

    return 0;
}


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

int main(){
    int n,s[13],h[13],c[13],d[13],rank;
    for(int i=0;i<13;i++){
        s[i]=0;
        h[i]=0;
        c[i]=0;
        d[i]=0;
    }
    char str[2];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>str[0]>>rank;
        if(str[0]=='S')s[rank-1]=1;
        else if(str[0]=='H')h[rank-1]=1;
        else if(str[0]=='C')c[rank-1]=1;
        else d[rank-1]=1;
    }
    for(int i=0;i<13;i++){
        if(s[i]!=1)cout<<"S "<<i+1<<endl;
    }
    for(int i=0;i<13;i++){
        if(h[i]!=1)cout<<"H "<<i+1<<endl;
    }
    for(int i=0;i<13;i++){
        if(c[i]!=1)cout<<"C "<<i+1<<endl;
    }
    for(int i=0;i<13;i++){
        if(d[i]!=1)cout<<"D "<<i+1<<endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <string.h>
#include <map>
#include <queue>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll a;
map<string,ll> res;

int main()
{
    string s="01234567";
    queue<string> q;
    q.push(s);
    res[s]=1;
    while (!q.empty()) {
        string cur=q.front();
        q.pop();
        ll idx=0;
        for (ll i=0;i<8;i++) {
            if (cur[i]=='0') {
                idx=i;
                break;
            }
        }
        if (idx!=0&&idx!=4) {
            string tmp=cur;
            swap(tmp[idx],tmp[idx-1]);
            if (res[tmp]==0) {
                q.push(tmp);
                res[tmp]=res[cur]+1;
            }
        }
        if (idx!=3&&idx!=7) {
            string tmp=cur;
            swap(tmp[idx],tmp[idx+1]);
            if (res[tmp]==0) {
                q.push(tmp);
                res[tmp]=res[cur]+1;
            }
        }
        if (idx<4) {
            string tmp=cur;
            swap(tmp[idx],tmp[idx+4]);
            if (res[tmp]==0) {
                q.push(tmp);
                res[tmp]=res[cur]+1;
            }
        }
        if (idx>=4) {
            string tmp=cur;
            swap(tmp[idx],tmp[idx-4]);
            if (res[tmp]==0) {
                q.push(tmp);
                res[tmp]=res[cur]+1;
            }
        }
    }
    while (true) {
        string t;
        for (ll i=0;i<8;i++) {
            if (!(cin >> a)) return 0;
            t+=a+'0';
        }
        printf("%lld\n",res[t]-1);
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	ll ans,befor;
	for(int i = 0; i < n; i++){
		if(i == 0){
			if(s[i] == t[i]){
				ans = 3;
				befor = 0;
			}else{
				ans = 6;
				befor = 1;
				i++;
			}
		}else{
			if(befor){
				if(s[i] == t[i]){
					ans *= 1;
					befor = 0;
				}else{
					ans *= 3;
					befor = 1;
					i++;
				}
			}else{
				if(s[i] == t[i]){
					ans *= 2;
					befor = 0;
				}else{
					ans *= 2;
					befor = 1;
					i++;
				}
			}
		}
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
   long c,s;
   long all;

   cin >> s >> c;

   all = s*2+c;

   if(c >= all/4*2) {
       cout << all/4 << endl;
   } else {
       cout << c/2 <<endl;
   }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>


using namespace std;
using ll = long long;

int N;
vector <ll> a(200001);
vector <ll> b(200001);
int sumball;

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i + 1];
	}
	for (int i = N; i >= 1; i--)
	{
		int k = i * 2, cnt = 0;
		while (k <= N)
		{	
			if (b[k] == 1) cnt++;
			k += i;
		}
		if (cnt % 2 == a[i]) continue;
		else
		{
			b[i] = 1;
			sumball++;
		}
	}
	cout << sumball << endl;
	for (int i = 1; i <= N; i++)
	{
		if (b[i] == 1) cout << i << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int s[n];
    for (int i=0; i<n; i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    int t[q];
    int ans=0;
    for (int i=0; i<q; i++){
        cin >> t[i];
        if (*lower_bound(s,s+n,t[i])==t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


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

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

  vector<int> ans(N);
  N--;
  while(N-->0){
    int a;
    cin >> a;
    a--;
    ans[a]++;
  }
  
  for(int elem:ans)
    cout << elem << endl;
}

Measured memory_bytes: 4052
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x==3||x==5||x==7){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
    
  }
  

  
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N,M;
int table[55];

int main(){

	scanf("%d %d",&N,&M);

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

		table[i] = 0;
	}

	int from,to;

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

		scanf("%d %d",&from,&to);
		from--;
		to--;

		table[from]++;
		table[to]++;
	}

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

		printf("%d\n",table[i]);
	}

	return 0;
}


Measured memory_bytes: 3824
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto M = RD;
	auto H = RDA;
	auto edges = new long[][](N);
	foreach (i; 0..M)
	{
		auto A = RD-1;
		auto B = RD-1;
		edges[A] ~= B;
		edges[B] ~= A;
	}

	long ans;
	foreach (i; 0..N)
	{
		auto x = H[i];
		bool ok = true;
		foreach (to; edges[i])
		{
			auto y = H[to];
			if (y >= x)
				ok = false;
		}
		if (ok)
			++ans;
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 19664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    int x1 = sum;
    for ( int i = 1; i < n; ++i ) {
        if ( i % 2 == 1 ) x1 -= 2 * a[i];
    }
    vector<ll> x(n);
    x[0] = x1;
    for ( int i = 1; i < n; ++i ) {
        x[i] = 2 * a[i-1] - x[i-1];
    }
    rep(i, n) {
        printf("%lld ", x[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<class T, class ...Tail>
void tiedSort(vector<T> &a, vector<Tail>&... tail) {
	int n = a.size();
	using S = tuple<T, Tail...>;
	vector<S> s(n);
	for (int i = 0; i < n; i++)
		s[i] = make_tuple(a[i], tail[i]...);
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++)
		tie(a[i], tail[i]...) = s[i];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> A(N), B(N); rep(i, 0, N) {
		cin >> A[i] >> B[i];
	}
	int sumB = accumulate(all(B), 0LL);
	vector<int> d(N);
	rep(i, 0, N)
		d[i] = A[i] - B[i];
	tiedSort(d, A, B);

	int minB = INF;
	bool end = true;
	rep(i, 0, N) {
		if (A[i] != B[i])end = false;
		if (A[i] > B[i])chmin(minB, B[i]);
	}
	if (end) {
		cout << 0 << endl;
		return 0;
	}
	cout << sumB - minB << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007;
#define MOD2 998244353;
#define INF ((1<<30)-1);
#define LINF (1LL<<60);
#define EPS (1e-10);
typedef long long Int;
typedef pair<Int, Int> P;

#define PI 3.141592653589793

int main() {
    double n;
    cin >> n;
    printf("%.10lf\n", 2*n*PI);
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int n;
vector<int> a;


int solve (int i, int m) {
  if (m == 0) return 1;
  if (i >= n) return 0;
  int res = solve(i+1, m) || solve(i+1, m-a[i]);
  return res;
}

int main() {
  int q;
  cin >> n;
  rep(i, n) {
    int ai;
    cin >> ai;
    a.push_back(ai);
  }
  cin >> q;
  rep(i, q) {
    int mi;
    cin >> mi;
    if (solve(0, mi)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3168
def f(x1,y1,x2,y2,x3,y3,x4,y4):
    p = (x3 - x4) * (y1 - y3) + (y3 - y4) * (x3 - x1)
    q = (x3 - x4) * (y2 - y3) + (y3 - y4) * (x3 - x2)
    r = (x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3)
    s = (x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4)
    return p * q < 0 and r * s < 0

while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split(','))
    except EOFError:
        break
    if f(x1,y1,x3,y3,x2,y2,x4,y4):
        print('YES')
    else:
        print('NO')

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

int main() {
    int n; cin >> n;
    long long pair[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> pair[i][j];
        }
    }
    vector<long long> dp((1<<n), 0);
    for (int bit = 0; bit < (1 << n); bit++) {
        bitset<16> b = bit;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if (b[i] && b[j]) {
                    dp[bit] += pair[i][j];
                }
            }
        }
    }
    for (int k = 2; k <= n; k++) {
        for (int bit = 0; bit < (1 << n); bit++) {
            bitset<16> b = bit;
            if (b.count() != k) continue;
            for (int bit2 = bit; bit2 > 0; bit2 = (bit2-1)&bit) {
                dp[bit] = max(dp[bit], dp[bit2]+dp[bit^bit2]);
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

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

if K % 2 != 0:
    if N >= K:
        print(int(N // K) ** 3)
    else:
        print(0)
else:
    if N >= K:
        ans = int(N // K) ** 3 + int(N // (K // 2) - (N // K)) ** 3
        print(ans)
    else:
        if 2 * N >= K:
            print(1)
        else:
            print(0)

Measured memory_bytes: 3060
from itertools import product

A, B, C, D, E, F = map(int, input().split())
conc = 0
water, sugar = 100*A, 0
for i, j in product(range(F // (100*A) + 1), range(F // (100*B) + 1)):
    wt = 100*(A*i + B*j)
    if wt > F or wt == 0:
        continue
    rem = F - wt
    for k, l in product(range(rem // C + 1), range(rem // D + 1)):
        sg = C*k + D*l
        sugar_water = wt + sg
        if sg <= wt*E // 100 and 0 < sugar_water <= F:
            temp = 100*sg/sugar_water
            if conc < temp:
                conc = temp
                water, sugar = wt, sg
print(water+sugar, sugar)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,k;
	int pat;
	scanf("%d%d",&n,&k);
	pat = k;
	for (int i = 1; i < n; ++i)	pat *= (k - 1);
	printf("%d\n", pat);
	return 0;
}


Measured memory_bytes: 128
abses = []

loop do
  n = gets.to_i
  break if n.zero?

  as = gets.split.map(&:to_i)
  min_abs = 1_001_001_001

  as.combination(2) do |a|
    min_abs = [min_abs, a.inject(:-).abs].min
  end

  abses << min_abs
end

abses.each do |abs|
  p abs
end



Measured memory_bytes: 6872
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  var k = o.a();
  var c = 100;
  var ans;
  for(var i = 0; i < k;){
    if(a % c === 0 && b % c === 0)ans = c, i++;
    c--;
  }
  return ans;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int difx=(x2-x1), dify=(y2-y1);
  int x3=x2-dify, y3=y2+difx, x4=x3-difx, y4=y3-dify;

  printf("%d %d %d %d\n", x3, y3, x4, y4);
}

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

using namespace std;

void b()
{
	int n, k;
	cin >> n >> k;
	int count = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t >= k) {
			count++;
		}
	}
	cout << count << endl;
}

int main()
{
	b();
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = a ; i <= b ; ++ i)
#define per(i,a,b) for (int i = a ; i >= b ; -- i)
#define pii pair < int , int >
#define X first
#define Y second
#define rint read<int>
#define int long long

using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
        while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
   return f * x ;
}

int m , d , ans ;

signed main() {
    scanf ("%lld%lld" , & m , & d ) ;
    for (int i = 1 ; i <= m ; ++ i)
        for (int j = 10 ; j <= d ; ++ j) {
            int t1 = j % 10 , t2 = j / 10 ;
            if ( t1 >= 2 && t2 >= 2 && t1 * t2 == i )
                ++ ans ;
        }
    printf ("%lld\n" , ans ) ; 
    return 0 ;
}

Measured memory_bytes: 256
h,w,a,b=map(int,input().split())
inv=[0]*(2*max(h,w)+1)
fact=[0]*(2*max(h,w)+1)
inv[0]=1;fact[0]=1
mod=10**9+7
for i in range(1,2*max(h,w)+1):
    fact[i]=fact[i-1]*i%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(2*max(h,w),0,-1):
    inv[i-1]=inv[i]*i%mod
ans=0
for yoko in range(b+1,w+1):
    re=fact[yoko-1+h-1-a]*inv[h-1-a]*inv[yoko-1]%mod
    rr=fact[w-yoko+a-1]*inv[w-yoko]*inv[a-1]%mod
    ans=(ans+re*rr%mod)%mod
print(ans)

Measured memory_bytes: 18804
n = int(input())
s = {}
mx = 0
for i in range(n):
    c = input()
    if c in s:
        s[c] += 1
    else:
        s[c] = 1
    mx = max(s[c], mx)
res = []

for key in s:
    if s[key] == mx:
        res.append(key)
for c in sorted(res):
    print(c)

Measured memory_bytes: 33072