akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    cin >> a;
    cin >> b;
    if (a == b) cout << "a == b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else if (a < b) cout << "a < b" << endl;
    return 0;
    
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 1;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (i <= m / n) ans = max(ans, i);
            if (m / i <= m / n) ans = max(ans, m / i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl;
#define coYES cout << "YES" << endl;
#define coyes cout << "yes" << endl;
#define coNo cout << "No" << endl;
#define coNO cout << "NO" << endl;
#define cono cout << "no" << endl;
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
   ll a,b;
   cin >> a >> b;
   rep0(i,max(a,b)){
       if(abs(a-i)==abs(b-i)){
           cout << i << endl;
           return 0;
       }
   }
   cout << "IMPOSSIBLE" << endl;
   return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
struct Node{
  struct Node *right;
  struct Node *left;
  struct Node *p;
  int key;
};
struct Node *root,*NIL;
//#define NIL NULL

struct Node* find(struct Node *u,int k){
while(u != NIL && k != u->key){
  if(k < u->key) u=u->left;
  else u=u->right;
}
return u;
}
void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z = malloc(sizeof(struct Node)); 
  z->key = k;                                                                   
  z->left = NIL;                                                                
  z->right = NIL;
  while (x!= NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
    z->p=y;
    if(y==NIL)root=z;
else if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
    }                                      
  }
void inorder(struct Node *u){
  if(u!=NIL){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  }
}
void preorder(struct Node *u){
if(u!=NIL){
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
  }
}

