akhauriyash/Code-Regression huggingface dataset:
//        THIS IS MY NINJA WAY
#include <bits/stdc++.h>
#include <ctime>
#include<vector>
#include<algorithm>
#include<string>

#define str string
#define dbl double
#define ll long long
#define vl vector<ll> 
#define vs vector<str>
#define pll  pair<ll,ll> 
#define vll vector<pll>
#define sl set<ll>
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define fr(i,a,b) for(long long i=a; i<b; i++)
#define nfr(i,a,b) for(long long i=a; i<=b; i++)
#define psl pair<str,ll>
#define pls pair<ll,str>
#define pss pair<str,str>
#define ALL(a) a.begin(),a.end()
#define stl stack<ll>
#define coml complex<ll>
#define INF 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
 const ll MOD = 1e9+7;
//c.real() and c.imag(), commands for a imaginary number c
// sort(v.begin(),v.end(),[&] (const str &s, const str &t){
//return s.size()<t.size();
//});

using namespace std;
	
	ll fact(ll n)
	{
		ll f=1;
		nfr(i,2,n)
			f*=i;
		return f;
	}

	ll ncr(ll n,ll r)
	{
		return fact(n)/(fact(r)*fact(n-r));
	}

	ll isPrime(ll n)
	{
		// Corner cases 
    if (n <= 1) 
        return 0; 
    if (n <= 3) 
        return 1; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return 0; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return 0; 
  
    return 1; 
	}

   ll isVowel(char s)
   {
   	if(s=='a' || s=='e' || s=='i' || s=='o' || s=='u')
   		return 1;
   	else 
   		return 0;
   }

   ll fib(ll n)
	{
		if(n<2)
			return n;
		return fib(n-1)+fib(n-2);
	} 

	ll isEven(char a)
	{
		if(a=='2'||a=='4'||a=='6'||a=='8'||a=='0')
			return 1;
		else
			return 0;
	} 	

	ll is_distinct(ll n){
		ll c=0;
		set<ll> se;
		while(n>0){
			ll d=n%10;
			se.insert(d);
			c++;
			n/=10;
		}
		if(se.size()==c){
			return 1;
		}
		else{
			return 0;
		}
	}

	ll lar_prime(ll n){
		for(ll i=n; i>=2; i--){
			if(n%i==0 && isPrime(i)==1)
				return i;
		}
		return 0;
	}
   
   ll isSub(str s,str t){
   	fr(i,0,s.size()){
   		str z=s.substr(i,t.size());
   		if(z==t)
   			return 1;
  	 	}
   	return 0;
   }
	
int main()
{
	fast
	//#ifndef ONLINE_JUDGE

	//	freopen("input.txt", "r" , stdin);
		//freopen("output.txt", "w" , stdout);

	//#endif

	

		ll n;
		cin>>n;
		vl v(n);
		fr(i,0,n)
			cin>>v[i];
		vl dp(n,INF);
		dp[0]=0;
		dp[1]=abs(v[1]-v[0]);
		fr(i,2,n){
			dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
		}
		cout<<dp[n-1];
		return 0;
	}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
using namespace std;
 
int main() {
 
    //ifstream cin("INPUT.txt");
    //ofstream cout("OUTPUT.txt");
 
    int n, m, sum, i;
    int a, b;
 
    while(cin >> n >> m, n != 0 && m != 0) {
 
    int friends[500] = {0}; //1=友達 2=友達の友達
    int m1[10000] = {0};
    int m2[10000] = {0};
    for(i = 0; i < m; i++) {
        cin >> m1[i] >> m2[i];
    }
    for(i = 0; i < m; i++) {
        a = m1[i];
        b = m2[i];
        if(friends[a-1] == 1 && friends[b-1] == 1) {
        } else if(a == 1) {
            friends[b-1] = 1;
        } else if(b == 1) {
            friends[a-1] = 1;
        } else if(friends[a-1] == 1) {
            friends[b-1] = 2;
        } else if(friends[b-1] == 1) {
            friends[a-1] = 2;
        }
    }
    for(i = 0; i < m; i++) {
        a = m1[i];
        b = m2[i];
        if(friends[a-1] == 1 && friends[b-1] == 1) {
        } else if(a == 1) {
            friends[b-1] = 1;
        } else if(b == 1) {
            friends[a-1] = 1;
        } else if(friends[a-1] == 1) {
            friends[b-1] = 2;
        } else if(friends[b-1] == 1) {
            friends[a-1] = 2;
        }
    }
    sum = 0;
    for(i = 0; i < n; i++) {
        if(friends[i] > 0)
            sum++;
    }
 
    cout << sum << endl;
 
    }
 
    return 0;
 
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
//#define f first
#define s second
#define int long long
#define vi vector<int>
#define pi pair<int,int>
const int mod = (int)1e9+7;
const int N = (int)1e5+7;
int a,b;
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin >> t;
    int c = 1;
    while(t--)
    {
      cin >> a >> b;
      int d = __gcd(a , b);
      int cnt = 1;
      for(int i=2;i*i<=d;i++)
      {
          if(d%i)continue;
          cnt++;
          while(d%i==0)d/=i;

      }
      if(d>1)cnt++;
      cout<<cnt<<"\n";


    }  
 
}


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

