akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  if (a[0]!=a[1]) cout << a[0] << endl;
  else cout << a[2] << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for(int i = 0; i < M; i++) {
    cin >> p.at(i) >> S.at(i);
  }
  int x, y = 0;
  vector<bool> b(N,false);
  //ACを数える
  for(int i = 0; i < M; i++) {
    if(S.at(i) =="AC" && b.at(p.at(i)-1) == false) {
      x++;
      b.at(p.at(i)-1) = true;
    }
  }
  cout << x << " ";
  vector<bool> bb(N,false);
  vector<bool> bbb(N,false);
  for(int i = 0; i < M; i++) {
    if(S.at(i) == "AC") {
      bbb.at(p.at(i)-1) = true;
    }
  }
  //ペナルティーを数える
  for(int i = 0; i < M; i++) {
    if(S.at(i) == "AC") {
      bb.at(p.at(i)-1) = true;
    }
    if(S.at(i) == "WA" && bb.at(p.at(i)-1) == false && bbb.at(p.at(i)-1) == true) {
      y++;
    }
  }
  cout << y << endl;
}


Measured memory_bytes: 6144
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	while (cin >> H >> W, W > 0)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

map<string, int> mp;

int dfs(string curr) {
  if (mp.find(curr) != mp.end()) return mp[curr];
  if (curr == "6174") return 0;
  string L(curr), S(curr);
  sort(L.rbegin(), L.rend());
  sort(S.begin(), S.end());
  string next = to_string(stoi(L) - stoi(S));
  while (next.size() < 4) next = "0" + next;
  return mp[curr] = dfs(next) + 1;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string N;
  while (cin >> N, N != "0000") {
    if (N[0] == N[1] && N[0] == N[2] && N[2] == N[3]) {
      cout << "NA" << endl;
      continue;
    }
    cout << dfs(N) << endl;
  }

  return 0;
}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long a, b, c; cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << "0" << endl;
	else {
		if(a > b) swap(a, b);
		if(b > c) swap(b, c);
		cout << a * b << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
	int a,b,c,buf;
	cin>>a>>b>>c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 3020
#include<cstdio>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n;
ll fac(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;	
	}
	return res;
}
int main(){
	SF("%d",&n);
	ll ans=(fac(10,n)-fac(9,n)*2ll+fac(8,n))%MOD;
	ans=(ans+MOD)%MOD;
	PF("%lld",ans);
}

Measured memory_bytes: 1728
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a==1){
		cout<<"YES\n";
		return 0;
	}
	else {
		for(int i=1;i<=100;i++){
			if(a*i%b==c){
				cout<<"YES\n";
				return 0;
			}
		}
	}
	cout<<"NO\n";
	return 0;
} 

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

int main(){
	double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	double distance=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
	cout<<fixed;
	cout<<setprecision(5)<<distance<<endl;
}


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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl;
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl;
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }
int mod(int a) { return (a % MOD + MOD) % MOD; }

/////////////////////////////////////////////////////////////////////

const int N = 1e5 + 20, P = 104729;

int32_t main(){

    sync;

    int n, h, w; cin >> n >> h >> w;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans << endl;
    

    return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
		int y = sc.nextInt();

    int x_group = -1;
    int y_group = -1;

    int[][] group = {{1,3,5,7,8,10,12},{4,6,9,11},{2}};

		for(int i=0; i<group.length; i++){
      for(int j=0; j<group[i].length; j++){
        if(x==group[i][j]){
          x_group = i;
        }
        if(y==group[i][j]){
          y_group = i;
        }
      }
    }

    if(x_group==y_group){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

	}

}


Measured memory_bytes: 21716
private val MOD = 1_000_000_007

fun main() {
    val n = nextInt()
    println((MOD + powmod(10, n) - powmod(9, n).times(2).rem(MOD) + powmod(8, n)).rem(MOD))
}

