akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(void) {
  int X;
  int A;
  int B;
  cin >> X >> A >> B;
  int ans = X - A;
  cout << ans % B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(void){
    int n=0;
    int w[100]={0};
    int s1=0;
    int s2=0;
    int min=0;
    int num=0;

    cin >> n;

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

    for(int i=0;i<n-1;i++){
        s1+=w[i];
        for(int j=i+1;j<n;j++){
            s2+=w[j];
        }
        num=abs(s1-s2);
        if(i==0)min=num;
        if(min>=num)min=num;
        s2=0;
    }

    cout << min << endl;

    return 0;
}

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

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

    // solve
    set<int> A;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (A.find(a) != A.end()) A.erase(a);
        else A.insert(a);
    }

    // output
    cout << A.size() << endl;

    return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays; 
class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		String str = a.substring(0,1) + b.substring(0,1) + c.substring(0,1);
    	System.out.println(str.toUpperCase());
}
}


Measured memory_bytes: 21972
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    for(int i=0; i*4<=n; ++i){
        for(int j=0; j*7<=n; ++j){
            int x = i * 4 + j * 7;
            if(x == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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


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

typedef int range_t;

struct Range {
	range_t from, to;

	Range() {}
	Range(range_t from, range_t to):from(from), to(to){}
};

bool cmpFrom (const Range& lhs, const Range& rhs) {
	return lhs.from < rhs.from;
}

template<typename numType>
inline bool updateMax(numType& lhs, const numType& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return true;
	}
	return false;
}

int calcRangeCover(vector<Range>& ranges, range_t from, range_t to) {
	const int n = ranges.size();
	sort(ranges.begin(), ranges.end(), cmpFrom);

	range_t cur = from;
	//already covered [from, cur)

	int ans = 0;
	for (int index = 0; cur < to;) {
		range_t nxtTo = cur;
		for (;index < n && ranges[index].from <= cur; ++index) {
			updateMax(nxtTo, ranges[index].to);
		}
		if (cur == nxtTo) {
			return -1;
		}
		++ans;
		cur = nxtTo;
	}

	return ans;
}

int N, M;
vector<Range> ranges;

void init() {
	scanf("%d%d", &N, &M);
	ranges.reserve(M);
	for (int i = 0; i < M; ++i) {
		int from, to;
		scanf("%d%d", &from, &to);
		ranges.push_back(Range(from, to + 1));
	}
}

void solve() {
	int ans = calcRangeCover(ranges, 1, N + 1);
	if (ans < 0) {
		puts("Impossible");
	}
	else {
		printf("%d\n", ans);
	}
}

int main() {
	init();
	solve();

	return 0;
}

Measured memory_bytes: 0
using System;

class Program
{
    public static void Main(string[] args)
    {
        

        int a = int.Parse(Console.ReadLine());

        string[] st1 = Console.ReadLine().Split(' ');
        string[] st2 = Console.ReadLine().Split(' ');

        int b = 0;
        int c = 0;

        int x = 0;
        int y = 0;
        for (int i = 0; i < a;i++){
            b = int.Parse(st1[i]);
            c = int.Parse(st2[i]);

            if(b > c){
                x = x + b;
                y = y + c;
            }

        }

        int ans = x - y;

        if (ans < 0){
            ans = 0;
        }


        Console.WriteLine(ans);
    }
}


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

#define INF 1e9
#define MAX 100005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int a[MAX];
int dp[MAX];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout << dp[n-1];
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;
const int MX = 1000010;

int N, M, K;
ll p3[MX], fact[MX], ifact[MX], inv[MX];

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

int main() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = p3[0] = 1;
    for (int i = 1; i < MX; ++i) {
    	p3[i] = p3[i-1] * 3 % MOD;
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }

	cin >> N >> M >> K;

	if (M > K) {
		swap(M, K);
	}

	ll ret = 0;
	ll la = -1;
	ll p2 = 1;

	for (int t = N; t <= N + M + K; ++t) {
		ll u = 0;

		int tt = t - N;

		if (tt <= M) {
			u = p2;

			if (tt == M) {
				la = p2;
			} else {
				p2 = p2 * 2 % MOD;
			}
		} else if (tt <= K) {
			la = la * 2 % MOD;
			la = (la - comb(tt-1, M)) % MOD;
			if (la < 0) la += MOD;
			u = la;
		} else {
			la = la * 2 % MOD;
			la = (la - comb(tt-1, M)) % MOD;
			la = (la - comb(tt-1, K)) % MOD;
			if (la < 0) la += MOD;
			u = la;
		}

		u = u * p3[N + M + K - t] % MOD * comb(t-1, N-1);	
		ret = (ret + u) % MOD;
	}

	cout << ret << endl;


	return 0;
}

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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(30)<<fixed;

	int d,t,s;
	cin>>d>>t>>s;
	double t1=(double)d/s;
	//cout<<t1<<endl;
	if(t1<=t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=3005;
const int mod=1000000007;

struct node{
	int l,r;
	node(){}
	node(int l,int r):l(l),r(r){}
}a[N];
int n,Q,m,L,R,l,r,x,tot;
int c[N][N],sum[N],dp[N][N];
char s[N];

void init(int n){
	int i,j;
	c[0][0]=1;
	for (i=1;i<=n;i++){
		c[i][0]=1;
		for (j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout); 
	int i,j,k;
	scanf("%d%d",&n,&Q);
	scanf("%s",s+1);
	init(n);
	for (i=1;i<=Q;i++){
		scanf("%d%d",&l,&r);
		if (r<=R) continue;
		a[++tot]=node(l,r);
	}
	for (i=1;i<=n;i=j+1){
		j=i; m++;
		a[m]=a[i];
		while (j<n&&a[j+1].l==a[i].l){
			a[m].r=max(a[m].r,a[j+1].r);
			j++;
		}
		if (a[m].r<=a[m-1].r) m--;
	}
	for (i=1;i<=n;i++) sum[i]=sum[i-1]+(s[i]=='1');
	a[m+1].l=n+1;
	dp[0][sum[a[1].l-1]]=1;
	for (i=1;i<=m;i++){
		L=a[i].l; R=a[i].r; l=a[i+1].l;
		if (l>R){
			for (j=0;j<=n;j++) if (dp[i-1][j]){
				x=sum[R]-j;
				(dp[i][sum[l-1]]+=1ll*dp[i-1][j]*c[R-L+1][x]%mod)%=mod;
			}
			continue;
		}
		for (j=0;j<=n;j++) if (dp[i-1][j]){
			x=sum[R]-j;
			for (k=max(x-R+l-1,0);k<=min(l-L,x);k++)
				(dp[i][j+k]+=1ll*dp[i-1][j]*c[l-L][k]%mod)%=mod;
		}
	}
	printf("%d\n",dp[m][sum[n]]);
	return 0;
}

Measured memory_bytes: 51072
a, b, c = input().split("/")
tmp1, tmp2 = 0, 0
if b[0] == 0:
    tmp1 = int(b[1])
else:
    tmp1 = int(b)
if c[0] == 0:
    tmp2 = int(c[1])
else:
    tmp2 = int(c)
if tmp1 < 5 or tmp1 == 4 and tmp2 == 30 or tmp1 == 4 and tmp2 == 31:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*--------------------------------------------------------------------*/

vi cnt(13,0);
string ans="";


signed main(){
  int n;
  cin>>n;
  vi cnt(13,0);
  string ans="";

  int len=0;
  for(int i=1;i<12;i++){
    
    cnt[i]=pow(26,i)+cnt[i-1];
    // cout<<cnt[i]<<endl;
  }

  for(int i=1;i<12;i++){
    if(n<=cnt[i]){
      len=i;
      break;
    }
  }
  rep(i,len){
    if(n%26==0){
      ans+='z';
    }else{
      ans+='a'+n%26-1;
    }
    n--;
    n/=26;

  }
  reverse(all(ans));
  cout<<ans<<endl;

  return 0;
}


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

const int M=100;
int a[M];

int main()
{
	int n; scanf("%d",&n);
	n*=2;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i+=2)
		ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void QuickSort(int arr[],int l,int h)
{
	if(!(l<h))
		return;
	int m,tmp=arr[l];
	int low=l,high=h;
	while(low<high)
	{
		while(arr[high]>=tmp&&high>low)high--;
		if(high>low)
		    arr[low++]=arr[high];
		while(arr[low]<=tmp&&high>low) low++;
		if(high>low)
		    arr[high--]=arr[low];
	}
	m=low;
	arr[m]=tmp;
	QuickSort(arr,l,m-1);
	QuickSort(arr,m+1,h);
} 
int main()
{
	int s=0,a[100],n=0,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	QuickSort(a,0,n-1);
	for(i=0;i<n;i++)
	{
		if(a[i]!=a[i+1])
			s++;
	} 
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

q = deque([0])
b = [0] * n
while q:
    x = q.popleft()
    for i in g[x]:
        if b[i] != 0:
            continue
        b[i] = x + 1
        q.append(i)

if 0 in b[1:]:
    print("No")
else:
    print("Yes")
    print(*b[1:], sep="\n")

Measured memory_bytes: 39192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<ll> a(3001, 0);

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
    
    ll ans = 0;
    for(int i = 0; i < N; ++i) ans += a[i] - 1;
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
//半分全列挙
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)

int main(void){
	int n, b;
	cin >> n >> b;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(all(s));
	rep(i, n) cout << s[i];
	printf("\n");

	return 0;
}



Measured memory_bytes: 256
N = int(input())
stack = [(0, 0)]
ans = 0
while stack:
  s = stack.pop()
  if s[0] > N:
    continue
  if s[1] == 7:
    ans += 1
  stack.append((s[0] * 10 + 3, s[1] | 1))
  stack.append((s[0] * 10 + 5, s[1] | 2))
  stack.append((s[0] * 10 + 7, s[1] | 4))
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
a, b = [int(i) for i in input().split()]

if b == 1:
    ans = 0
else:
    ans = 1
    count = a
    while True:
        if count >= b:
            break
        else:
            #count = count - 1 + a
            count += (a - 1)
            ans += 1
print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;

class Program
{
    public void Proc()
    {
        string[] inpt = Console.ReadLine().Split(' ');
        long a = long.Parse(inpt[0]);
        long b = long.Parse(inpt[1]);

        long num1 = a / b;
        long num2 = a % b;
        decimal num3 = (decimal)a / b;
        Console.WriteLine(num1 + " " + num2 + " " + num3);
    }



    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9044
a=input()
len_a=len(a)
#maxpoint=len_a * (len_a+1) / 2
point=0
howmany_w=0
for a_n in range(len(a)):
	if a[a_n]=='W':
		point+=(len_a-a_n)
		howmany_w+=1

maxpoint = (len_a - howmany_w/2 + 1/2) * (howmany_w)

kaisu=maxpoint-point
print(int(kaisu))

Measured memory_bytes: 3500
#include<stdio.h>
int main()
{
  int x[10000],j, count=0;
int i;

  for(i=1; i<=10000; i++) {
    scanf("%d",&x[i]);
    if(x[i]==0){ break;
    }
    count++;
  }

  for(i=1; i<=count; i++) {
    printf("Case %d: %d\n" ,i ,x[i]);
  }

  return 0;
}

Measured memory_bytes: 636
str = input()
num0,num1 = 0,0
for i in range(len(str)):
	if str[i] == '0':
		num0 += 1
	elif str[i] == '1':
		num1 += 1
if num1 >= num0:
	count = num0*2
	print(count)
else:
	count = num1*2
	print(count)

Measured memory_bytes: 3188
#include<stdio.h>
int selectionSort(int A[], int N){
int i, j, t, sw = 0, minj;
for(i =0; i < N - 1; i++){
minj = i;
for(j = i; j < N; j++){
if(A[j] < A[minj]) minj = j;
}
t = A[i]; A[i] = A[minj]; A[minj] = t;
if(i != minj) sw++;
}
return sw;
}
int main(){
int A[100], N, i, sw;
scanf("%d", &N);
for(i = 0; i < N; i++) scanf("%d", &A[i]);
sw = selectionSort(A, N);
for(i = 0; i < N; i++){
if(i > 0) printf(" ");
printf("%d", A[i]);
}
printf("\n");
printf("%d\n", sw);
return 0;
}


Measured memory_bytes: 2704
N=int(input())
L=list(map(int,input().split()))
count=0
for i in range(N):
	if L[i]%2==0:
		if L[i]%3!=0 and L[i]%5!=0:
			count=1
if count==0:
	print("APPROVED")
else:
	print("DENIED")

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a[4];
	int i;
	for(i=0;i<3;i++){  	scanf("%d",&a[i]);  }
	if(a[0]+a[1]+a[2]>=22)    	 {  printf("bust");}  
	else    {   printf("win");}  
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
  cin>>n>>a>>b;
  if(a*n<=b)
  {
    cout<<a*n<<"\n";
  }
  else
  {
    cout<<b<<"\n";
  }
    return 0;
}


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

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    if (s != 1e+9){
        rep(i,k) cout << s << " ";
        rep(i,n-k) cout << s + 1 << " ";
    }
    else{
        rep(i,k) cout << s << " ";
        rep(i,n-k) cout << 1 << " ";
    }
}

Measured memory_bytes: 1280
import std.stdio;
import std.array;
import std.conv;


void main()
{
    auto op = ['+', '-', '*'];
    
    while (true) {
        auto flag = false;
        auto num = readln.split.to!(int[]);
        if (num[] == [0, 0, 0, 0]) break;
        
    loop:
        foreach (i; 0..3) {
            foreach (j; 0..3) {
                foreach (k; 0..3) {
                    foreach (a; 0..4) {
                        foreach (b; 0..4) {
                            if (b == a) continue;
                            foreach (c; 0..4) {
                                if (c == a || c == b) continue;
                                foreach (d; 0..4) {
                                    if (d == a || d == b || d == c) continue;
                                    if (cal(k, cal(j, cal(i, num[a], num[b]), num[c]), num[d]) == 10) {
                                        writefln("(((%d %c %d) %c %d) %c %d)", num[a], op[i], num[b], op[j], num[c], op[k], num[d]);
                                        flag = true;
                                        break loop;
                                    }
                                    if (cal(k, cal(i, num[a], cal(j, num[b], num[c])), num[d]) == 10) {
                                        writefln("((%d %c (%d %c %d)) %c %d)", num[a], op[i], num[b], op[j], num[c], op[k], num[d]);
                                        flag = true;
                                        break loop;
                                    }
                                    if (cal(i, num[a], cal(j, num[b], cal(k, num[c], num[d]))) == 10) {
                                        writefln("(%d %c (%d %c (%d %c %d)))", num[a], op[i], num[b], op[j], num[c], op[k], num[d]);
                                        flag = true;
                                        break loop;
                                    }
                                    if (cal(i, num[a], cal(k, cal(j, num[b], num[c]), num[d])) == 10) {
                                        writefln("(%d %c ((%d %c %d) %c %d))", num[a], op[i], num[b], op[j], num[c], op[k], num[d]);
                                        flag = true;
                                        break loop;
                                    }
                                    if (cal(j, cal(i, num[a], num[b]), cal(k, num[c], num[d])) == 10) {
                                        writefln("((%d %c %d) %c (%d %c %d))", num[a], op[i], num[b], op[j], num[c], op[k], num[d]);
                                        flag = true;
                                        break loop;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!flag) writeln(0);
    }
}


int cal(const int op, const int n1, const int n2)
{
    switch (op) {
    case 0:
        return n1 + n2;
        break;
    case 1:
        return n1 - n2;
        break;
    case 2:
        return n1 * n2;
        break;
    default:
        writeln("ERROR!");
        return 0;
        break;
    }
}

Measured memory_bytes: 1088
#include<iostream>
#include<vector>
using namespace std;
const int MAX = 100;
const int INF = 10000000;
int n, G[MAX][MAX];
int dis[MAX];
bool Flag[MAX] = { false };
void init()
{
	for (int i = 0; i < n; i++)
		dis[i] = G[0][i];
	Flag[0] = true;
}
void dijkstra()
{
	for (int k = 1; k <= n - 1; k++)
	{
		int min = INF;
		int u;
		for (int j = 0; j < n; j++)
			if (dis[j] > 0 && dis[j] < INF && !Flag[j] && dis[j] < min)
			{
				min = dis[j];
				u = j;
			}
		Flag[u] = true;
		for (int v = 0; v < n; v++)
			if (!Flag[v] && dis[u]+G[u][v] < dis[v])
				dis[v] = dis[u] + G[u][v];
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j)
				G[i][j] = INF;
			else
				G[i][j] = 0;
	for (int i = 0; i < n; i++)
	{
		int u, d;
		cin >> u >> d;
		for (int j = 0; j < d; j++)
		{
			int v, w;
			cin >> v >> w;
			G[u][v] = w;
		}
	}
	init();
	dijkstra();
	for (int i = 0; i < n; i++)
		cout << i << " " << dis[i] << endl;
}



Measured memory_bytes: 3128
# -*- coding: utf-8 -*-


def main():
    # ヒープキューをインポート
    from heapq import heappush, heappop

    n, m = map(int, input().split())
    jobs = [[] for _ in range(m)]  # 締め切り別に，報酬を管理

    # See:
    # https://www.youtube.com/watch?v=1Z6ofKN03_Y
    for i in range(n):
        ai, bi = map(int, input().split())

        # 報酬が振り込まれる日がM日よりも後になる場合は除外
        if ai > m:
            continue

        # i件目のアルバイトを遅くてもいつまでに始める必要があるかを計算
        # heappopは最小値を返す．biを-1倍することで，最大値が取り出せる
        deadline = m - ai
        jobs[deadline].append(-bi)

    ans = 0
    reward = []

    # M-1日に始める必要があるアルバイトのうち，最も報酬の高いものを選択
    # 以降，今日始める必要があるアルバイトまで，順番に調べる
    # ある時点で得られる報酬の大小に着目
    for i in range(m - 1, -1, -1):
        for job in jobs[i]:
            # ヒープキューに，報酬の候補を追加
            heappush(reward, job)

        # 条件を満たすもののうち，最大の報酬を選択
        if reward:
            ans += heappop(reward)

    # ヒープキューに追加するときに，-1倍した分を元に戻す
    print(-ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17600
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    repi(i, q, 0)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            rev = !rev;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
            {
                if (rev)
                {
                    s.insert(s.end(), c);
                }
                else
                {
                    s.insert(s.begin(), c);
                }
            }
            else
            {
                if (rev)
                {
                    s.insert(s.begin(), c);
                }
                else
                {
                    s.insert(s.end(), c);
                }
            }
        }
    }
    if(rev){
        reverse(s.begin(),s.end());
    }
    cout << s << endl;
    return 0;
}

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

const int INF = 1e9;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> w(n), e(n);
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'W')
      w[i] = w[i - 1] + 1;
    else
      w[i] = w[i - 1];
  }

  for (int i = n - 2; i >= 0; i--) {
    if (s[i + 1] == 'E')
      e[i] = e[i + 1] + 1;
    else
      e[i] = e[i + 1];
  }

  int ans = INF;
  rep(i, n) ans = min(ans, w[i] + e[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
n, m, c = gets.chomp.split(" ").map(&:to_i)
arB = gets.chomp.split(" ").map(&:to_i)

arA = []
n.times do
  arA << gets.chomp.split(" ").map(&:to_i)
end

ans = 0

for i in 0..(n-1) do
  sum = 0
  for j in 0..(m-1) do
    sum += arA[i][j] * arB[j]
  end
  sum += c
  if sum > 0 then
    ans += 1
  end
end

puts ans


Measured memory_bytes: 1788
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int s,w;
	cin >> s >> w;
	if(w>=s)cout << "unsafe" << endl;
	else cout << "safe" << endl;
}	


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

int mod_pow(int x, int n, int mod) {
	int res = 1;
	while (n > 0) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		mp[a]++;
	}

	auto zero = [&]() {
		cout << 0 << endl; exit(0);
	};

	if (n % 2) {
		if (mp[0] != 1) zero();
		for (int i = 2; i <= n - 1; i += 2) {
			if (mp[i] != 2)zero();
		}
	}
	else {
		for (int i = 1; i <= n - 1; i += 2) {
			if (mp[i] != 2)zero();
		}
	}

	cout << mod_pow(2, n / 2, mod) << endl;

	return 0; 
}

Measured memory_bytes: 4224
def main():
    N = int(input())
    T = 1
    A = 1
    for _ in range(N):
        t, a = map(int, input().split())
        m1 = -(-T//t)
        m2 = -(-A//a)
        T1, T2 = min(m1, m2) * t, max(m1, m2) * t
        A1, A2 = min(m1, m2) * a, max(m1, m2) * a
        if T <= T1 and A <= A1:
            T = T1
            A = A1
        else:
            T = T2
            A = A2
    print(T+A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
#Satoooh 
H, W = map(int, input().split())
S = [input() for _ in range(H)]

# そのマスを含めてLeft, Right, Up, Downにそれぞれ何マス分明かりを照らせるかを配列に記録
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == ".":
			if j == 0:
				L[i][j] = 1
			else:
				L[i][j] = L[i][j - 1] + 1

for i in range(H):
	for j in range(W - 1, -1, -1):
		if S[i][j] == ".":
			if j == W - 1:
				R[i][j] = 1
			else:
				R[i][j] = R[i][j + 1] + 1

for j in range(W):
	for i in range(H - 1, -1, -1):
		if S[i][j] == ".":
			if i == H - 1:
				D[i][j] = 1
			else:
				D[i][j] = D[i + 1][j] + 1

for j in range(W):
	for i in range(H):
		if S[i][j] == ".":
			if i == 0:
				U[i][j] = 1
			else:
				U[i][j] = U[i - 1][j] + 1


ans = 0
X = [[0] * W for _ in range(H)]
for i in range(H):
	for j in range(W):
		X[i][j] = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
	ans = max(ans, max(X[i]))

print(ans)

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int x;
  cin >> x;
  int res = x == 0 ? 1 : 0;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3592
from collections import deque
s, t = [0, 0], [0, 0]
s[0], s[1], t[0], t[1] = map(int, input().split())

dx, dy = t[0] - s[0], t[1] - s[1]
ans = deque()

ans.append("U" * (dy))
ans.append("R" * (dx + 1))
ans.append("D" * (dy + 1))
ans.append("L" * (dx + 1))
ans.append("U")

ans.append("L")
ans.append("U" * (dy + 1))
ans.append("R" * (dx + 1))
ans.append("D" * (dy + 1))
ans.append("L" * dx)

print("".join(ans))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const int MOD = ((int)1e9)+7;
const int INF = (int)(1e9)+(int)(1e7);
const ll INFL = (ll)(1e18)+INF;
const double EPS = 1e-8;
using namespace std;
int main()
{
    string S,T;
    int A,B;
    string U;
    cin >> S >> T >> A >> B >> U;
    if(U==S){cout << A-1 << " " << B << endl;}
    else{cout << A << " " << B-1 << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
char s[10];
int vis[MAXN], cnt[MAXN];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; cin >> n >> m;
  int ans1 = 0, ans2 = 0;
  for (RI i = 1; i <= m; ++i) {
    int num; cin >> num;
    cin >> s;
    if (s[0] == 'W')
      cnt[num] += !vis[num];
    else {
      ans1 += !vis[num];
      vis[num] = 1;
    }
  }
  for (RI i = 1; i <= n; ++i)
    if (vis[i]) ans2 += cnt[i];
  printf("%d %d\n", ans1, ans2);

  return 0;
}


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

def bfs(start):
    checked = [False]*N
    q = [start]
    c = -1
    while q:
        qq = []
        c += 1
        for p in q:
            for np in graph[p]:
                if not checked[np]:
                    checked[np] = True
                    qq.append(np)
        if not qq:
            break
        q = qq
    return c, q

_, q = bfs(0)
d, _ = bfs(q[0])
if d%3 == 1:
    print('Second')
else:
    print("First")

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

const long long TOO_MUCH = 1000000000000000000LL;

long long A[100005];

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

    long long ans = 1;

    for(int i = 0; i < N; i ++){
        scanf("%lld", &A[i]);
        if(A[i] == 0){
            printf("0");
            return 0;
        }
    }

    for(int i = 0; i < N; i ++){
        long long temp = A[i];
        if((double)temp*(double)ans > 1.1e18){
            ans = -1;
            break;
        }else{
            ans = ans*temp;
        }
    }

    if(ans > TOO_MUCH){ans = -1;}
    printf("%lld\n", ans);
}


Measured memory_bytes: 4516
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define vvi(dt) vector<vector<dt>>
#define vec vector<int>
#define un unsigned
#define mp(x,y) make_pair(x,y)
#define dbl double
#define wking(t) cout<<"Working "<<t<<endl;
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define min2(a,b) (a)<(b)?(a):(b)
#define eps 0.000000001
#define inf 100000000000000001
using namespace std;

ll f(int n,int V,ll w[],int v[],vvi(ll) &dp,vvi(bool) &vis)
{
    // cout<<n<<" "<<V<<endl;
    if(V<0) return inf;
    if(V==0) return 0;
    if(n<=0) return inf;
    if(vis[n][V]) return dp[n][V];

    vis[n][V] = true;
    ll val1 = f(n-1,V-v[n],w,v,dp,vis);
    ll val2 = f(n-1,V,w,v,dp,vis);
    dp[n][V] = min2(min2(w[n]+val1, val2),inf);

    // wking(dp[n][V]);
    // cout<<n<<" "<<V<<" "<<dp[n][V]<<endl;
    return dp[n][V];
}


int calc(int n,ll W,ll w[],int v[])
{
    int sum=0;
    loop(i,1,n+1) sum += v[i];
    vvi(ll) dp(n+1,vector<ll> (sum+1,inf));
    vvi(bool) vis(n+1,vector<bool> (sum+1,false));
    dp[0][0] = 0;
    vis[0][0] = true;
    int ans=0;
    loop(i,1,sum+1)
    {
        // cout<<f(1,30,w,v,dp,vis)<<endl;
        if(f(n,i,w,v,dp,vis)<=W) ans = i;
    }
    return ans;
}

int main()
{
    int n; ll W;
    cin>>n>>W;
    ll w[n+1];
    int v[n+1];
    w[0] = 0;
    v[0] = 0;
    loop(i,0,n) cin>>w[i+1]>>v[i+1];
    cout<<calc(n,W,w,v)<<endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int arr[n][3];
  for(int i=0; i<n; i++)
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  int cost[n][3];
  cost[0][0] = arr[0][0];
  cost[0][1] = arr[0][1];
  cost[0][2] = arr[0][2];
  for(int i=1; i<n; i++){
    cost[i][0] = arr[i][0] + max(cost[i-1][1], cost[i-1][2]);
    cost[i][1] = arr[i][1] + max(cost[i-1][0], cost[i-1][2]);
    cost[i][2] = arr[i][2] + max(cost[i-1][1], cost[i-1][0]);
  }
  int r = max(cost[n-1][0], max(cost[n-1][1], cost[n-1][2]));
  cout<<r;
}

Measured memory_bytes: 2688
#include <stdio.h>

int main(void)
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  int ans;
  if (c <= a + b + 1)
    ans = b + c;
  else
    ans = b + a + b + 1;

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

  return 0;
}

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

int main(){
	int k; 
  	cin >> k;
	int count = 1, x = 7;
	
  	while(x % k){
		count++;
		x *= 10;
      	x += 7;
      
		if(count > 1e6 + 1){
          break;
        }
		x %= k;
	}
  
	if(x % k){
      cout << -1;
    }
	else{
      cout << count;
    }
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>

#define long long long

using namespace std;



int main(){

    int r,g,b,N;

    cin >> r >> g >> b >> N;

    int maxv = max(max(r,g),b);

    int minc = N / maxv;

    int count = 0;

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(N >= i * r + j * g && (N - i * r - j * g) % b == 0) count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
/*
   TASK: nocows
   LANG: C++14
 */

#include "bits/stdc++.h"
typedef long long ll;
typedef long double ld;

using namespace std;
#define finish(x) return cout << x, 0;

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

const string USCAO_TAG = "nocows";
void usaco() { setIn(USCAO_TAG + ".in"); setOut(USCAO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	((std::cout << args << " "), ...);
}
*/
ll a[100001];
ll dp[100001][2];

int main() {
	//usaco();
	#ifndef ONLINE_JUDGE
	//setIn("in.txt");
	#endif

	int n;
	cin >> n;


	memset(dp, 0, sizeof dp);
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	a[0] = a[1];

	dp[n][1] = abs(a[n] - a[n - 1]);
	if(n > 1) dp[n][0] = abs(a[n] - a[n - 2]);

	for(int i = n - 1; i >= 1; i--){
		dp[i][1] = dp[i + 1][1] + abs(a[i] - a[i - 1]);
		if(i + 2 <= n) dp[i][1] = min(dp[i][1], dp[i + 2][0] + abs(a[i] - a[i - 1]));
		if(i - 2 >= 0) dp[i][0] = dp[i + 1][1] + abs(a[i] - a[i - 2]);
		if(i + 2 <= n && i - 2 >= 0) dp[i][0] = min(dp[i][0], dp[i + 2][0] + abs(a[i] - a[i - 2]));
	}

	cout << dp[1][1];
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main() {
	int N, *p;
	int P1, I1, P2, I2;
	int ans = 0;	//YESと表示

	//Nとp1からpnの読み込み
	scanf("%d", &N);

	p = calloc(N, sizeof(int));
	for (int i = 0; i < N; i++)
		scanf("%d", &p[i]);

	for (int i = 1; i < N; i++) {
		//順番の入れ替わり一つ目があったとき
		if (p[i - 1] > p[i]) {
			P1 = p[i - 1];
			I1 = i - 1;
			ans = 1;	//NOの表示に切り替えておく。順番の入れ替わりが1つのみのとき、NOと表示されるようになる。

			for (int j = I1 + 2; j < N; j++) {
				//順番の入れ替わり二つ目があったとき
				if (p[j - 1] > p[j]) {
					P2 = p[j];
					I2 = j;

					p[I1] = P2;
					p[I2] = P1;
					ans = 0;	//YESの表示に切り替えておく。

					for (int k = I1; k < N; k++) {
						if (p[k - 1] > p[k]) {
							ans = 1;
							break;
						}
					}
					break;
				}
			}
			break;
		}
	}
	ans == 0 ? printf("YES") : printf("NO");
}

Measured memory_bytes: 128
#include<cstdio>
typedef long long int ll;
int main(){
	ll n,k,ans = 0;
	scanf("%lld%lld",&n,&k);
	if(k==0){
		ans = n*n;
		printf("%lld\n",ans);
		return 0;
	}
	for(int i=k+1;i<=n;i++){
		ll m = (n+1)/i;
		ans += (i-k)*m;
		ll t = n+1-m*i-k;
		if(t>0) ans += t;
	}
	printf("%lld\n",ans);
}


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

if a ** 2 * b / 2 <= x:
    theta = math.atan(2 * b / a - 2 * x / (a ** 3))
    print(180 * theta / math.pi)
else:
    theta = math.pi / 2 - math.atan(2 * x / (a * b ** 2))
    print(180 * theta / math.pi)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string S;
  cin>>S;
  long long ans=0,cnt=0;
  int n=S.length();
  for(int i=0;i<n;i++){
    if(S[i]=='W'){
      ans+=i-cnt;
      cnt++;
    }
  }
  cout<< ans <<endl;
}



Measured memory_bytes: 640
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]


z = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] > A[j]:
            z += 1

y = 0
for a1 in A:
    for a2 in A:
        if a1 > a2:
            y+=1

mod = 10**9 + 7

ans = z * (K) + y * (K) * (K-1)//2
print(ans % mod)



Measured memory_bytes: 3316
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	string a,b,res = "No";
	cin >> a >> b;
	string s = a+b;
	int i,ab = stoi(s);
	for(i = 1; i< 100100; i++){
		if(i*i == ab){
			res = "Yes";
			break;
		}
	}
	cout << res << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e6 + 9;
bitset<maxn> num;
vector<int> prime;
inline void init(int n)
{
    for (int i = 2; i <= n; ++i)
    {
        if (!num[i])
        {
            prime.push_back(i);
        }
        for (int j = 0; j < prime.size(); ++j)
        {
            if (i * prime[j] >= n)
                break;
            num[i * prime[j]] = 1;
            if (i % prime[j] == 0)
                break;
        }
    }
}
vector<ll> v;
unordered_map<ll, int> ump;
int main()
{
    init(1000000);
    int sz = prime.size();
    //cout << sz << endl;
    int n;
    ll maxx = 0;
    read(n);
    bool flag = true;
    for (int i = 1; i <= n; ++i)
    {
        ll x;
        maxx = max(maxx, x);
        read(x);
        ump[x]++;
        v.emplace_back(x);
    }
    for (int i = 0; i < sz; ++i)
    {
        int tot = 0;
        for (int j = 1;; ++j)
        {
            if (1LL * j * prime[i] > 1LL * maxx)
                break;
            tot += ump[j * prime[i]];
        }
        if (tot > 1)
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    ll g = v[0];
    for (int i = 1; i < n; ++i)
        g = __gcd(g, v[i]);
    if (g == 1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 50992
#include<bits/stdc++.h>
using namespace std;
main()
{
	int t,p[2],pp;
	p[0]=0;
	p[1]=0;
	scanf("%d",&t);
	for(int i = 0;i < t;i++)
	{
		scanf("%d",&pp);
		p[pp%2]++;
	}
	if(p[1]%2==1)
	printf("NO");
	else
	printf("YES");
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

int N, A, B;

int main(void) {
  scanf("%d%d%d", &N, &A, &B);
  if (B - A == 1 || (B - A - 1) % 2 == 0)
    printf("Borys\n");
  else
    printf("Alice\n");

  return 0;
}



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

#define ll long long

int main(){
    int N,state = 0,count = 0;
    cin >> N;
    int h[N];
    for(int i = 0; i < N; i++)cin >> h[i];
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < N; j++){
            if(h[j] >= i+1 && !state){
                state = 1;
                count++;
            }else if(h[j] < i+1)state = 0;
        }
        state = 0;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	double x[4],y[4];
	double ab[2],bc[2],cd[2],da[2];
	double abc,bcd,cda,dab;
	while(EOF!=scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
		&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])){
		ab[0]=x[1]-x[0];
		ab[1]=y[1]-y[0];
		bc[0]=x[2]-x[1];
		bc[1]=y[2]-y[1];
		cd[0]=x[3]-x[2];
		cd[1]=y[3]-y[2];
		da[0]=x[0]-x[3];
		da[1]=y[0]-y[3];
		abc=ab[0]*bc[1]-ab[1]*bc[0];
		bcd=bc[0]*cd[1]-bc[1]*cd[0];
		cda=cd[0]*da[1]-cd[1]*da[0];
		dab=da[0]*ab[1]-da[1]*ab[0];
		if(abc*bcd>0&&bcd*cda>0&&cda*dab>0)printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<vector<int> > Graph;
#define rep(i, n) for(int i=0; i<n; i++) 

int main() {
    int N, M;
    cin >> N >> M;
    
    Graph G(N, vector<int>(N, 0));
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        
        G[u][v] = 1;
        G[v][u] = 1;
    }
    
    int array[N-1];
    rep(i, N-1) {
        array[i] = i+1;
    }

    int ans=0;
    
    do {
        int st = 0;
        bool flag;
        
        rep(i, N-1) {
            flag=false;
            if(G[st][array[i]]) flag=true;
            if(!flag) break;
            st = array[i];
        }
        
        if(flag) ans++;
        
    } while(next_permutation(array, array+N-1));

    cout << ans << endl;

    return 0;
    
}

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

using namespace std;
using ll = long long;
int main() {
  while (true) {
    long long n, m;
    cin >> n >> m;
    if (n == 0)
      break;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
      cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        if (ans < a[i] + a[j] && a[i] + a[j] <= m) {
          ans = a[i] + a[j];
        }
      }
    if (ans)
      cout << ans << endl;
    else
      cout << "NONE" << endl;
  }
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n;
vi vals;
LL ans = 0;
int val[111111];
int d[111111];
vi g[111111];
bool was[111111];

priority_queue<ii> stopp;
vector<ii> vert;

void dfs(int v) {
	was[v] = true;
	
	FOREACH(it, g[v]) {
		int u = *it;
		if(was[u]) continue;

		dfs(u);
		ans+= min(val[u], val[v]);
	}
}

void dane() {
	cin>>n;
	F(i,0,n-1) {
		int a,b;
		cin>>a>>b;
		d[a]++;
		d[b]++;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	F(i,0,n) {
		int a;
		cin>>a;
		vals.push_back(a);
	}
	sort(ALL(vals));

	F(i,1,n+1) {
		stopp.push({-d[i], i});
	}

	int idx = 0;
	while(!stopp.empty()) {
		ii v = stopp.top();
		//cout<<v.first<<" "<<v.second<<endl;
		stopp.pop();

		int kto = v.second;
		if(val[kto] == 0) {
			FOREACH(it, g[kto]) {
				int u = *it;
				d[u]--;
				stopp.push({-d[u], u});
			}
			val[kto] = vals[idx++];
		}
	}


	dfs(1);

	cout<<ans<<endl;
	F(i,0,n) cout<<val[i+1]<<" ";cout<<endl;
}   


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            int X = int.Parse(strs[2]);
            var C = new int[N];
            var A = new int[N, M];
            for(int i = 0; i < N; i++)
            {
                line = Console.ReadLine();
                strs = line.Split(' ');
                C[i] = int.Parse(strs[0]);
                for(int j = 1; j <= M; j++)
                {
                    A[i, j-1] = int.Parse(strs[j]);
                }
            }

            int[] Xi = new int[M];
            for (int i = 0; i < M; i++) Xi[i] = 0;
            Money(Xi, C, A, X, M, N, 0, 0);
            Console.WriteLine(Money(Xi, C, A, X, M, N, 0, 0));
        }

        //全部をX以上にしたい
        static int Money(int[] Xi,int[] C,int[,] A, int X, int M,int N, int next, int sum)
        {
            if (N == next)
            {
                //計算するとき
                for(int i = 0; i < Xi.Length; i++)
                {
                    if (Xi[i] < X) return -1;
                }
                return sum;

            }
            // 買わない時
            var notbuy = Money(Xi, C, A, X, M, N, next + 1, sum);
            // 買う時
            //まず足す
            for(int i = 0; i < M; i++)
            {
                Xi[i] += A[next, i];
            }
            var buy = Money(Xi, C, A, X, M, N, next + 1, sum + C[next]);
            for (int i = 0; i < M; i++)
            {
                Xi[i] -= A[next, i];
            }
            if (notbuy == -1) return buy;
            if (buy == -1) return notbuy;
            if (notbuy > buy) return buy;
            return notbuy;
        }
    }
}


Measured memory_bytes: 27524