using namespace std;

int main(void) {
	int num, t, i, ans;
	cin >> num >> t;
	vector<int> d(t);
	for (i = 0; i < t; i++)
		scanf("%d", &d[i]);
	sort(d.begin(), d.end(), greater<int>());
	for (ans = d[0], i = 1; i < t; i++)
		ans = abs(ans - d[i]);
	if (ans > 0)
		ans--;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[105][105];

int main(int argc, char* argv[])
{
    long h, w;
    scanf("%ld%ld", &h, &w);

    long i;
    for(i=0; i<h; i++) {
        scanf("%s", str[i]);
    }

    for(i=0; i<h; i++) {
        printf("%s\n", str[i]);
        printf("%s\n", str[i]);
    }

    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int d[100],f[100],G[100][100],color[100];
int time,n;


void visit(int);

int main(){

  int u,k,i,j,v;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      G[i][j]=0;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    if(k!=0)for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }

  for(i=0;i<n;i++)
    color[i]=0;
  time=0;

  for(i=0;i<n;i++){
    if(color[i]==0){
      visit(i);
    }}
  
  for(i=0;i<n-1;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  printf("%d %d %d\n",i+1,d[i],f[i]);
  
  return 0;

}

void visit(int u){

  int i;

  color[u] = 1;
  d[u] = ++time;
  for(i=0;i<n;i++){
    if(G[u][i]==1&&color[i]==0)
      visit(i);
  }
  color[u] = 2;
  f[u] = ++time;

}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll d, c[33], s[444][33], last[33] = {};

vector<ll> score(vector<ll> t) {
    ll last[33] = {}, i, j, sc = 0;
    vector<ll> v;
    for (i = 1; i <= d; i++){
        sc += s[i-1][t[i-1]];
        last[t[i-1]] = i;
        for (j = 0; j < 26;j++)
            sc -= c[j] * (i - last[j]);
        v.pb(sc);
    }
    return v;
}

int main(){
    ll i, j;
    cin >> d;
    for (i = 0; i < 26;i++)
        cin >> c[i];
    for (i = 0; i < d;i++)
        for (j = 0; j < 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= d;i++){
        ll ma = -1e9, p = -1;
        for (j = 0; j < 26; j++){
            if(c[j]*(i-last[j])+s[i-1][j]>ma){
                ma = c[j] * (i - last[j]) + s[i - 1][j];
                p = j;
            }
        }
        cout << p + 1 << endl;
        last[p] = i;
    }
}

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

const int INF = 1e9;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> f(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> f[i][j];
        }
    }
    vector<vector<int>> g(h, vector<int>(w, INF));
    g[0][0] = 1;

    vector<int> di = {-1, 0, 1, 0}, dj = {0, -1, 0, 1};
    queue<pair<int, int>> que;
    que.push({0, 0});
    while (que.size() > 0) {
        auto pos = que.front();
        que.pop();
        int i = pos.first, j = pos.second;
        for (int k = 0; k < 4; k++) {
            int ni = i + di[k], nj = j + dj[k];
            if (0 <= ni and ni < h and 0 <= nj and nj < w and f[ni][nj] == '.') {
                if (g[i][j] + 1 < g[ni][nj]) {
                    g[ni][nj] = g[i][j] + 1;
                    que.push({ni, nj});
                }
            }
        }
    }

    int cb = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (f[i][j] == '#') {
                cb++;
            }
        }
    }
    int ans = max(-1, h * w - g[h - 1][w - 1] - cb);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int H,N,sum=0;
  cin>>H>>N;
  for(int i=0; i<N; i++){
    int A;
    cin>>A;
    sum+=A;
  }
  cout<<(H-sum<=0?"Yes":"No");
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		String[] picLines = new String[h];
		
		for(int i=0; i<picLines.length; i++) {
			picLines[i] = sc.next();
		}
		
		sc.close();
		
		// printout
		paint(w);
		
		for(int i=0; i<picLines.length; i++) {
			System.out.print("#");
			System.out.print(picLines[i]);
			System.out.println("#");
		}
		
		paint(w);
		

	}
	
	public static void paint(int w) {
		for(int i=0; i<w+2; i++) {
			System.out.print("#");
		}
		System.out.println();
	}
	

}