fun powmod(base: Int, n: Int): Long {
    var res = base.toLong()
    repeat(n - 1) {
        res *= base
        if (res >= MOD) {
            res %= MOD
        }
    }
    return res
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{   
    string S;
    cin >> S;
    for(int i=0;i<=7;i++){
        auto s = S.substr(0,i) + S.substr(S.size()-7+i,7-i);
        if(s=="keyence"){
            cout<<"YES"<<endl;
            return 0;
        }   
    }
    cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
unsigned long long a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a+b>c){
        printf("No\n");
        return 0;
    }
    if((c-a-b)*(c-a-b)>4*a*b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<map>
#define ll long long int
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll t=360;
    ll x = __gcd(n,t);
    x = (n*360)/x;
    cout<<x/n;
}

Measured memory_bytes: 3560
candidates = set([1])

for b in range(2, int(1000**1/2)+1):
  p = 2
  while b**p <= 1000:
    candidates.add(b**p)
    p += 1

X = int(input())

for c in sorted(candidates, reverse=True):
  if c <= X:
    print(c)
    exit()
  

Measured memory_bytes: 2940
import math
a, b, c = map(float, input().split()) #4, 3, 90
d = (a**2) + (b**2) - (2*(a*b * math.cos(math.radians(c))))
L = a + b + (d**0.5)
S = a * b * math.sin(math.radians(c)) / 2
h = 2 * S / a
print(str(S))
print(str(L))
print(str(h))


Measured memory_bytes: 5696
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
a,b,c,d=map(int,input().split())
t=(b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//(lcm(c,d))-(a-1)//(lcm(c,d)))
print(b-a+1-t)

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi xs(n);
    forn(i, n) cin>>xs[i];
    vvll D(2, vll(n));
    forn(_, 2) {
        vpii stk;
        stk.pb(pii(0, -1));
        forn(i, n)  {
            while (stk.back().ff >= xs[i])
                stk.pop_back();
            D[_][i] = i - stk.back().ss;
            stk.pb(pii(xs[i], i));
        }
        reverse(all(xs));
    }
    reverse(all(D[1]));
    ll ans = 0;
    forn(i, n) ans += xs[i]*(D[0][i]*D[1][i]);
    cout << ans << '\n';
}


Measured memory_bytes: 7780
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

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

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    ll K;
    cin >> K;

    for (ll i = 0; i < s.size(); i++) {
        if (s[i] == 'a' ){
            continue;
        }

        ll c = s[i] - 'a';
        ll d = 26 - c;
        if (d <= K) {
            K -= d;
            s[i] = 'a';
        }
    }

    cerr << s << endl;

    if (K > 0) {
        s.back() = ((s.back() - 'a') + K) % 26 + 'a';
    }

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main(void){
    int h, w;
    cin >> h >> w;
    
    char a[1005][1005];
    for (int i = 0; i < h; i++) cin >> a[i];
    
    queue<int> bh, bw;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                bh.push(i);  bw.push(j);
            }
        }
    }
    
    int x[10000], dh[] = {1, 0, -1, 0}, dw[] = {0, 1, 0, -1}, all;
    x[0] = all = bh.size(); 
    for (int i = 1; i < 10000; i++) x[i] = 0;
    
    if (all == h * w) {
            cout << 0 << endl;
            return 0;
        }
        
    for (int i = 0; 1; i++) {
        for (int j = 0; j < x[i]; j++) {
            int xh = bh.front(), xw = bw.front();
            for (int l = 0; l < 4; l++) {
                if (xh + dh[l] != -1 && xh + dh[l] != h && 
                xw + dw[l] != -1 && xw + dw[l] != w && a[xh + dh[l]][xw + dw[l]] == '.') {
                    a[xh + dh[l]][xw + dw[l]] = '#';
                    bh.push(xh + dh[l]);  bw.push(xw + dw[l]);
                    x[i + 1]++;  all++;
                }
            }
            bh.pop(); bw.pop();
        }
        if (all == h * w) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    
    
    
    
}