int main(){
  int n, i, x, z;
  char com[20];
  scanf("%d", &n);
 for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0]== 'f'){
      scanf("%d", &x);
      struct Node *t =find(root,x);
      if(t == NIL)printf("no\n");
      else printf("yes\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &z);
      insert(z);
    } else {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}




Measured memory_bytes: 20500
#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;

    int x = (int)n / 1.08;
    for(int i=0; i<2; ++i){
        if(x * 108 / 100 == n){
            cout << x << endl;
            return 0;
        }
        ++ x;
    }

    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int N = 10000;
long double a,b,c;

int main()
{
    cin>>a>>b>>c;
    if((a+b+sqrt(a*b)*2) < c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    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(void){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}

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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) return 0;
		vector<int> V(N);
		for (int i = 0; i < N; i++) {
			char C, D;
			cin >> C >> D;
			if (C == 'l') V[i] = 0;
			else V[i] = 1;
		}
		int ANS = 0;
		for (int i = 0; i < N / 2; i++) {
			ANS += V[i * 2] != V[i * 2 + 1];
		}
		cout << ANS << endl;
	}
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3912
import java.util.Scanner;

public class Main {

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

    long A = Long.parseLong(sc.next());
    long B = Long.parseLong(sc.next());

    long n = Math.abs(A - (A-B) / 2);

    if (Math.abs(A-n) == Math.abs(B-n)) {
      System.out.println(n);
    } else {
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 21972
# include <bits/stdc++.h>
/// my holy template
# define F first    
# define S second
# define mp make_pair
# define pii pair<int,int>         
/// eveything goes according to my plan
# define long long long  
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
/// countdown BEGAN. 10 , 9 , 8 ...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right
/// dzyn dzyn dzyn   
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 9223372036854775807;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
pii a[Sz];

int n;

int cur, ans;

vec<int> del[Sz], add[Sz];

int C;
                   
int main() 
{
  Read_rap ();
  cin >> n >> C;       
  for (int i = 1; i <= n; i++) {
    int l, r, c;  cin >> l >> r >> c;
    add[l].pb (c);
    del[r].pb (c);
  }
  int have[31] = {0};
  for (int i = 1; i <= 1e5; i++) {
    for (int x : add[i])
      have[x] ++;
    int cur = 0;
    for (int i = 1; i <= C; i++)
      cur += (have[i] > 0);
    ans = max (ans, cur);

    for (int x : del[i])
      have[x] --;
  }
  cout << ans; 
    
  return 0;
} 










// Coded by Z...

Measured memory_bytes: 59776
#include <iostream>

 

using namespace std;

 

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


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

int m, n, res;
int blue[510], red, match[510];
bool used[510];
vector<int> g[510];

int gcd(int x, int y)
{
	int t;
	if(x < y) swap(x, y);
	while(y)
		t = x % y, x = y, y = t;
	return x;
}

bool dfs(int v)
{
	for(int i = 0; i < g[v].size(); ++i)
	{
		int t = g[v][i];
		if(used[t]) continue;
		used[t] = true;
		if(match[t] == -1 || dfs(match[t]))
		{
			match[t] = v;
			return true;
		}
	}
	return false;
}

int main()
{
	while(cin >> m >> n && m)
	{
		for(int i = 0; i < m; ++i)
			cin >> blue[i], g[i].clear();
		for(int i = 0; i < n; ++i)
		{
			cin >> red;
			for(int j = 0; j < m; ++j)
				if(gcd(blue[j], red) > 1)
					g[j].push_back(i);
		}
		res = 0;
		fill_n(match, n, -1);
		for(int i = 0; i < m; ++i)
		{
			fill_n(used, n, false);
			if(dfs(i)) ++res;
		}
		cout << res << endl;
	}
}

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

int c[52][52];
bool c2[52][52];int w2, h2;
int dp(int h, int w);
int main()
{
	while (1) {
		
		cin >> w2 >> h2;
		if (w2 == 0 && h2 == 0)return 0;
		for (int i = 0; i < h2; i++) {
			for (int j = 0; j < w2; j++) {
				cin >> c[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < h2; i++) {
			for (int j = 0; j < w2; j++) {
				if (!c2[i][j]) {
					
					if (c[i][j]) {
						ans++;
						dp(i, j);
					}else c2[i][j] = true;
				}
			}
			
		}
		cout << ans << endl;
		for (int i = 0; i < h2; i++) {
			for (int j = 0; j < w2; j++) {
				c2[i][j]=false;
			}
		}
	}
}
	int dp(int h, int w){
		if (h >= h2 || h < 0 || w >= w2 || w < 0)return 0;
		if (!c2[h][w]) {
			c2[h][w] = true;
			if (c[h][w]) {
				dp(h + 1, w);
				dp(h + 1, w + 1);
				dp(h + 1, w - 1);
				dp(h - 1, w);
				dp(h - 1, w + 1);
				dp(h - 1, w - 1);
				dp(h, w + 1);
				dp(h, w - 1);
			}
		}
		return 0;
	}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	
	static long[] maxPas = new long[5];
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] V = new int[N];
		int[] C = new int[N];
		for(int i=0; i<N; i++) {
			V[i] = sc.nextInt();
		}
		for(int i=0; i<N; i++) {
			C[i] = sc.nextInt();
		}
		
		int ans = 0;
		for(int i=0; i<N; i++) {
			if(V[i] -C[i] > 0) {
				ans += V[i] - C[i];
			}
		}
		
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <deque>
using namespace std;
int main(void){
  bool forward = true;
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  
  deque<string> before;
  deque<string> after;
  
  for(int i=0;i<Q;i++){
    int t;
    cin >> t;
    if(t==2){
      int f;
      string c;
      cin >> f >> c;
      if(f==1){
        if(forward){
          before.push_front(c);
        } else {
          after.push_back(c);
        }
      } else {
        if(forward){
          after.push_back(c);
        } else {
          before.push_front(c);
        }
      }
    } else {
      forward = !forward;
    }
  }
  
  string sbefore,safter;
  for(auto it: before){
    sbefore += it;
  }
  for(auto it: after){
    safter += it;
  }
  
  S = sbefore + S + safter;
  
  if(!forward){
    reverse(S.begin(),S.end());
  }
 
  cout << S << endl;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=a;i<=b;i++){
    for(int j=1;j<10;j++){
      for(int k=0;k<10;k++){
        for(int l=0;l<10;l++){
          if(i==10001*j+1010*k+100*l){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n; long long aux;
	cin >> n;
	long long eliminados = 0;
	int nums[100005];
	for(int i = 1; i <= 100005; i++) nums[i] = 0;
	while(n--){
		cin >> aux;
		if(aux > 100000) eliminados++; else nums[aux]++;
	}
	for(int i = 1; i <= 100005; i++){
		if(nums[i] > i) eliminados += nums[i] - i; else if(nums[i] < i) eliminados += nums[i];
	}
	cout << eliminados;
	return 0;
}

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

int main(){
  ll h,w;
  cin >> h >> w;
  if(h==1 or w==1){
    cout<<1;
    return 0;
  }
  ll h1,h2,w1,w2;
  if(h%2){h1=h/2;h2=h/2+1;}
  else{h1=h/2;h2=h/2;}
  if(w%2){w1=w/2;w2=w/2+1;}
  else{w1=w/2;w2=w/2;}
  cout<<h1*w1+h2*w2;
  return 0;
}

Measured memory_bytes: 3604
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> grid;
    string tmp;
    string ans[w*2];
    rep(i,h){
        cin >> tmp;
        //ans[i] = ans[i+1] = tmp;
        cout << tmp << "\n" << tmp << "\n";
    }
    
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<vector<ll>> a(n,vector<ll>(n));
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			cin>>a[i][j];
	ll res=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j){
			bool ok=true;
			for(int k=0;k<n;++k)
				if(i!=j&&i!=k&&j!=k){
					if(a[i][k]+a[k][j]<a[i][j])
						return cout<<"-1\n",0;
					if(a[i][k]+a[k][j]==a[i][j])
						ok=false;
				}
			if(ok) res+=a[i][j];
		}
	cout<<res/2<<'\n';
}




Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
#define PI 3.14159265358979323846
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    //wを求める
    double w = 2*x/(double)(a*b);
    double h = (double)(2*pow(a,2)*b-2*x)/pow(a,2);
    double ans;
    if(w<=a){
        ans = atan((double)b/w);
    }
    else{
        ans = atan((double)h/a);
    }
    
    // cout << (double)b/w << endl;
    printf("%.12f", (double)ans*180/PI);
    return 0;
}

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

#define LIM_S 200002
#define LIM_N 200001

char str[LIM_S];

int N, K;
char S[LIM_S];

int line[LIM_N];
int left;
int right;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%s", S);
}

void initialize() {
	for (size_t i = 0; i < N; i++) {
		line[i] = (S[i] == '#');
		right += S[i] == '.';
	}
}

int solve() {
	int min = left + right;
	for (size_t i = 0; i < N; i++) {
		int temp = left + right;
		min = min < temp ? min : temp;

		if (S[i] == '#') {
			left++;
		}
		if (S[i] == '.') {
			right--;
		}
	}

	int temp = left + right;
	min = min < temp ? min : temp;

	return min;
}

int main(void) {
	receive_input();
	initialize();

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

	return 0;
}


Measured memory_bytes: 1280
A_cards, B_cards = [], []
A_result, B_result = 0, 0

while True:
    n = int(input())
    
    if n == 0:
        break

    for i in range(n):
        A, B = map(int, input().split())
        A_cards.append(A)
        B_cards.append(B)
        if A_cards[i] > B_cards[i]:
            A_result += A_cards[i] + B_cards[i]
        elif A_cards[i] < B_cards[i]:
            B_result += A_cards[i] + B_cards[i]
        elif A_cards[i] == B_cards[i]:
            A_result += A_cards[i]
            B_result += B_cards[i]
    print('{} {}'.format(A_result, B_result))
    
    A_cards, B_cards = [], []
    A_result, B_result = 0, 0

Measured memory_bytes: 7860
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,m,ans=1;
	cin >> n >> m;
	if(n == m){
		FOR(i,1,n+1){
			ans *= i;
			while(ans > 1000000007){
				ans -= 1000000007;
			}
		}
		ans *= ans*2;
	}else if(abs(n-m) == 1){
		FOR(i,1,n+1){
			ans *= i;
			while(ans > 1000000007){
				ans -= 1000000007;
			}
		}
		FOR(i,1,m+1){
			ans *= i;
			while(ans > 1000000007){
				ans -= 1000000007;
			}
		}
	}
	else{
		ans = 0;
	}
	while(ans >= 1000000007){
				ans -= 1000000007;
			}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
mod = 10**9+7

NNN = [i for i in range(1,N+1)]
numofprime=[]

for i in range(2,N+1):
    counti = 0
    for j in range(len(NNN)):
        while True:
            if NNN[j] %i !=0:
                break
            NNN[j] = NNN[j]/i
            counti += 1
    numofprime.append([i,counti])



ans = 1
for i in numofprime:
    ans = ans*(i[1]+1) % mod

#print(numofprime)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf double
#define N 4
#define err {puts("-1");exit(0);};
ll color[408][4];
ll has(ll a[])
{
	ll res=0;
	for(ll i=N-1;i>=0;i--) res=res*1008ll+(ll)a[i];
	return res;
}
vector<ll> _rotate(ll c[])
{
	vector<ll> res;
	for(ll i=0;i<N;i++) 
	{
		ll a[4];for(ll j=0;j<N;j++) a[j]=c[(i+j)%N];
		res.push_back(has(a));
	}return res;
}
ll same(ll x,ll y)
{
	ll a[N],c[N];ll sum=0;
	for(ll i=0;i<N;i++) a[i]=x%1008,x/=1008;
	for(ll i=0;i<N;i++) 
	{
		for(ll j=0;j<N;j++) c[j]=a[(i+j)%N];
		sum+= has(c)==y;
	}return sum;
}
map<ll,ll >m;
void ins(ll x)
{
	vector<ll> v=_rotate(color[x]);
	for(ll i=0;i<v.size();i++) m[v[i]]++;
}
ll ans;
ll operate(ll c1[],ll c2[])
{
	ll p=has(c2);
	ll a[4];ll ck[4];
	for(ll i=0;i<N;i++)
	{
		a[0]=c1[i],a[1]=c1[(i+1)%N],a[2]=c2[(i+1)%N],a[3]=c2[i];
		ck[i]=has(a);
	}
	ll cnt=1;
	for(ll i=0;i<4;i++)
	{
		ll over=same(p,ck[i]);
		for(ll j=0;j<i;j++) over+=same(ck[j],ck[i]);
		cnt*=(ll)m[ck[i]]-over;
	}
	return cnt;
}
int main()
{
	ll n;cin>>n;
	for(ll i=1;i<=n;i++) for(ll j=0;j<N;j++) cin>>color[i][j];
	for(ll i=n;i>=1;i--)
	{
		for(ll j=i+1;j<=n;j++)
		{
			ll a[N],b[N];for(ll k=0;k<N;k++) b[k]=color[i][k];
			for(ll k=0;k<N;k++)
			{
				ll c[4];
			//	c[0]=color[j][0],c[1]=color[j][3],c[2]=color[j][2],c[3]=color[j][1];
				for(ll l=0;l<N;l++)
					a[l]=color[j][(l+k)%N];
				ans+=operate(b,a);
			}
		}
		swap(color[i][1],color[i][3]);
		ins(i);
	}
	cout<<ans;
    return 0;
}
/*
3
2 6 3
4
1 1 2 2
1 1 3 3
2 1 9
1 1 3 2
*/
/*
5
1 2 3 4 5
6
1 1 4 2
2 3 6
1 1 4 2
1 1 5 2
2 5 10
1 1 5 2
*/

Measured memory_bytes: 80128
#include<iostream>
using namespace std;
int sum, n, x;
int main() {
	while (cin >> n) {
		if (!n) { break; }
		sum = 0;
		for (int i = 1; i <= n; i++) {
			x = i;
			while (x % 5 == 0) {
				sum++;
				x /= 5;
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 200010
#define mod 1000000007
char a[maxn];
ll c[100],cn=0;
int main(){
	int n;
	scanf("%s",a);
	n=strlen(a);
	ll m;
	cin>>m;
	ll ans=0;
	if(n==1){
		ans=m/2;
		cout<<ans;
		return 0;
	}
	c[0]=1;
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1]){
			cn++;
		}
		c[cn]++;
	}
	if(cn==0){
		ans=n*m/2;
	}
	else if(a[0]==a[n-1]){
		for(int i=1;i<cn;i++){
			ans+=(c[i]/2)*m;
		}
		ans+=(m-1)*((c[0]+c[cn])/2);
		ans+=c[0]/2;
		ans+=c[cn]/2;
	}
	else{
		for(int i=0;i<=cn;i++){
			ans+=(c[i]/2)*m;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    to = [0]*n
    ans = 0
    for i in range(m):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        to[a] = max(to[a], h[b])
        to[b] = max(to[b], h[a])
    for i, hi in enumerate(h):
        if hi > to[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20040
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    long long N;
    cin >> N;
    string s;
    long long n;
    if(N % 2 == 0){
        s = '0';
        n = 0;
    }
    else{
        s = '1';
        n =  1;
        }
    long long t = 4;
    long long pow = -2;
    while(true){
        if(n == N) break;
        s += abs(((N % t + t) % t - (t + n) % t)) / (t / 2) + '0';
        n += (s[s.size() - 1] - '0') * pow;
        pow *= -2;
        t *= 2;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  map<int,int> hoge;
  set<int> all;
  for(int i=0; i<n; i++){
    int a;
    cin>>a;
    all.insert(a);
    hoge[a]++;
  }
  if(all.size()==1){
    if(hoge.count(0)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else if(all.size()==2){
    if(hoge[0]==n/3){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else if(all.size()==3){
    int a,b,c;
    auto itr=all.begin();
    a=*itr;
    itr++;
    b=*itr;
    itr++;
    c=*itr;
    int x=a^b;
    int y=x^c;
    if(y==0&&hoge[a]==n/3&&hoge[b]==n/3&&hoge[c]==n/3){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
signed main()
{
    speed
    int n;cin>>n;
    vector<int> inp(n);
    for(int i=0;i<n;++i){cin>>inp[i];}
    std::vector<int> tinp=inp;
    sort(tinp.begin(),tinp.end());
    int ct=0;
    for(int i=0;i<n;++i)
    {
        if(tinp[i]!=inp[i]){++ct;}
    }
    if(ct==0||ct==2){cout<<"YES";}
    else{cout<<"NO";}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

long long int fact(int N){
	long long int ret = 1;
	FOR(i,1,N+1){
		ret = (ret * i)% SURP;
	}
	return ret;
}

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

	if ((N == M + 1) || (M == N+1)){
		ret = (fact(N)*fact(M))% SURP;
	}else if (N == M){
		ret = (fact(N)*fact(M))% SURP;
		ret = (ret * 2) % SURP;
	}else{
		ret = 0;
	}

	cout << ret << endl;
	return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll m,d;
  cin>>m>>d;
  //vll v(100);
  ll a=0,b=0,c=0;
  if(d>=22){
    for(ll i=22;i<=d;i++){
      b=i;
      if(b/10>=2&&b%10>=2){
        a=(b%10)*(b/10);
        if(a<=m){
          c++;
        }
      }
    }
  }
  co(c);
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll MOD=1e9+7,n,a,b,c,ans,bik[200001],tmp,A[100001],B[100001],H[200001],M;
ll f(ll n,ll k){
    if(k==0)return 1;
    if(k%2==0)return f(n,k/2)*f(n,k/2)%MOD;
    return n*f(n,k-1)%MOD;
}
int main(void){
    cin>>n>>a>>b>>c;
    bik[0]=1,A[0]=1,B[0]=1,H[0]=1;
    for(int i=1;i<=2*n;i++){
        bik[i]=bik[i-1]*i%MOD;
        H[i]=H[i-1]*(100LL-c)%MOD;
    }
    for(int i=1;i<=n;i++){
        A[i]=A[i-1]*a%MOD;
        B[i]=B[i-1]*b%MOD;
    }
    M=f(bik[n-1],MOD-2)*f(100LL-c,MOD-2)%MOD*100LL%MOD;
    for(int i=n;i<=2*n-1;i++){
        tmp=((A[n]*B[i-n])%MOD+(B[n]*A[i-n])%MOD)*i%MOD*bik[i-1]%MOD*f(H[i],MOD-2)%MOD*f(bik[i-n],MOD-2)%MOD;
        //cout<<tmp<<endl;
        ans=(ans+tmp)%MOD;
    }
    //cout<<ans<<endl;
    cout<<(ans*M%MOD)<<endl;
}


Measured memory_bytes: 4992
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) cout << s << endl;
# define printStr(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

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

    res = (a <= b ? a : a-1 );

    p(res)
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
char data;
void solve(){
        data+=1;
        cout<<data<<endl;
}

int main(){
        cin>>data;

        solve();
        return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  char s[n+1];
  cin >> s;
  long long p=1,c[26];
  for(char i='a';i<='z';i++){
    c[i-'a']=1;
  }
  for(int i=0;i<n;i++){
    c[s[i]-'a']++;
  }
  for(int i='a';i<='z';i++){
    p*=c[i-'a'];
    p%=1000000007;
  }
  cout << p-1;
}


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

using ll = long long;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<ll> A(N + N % 2, 0);
    rep(i, N) cin >> A[N % 2 + i];
    N += N % 2;
    vector<ll> s1(N + 1, 0), s2(N + 2, 0);
    rep(i, N) {
        s1[i + 1] = s1[i] + A[i];
        s2[i + 2] = s2[i] + A[i];
    }
    vector<ll> ans1(0), ans2(0);
    rep(i, N / 2) {
        ans1.push_back(A[i * 2 + 1] + A[N / 2 + i]);
        ans2.push_back(s1[N] - s1[N / 2 + i] + s2[i * 2 + 1]);
    }
    ans1.push_back(2e9);
    ans2.push_back(s2[N + 1]);
    vector<ll> X(Q);
    rep(i, Q) cin >> X[i];
    rep(i, Q) {
        int j = lower_bound(ans1.begin(), ans1.end(), X[i] * 2) - ans1.begin();
        cout << ans2[j] << endl;
    }
    /*
    rep(i, N / 2) cout << ans1[i] << " ";
    cout << endl;
    rep(i, N / 2) cout << ans2[i] << " ";
    cout << endl;
    */
}

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

using pxy =  pair<int, int>;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main()
{
  int H, W;
  cin >> H >> W;

  vector<vector<bool>> used = vector<vector<bool>>(H, vector<bool>(W, false));
  
  vector<string> m(H);
  for(int i = 0; i < H; ++i) cin >> m[i];
  
  int x, y;
  long long int b, w;
  queue<pxy> q;
  long long int ans = 0;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(used[i][j]) continue;
      
      b = w = 0;
      q.push(pxy(i, j));
      used[i][j] = true;
      
      while(!q.empty()){     
        x = q.front().first;
        y = q.front().second;
        
        q.pop();
        
        if(m[x][y] == '#') ++b;
        else ++w;
        
        for(int k = 0; k < 4; ++k){
          int next_x = x + dx[k], next_y = y + dy[k];
          if(next_x < 0 || next_x >= H || next_y < 0 || next_y >= W || m[next_x][next_y] == m[x][y] || used[next_x][next_y]) continue;
          q.push(pxy(next_x, next_y));
          used[next_x][next_y] = true;
        }
      }
      ans += b*w;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 1e6+100;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
 
 
#define popcount __builtin_popcountll
 
ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

ll findGcd(ll a, ll b){
    while(a != 0) { ll temp = b % a; b = a; a = temp; }
    return b;
}

set<ll> S[lim];
ll Array[lim], Prime[lim];

ll dfs(ll node,ll Vis[]) {
    ll countA=1;
    Vis[node]=1;
    for(auto i: S[node]) {
        if(!Vis[i]) countA+= dfs(i,Vis);
    }

    return countA;
}

int main(){

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

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    string A,B;
    A = "Yes", B="No";
    cin>>n;
    rep(i,1,n) {
        cin>>Array[i];
        if(i==1) c = Array[i];
        else c = findGcd(c,Array[i]);
        // Error(Array[i]);
    }


    set<ll> P;
    rep(i,2,1e6) {
        if(Prime[i]==1) continue;
        for(ll j=i; j<=1e6; j+=i) {
            Prime[j]=1;
            S[j].insert(i);
        }
    }


    indicator=0;
    for(ll j=n;j>=1;j--) {
        // Error(Array[j]);
        for(auto i: S[Array[j]]) {
            // Error(Array[j],i);
            if(P.count(i)) indicator=1;
            P.insert(i);
        }
    }

    if(indicator==0) cout<<"pairwise coprime"<<endl;
    else if(c==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;

    return 0;
}
    

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


#define INF 1000000000000

signed main()
 {
int n,m;
cin>>n;
vector<string>s(n);
rep(i,n){cin>>s[i];}

cin>>m;
vector<string>t(m);
rep(i,m){cin>>t[i];}

int ans=0;

rep(i,n){
int tmp=0;
rep(j,n){
  if(s[j]==s[i]){tmp++;}
}
rep(j,m){
  if(t[j]==s[i]){tmp--;}
}
if(tmp>ans){ans=tmp;}
}
cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i;
    cin>>n;
    pair<long long, long long> p[n];
    for(i=0;i<n;i++)
    {
        cin>>p[i].first;
        p[i].second=i+1;
    }
    sort(p,p+n);
    for(i=0;i<n;i++)
    {
        cout<<p[i].second<<" ";
    }
    return 0;
}


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

void push(int);
int pop();

int top,S[1000];

int main(){
  int a,b;
  top = 0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }

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

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}



Measured memory_bytes: 2108
def run(N, A, B):
    min_ = A + B - N
    if min_ < 0:
        min_ = 0
    return '{} {}'.format(min(A, B), min_)


def main():
    N, A, B = list(map(int, input().split()))
    print(run(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<int> memo(N + 1), A(N);
    REP(i, N - 1) {
        cin >> A[i];
        memo[A[i]]++;
    }
    REP(i, N) cout << memo[i + 1] << endl;

    return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>
int main(void)
{
    int x,y,i;
    while(1)
    {
        scanf("%d%d",&x,&y);
        if(x==0&&y==0)
        {
            break;
        }
        if(x<=y)
        {
            printf("%d %d\n",x,y);
        }
        if(x>y)
        {
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


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

class weighted_unionfind {
  vector<int> par, weight, s;
  
public:
  weighted_unionfind(int n) {
    for (int i = 0; i < n; i++) {
      par.push_back(i);
      weight.push_back(0);
      s.push_back(1);
    }
  }
  
  int find(int n) {
    if (par.at(n) == n) return n;
    int r = find(par.at(n));
    weight.at(n) += weight.at(par.at(n));
    return par.at(n) = r;
  }
  
  void merge(int m, int n, int d) {
    d += diff(m) - diff(n);
    if (s.at(m) < s.at(n)) {
      swap(m, n);
      d = -d;
    }
    m = find(m); n = find(n);
    par.at(n) = m;
    weight.at(n) = d;
    if (s.at(m) == s.at(n)) s.at(m)++;
  }
  
  int diff(int n) {
    if (par.at(n) == n) return 0;
    return weight.at(n);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  weighted_unionfind t(n);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    if (t.find(l) != t.find(r)) {
      t.merge(l, r, d);
    } else {
      if (t.diff(r) - t.diff(l) != d) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}


Measured memory_bytes: 1644
import heapq
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
c.sort()
d=[[0]for i in range(b)]
sum=0
for i,j in c:
  if i<=b:
    d[i-1].append(j)
e=[]

for i in d:
  for j in i:
    heapq.heappush(e,-j)
  sum-=heapq.heappop(e)
      
    
  
print(sum)

Measured memory_bytes: 40024
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

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

int main(){
	int Case = 0, n, dir, cnt;
	int x, y, nx, ny, nd;
	while(cin >> n && n && ++Case){
		dir = cnt  = 0;
		vii v(n, vi(n, 0));
		x = y = 0;
		while(cnt<n*n){
			v[x][y]=++cnt;
			x += dx[dir];
			y += dy[dir];
			if(x >= 0 && y >= 0 && x < n && y < n) continue;
			if(y < 0 && x >= n){
				x = n-1;
				y+=2;
			}
			if(x < 0 && y >= n){
				y = n-1;
				x+=2;
			}
			if(y>=n) {
				y = n-1;
				x+=2;
			}
			else if(x>=n) {
				x = n-1;
				y+=2;
			}
			else if(y<0) y = 0;
			else if(x<0) x = 0;
			dir++;
			dir%=2;
		}
		printf("Case %d:\n", Case);
		rep(i, n){
			rep(j, n){
				printf("%3d", v[j][i]);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1216
N, K = map( int, input().split())
X = [0]*N
Y = [0]*N
for i in range(N):
    x, y = map( int, input().split())
    X[i] = x
    Y[i] = y
SX = sorted(X)
SY = sorted(Y)
ans = 10**19
for xleft in range(N-1):
    a = SX[ xleft]
    for xright in range(xleft, N):
        b = SX[ xright]
        for yunder in range(N-1):
            c = SY[ yunder]
            for yabove in range(yunder, N):
                d = SY[ yabove]
                cnt = 0
                for i in range(N):
                    if a <= X[i] and X[i] <= b and c <= Y[i] and Y[i] <= d:
                        cnt += 1
                if cnt >= K:
                    ans = min( ans, (b-a)*(d-c))
print(ans)


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


int main() {
  int K;
  cin >> K;
  vector<int> Row(K);
  int Ans = 0;
  
  for(int i=K; i>=1; i--){
    int I =(K/i)*(K/i)*(K/i);
    for(int j = 2 * i; j<=K; j = j+i){
      I = I - Row.at(j-1);
    }
    Row.at(i-1) = I;
  }
  
  for(int i=0; i<K; i++){
    Ans = Ans + (i+1) * Row.at(i);
  }
    
  cout << Ans;

}


Measured memory_bytes: 3604
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    a, b, c, d = input_int_map()

    reuslt = max(a * c, a * d, b * c, b * d)
    print(reuslt)
run()



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 200000;
int n;
int a[MAX_N],b[MAX_N];

int main()
{
  cin >> n;
  forn(i,n) cin >> a[i] >> b[i];

  bool same = true;
  ll total = accumulate(a,a+n,0LL);
  ll res = total;
  forn(i,n) {
    same &= a[i] == b[i];
    if (a[i] > b[i]) chmin(res,1LL*b[i]);
  }

  if (same)
    cout << 0 << endl;
  else
    cout << total-res << endl;

  return 0;
}


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

int main(){
	ll n, u, v;
	cin >> n >> u >> v;
	--u; --v;
	
	vector<vector<ll>> to(n);
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	
	vector<ll> daoki(n,-1);
	queue<ll> q;
	q.push(v);
	daoki[v] = 0;
	while(!q.empty()){
		auto p = q.front();
		q.pop();
		for(auto pp : to[p]){
			if(daoki[pp] != -1) continue;
			q.push(pp);
			daoki[pp] = daoki[p]+1;
		}
	}
	
	vector<ll> dtakahashi(n,-1);
	q.push(u);
	dtakahashi[u] = 0;
	while(!q.empty()){
		auto p = q.front();
		q.pop();
		for(auto pp : to[p]){
			if(dtakahashi[pp] != -1) continue;
			q.push(pp);
			dtakahashi[pp] = dtakahashi[p]+1;
		}
	}
	
	ll res = 0;
	rep(i,n){
		if(dtakahashi[i] < daoki[i]){
			res = max(res, daoki[i]-1);
		}
	}
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		try {
			while(scan.hasNext()){
				StringBuffer sb=new StringBuffer(scan.nextLine());
				System.out.println(sb.reverse());
				
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
int main() {
cout << fixed << setprecision(30);
 ll x,y;
  cin>>x>>y;
  ll ans=0;
  if(x==3)ans+=100000;
  if(x==2)ans+=200000;
  if(x==1)ans+=300000;
if(y==3)ans+=100000;
  if(y==2)ans+=200000;
  if(y==1)ans+=300000;
  if(x==1&&y==1)ans+=400000;
  putout(ans);
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = defaultdict(list)
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns[u-1].append(v-1)
    ns[v-1].append(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     print(dd, u, ss)
    if ans[u][ss] is not None and ans[u][ss] <= dd:
        continue
    ans[u][ss] = dd
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or ans[v][ss-a[e]] is not None:
            continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        heapq.heappush(h, (dd + d[u], u, ss+c[u]))
    elif ss < maxs:
        heapq.heappush(h, (dd + d[u], u, maxs))

for item in ans[1:]:
    print(min(item))

Measured memory_bytes: 124832
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int tmp;
int main(){
    int N;
    cin >> N;
    int a[N];
    int maxindex = 0;
    int absmax = -1;
    rep(i, N) cin >> a[i];
    rep(i, N){
        if(abs(absmax) < abs(a[i])){
            absmax = a[i];
            maxindex = i;
        }
    }
    cout << 2 * N - 1 << endl;
    rep(i, N) cout << maxindex + 1 << " " << i + 1 << endl;
    rep(i, N - 1){
        if(absmax < 0) cout << N - i << " " << N - i - 1 << endl;
        else cout << i + 1 << " " << i + 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
#include <algorithm>    
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=1;i<=(ll)(n);i++)

#define MX 3000

//int main(int argc, char const* argv[]){

int main(){ 
   
   int a[MX],b[MX];
   REP(i,MX){
     cin>>a[i];
     cin>>b[i];
     if((a[i]==0)&&(b[i]==0))break;
     if(a[i]>b[i])swap(a[i],b[i]);
      cout<<a[i]<<" "<<b[i]<<endl; 
   }
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int num_op=0;
    bool game_fin = false;
    while(!game_fin){
        bool can_op = false;
        int i_e;
        for(int i=1;i<s.size()-1;i++){
            if(s[i-1]!=s[i+1]){
                can_op=true;
                i_e = i;
                break;
            }
        }
        if(can_op) {
            s.erase(i_e,1);
            num_op++;
        }
        if(s.size()==2||!can_op) game_fin=true;
    }
    if(num_op%2==1){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3744
#include<stdio.h>
int main()
{
    char s[100],s1[10],s2[10],c;
    scanf("%s",s1);
    scanf("%s",s);
    c=s[0];
    scanf("%s",s2);
    getchar();
    printf("A%cC\n",c);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(n)]

def f(a,b,n):
     for i in range(n):
          flag = True
          for j in range(n-i-1,-1,-1):
               if a[j] == j+1:
                    a = a[:j]+a[j+1:]
                    b[n-i-1] = j+1
                    flag = False
                    break
          if flag:
               print("-1")
               return
     for i in range(n):
          print(b[i])
     return
     
f(a,b,n)


Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	char a[200000];
	cin>>a;
	int i=0;
	unsigned long long c=0;
	unsigned long long n=0;
	for(i=0;i<200000;i++)
	{
		if(a[i]==0)
		{
			break;
		}
		if(a[i]=='B')
		{
			c++;
		}
		if(a[i]=='W')
		{
			n=n+c;
		}
		
	}
	cout<<n;
	return 0;
}

Measured memory_bytes: 384