Measured memory_bytes: 23636
use proconio::input;

fn main() {
    input!(n: usize, s: proconio::marker::Chars);
    let mut a = vec![0; n + 1];
    for (i, c) in s.iter().copied().enumerate() {
        a[i + 1] = match c {
            'W' => a[i] + 1,
            'R' => a[i],
            _ => panic!(),
        }
    }
    println!(
        "{}",
        (0..=n)
            .map(|i| a[i].max(n - i - (a[n] - a[i])))
            .min()
            .unwrap()
    );
}


Measured memory_bytes: 4688
#include <stdio.h>

int main()
{
	int h, n, i;
	int sum = 0;
	int *a;
	scanf("%d %d", &h, &n);
	a = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < n; i++){
		sum += a[i];
	}
	if(sum >= h){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	free(a);
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;


int main() {
    int x, y, tmp;
    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        if (x > y) {
            tmp = y;
            y = x;
            x = tmp;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int d = in.nextInt();
        int[] ci = new int[26];
        int[][] sdi = new int[d][26];
        for(int i=0; i<26; i++) {
            ci[i] = in.nextInt();
        }
        for(int day=0; day<d; day++) {
            for(int i=1; i<26; i++) {
                sdi[day][i] = in.nextInt();
            }
        }
        
        // calc!
        
        for(int i=0; i<d; i++) {
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 46816
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, x);
    
    for(int n = 1; true; n ++){
        int r = x - 100*n;
        if(r < 0) break;
        if(r <= 5*n){
            Cout(1);
            return 0;
        }
    }
    Cout(0);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
bool used[111111];
ll cnt[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  ll ans = 0;
  ll pe = 0;
  for(int i=0;i<m;i++){
    ll a;
    string s;
    cin>>a>>s;
    if(used[a] == false){
      if(s == "AC"){
	used[a] = true;
	ans++;
	pe += cnt[a];
      }else{
	cnt[a]++;
      }
    }
  }
  cout<<ans<<" "<<pe<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a>>b;
    vector<int> vec(b);
    int sum=0;
    for (int i = 0; i < b; i++) {
        cin >> vec.at(i);
        sum+=vec.at(i);
    }
    if(a>sum){
        cout << "No"<<endl;
    }
    else{
        cout << "Yes"<<endl;
    }
    
}


Measured memory_bytes: 640
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t,q;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>s;
		// n=s.length();
		map<ll,vector<ll> > a;
		map<char,ll> mp;
		mp['R']=0;
		mp['G']=1;
		mp['B']=2;
		rep(i,n)
		{
			a[mp[s[i]]].pb(i);
		}
		rep(i,n)
		{
			rep(j,3)
			{
				m=upper_bound(all(a[j]),i)-a[j].begin();
				if(j==mp[s[i]] || m==a[j].size()) continue;
				repe(k,m,a[j].size())
				{
					rep(z,3) if(z!=mp[s[i]] && z!=j) q=z;
					ll p= upper_bound(all(a[q]),a[j][k])-a[q].begin();
					if(p==a[q].size()) continue;
					c+=(a[q].size()-p);
					// debug(c);
					if((2*a[j][k]-i)>=a[q][p] && bs(all(a[q]),2*a[j][k]-i)) c--;
					// debug3(i,j,m);
					// debug3(k,q,p);
					// debug3(c,a[j][k],a[q].size());
				}
			}
		}
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3732
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int a1 = sc.nextInt();
        if (n == 1) {
            System.out.println(a1 == k ? "POSSIBLE" : "IMPOSSIBLE"); return;
        }

        int a2 = sc.nextInt();
        if (a1 == k || a2 == k) {
            System.out.println("POSSIBLE"); return;
        }

        boolean greaterNumExists = false;
        if (a1 > k || a2 > k) {
            greaterNumExists = true;
        }

        int gcd = GCD(a1, a2);
        int tmp;
        for (int i=2; i<n; i++) {
            tmp = sc.nextInt();
            if (tmp == k) { System.out.println("POSSIBLE"); return; }
            if (!greaterNumExists && tmp > k) { greaterNumExists = true; }
            if (tmp % gcd != 0) { gcd = GCD(gcd, tmp); }
        }
        if (!greaterNumExists) { System.out.println("IMPOSSIBLE"); return; }
        System.out.println(k % gcd == 0 ? "POSSIBLE" : "IMPOSSIBLE");
    }

    public static int GCD(int x, int y) {   
        int r;
        while (y!=0) {
            r = x%y; x = y; y = r;
        }
        return x;
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        if (a.at(i) % 2 == 0) {
            if (a.at(i) % 3 != 0 && a.at(i) % 5 != 0) {
                cout << "DENIED" << endl;
                exit(0);
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

def dp(v,dpv,e):
    if dpv[v] != -1:
        return dpv[v]
    if len(e[v])==0:
        dpv[v]=0
        return 0
    res = 0
    for w in e[v]:
        res = max(dp(w,dpv,e),res)
    res += 1
    dpv[v] = res
    return res

def solve(edge):
    dpv = [-1]*N
    for i in range(N):
        dp(i,dpv,edge)
    ans = max(dpv)
    # print(dpv)
    return ans
print(solve(edge))

Measured memory_bytes: 59056
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=1e6+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    ll d,t,s;cin>>d>>t>>s;
    if(d<=s*t) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

int main(){
    int n,cnt=0;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=1; i<n-1; i++){
        
        if((p[i-1]<=p[i]&&p[i]<p[i+1])||p[i+1]<=p[i]&&p[i]<p[i-1])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    string s;cin>>s;
    if(s.at(0)==s.at(2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
#define ull unsigned long long
#define inf 2e9+10
using namespace std;
inline ll read(){
    ll x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline int gcd(int a,int b){
	return !b?a:gcd(b,a%b);
}
const int MAXN=1e6+10;
int main(){
	int n=read();int x=read();int gc=0;
	for(int i=1;i<=n;i++){
		int t=read();
		t=abs(x-t);
		gc=gcd(t,gc);
	}
	printf("%d\n",gc);
	return 0;
}

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

S_out = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        edge0 = (i == 0)
        edge1 = (i == H - 1)
        edge2 = (j == 0)
        edge3 = (j == W -1)

        if S[i][j] == "#":
            S_out[i][j] = "#"
        else:
            S_out[i][j] = str(((S[i - 1][j - 1 + edge2:j + 2 - edge3] if not edge0 else "")
                           + S[i][j - 1 + edge2:j + 2 - edge3]
                           + (S[i + 1][j - 1 + edge2:j + 2 - edge3] if not edge1 else "")).count("#"))

print("\n".join(list(map(lambda x: "".join(x), S_out))))

Measured memory_bytes: 3188
import collections

n = int(input())
strings = list()
for line in range(0,n):
    strings.append(str(input()))

c = collections.Counter(strings)
most_common = c.most_common()[0][1]

outputs = list()
for key , val in c.items():
    if val == most_common:
        outputs.append(key)

outputs = sorted(outputs)
for line in outputs:
    print(line)

Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,m,a,b,c,d;cin>>n>>m>>a>>b>>c>>d;
    ll i=(a-c)*n,j=(b-d)*m;
    if(i>0){
        i*=-1;
        j*=-1;
    }
    if(i+j==0)out("infinity");
  	else if(i+j<0)out(0);
    else{
        ll ans=(-i)/(i+j)*2;
        if((-i)%(i+j)!=0)ans++;
        out(ans);
    }
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int dp[13][100009];
constexpr int mod=1000000007;
int cycle[]{1,10,9,12,3,4};
string s;
int n;
bool leading=0;

int solve(int rem,int idx,bool ok){
    //Just in case
    rem%=13;
    if(idx==n){
        //debug()<<imie(rem) imie(idx);
        if(rem==5) return 1;
        return 0;
    }
    assert(rem<13);
    auto &ref=dp[rem][idx];
    if(ref!=-1) return ref;
    int ans=0;
    if(s[idx]!='?'){
        int num=s[idx]-'0';
        int ci=n-idx-1;
        ci%=6;
        ans+=solve(rem+cycle[ci]*num,idx+1,1);
        ans%=mod;
        return ref=ans;
    }
    f(10){
        if(!ok&&i==0) ans+=solve(0,idx+1,0);
        else{
            int ci=n-idx-1;
            ci%=6;
            ans+=solve(rem+i*cycle[ci],idx+1,1);
        }
        ans%=mod;
    }
    return ref=ans%mod;
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>s;
    n=sz(s);
    bool b=0;
    if(s[0]!='?') b=1;
    f(13){
        f2(100002) dp[i][j]=-1;
    }
    cout<<solve(0,0,b);

    return 0;
}



Measured memory_bytes: 16556
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

int32_t main()
{	
	IOS
	int n, k;
	cin >> n >> k;
	int ans = min(n % k, k - (n % k));
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll mn1 = min(Q*4, min(H*2, S));
  ll mn2 = min(mn1*2, D);
  cout << mn2 * (N/2) + mn1 * (N%2) << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    string S;
    cin >> S;
    int height[20001], max_h[20001];
    height[0]=max_h[0]=0;
    for(int i=1;i<=S.size();i++){
        int d;
        if(S[i-1]=='_') d=0;
        else if(S[i-1]=='/') d=1;
        else d=-1;

        height[i]=height[i-1]+d;
        max_h[i]=max(max_h[i-1], height[i]);
    }
    stack<int> L;
    int k=0;
    int A=0;
    int dbl_s = 0;
    int level=-1000000;
    for(int i=S.size()-1;i>=0;i--){
        if(level==-1000000){
            if(S[i]=='/'){
                int l = -1;
                for(int j=i-1;j>=0;j--){
                    if(S[j]=='\\'){
                        l=j;
                        break;
                    }
                }
                if(l==-1) break;
                level=min(max_h[l], height[i+1]);
                if(height[i]<level) dbl_s = 1;
                else dbl_s = 0;
            }
        }else{
            if(S[i]=='/'){
                if(height[i]<level) dbl_s += (level-height[i])*2-1;
            }else if(S[i]=='_'){
                if(height[i]<level) dbl_s += (level-height[i])*2;
            }else{
                if(height[i+1]<level) dbl_s += (level-height[i])*2+1;
                if(height[i]==level){
                    L.push(dbl_s/2);
                    A += dbl_s/2;
                    k++;

                    level=-1000000;
                    dbl_s=0;
                }
            }
        }
    }

    cout << A << endl << k;
    while(!L.empty()){
        int l = L.top();
        L.pop();
        cout << ' ' << l;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3368
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = set(a)
if k >= len(b):
    print(0)
else:
    d = {}
    for i in a:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    c = list(d.values())
    c.sort()
    e = 0
    for i in range(len(b) - k):
        e += c[i]
    print(e)

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

int main(){
    int n, x, sum = 0, mi;
    cin >> n >> x;
    int array[n];
    for(int i = 0; i < n; i++){
        cin >> array[i];
        if(i == 0) mi = array[i];
        else mi = std::min(mi, array[i]);
        sum++;
        x -= array[i];
    }
    int diff = x/mi;
    cout << sum + diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#define a 3.14159265358979
using namespace std;
int main(){
  double r;
  cin >> r;
  cout << fixed << setprecision(7) << r*r*a << ' ' << fixed << setprecision(7) << 2*r*a << endl;
  return 0;
}

Measured memory_bytes: 1288
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
10 9
0 1
0 2
3 4
5 7
5 6
6 7
6 8
7 8
8 9
3
0 1
5 9
1 3

output:
yes
yes
no

"""

import sys


def assign_color():
    current_color = 1
    for v in range(vertices):
        if color[v] == -1:
            graph_dfs(v, current_color)
            current_color += 1
    return None


def graph_dfs(vertex, current_color):
    vertices_stack = list()
    vertices_stack.append(vertex)
    color[vertex] = current_color

    while vertices_stack:
        current_vertex = vertices_stack.pop()
        for v in adj_table[current_vertex]:
            if color[v] == -1:
                color[v] = current_color
                vertices_stack.append(v)
    return None


def solve():
    for relation in relation_info:
        key, value = map(int, relation)
        adj_table[key].append(value)
        adj_table[value].append(key)

    assign_color()

    # print(adj_list)
    for question in questions:
        source, target = map(int, question)
        if color[source] == color[target]:
            print("yes")
        else:
            print("no")
    return color


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, relations = map(int, _input[0].split())

    relation_info = map(lambda x: x.split(), _input[1:relations + 1])

    q_num = int(_input[relations + 1])
    questions = map(lambda x: x.split(), _input[relations + 2:])

    adj_table = tuple([] for _ in range(vertices))
    color = [-1] * vertices
    ans = solve()

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

int main() {
  long long N;
  cin >> N;
  
  if (N == 1) {
    cout << "Hello World" << endl; 
  } else {
    long long X, Y;
    cin >> X >> Y;
    cout << X + Y << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int k = 0;
  string s;
  cin >> s;
  for(int i = 0; i < 4; i++)
  {
      if(s[i] == '+')
        k++;
      if(s[i] == '-')
        k--;
  }
  cout << k;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=(a>b)?(a):(b);
#define chmin(a, b) (a)=(a<b)?(a):(b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

class Edge {
public:
  ll t, w;
  Edge() {}
  Edge(ll t, ll w): t(t), w(w) {}
};

ll N, M;
vector<Edge> g[2222];
ll d[2222][2222];

void dijkstra(ll s) {
  ll i, u;
  ll clr[2222]={};
  priority_queue<pll> q;
  for(i=0; i<N; i++) {
    d[s][i]=INF;
    clr[i]=0;
  }
  d[s][s]=0;
  q.push({0, s});
    
  while(q.size()) {
    pll f=q.top(); q.pop();
    u=f.second;
    clr[u]=1;
    if(d[s][u]<-f.first) continue;
    
    for(i=0; i<g[u].size(); i++) {
      Edge e=g[u][i];
      if(clr[e.t] || d[s][e.t]<=d[s][u]+e.w) continue;
      
      d[s][e.t]=d[s][u]+e.w;
      q.push({-d[s][e.t], e.t});
    }
  }
}
int main(void) {
  ll i, j, k;
  
  ll X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  
  for(i=0; i<N-1; i++) {
    g[i].push_back(Edge(i+1, 1));
    g[i+1].push_back(Edge(i, 1));
  }
  
  g[X].push_back(Edge(Y, 1));
  g[Y].push_back(Edge(X, 1));
  
  for(i=0; i<N; i++) dijkstra(i);
  
  ll cnt[2222]={};
  for(i=0; i<N; i++) for(j=i+1; j<N; j++) cnt[d[i][j]]++;
  
  for(i=1; i<N; i++) pt(cnt[i]);
  
  
  
}




Measured memory_bytes: 35200
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

import static java.util.Collections.reverseOrder;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Queue<Long> a = new PriorityQueue<>(reverseOrder());
        for (int i = 0; i < n; i++) {
            a.add(sc.nextLong());
        }
        for (int i = 0; i < m; i++) {
            long polled = a.poll();
            a.add(polled / 2);
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a.poll();
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 61076
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a[3], n;
    cin >> n;
    while(n > 0){
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a + 3);
        if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
            cout << "YES" << endl;
		else
            cout << "NO" << endl;
        n--;
    }
     return 0;
}

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

int main(){
  int n, d, x;
  cin >> n >> d >> x;
  int a[n];
  for(int i=0; i<n; ++i){
    cin >> a[i];
    for(int j=1; j<d+1; j+=a[i]){
      x++;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        if (rate < 1200) {
            System.out.println("ABC");
        } else if(rate < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}


Measured memory_bytes: 23892
# coding: utf-8
# Your code here!

N, M = map(int, input().split())
std_li = [list(map(int, input().split())) for i in range(N)]
chk_li = [list(map(int, input().split())) for j in range(M)]
dist = 0

for i in range(N):
    ctr = 0
    min_dist = pow(10,8) * 4 + 1
    for j in range(M):
        dist = abs(std_li[i][0] - chk_li[j][0]) + abs(std_li[i][1] - chk_li[j][1])
        if dist < min_dist:
            min_dist = dist
            ctr = j + 1
    print(ctr)

Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nm = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        if (n >= m) {
            System.out.println(0);
            return;
        }

        String[] line = scanner.nextLine().split(" ", m);
        int[] arr = new int[m];
        for (int i = 0; i < m; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        Arrays.sort(arr);

        int[] diff = new int[m-1];
        for (int i = 0; i < m - 1; i++) {
            diff[i] = arr[i+1] - arr[i];
        }
        Arrays.sort(diff);

        long sum = 0;
        for (int i = 0; i < m - n; i++) {
            sum += diff[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 48584
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;

void main()
{
	auto n = to!int(chomp(readln()));
	string[] ws;
	ws ~= chomp(readln());
	bool isYes = true;
	foreach (i; 1..n)
	{
		ws ~= chomp(readln());
		if (ws[i-1][$-1] != ws[i][0])
		{
			isYes = false;
			break;
		}
		else if (countUntil(ws[0..$-1], ws[$-1]) != -1)
		{
			isYes = false;
			break;
		}
	}

	if (isYes)
		writeln("Yes");
	else
		writeln("No");

	stdout.flush();
}

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

using namespace std;

typedef long long ll;

const int MAXN = 1E5 + 10;

int n, m;
vector<int> E[MAXN];
int color[MAXN];

void DFS(int u, bool &flag){
	for (auto v: E[u])
		if (~color[v])
			flag |= color[u] == color[v];
		else{
			color[v] = !color[u];
			DFS(v, flag);
		}
}

int main(){
	scanf("%d%d", &n, &m);
	for (int u, v, i = 0; i < m; ++i){
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}

	ll cnt[3] = {0, 0, 0};
	fill_n(color + 1, n, -1);
	for (int i = 1; i <= n; ++i)
		if (E[i].size() == 0)
			++cnt[0];
		else if (!~color[i]){
			bool flag = false;
			color[i] = 0;
			DFS(i, flag);
			++cnt[1 + flag];
		}
	printf("%lld\n", (cnt[1] + cnt[2]) * (cnt[1] + cnt[2]) + cnt[1] * cnt[1] + cnt[0] * n * 2 - cnt[0] * cnt[0]);
	return 0;
}


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

int main(){
  int s;
  cin >>s;
  
  int a;
  a = s /100;//100の位
  int b;
  b = a*100;
  int p;
  p = s - b;//10の位と1のくらい
  
  int c;
  c = p/10;//10の位
  int d;
  d = c *10;
  int q;
  q = p - d;//1の位
  
  cout<<a+c+q<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200010;
ll ans;
int mx, mn, mxa, mnb, k;
int n;
struct arr {
	int x, y;
	void r() {
		scanf ("%d%d", &x, &y);
		if (x > y) swap(x, y);
		mn = min(mn, x);
		mx = max(mx, y);
		mxa = max(mxa, x);
		mnb = min(mnb, y);
	}
} a[N];
bool cmp(arr a, arr b) { return a.x < b.x; }
int main()
{
	mn = mnb = k = 1 << 30;
	scanf ("%d", &n);
	Rep(i, 1, n) a[i].r();
	/* {
		scanf ("%d%d", &a[i], &b[i]);
		if (a[i] > b[i]) swap(a[i], b[i]);
	} */
	ans = ll(mxa - mn) * (mx - mnb);
	sort(a + 1, a + n + 1, cmp);
	Rep(i, 1, n - 1) {
		mxa = max(mxa, a[i].y);
		k = min(k, a[i].y);
		ans = min(ans, ll(mxa - min(a[i + 1].x, k)) * (mx - mn));
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int a,b;
  cin >> a>> b;
  cout << a*b << endl;
  return 0;
} 


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


struct low_link {
public :
	vector<int> articulation;
	vector<pair<int, int>> bridge;
private :
	struct edge {
		int to, idx;
		edge (int to, int idx) : to(to), idx(idx) { }
	};
	int n, edge_index = 0;
	vector<vector<edge>> g;
	vector<int> order, low;
	vector<bool> seen;

	int dfs (int v, int p, int ord) {
		seen[v] = true;
		order[v] = ord++;
		low[v] = order[v];
		int child = 0;
		bool isart = false;
		for (const edge &e : g[v]) if (p != e.idx) {
			if (seen[e.to]) {
				low[v] = min(low[v], order[e.to]);
			} else {
				child++;
				ord = dfs(e.to, e.idx, ord);
				low[v] = min(low[v], low[e.to]);
				if (p != -1) isart |= (order[v] <= low[e.to]);
				if (order[v] < low[e.to]) {
					bridge.push_back(minmax(v, e.to));
				}
			}
		}
		isart |= (p == -1 and child >= 2);
		if (isart) articulation.push_back(v);
		return ord;
	}

public :
	low_link (int n) : n(n), g(n), order(n), low(n), seen(n) { }

	void add_edge (int v, int u) {
		g[v].emplace_back(u, edge_index);
		g[u].emplace_back(v, edge_index);
		edge_index++;
	}

	void build (int r = 0) {
		bridge.clear(); articulation.clear();
		fill(seen.begin(), seen.end(), false);
		for (int s = 0; s < g.size(); s++) {
			if (not seen[s]) dfs(s, -1, 0);
		}
	}

};


int main() {
	int n, m;
	cin >> n >> m;
	low_link g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g.add_edge(a, b);
	}
	
	g.build();
	sort(g.bridge.begin(), g.bridge.end());
	for (pair<int, int> e : g.bridge) {
		cout << e.first << ' ' << e.second << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 5088
import java.util.Scanner;

public class Main {

    private static final String KEYENCE = "keyence";
    private static final int K_LEN = KEYENCE.length();

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

        String S = scanner.next();

        scanner.close();

        if (S.equals(KEYENCE)) {
            System.out.println("YES");
            return;
        }

        int length = S.length();
        for (int i = 0; i < K_LEN; i++) {
            String s = S.substring(0, i) + S.substring(length - K_LEN + i, length);
            if (s.equals(KEYENCE)) {
                System.out.println("YES");
                return;
            }
        }

        System.out.println("NO");
    }
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	std::vector<int> hen[n];
	for (int i = 0; i < m; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		hen[a].push_back(b);
		hen[b].push_back(a);
	}
	
	std::vector<bool> used(n);
	auto extend = [&] (int start) {
		std::vector<int> path{start};
		int cur = start;
		used[cur] = true;
		while (1) {
			if (!hen[cur].size()) break;
			int next = hen[cur].back();
			hen[cur].pop_back();
			if (used[next]) continue;
			path.push_back(next);
			cur = next;
			used[next] = true;
		}
		return path;
	};
	auto r0 = extend(0);
	auto r1 = extend(0);
	std::reverse(r1.begin(), r1.end());
	r1.pop_back();
	r0.insert(r0.begin(), r1.begin(), r1.end());
	printf("%d\n", (int) r0.size());
	for (auto i : r0) printf("%d ", i + 1);
	puts("");
	return 0;
}


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

long long int N, K, b, i, r, m, n, a[20];
vector<bool> f;

int main(){
    scanf("%lld%lld", &N, &K);
    for(i = 0; i < N; ++i){
        scanf("%lld", a + i);
        f.push_back(i < K);
    }
    n = 1145141919810LL;
    do{
        r = 0;
        m = *a;
        for(i = 1; i < N; ++i){
            if(m >= a[i]){
                if(f[i]){
                    r += m - a[i] + 1;
                    ++m;
                }
            }else{
                m = a[i];
            }
        }
        n = min(r, n);
    }while(prev_permutation(f.begin(), f.end()));
    cout << n << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll N= 1e5+7;
ll  n , l,r , x , y;
vector<int>v;
ll GCD( ll num1 , ll num2)
{
    if(min(num1 , num2)==0)
    {
        return max(num1, num2);
    }
    return GCD(max(num1,num2)%min(num1,num2) , min(num1 , num2));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >>l>>r;
    y=2019;
    if((r-l+1)>=2019)
    {
        cout << 0;
        return 0;
    }
    else
    {
        for(int i = l ; i <= r ;i++)
        {
            for(int j = i+1 ; j <= r ;j++)
            {
                x=((i%2019)*(j%2019))%2019 ;
                y=min(y,x);
            }
        }
    }
    cout << y ;
    return 0;
}


Measured memory_bytes: 256