Measured memory_bytes: 9472
#include <stdio.h>
#include<string.h>
#include<stdlib.h>

int cmp(const void *a, const void *b)
{
  return strcmp(a,b);
}

int main()
{
 
  int n;
  
  scanf("%d",&n);
  
  char s[n][11];
  int i;
  int count=1;
  for(i=0;i<n;i++)
  {
    scanf("%s",&s[i]);
  }
 
  qsort(s,n,sizeof(*s),cmp);
  
  for(i=0;i<n-1;i++)
  {
    if(strcmp(s[i],s[i+1])!=0)
    {
      count++;
    }
  }
  
  printf("%d\n",count);
      
  return 0;
}

Measured memory_bytes: 5740
#include <stdio.h>

int main(void)
{
    int h, w;
    int i, j;
    
    scanf("%d%d", &h, &w);
    
    while(h!=0 || w!=0){
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                if(i==0 || j==0 || i==h-1 || j==w-1){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
        
        scanf("%d%d", &h, &w);
    }
    
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> high(n);
  for(int i = 0;i < n;i++){
    cin >> high[i];
  }
  vector<bool> ok(n);
  for(int i = 0;i < n;i++)ok[i] = true;
  for(int i = 0;i < m;i++){
    int a,b;
    cin >> a >> b;
    a--,b--;
    if(high[a] <= high[b])ok[a] = false;
    if(high[b] <= high[a])ok[b] = false;
  }
  int res = 0;
  for(int i = 0;i < n;i++){
    if(ok[i])res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int n;
	cin >> n;
	vector<pair<int, int>> x(n);
	rep(i, n) cin >> x[i].second>>x[i].first;
	sort(x.begin(), x.end());
	ll t = 0;
	rep(i, n) {
		t += x[i].second;
		if (t > x[i].first) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0; 
}









Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <map>
using namespace std;

long long N, M, A[100009], B[100009], s1, s2;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) { cin >> A[i]; s1 += A[i]; }
	for (int i = 0; i < M; i++) { cin >> B[i]; s2 += B[i]; }
	cout << s1 * s2 << endl;
	return 0;
}


Measured memory_bytes: 4668
def resolve():
    import sys
    input = sys.stdin.readline
    import heapq
    def dijkstra_heap(s,edge):
        d = [10**20] * n
        used = [True] * n #True:未確定
        d[s] = 0
        used[s] = False
        edgelist = []
        for a,b in edge[s]:
            heapq.heappush(edgelist,a*(10**6)+b)
        while len(edgelist):
            minedge = heapq.heappop(edgelist)
            #まだ使われてない頂点の中から最小の距離のものを探す
            if not used[minedge%(10**6)]:
                continue
            v = minedge%(10**6)
            d[v] = minedge//(10**6)
            used[v] = False
            for e in edge[v]:
                if used[e[1]]:
                    heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
        return d

    n,m,s,t = map(int,input().split())
    edge1 = [[] for i in range(n)]
    edge2 = [[] for i in range(n)]
    for i in range(m):
        u,v,a,b= map(int,input().split())
        edge1[u-1].append([a,v-1])
        edge1[v-1].append([a,u-1])
        edge2[u-1].append([b,v-1])
        edge2[v-1].append([b,u-1])
    d1=dijkstra_heap(s-1,edge1)
    d2=dijkstra_heap(t-1,edge2)
    ma,ans=0,[]
    for c1,c2 in zip(d1[::-1],d2[::-1]):
        ma=max(ma,10**15-c1-c2)
        ans.append(ma)
    for i in ans[::-1]:print(i)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 124592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
constexpr long MOD = 1e9 + 7;
using namespace std;

long modfact[200000];
long modfactinv[200000];

long power(long x, long n) {
    if (n == 0) return 1;
    if (n == 1) return x;
    if (n % 2 == 0) {
        long t = power(x, n / 2);
        return t * t % MOD;
    }
    long t = power(x, n / 2);
    return x * t % MOD * t % MOD;
}

long choose(int n, int r) {
    return modfact[n] * modfactinv[r] % MOD * modfactinv[n - r] % MOD;
}

int main() {
    modfact[0] = 1;
    for (int i = 1; i < 200000; i++) {
        modfact[i] = modfact[i-1] * i % MOD;
    }
    
    modfactinv[199999] = power(modfact[199999], MOD - 2);
    for (int i = 199998; i >= 0; i--) {
        modfactinv[i] = modfactinv[i + 1] * (i + 1) % MOD;
    }
    
    for (int i = 2; i < 200000; i++) {
        if (modfact[i] * modfactinv[i] % MOD != 1) {
            cout << "Error calculating modulus at i = " << i << endl;
            cout << "i! = " << modfact[i] << endl;
            cout << "(i!)^-1 = " << modfactinv[i] << endl;
            exit(1);
        }
    }
    
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    
    long ans = 0;
    int p = h - a + b - 1;
    int q = a + w - b - 2;
    for (;q >= a - 1;) {
        ans += choose(p, h - a - 1) * choose(q, a - 1);
        ans %= MOD;
        p++;
        q--;
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int n;

int dat[1000000]={};


int main(void){
	while(1){
nextn:;
		scanf("%d",&n);
		if(n==0)break;
		memset(dat,0,sizeof(dat));
		rep(i,n){
			scanf("%d",&dat[i]);
		}
		
		int ns = n;
		rep(i,10001){
			
			if(dat[0]==1){
				rep(k,ns){
					if(k==ns-1){
						printf("%d\n",i);
						goto nextn;
					}
					if(dat[k+1]!=dat[k]+1)break;
				}
			}
			
			int st = 0;
			rep(k,ns){
				dat[k]--;
				dat[st]=dat[k];
				if(dat[k]!=0)st++;
			}
			dat[st] = ns;
			ns = st+1;
			/*
			rep(i,ns){
				printf("%d ",dat[i]);
			}
			printf("\n");*/
		}
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 4952
n=int(input())
S=[[i for i in map(int,input().split())] for _ in range(n)]
S=sorted(S, key=lambda x: x[1])
Sum=0
#dp=[[0 for __ in range(2)] for _ in range(n)]
for i in range(n):
  Sum += S[i][0]
  if Sum > S[i][1]:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 42712
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define INF 999999999999

int main(){
  int N,avg=0,min=0; cin>>N;
  vll X(N);
  rep(i,N){
    cin>>X[i];
    avg+=X[i];
  }
  avg=round((double)avg/N);
  rep(i,N){
    min+=(X[i]-avg)*(X[i]-avg);
  }
  cout<<min<<endl;
return 0;
}


Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

k = min(n-1, k)

inf = 100000000

dp = [inf for _ in [0]*n]

def cost(i, j):
	return abs(h[i] - h[j])

for i in range(k+1):
	dp[i] = cost(0, i)

for i in range(k+1, n):
	
	dp[i] = min([dp[i-j] + cost(i-j, i) for j in range(1, k+1)])

print(dp[-1])


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

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

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

    // start
    float t, x;
    cin >> t >> x;
    cout << t / x << endl;
    // end

    return 0;
}


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

template <typename T>
vector<T> divisor(T n)
{
    vector<T> divisor;
    for (T i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            divisor.push_back(i);
            if (i * i != n)
                divisor.push_back(n / i);
        }
    }
    return divisor;
}

template <typename T>
map<T, int> prime_factor(T n)
{
    map<T, int> res;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n]++; //nは素数
    return res;
}

int main()
{
    long long n;
    cin >> n;
    vector<long long> d = divisor(n);
    map<long long, int> mp = prime_factor(n);
    cout << mp.size() << " " << d.size() - 1 << endl;
}



Measured memory_bytes: 3172
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	long long a, b;

	scanf("%lld %lld", &a, &b);

	if ((a + b) % 2)
	{
		printf("IMPOSSIBLE\n");
	}

	else
	{
		printf("%lld\n", (a + b) / 2);
	}

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] input = new int[n];
            for (int i = 0; i < n; i++) {
                input[i] = sc.nextInt();
            }

            int now = input[0];
            int count = 1;
            boolean flag = false;
            while (count < n) {
                if (now == 2) {
                    System.out.println(count);
                    flag = true;
                    break;
                }
                now = input[now - 1];
                count++;
            }
            if (!flag) {
                System.out.println(-1);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 51764
#include<iostream>
#include<stdio.h>

int main(void){
    int time,h,m,s;
    scanf("%d",&time);
    int temp;
    h = time/3600;
    m = (time-h*3600)/60;
    s = time-h*3600-m*60;
    
    printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<malloc.h>

using namespace std;

int ishappy(string s,int k){
	int len=s.size();
	char direction=s[k];
	if(direction=='L'){
		if(k==0) return 0;
		char front=s[k-1];
		if(front=='L') return 1;
	}
	if(direction=='R'){
		if(k==len-1) return 0;
		char front=s[k+1];
		if(front=='R') return 1;
	}
	return 0;
}

int Cal(string s){
	int sum=0;
	for(int i=0;i<s.size();i++)
	    sum+=ishappy(s,i);
	return sum;
}

int main(){
	
    int N,K,MAX;
    string S; 
    cin>>N>>K>>S;
    MAX=Cal(S); 
	for(int i=0;i<K;i++){
	 if(MAX==N-1)  break;
	 if(MAX==N-2)  {
	     MAX+=1;
	     break;
	 }
     MAX+=2;
	}
	
    cout<<MAX<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    cpp_int ans = 1;
    rep(i, n){
        ans *= a[i];
        if(ans > (cpp_int)1e18){
            print(-1);
            return 0;
        }
    }
    print(ans);

}




Measured memory_bytes: 4068
#include <stdio.h>

int main(void){
    char s[50];
    int n,k;
    
    scanf("%d %d", &n, &k);
    scanf("%s", s);
    
    switch(s[k-1]){
        case 'A':
        s[k-1] = 'a';
        break;
        case 'B':
        s[k-1] = 'b';
        break;
        case 'C':
        s[k-1] = 'c';
        break;
    }
    
    printf("%s\n",s);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define mem(a) memset(a, 0, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
ll mod = 1000000007;
int Ceil(int a, int b){
	if(a%b==0) return a/b;
	else return (a/b)+1;
}

int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);   
	// freopen("output.txt", "w", stdout);
	// #endif
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n,x;
	cin >> n >> x;
	int arr[n], j=n-1;
	ll ans=0;
	rep(i,n)cin >> arr[i];
	if(n==1){
		if(arr[0]<=x)
			cout <<"0\n";
		else
			cout << arr[0]-x << "\n"; 
		return 0;
	}
	if(n==2){
		if(arr[0]+arr[1]>x)
			cout << arr[0]+arr[1]-x << "\n";
		else
			cout << "0\n";
		return 0;
	}
	repA(i,0,(n-2)/2){
		ll temp=0;
		if(arr[i]+arr[i+1]>x){
			temp=arr[i]+arr[i+1]-x;
			ans+=temp;
			if(arr[i+1]>temp)
				arr[i+1]-=temp;
			else{
				temp-=arr[i+1];
				arr[i+1]=0;
				arr[i]-=temp;
			}
		}
		if(arr[j]+arr[j-1]>x){
			temp=arr[j]+arr[j-1]-x;
			ans+=temp;
			if(arr[j-1]>temp)
				arr[j-1]-=temp;
			else{
				temp-=arr[j-1];
				arr[j-1]=0;
				arr[j]-=temp;
			}
		}
		j--;
	}cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
    double x, y;

    Point(double x = 0.0, double y = 0.0): x(x), y(y) {};

    Point operator + (Point &p) {return Point(x + p.x, y + p.y);}
    Point operator - (Point &p) {return Point(x - p.x, y - p.y);}
    Point operator * (double k) {return Point(x * k, y * k);}
    Point operator / (double k) {return Point(x / k, y / k);}

    double norm(void) {return x * x + y * y;}
    double abs(void) {return sqrt(norm());}

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    double dot(Point a) {
        return x * a.x + y * a.y;
    }

    double cross(Point a) {
        return x * a.y - y * a.x;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
};

typedef Segment Line;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (a.cross(b) > EPS) return COUNTER_CLOCKWISE;
    if (a.cross(b) < -EPS) return CLOCKWISE;
    if (a.dot(b) < -EPS) return ONLINE_BACK;
    if (a.norm() < b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
            ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

double getDistanceLP(Line l, Point p) {
    return abs((l.p2 - l.p1).cross(p - l.p1) / (l.p2 - l.p1).abs());
}

double getDistanceSP(Segment s, Point p) {
    if ((s.p2 - s.p1).dot(p - s.p1) < 0.0) return (p - s.p1).abs();
    if ((s.p1 - s.p2).dot(p - s.p2) < 0.0) return (p - s.p2).abs();
    return getDistanceLP(s, p);
}

double getDistance(Segment s1, Segment s2) {
    if (intersect(s1.p1, s1.p2, s2.p1, s2.p2)) return 0.0;
    return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),
               min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}


int main(void) {
    int x1, x2, x3, x4, y1, y2, y3, y4, q;
    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        scanf("%d %d %d %d %d %d %d %d",
                &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        Segment s1, s2;
        s1.p1 = Point(x1, y1);
        s1.p2 = Point(x2, y2);
        s2.p1 = Point(x3, y3);
        s2.p2 = Point(x4, y4);
        double ret = getDistance(s1, s2);
        printf("%.10f\n", ret);
    }

    return 0;
}

Measured memory_bytes: 1068
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s;
    int ans = 0;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == '?') s[i] = 'D';
    }
    rep(i, s.size()) {
        if (s[i] == 'D') {
            ans++;
            if (i != 0 && s[i - 1] == 'P') ans++;
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3808
#include <vector>
#include <iostream>
#include <set>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define REP(i,n) FOR(i,0,n)

int h,w,s,total;
pii dp[32][32][32][32];
pii search(int x1,int y1,int x2,int y2,vvi &u){
	if(dp[x1][y1][x2][y2].first>0){
		return dp[x1][y1][x2][y2];
	}
	if(x1==x2&&y1==y2){
		return make_pair(1,total-u[x1][y1]);
	}
	int t=0;
	FOR(i,x1,x2+1)FOR(j,y1,y2+1)
		t+=u[i][j];
	pii best=make_pair(1,total-t);
	FOR(i,x1,x2){
		pii p1=search(x1,y1,i,y2,u),p2=search(i+1,y1,x2,y2,u);
		int ff=p1.first+p2.first,ss=max(p1.second,p2.second);
		if(ss>s)continue;
		if(best.first<ff||(best.first==ff&&best.second>ss)){
			best.first=ff;
			best.second=ss;
		}
	}
	FOR(i,y1,y2){
		pii p1=search(x1,y1,x2,i,u),p2=search(x1,i+1,x2,y2,u);
		int ff=p1.first+p2.first,ss=max(p1.second,p2.second);
		if(ss>s)continue;
		if(best.first<ff||(best.first==ff&&best.second>ss)){
			best.first=ff;
			best.second=ss;
		}
	}
	return dp[x1][y1][x2][y2]=best;
}
int main(){
	while(cin>>h>>w>>s,h){
		vvi u(w,vi(h,0));
		REP(i,h){
			REP(j,w){
				cin>>u[j][i];
			}
		}
		REP(i,32)REP(j,32)REP(k,32)REP(l,32)
			dp[i][j][k][l]=make_pair(0,0);
		total=0;
		REP(i,w)REP(j,h)
			total+=u[i][j];
		pii p=search(0,0,w-1,h-1,u);
		cout<<p.first<<" "<<s-p.second<<endl;
	}
}

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

int main () {
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  if ((2*x) == W && (2*y) == H) {
    cout << setprecision(6) << W * H / 2.0  << " " << 1 << endl;
  } else {
    cout << setprecision(6) << W * H / 2.0 << " " << 0 << endl;
  }
  return 0;
}


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

using namespace std;

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

int main()
{
	int k;
	cin >> k;
	long long ans=0;
	for(int i=1;i<=k;i++)
	for(int j=1;j<=k;j++)
	for(int l=1;l<=k;l++)
	{
		long long tmp=gcd(i,j);
		tmp=gcd(tmp,l);
		ans+=tmp;
	}


	cout << ans << endl;


}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
typedef int64_t lint;
lint gcd(lint a, lint b) { return b?gcd(b,a%b):a;}
struct Sieve {
	int n;
	vector<int> p;
	Sieve(int n=1):n(n), p(n+1) {
		p.at(0) = 0, p.at(1) = 0;
		for(lint i=2; i<=n; i++) {
			if(!p.at(i)) {
				p.at(i) = i;
				for(lint j=i*i; j<=n; j+=i) {
					if (!p.at(j)) p.at(j) = i;
				}
			}
		}
	}
	bool isPrime(int x) { return p.at(x) == x;}
	vector<int> factorList(int x) {
		vector<int> v;
		while (x != 1) {
			v.push_back(p.at(x));
			x /= p.at(x);
		}
		return v;
	}
	vector<int> factor(int x) {
		vector<int> v;
		while (x != 1) {
			int t = p.at(x);
			v.push_back(t);
			while (x % t == 0) x /= t;
		}
		return v;
	}
};

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}

	int a=0, b=0, c=v.at(0), x, y, z;
	Sieve S(1000000);
	set<int> P;
	rep(i, N) {
		x = v.at(i);
		for (int j : S.factor(x)) {
			if (P.count(j)) {
				rep1(i, N) {
					c = gcd(c, v.at(i));
					if (c == 1) {
						std::cout << "setwise coprime" << '\n';
						return 0;
					}
				}
				std::cout << "not coprime" << '\n';
				return 0;
			}
			P.insert(j);
		}
	}
	std::cout << "pairwise coprime" << '\n';
}


Measured memory_bytes: 11176
let f=Scanf.scanf open List;;let s(a,b)=(b,a);;let($)d c=match d with|[x;y;z]->(match c with|'N'->[y;s x;z]|'S'->[s y;x;z]|'E'->[s z;y;x]|'W'->[z;y;s x]|'Z'->[x;z;s y]|_->[])|_->[]and z=f"%d %d %d %d %d %d\n"(fun a b c d e f->[(a,f);(b,e);(c,d)])in for _=1to f"%d
"(fun i->i)do f"%d %d
"(fun x y->Printf.printf"%d
"(fst(nth(hd(filter(fun d->x=(fst(hd d))&&y=(fst(nth d 1)))(concat(map(fun d->[d;d$'Z';d$'Z'$'Z';d$'Z'$'Z'$'Z'])[z;z$'N';z$'W';z$'E';z$'S';z$'S'$'S']))))2)))done

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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;


int cnt[200020];
int arr[200020];
int main(){

    ios::sync_with_stdio(0);
    cin .tie(0),cout.tie(0);

    int n; cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> arr[i];
        ans += cnt[arr[i]];
        cnt[arr[i]]++;
    }
    for(int i = 1;i <= n;i++)
    {
        cout << ans - (cnt[arr[i]] - 1)  << '\n';
    }

    return 0;
}


Measured memory_bytes: 3712
#include<iostream>

using namespace std;

int par[10000];
int rank[10000];
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rank[i] = 0;
    }
}
int find(int x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)return;
    par[x] = y;
}
bool same(int x, int y) {
    return find(x) == find(y);
}
int main()
{
    int n;
    long q;
    cin >> n >> q;
    init(n);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) unite(x, y);
        else if (com == 1) {
            if (same(x, y))cout << "1\n";
            else cout << "0\n";
        }
    }
    return 0;
}

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

int main() {
    int i, n, x, d, sum_d=0, min_d=10000;
    cin >> n >> x;
    for(i=0; cin >> d; i++) {
        sum_d += d;
        min_d = min(d, min_d);
    }
    cout << n + (x-sum_d)/min_d << endl;
}

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

int main(){
    ll l, r; cin >> l >> r;
    ll ans = 1LL<<59;
    for(ll i=l; i<=min(r,l+2019); ++i){
        for(ll j=i+1; j<=min(r, i+2020); ++j){
            chmin(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
const int N = (int)1e6 + 10;
const int MAXA = (int)1e6;
const int mod = (int)1e9 + 7;
int lp[MAXA],arr[N];
bool have[MAXA];
vector<int> prime;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    for(int i = 2;i <= MAXA;++i){
        if(lp[i] == 0){
            lp[i] = i;
            prime.push_back(i);
        }
        for(int j = 0;j < (int)prime.size() && prime[j] <= lp[i] && i * prime[j] <= MAXA;++j){
            lp[i * prime[j]] = prime[j];
        }
    }
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> arr[i];
    bool ok = 1;
    for(int i = 1;i <= n;i++){
        int p = arr[i];
        while(p != 1){
            if(have[lp[p]])ok = 0;
            p/=lp[p];
        }
        if(!ok)break;
        p = arr[i];
        while(p != 1){
            have[lp[p]] = 1;
            p/=lp[p];
        }
    }
    if(ok){
        cout << "pairwise coprime";
        exit(0);
    }
    int g = arr[1];
    for(int i = 2;i <= n;i++)g = __gcd(arr[i], g);
    if(g == 1){
        cout << "setwise coprime"; 
    }else{
        cout << "not coprime";
    }
    return 0;
} 

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

using namespace std;

#define ll long long
#define MAX 300005
#define MOD 1000000007
ll suff[MAX][62];
ll arr[MAX], po[62];

int main()
{
    //freopen("in.txt", "r", stdin);
    po[0] = 1LL;
    for(int i=1; i<62; i++) po[i] = po[i-1]*2;
    ll n;
    scanf("%lld", &n);
    memset(suff, 0, sizeof suff);
    for(ll i=1; i<=n; i++){
        scanf("%lld", &arr[i]);
        for(ll j=0; j<62; j++){
            if(arr[i] & po[j]) suff[i][j]++;
        }
    }
    for(ll i=n; i>=1; i--){
        for(ll j=0; j<62; j++){
            suff[i][j] += suff[i+1][j];
        }
    }
    ll ans = 0;
    for(ll i=1; i<=n-1; i++){
        for(ll j=0; j<62; j++){
            if(arr[i] & po[j]){
                ll cnt = suff[i+1][j];
                cnt = (n-i) - cnt;
                ll x = po[j]%MOD;
                ans += (x*cnt)%MOD;
                ans = ans%MOD;
            }
            else {
                ll cnt = suff[i+1][j];
                ll x = po[j]%MOD;
                ans += (x*cnt)%MOD;
                ans = ans%MOD;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 147840
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 1000005

int np[N+1];

int main() {
  np[0] = np[1] = 1;
  repl(i, 2, 1000) {
    if(!np[i]) {
      repf(j, i*i, N, i) {
        np[j] = 1;
      }
    }
  }
  int n;
  while(cin >> n && n) {
    int ans = 0;
    repl(x, 2, n/2) {
      if(!np[x] && !np[n-x]) {
        ++ans;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6900