akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i <= (n); i++)
#define repb(i, a, n) for (int i = (a); i >= (n); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}

void co_elem(auto &A) {
    rep(i, 0, A.size() - 1) {
        if (i < A.size() - 1) {
            cosp(A[i]);
        } else {
            co(A[i]);
        }
    }
}

void bubbleSort(vector<string> &A, int N, int &changed) {
    int flag = 1;
    int i = 0;
    while (flag) {
        flag = 0;
        repb(j, N - 1, i + 1) {
            if (A[j][1] < A[j - 1][1]) {
                swap(A[j], A[j - 1]);
                flag = 1;
                changed++;
            }
        }
        i++;
    }
}

void selectionSort(vector<string> &A, int N, int &changed) {
    rep(i, 0, N - 1) {
        int minv = A[i][1], tmp = 0;
        rep(j, i + 1, N - 1) {
            if (A[j][1] < minv) {
                minv = A[j][1];
                tmp = j;
            }
        }
        if (A[i][1] != minv) {
            swap(A[i], A[tmp]);
            changed++;
        }
    }
}

string isStable(vector<string> &in, vector<string> &out) {
    int N = in.size();
    rep(i, 0, N - 1) {
        rep(j, i + 1, N - 1) {
            rep(a, 0, N - 1) {
                rep(b, a + 1, N - 1) {
                    tuple<string, string, string, string, string, string> t;
                    t = make_tuple(in[i][1], in[j][1], in[i], out[b], in[j], out[a]);
                    if (in[i][1] == in[j][1] && in[i] == out[b] && in[j] == out[a]) {
                        return "Not stable";
                    }
                }
            }
        }
    }
    return "Stable";
}

int main() {
    int N, changed = 0;
    cin >> N;
    vector<string> A(N);
    rep(i, 0, N - 1) {
        cin >> A[i];
    }
    vector<string> A1 = A;
    vector<string> A2 = A;
    bubbleSort(A1, N, changed);
    co_elem(A1);
    co(isStable(A, A1));
    selectionSort(A2, N, changed);
    co_elem(A2);
    co(isStable(A, A2));
    return 0;
}


Measured memory_bytes: 3168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=a/100;
        a%=100;
        if(a<=12&&a>=1){
            if(b<=12&&b>=1)
                System.out.println("AMBIGUOUS");
            else
                System.out.println("YYMM");
        }
        else {
            if(b<=12&&b>=1)System.out.println("MMYY");
            
            else
            System.out.println("NA");
        }
    }
}


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

int tt,tx,ty,x,y,t,f;
int n;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> tt >> tx >> ty;
		if((((tt-t)-(abs(tx-x)+abs(ty-y)))%2!=0||abs(tx-x)+abs(ty-y)>tt-t))
		{
			cout << "No";
			return 0;
		}
		t=tt,x=tx,y=ty;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define MOD 1000000007

typedef long long ll;

typedef struct pair {
    ll x, h;
}pair;

int asc(const void* a, const void* b) { return *(int*)a - *(int*)b; }

ll max(ll x, ll y) { return (x > y) ? x : y; }

ll min(ll x, ll y) { return (x < y) ? x : y; }

int main() {
    ll n, d, a;
    pair monster[200001];
    scanf("%lld%lld%lld", &n,&d,&a);
    ll X, H;
    for (ll i = 0; i < n; i++) {
        scanf("%lld%lld", &X, &H);
        monster[i].x = X;
        monster[i].h = (H - 1) / a + 1;
    }
    qsort(monster, n, sizeof(pair), asc);
    ll arr[200001] = {}, r = 0, ans = 0;
    for (ll l = 0; l < n; l++) {
        if (l) arr[l] += arr[l - 1];
        if (monster[l].h <= arr[l]) continue;
        while (r < n && monster[r].x - monster[l].x <= 2 * d) r++;
        ll cnt = monster[l].h - arr[l];
        ans += cnt;
        arr[l] += cnt;
        arr[r] -= cnt;
    }
    
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 8184
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-12;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int t;
    cin>>t;
    while(t--){
        ll n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        ll ans = 1e18;
        queue<array<ll,2>> q;
        q.push({n,0});
        unordered_map<ll,ll> mp;
        while(q.size()){
            ll now = q.front()[0], cost = q.front()[1];
            q.pop();
            if(mp.count(now) && cost >= mp[now]) continue;
            mp[now] = cost;
            if(now <= 1e18/d){
                chmin(ans,cost+d*now);
            }
            //if(now==1)cerr << cost << "\n";
            for(ll i = -4;i<5;i++){
                ll ret = now + i;
                ll nc = cost + abs(i)*d;
                if(ret < 0)continue;
                else if(ret == 0){
                    chmin(ans,nc);
                    continue;
                }
                if(-1<=i && i<=1 && ret % 2 == 0){
                    q.push({ret/2LL,nc+a});
                }
                if(-2<=i && i<=2 && ret % 3 == 0){
                    q.push({ret/3LL,nc+b});
                }
                if(ret % 5 == 0){
                    q.push({ret/5LL,nc+c});
                }
            }
        }
        cout << ans << "\n";
    }
    

}


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

int main(){
    bool flg=true;
    int N,i,a=0,b=0;
    cin>>N;
    vector<int>P(N),Q(N),Pc(N),A(N);
    for(i=0;i<N;i++)cin>>P[i];P[i]=Pc[i];
    for(i=0;i<N;i++)cin>>Q[i];
    for(i=1;i<=N;i++)A[i-1]=i;

    do{
        for(i=0;i<N;i++)if(A[i]!=P[i])flg=false;
        if(flg)break;
        flg=true;
        a++;
    }while(next_permutation(A.begin(),A.end()));

    for(i=1;i<=N;i++)A[i-1]=i;
    do{
        for(i=0;i<N;i++)if(A[i]!=Q[i])flg=false;
        if(flg)break;
        flg=true;
        b++;
    }while(next_permutation(A.begin(),A.end()));

    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string.h>

int main()
{
    char s[128];
    char t[128];
    std::cin >> s >> t;
    std::sort(s, s + strlen(s));
    std::sort(t, t + strlen(t), [](char a, char b) { return a > b; });
    
    std::cout << (strcmp(s, t) < 0 ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

fn main() {
  let (h, n) = {
    let tmp: Vec<u64> = read_vec();
    (tmp[0], tmp[1])
  };
  let a = read_vec::<u64>();
  let sum: u64 = a.iter().sum();
  let ans: &str = if (sum >= h) {
    "Yes"
  }  else {
    "No"
  };
  println!("{}", ans);
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e5+10;
int a[maxx];
int cmp(int a,int b){
	return a<b;
}
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,n){
		scanf("%d",&a[i]);
	}
	sort(a,a+n,cmp);
	int all=0;
	rep(i,0,m){
		all+=a[i];
	}
	printf("%d",all);
} 

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll mod = static_cast<ll>(1e9) + 7;

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

    vector<ll> A(N);
    for (auto& a : A) { cin >> a; }


    ll sum = 0;
    for (const auto& a : A) { sum += a; }


    ll lhs = 0, rhs = sum, minDistance = sum;

    for (const auto& a : A)
    {
        lhs += a;
        rhs -= a;

        const auto& distance = abs(rhs - lhs);
        minDistance = min(distance, minDistance);
    }

    cout << minDistance << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int e = 2e6 + 69;

vector<int>rel[e];
bool checked[e];

void dfs(int i){
    checked[i] = true;
    for (int j : rel[i])
    {
        if(!checked[j]) dfs(j);
    }    
}

int main(){
    int n,m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin>> a >> b >> c;
        rel[a-1].push_back(b-1);
        rel[b-1].push_back(a-1);
    }
    memset(checked,false, sizeof(checked));
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if(!checked[i]){
            dfs(i);
            sum ++ ;
        }
    }
    cout << sum << endl; 
}

Measured memory_bytes: 58656
#include <stdio.h>

int main(void){
	int W,H,N,i,j,ans=0;
	scanf("%d %d %d",&W,&H,&N);
	int x[N],y[N];
	for(i=0;i<N;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	int nx=x[0],ny=y[0];
	
	for(i=1;i<N;i++){
		while(!(nx==x[i]&&ny==y[i])){
		if(nx<x[i]&&ny<y[i]){
			ans++;
			nx++;
			ny++;
		}
		
		else if(nx<x[i]&&ny==y[i]){
			ans++;
			nx++;
		}
		
		else if(nx<x[i]&&ny>y[i]){
			ans++;
			nx++;
//			ny--;
		}
		
		else if(nx==x[i]&&ny<y[i]){
			ans++;
			ny++;
		}
		
		else if(nx==x[i]&&ny>y[i]){
			ans++;
			ny--;
		}
		
		else if(nx>x[i]&&ny<y[i]){
			ans++;
			nx--;
//			ny++;
		}
		
		else if(nx>x[i]&&ny==y[i]){
			ans++;
			nx--;
		}
		
		else if(nx>x[i]&&ny>y[i]){
			ans++;
			nx--;
			ny--;
		}
		}
	}
	
	printf("%d\n",ans);
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, m; cin >> n >> m;
    vint l(m), r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }
    vint imos(n+1, 0);
    rep(i, m) {
        imos[l[i]]++;
        imos[r[i]+1]--;
    }
    rep(i, n) imos[i+1] += imos[i];
    int cnt = 0;
    rep(i, n) {
        if(imos[i] == m) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1408
while True: 
    try: 
        H, W = map(int, input().split())
        if H == 0 and W == 0:
            break;
            
        for i in range(H):
            for j in range(W):
                if (i+j)%2 == 0:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
        print()
        
    except:
        break;


Measured memory_bytes: 7012
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
ll N,M;
priority_queue<P> ABC;

int main(){
    cin>>N>>M;
    rep(i,N){
        ll a;
        cin>>a;
        ABC.push(P(a,1));
    }
    rep(i,M){
        ll b,c;
        cin>>b>>c;
        ABC.push(P(c,b));
    }

    ll ans=0;
    while(N>0){
        ll c=ABC.top().first;
        ll b=ABC.top().second;
        while(b>0){
            ans+=c;
            b--;
            N--;
            if(N<=0) break;
        }
        ABC.pop();
    }

    cout<<ans<<endl;
}

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

template <typename Cost>
class BellmanFord {
private:
	struct Edge {
		int src, dst;
		Cost cost;
	};
	
public:
	BellmanFord(int n = 0) : n(n), INF(numeric_limits<Cost>::max()){}
	
	void addEdge(int src, int dst, Cost cost){
		g.push_back({src, dst, cost});
	}
	
	void solve(int s){
		d.assign(n, INF);
		p.assign(n, -1);
		nega = false;
		
		auto update = [&](int src, int dst, Cost sum){
			if (d[dst] > sum){
				d[dst] = sum;
				p[dst] = src;
				return true;
			}
			return false;
		};
		
		d[s] = 0;
		for (int k = 0; k < n; k++){
			for (Edge &e : g){
				if (!reach(e.src)) continue;
				if (update(e.src, e.dst, d[e.src] + e.cost) && k == n - 1){
					d[e.dst] = -INF;
					nega = true;
				}
			}
		}
	}
	
	bool negativeCycle(){
		return nega;
	}
	
	bool reach(int v){
		return d[v] != INF;
	}
	
	Cost dist(int v){
		return d[v];
	}
	
	vector<int> path(int v){
		vector<int> res;
		for (int u = v; ~p[u]; u = p[u]){
			res.push_back(u);
		}
		reverse(begin(res), end(res));
		return res;
	}
	
private:
	const Cost INF;
	int n;
	vector<Edge> g;
	vector<Cost> d;
	vector<int> p;
	bool nega;
};


int main()
{
	int n, m, r;
	scanf("%d %d %d", &n, &m, &r);
	
	BellmanFord<int> solver(n);
	
	for (int i = 0; i < m; i++){
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);
		
		solver.addEdge(s, t, d);
	}
	
	solver.solve(r);
	
	if (solver.negativeCycle()){
		puts("NEGATIVE CYCLE");
	}
	else {
		for (int i = 0; i < n; i++){
			if (solver.reach(i)) printf("%d\n", solver.dist(i));
			else puts("INF");
		}
	}
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define MOD 1000000007
#define int long long
#define N 100005
 
int a[105], freq[N] = {0}, dp[N];
signed main()
{
    int n;
    cin>>n;
    int i;
    int even =0,odd=0;
    for(i=1;i<=n;i++)
    {
        if(i%2==0)
        even++;
        else
        odd++;
    }
    double total=odd+even;
    double p1,p2;
    p1=(double)even/(double)total;
    p2=odd/total;
    printf("%.10lf",p2);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


vll par(MAX),siz(MAX);

//par[i]=iならiは根（はじめは全て根）
void init(ll n){
  rep(i,0,n){
    par[i]=i;siz[i]=1LL;
  }
  return;
}
//xの根
ll root(ll x){
  return (par[x]==x)?x:par[x]=root(par[x]);
}
//xが根の木とyが根の木を繋げる
void unite(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y){return;}
  if(siz[x]<siz[y]){swap(x,y);}
  siz[x]+=siz[y];
  par[y]=x;
}
//根が同じかどうか
bool same(ll x,ll y){
  return root(x)==root(y);
}
int main(){
  ll n,m;cin>>n>>m;
  init(n);
  vp g(m);
  rep(i,0,m){
    cin>>g[i].first>>g[i].second;
    g[i].first--;g[i].second--;
  }
  vll ans(m);
  ans[m-1]=(n*(n-1))/2;
  set<ll>s;
  
  drep(i,m-1,1){
    if(root(g[i].first)!=root(g[i].second)){
      ans[i-1]=ans[i]-siz[root(g[i].first)]*siz[root(g[i].second)];
    }
    else ans[i-1]=ans[i];
    unite(g[i].first,g[i].second);
    
  }
  rep(i,0,m)cout<<ans[i]<<endl;
  
}



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

int main()
{

string s ,t;
cin>>s>>t;

for(int index = 0;index<s.size();index++)
if(s[index]!=t[index])
{
    cout<<"No"<<endl;
    return 0 ;
}
cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
#include<numeric>
using namespace std;

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

    vector<int> B(N - 1);
    for (int i = 0; i < N - 1; i++)
        cin >> B[i];

    vector<int> A(N, INT_MAX);
    for (int i = 0; i < N; i++) {
        if (i == 0)
            A[0] = B.front();
        else if (i == N - 1)
            A[N - 1] = B.back();
        else
            A[i] = min(B[i], B[i - 1]);
    }

    int ans = accumulate(A.begin(), A.end(), 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");
        int inta = Integer.parseInt(str[0]);
        int intb = Integer.parseInt(str[1]);
 
        System.out.printf("%d %d %f", inta/intb, inta%intb, (double)inta/intb);
 
    }
 
}

Measured memory_bytes: 26424
def main():
  S = input()
  for i in range(len(S)):
    if (i+1) % 2 == 1 and S[i] == 'L':
      print('No')
      exit()
    elif (i+1) % 2 == 0 and S[i] == 'R':
      print('No')
      exit()
  print('Yes')


if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
/* The journey is what brings us pleasure, not the destination <3 */

#include<bits/stdc++.h>

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int tc;


void solve()
{

    ll n,x;
    cin>>n;
    x=n/1000;
    if(n%1000)x++;
    cout<<(x*1000)-n<<endl;
}

int main()
{

    _fastIO;

    //cin>>tc;while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    string s;   cin >> s;
    ll res=0, rc=0;
    rep(i, n){
        if(s[i]=='R') rc += 1;
    }
    if(0<rc){
        rep(i, n){
            if(s[i]=='W') res += 1;
            rc -= 1;
            if(rc==0) break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int gcd(int i, int j){
   if(i>j) return gcd(j,i);
   if(j%i==0) return i;
   return gcd(j%i, i);
}

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

   return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
    int a,b,c,d,ab,cd;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    ab=a*b;
    cd=c*d;
    if(ab>cd)
        printf("%d\n",ab);
    else
        printf("%d\n",cd);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T, typename E> struct Segtree {
    inline T merge(const T &a, const T &b) { return min(a, b); }
    inline void act(E &a, const E &b) { a += b; }
    inline void comb(T &a, const E &b) { a += b; }
    int n;
    T et;
    E ee;
    vector<T> dat;
    vector<E> laz;
    Segtree(int n_, T et, E ee) : et(et), ee(ee) {
        n = 1;
        while (n < n_) {
            n <<= 1;
        }
        dat.resize(2 * n);
        laz.resize(2 * n, ee);
    }
    inline void eval(int k) {
        if (laz[k] == ee) {
            return;
        }
        comb(dat[k], laz[k]);
        if (k < n) {
            act(laz[k << 1], laz[k]);
            act(laz[k << 1 | 1], laz[k]);
        }
        laz[k] = ee;
    }
    void upd(const int &a, const int &b, const E &x, int k, int l, int r) {
        eval(k);
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            act(laz[k], x);
            eval(k);
            return;
        }
        upd(a, b, x, k << 1, l, (l + r) >> 1);
        upd(a, b, x, k << 1 | 1, (l + r) >> 1, r);
        dat[k] = merge(dat[k << 1], dat[k << 1 | 1]);
    }
    inline void upd(const int &a, const int &b, const E &x) {
        if (a >= b) {
            return;
        }
        upd(a, b, x, 1, 0, n);
    }
    T get(const int &a, const int &b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return et;
        }
        eval(k);
        if (a <= l && r <= b) {
            return dat[k];
        }
        return merge(get(a, b, k << 1, l, (l + r) >> 1),
                     get(a, b, k << 1 | 1, (l + r) >> 1, r));
    }
    inline T get(const int &a, const int &b) {
        if (a >= b) {
            return et;
        }
        return get(a, b, 1, 0, n);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    Segtree<ll, ll> tree(n + 10, LINF, 0);
    while (q--) {
        int a;
        cin >> a;
        int s, t, x;
        if (a == 1) {
            cin >> s >> t;
            cout << tree.get(s, t + 1) << endl;
        } else {
            cin >> s >> t >> x;
            tree.upd(s, t + 1, x);
        }
    }
}



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

int main() {
    int a, b, c;
    cin>>a>>b>>c;
     
    if((a<c && c<b) || (b<c && c<a)) {
        cout<<"Yes";
    } else {
        cout<<"No";
    }
    cout<<endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  string ans = "No";
  if (S[0] != S[1] || S[0] != S[2] || S[1] != S[2]) {
    ans = "Yes";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

if n == 3:
    print("2")
    print("1 3")
    print("2 3")
if n == 4:
    print("4")
    print("1 2")
    print("1 3")
    print("2 4")
    print("3 4")
if n >= 5:
    ans = []
    if n % 2 == 0:
        for i in range(1, n):
            for j in range(i+1, n+1):
                if i + j != n+1:
                    ans.append(str(i)+" "+str(j))
                    # print(str(i)+" "+str(j))
    if n % 2 == 1:
        for i in range(1, n-1):
            for j in range(i+1, n):
                if i + j != n:
                    ans.append(str(i)+" "+str(j))
                    # print(str(i)+" "+str(j))
        for i in range(1, n):
            ans.append(str(i)+" "+str(n))
            # print(str(i)+" "+str(n))
    ans_len = len(ans)
    print(ans_len)
    for a in ans:
        print(a)

# for ptn1 in range(2 ** 5):
#     ptn_str1 = format(ptn1, '05b')
#     p1 = []
#     for i, p in enumerate(ptn_str1):
#         if p == '1':
#             p1.append(i+2)
#     for ptn2 in range(2 ** 4):
#         ptn_str2 = format(ptn2, '04b')
#         p2 = []
#         for j, q in enumerate(ptn_str2):
#             if q == '1':
#                 p2.append(j+3)
#         for ptn3 in range(2 ** 3):
#             ptn_str3 = format(ptn3, '03b')
#             p3 = []
#             for k, r in enumerate(ptn_str3):
#                 if r == '1':
#                     p3.append(k+4)
#             for ptn4 in range(2 ** 2):
#                 ptn_str4 = format(ptn4, '02b')
#                 p4 = []
#                 for l, s in enumerate(ptn_str4):
#                     if s == '1':
#                         p4.append(l+5)
#                 adds = [0, 0, 0, 0, 0, 0]
#                 for x in p1:
#                     adds[0] += x
#                     adds[x-1] += 1
#                 for y in p2:
#                     adds[1] += y
#                     adds[y-1] += 2
#                 for z in p3:
#                     adds[2] += z
#                     adds[z-1] += 3
#                 for zz in p4:
#                     adds[3] += zz
#                     adds[zz-1] += 4
#                 if adds[4]+6 == adds[5]+5:
#                     # print("adds5&6"+ptn_str1+"/"+ptn_str2+"/"+ptn_str3+"/"+ptn_str4)
#                     adds[4] += 6
#                     adds[5] += 5
#                 eq = adds[0]
#                 if eq != 0:
#                     equal = True
#                     for s in adds:
#                         if s != eq:
#                             equal = False
#                             break
#                     if equal is True:
#                         print(eq)
#                         print(ptn_str1)
#                         print(ptn_str2)
#                         print(ptn_str3)
#                         print(ptn_str4)



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

string S;
int str_len, w, i, j;
long long sum;
int w_place[200010];


int main(void) {
    cin >> S;
    str_len = int(S.size());
    w = 0;
    j = 0;
    for (i=0; i<str_len; i++) {
        if (S[i] == 'W') {
            w_place[j] = i;
            j++;
        }
    }
    

    
    sum = 0;
    for (i=0; i<j; i++) {
        sum += w_place[i] - w;
        w++;
    }
    
    cout << sum << endl;
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int maa = 0, res = 0;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		if (A > maa) {
			maa = A;
			res = A + B;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let ab = reada int
    let a = ab.[0]
    let b = ab.[1]
    let f = if (a * b) % 2 = 0 then "Even" else "Odd"
    printfn "%s" f
    0


Measured memory_bytes: 13916
#include <iostream>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

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

  for (int i = 0; i < a; i++) {
    if (!isdigit(s[i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = a + 1; i < s.size(); i++) {
    if (!isdigit(s[i])) {
      cout << "No" << endl;
      return 0;
    }
  }

  if (s[a] != '-') {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

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

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  REP(i,n)cin>>v[i];
  int mn = *min_element(begin(v),end(v));
  for(int i=1;i<=mn;++i){
    bool ok=true;
    REP(j,n){
      if(v[j]%i)
        ok=false;
    }
    if(ok)
      cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 1192
N, x = map(int, input().split())

if N == 2:
    if x == 2:
        print('Yes')
        print(1)
        print(2)
        print(3)
    else:
        print('No')
    exit()

if x == 1 or x == 2*N-1:
    print('No')
elif x == 2:
    print('Yes')
    for i in range(N-2):
        print(i+3)
    print(1)
    print(2)
    for i in range(N+1, 2*N):
        print(i)
else:
    print('Yes')
    ans = list(range(1, 2*N))
    ans[N-3], ans[x-2] = ans[x-2], ans[N-3]
    ans[N-2], ans[x] = ans[x], ans[N-2]
    ans[N-1], ans[x-1] = ans[x-1], ans[N-1]
    ans[N], ans[x-3] = ans[x-3], ans[N]
    for a in ans:
        print(a)


Measured memory_bytes: 48348
import sys
s = sys.stdin.read().lower()
a = {chr(i): 0 for i in range(ord('a'), ord('z')+1)}
for i in s:
    if ord(i) in range(ord('a'), ord('z')+1):
        a[i] += 1
[print(f'{k} : {v}') for k, v in a.items()]


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

int main() {
  long long int N;
  cin >> N;
  for (long long int i = 1; i <= 3500; i++) {
    bool X = false;
    for (long long int j = 1; j <= 3500; j++) {
      if (4 * i * j - N * i - N * j > 0 &&
          (N * i * j) % (4 * i * j - N * i - N * j) == 0) {
        int k = (N * i * j) / (4 * i * j - N * i - N * j);
        if (k >= 1 && k <= 3500) {
          cout << i << " " << j << " " << k << endl;
          X = true;
          break;
        }
      }
    }
    if (X) break;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n == 25)
    {
        cout << "Christmas" << endl;
    }
    if (n == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    if (n == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    if (n == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int dataCount = Integer.parseInt(scanner.nextLine());
        
        int[] data = new int[dataCount];
        
        for (int i = 0; i < dataCount; i++) {
            data[i] = Integer.parseInt(scanner.nextLine());
        }
        int profit = Integer.MIN_VALUE;
        int min = data[0];
        
        for (int i = 1; i < dataCount; i++) {
            profit = Math.max(profit, data[i] - min);
            min = Math.min(min, data[i]);
        }
        System.out.println(profit);
    }
}


Measured memory_bytes: 169692
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  REP(a,1,10){
    REP(b,1,10){
      if(a*b==N){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define ftt ft.ft
#define ftc ft.sc
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 




    bool a ,b ,c;
int main(){FAST;
        char ch[3];
        forp(i ,0 ,3){
            cin >> ch[i];
            if(ch[i] == 'a')
                a = true;
            else if(ch[i] == 'b')
                b = true;
            else if(ch[i] == 'c')
                c = true ,err(i);
    }
        a && (b && c) ? cout << "Yes" : cout << "No";

   return 0;
}
 












Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 23124
import math

while True:
    X = input().split()
    a = int(X[0])
    op = X[1]
    b = int(X[2])
    
    if op == "?":
        break
    
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(math.floor(a / b))
        


Measured memory_bytes: 5660
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

vector<vector<int>> edge;
vector<int> depth;

void paint(int node, int parent, int d) {
  depth[node] = d;
  for (int e : edge[node]) {
    if (e != parent) {
      paint(e, node, d + 1);
    }
  }
}

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

  edge.resize(N);
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  depth.resize(N);
  paint(0, 0, 0);

  int odd = 0;
  rep(i, N) { odd += depth[i] % 2; }

  using P = pair<int, int>;
  vector<P> idx;
  rep(i, N) { idx.push_back(P(depth[i] % 2, i)); }
  sort(idx.begin(), idx.end());

  vector<P> tmp;
  if (N - odd <= N / 3) {
    rep(i, N) { tmp.push_back(P((i + 1) % 3, i + 1)); }
  } else if (odd <= N / 3) {
    rep(i, N) { tmp.push_back(P(-((i + 1) % 3), i + 1)); }
  } else {
    rep(i, N) {
      int r = (i + 1) % 3;
      int key = (r == 0 ? 0 : (r == 1 ? -1 : 1));
      tmp.push_back(P(key, i + 1));
    }
  }
  sort(tmp.begin(), tmp.end());

  vector<int> result(N);
  rep(i, N) { result[idx[i].second] = tmp[i].second; }

  rep(i, N) { cout << result[i] << " "; }

  return 0;
}

Measured memory_bytes: 23044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <numeric>
using namespace std;
#define ll long long
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    char a;
    int sum=0;
    cin >> n;
    for(int i=0;i<n.size();i++){
        a=n[i];
        sum+=a-'0';
    }
    if(stoi(n)%sum==0){cout << "Yes" << endl;}
    else cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    Integer[] L= new Integer[N];
    for(int i = 0;i<N;i++) L[i]=Integer.parseInt(sc.next());
    int r = 0;
    Arrays.sort(L,Collections.reverseOrder());
    for (int i = 0;i<N-2;i++){
      for(int k = i+1;k<N-1;k++){
        int invm = -1;
        int invs = -1;
        int m = L[i]+L[k];
        int s = L[i]-L[k];
        int Mstart = 0;
        int Sstart = 0;
        if(L[k+(N-k)/2]>=m) Mstart = (N-k)/2;
        if(L[k+(N-k)/2]>s) Sstart = (N-k)/2;
        for(int j = 0;j<(N-k)/2;j++){
          if(invm == -1 && k + Mstart + j + 1 < N && L[k+Mstart+j+1]<m){
            if(L[(k+Mstart+j+1+N)/2]>=m){
              invm = (k+Mstart+j+1+N)/2-1;
            }else{
              invm = k+Mstart+j;
            }
          }
          if(invs ==-1 &&k+Sstart+j+1<N&&L[k+Sstart+j+1]<=s){
            if(L[(k+Mstart+j+1+N)/2]>=m){
              invs=(k+Sstart+j+1+N)/2-1;
            }else{
            invs = k+Sstart+j;
            }
          }
        }
        if(invs == -1) invs = N-1;
        if(invs>invm) r+=invs-invm;
      }
    }
    System.out.println(r);
  }
}

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

template<class T> inline void chmax(T &a,T b){
	if(a<b){
		a=b;
		return;
	}
	return;
}

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

	vector<vector<long long>> p(n);
	
	for(int i=0;i<n;i++){
		int t;
		for(int j=0;j<3;j++){
			cin >> t;
			p[i].push_back(t);
		}
	}

	long long dp[1000000][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=0;
		}
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				chmax(dp[i+1][k],dp[i][j]+p[i][k]);
			}
		}
	}

	long long ans=0;

	for(int i=0;i<3;i++)chmax(ans,dp[n][i]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 11520
# https://atcoder.jp/contests/abc063/tasks/arc075_b
# 問題文あなたが散歩していると、突然 N 体の魔物が出現しました。
# それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
# 体力が 0以下となった魔物は直ちに消滅します。
# 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
# 一回の爆発では、以下のように魔物の体力を減らすことができます。
# 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
# 爆発の中心となる魔物の体力は A 減り、
# その他の魔物の体力はそれぞれ B 減る。
# ここで、A と B はあらかじめ定まった値であり、A>B である。
# すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
# 制約入力値はすべて整数である。
# 1≤N≤10^5
# 1≤B<A≤10^9
# 1≤hi≤10^9

# N A B
# h1
# h2
# :
# hN

# 4 5 3
# 8
# 7
# 4
# 2

# 2

# 2 10 4
# 20
# 20

# 4

# 5 2 1
# 900000000
# 900000000
# 1000000000
# 1000000000
# 1000000000

# 800000000

N, A, B = gets.split.map(&:to_i)
H = []
N.times {
  H << gets.to_i
}
H.sort!.reverse!

A_B = A - B

class Integer
  def able?
    counter = self
    bself = B * self
    b2 = - bself + A_B - 1
    H.each do |value|
      break if value <= bself
      counter -= ((value + b2)/(A_B))
      break if counter < 0
    end
    counter >= 0
  end
end

# T回で倒しきれるか？ を二分探索
# ng = 0, ok = h.max
ng = 0
ok = H[0]/B + 1
mid = 0
while (ok - ng) > 1
  mid = (ng + ok)/2
  if mid.able?
    ok = mid
  else
    ng = mid
  end
end
puts ok

Measured memory_bytes: 6000
//
//  main.cpp
//  atcoder166
//
//  Created by zer0 on 2020/05/03.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    int n,k;
    int d;
    int ans=0;
    
    cin >> n >> k;
    
    vector<int> A(n,0);
    
    for(int i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            int a=0;
            cin >> a;
            A[a-1]++;
        }
    }
    
    for(int i=0;i<A.size();i++){
        if(A[i]==0){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3600
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=5e5+5,M=676;
char t[N];int sz[N],size[N],pos[N],fa[N],ch[N][26];
int id[N],bg[N],len[N],pi[26],n,q,nd;
vector<int>cnt[N];
void ins(R int ID,R int len){
	R int p=0;
	for(R int i=1,c;i<=len;++i){
		c=t[i]-'a';
		if(!ch[p][c])ch[p][c]=++nd;
		p=ch[p][c],++sz[p];
	}
	id[p]=ID,pos[ID]=p;
}
void dfs(int p,int ga,int s){
	fa[p]=ga;if(ga==-1)cnt[p].resize(M),fa[p]=p;
	if(id[p])++s,size[id[p]]=s;
	R int cp=0;fp(i,0,25)cp+=(ch[p][i]!=0);
	ga=fa[p];if(cp>1)ga=-1;
	fp(i,0,25)if(ch[p][i])dfs(ch[p][i],ga,s);
}
void dd(int p,int ga){
	if(p&&fa[p]==p)fp(i,0,M-1)cnt[p][i]+=cnt[ga][i];
	fp(i,0,25)if(ch[p][i])fp(j,i+1,25)if(ch[p][j]){
		cnt[ch[p][i]][j*26+i]+=sz[ch[p][j]];
		cnt[ch[p][j]][i*26+j]+=sz[ch[p][i]];
//		printf("%d %d\n",cnt[ch[p][i]][j*26+i],cnt[ch[p][j]][i*26+j]);
	}
	fp(i,0,25)if(ch[p][i])dd(ch[p][i],fa[p]);
}
int solve(int k){
	R int res=size[k];
	fp(i,0,25)fp(j,i+1,25)res+=cnt[fa[pos[k]]][pi[i]*26+pi[j]];
	return res;
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n)scanf("%s",t+1),len[i]=strlen(t+1),ins(i,len[i]);
	dfs(0,-1,0);dd(0,-1);
	scanf("%d",&q);
	for(R int k;q;--q){
		scanf("%d%s",&k,t+1);
		fp(i,1,26)pi[i-1]=t[i]-'a';
		printf("%d\n",solve(k));
	}
	return 0;
}

Measured memory_bytes: 349824
#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
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";
}


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

int main() {
  int N,Z=0;
  cin>>N;
  vector<tuple<int,int,int>> p(2*N);
  for(int i=0;i<N*2;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)=make_tuple(a,b,i/N);
  }
  vector<int> q(2*N);
  sort(p.begin(),p.end());
  for(int i=0;i<2*N;i++){
    int a,b,c;
    tie(a,b,c)=p.at(i);
    if(c==0){
      q.at(b)++;
    }
    else{
      for(int j=b;j>=0;j--){
        if(q.at(j)==1){
          Z++;
          q.at(j)=0;
          break;
        }
      }
    }
  }
  cout<<Z<<endl;
}


Measured memory_bytes: 3632
N = int(input())
rec = []
for i in range(N):
    x, y, h = map(int, input().split())
    rec.append((x, y, h))
    if h >= 1:
        q = [x, y, h]


for i in range(101):
    for j in range(101):
        cx, cy = i, j
        h = q[2] + abs(i - q[0]) + abs(j - q[1])
        flag = True
        for k in range(N):
            if max(h - abs(i - rec[k][0]) - abs(j - rec[k][1]), 0) != rec[k][2]:
                flag = False
                break

        if flag:
            print(i, j, h)
            break



Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>

using namespace std;

#define ll long long

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int result = 0;
	int pos = s.find("ABC");
	while (pos != std::string::npos) {
		result++;
		pos = s.find("ABC", pos + 1);
	}

	printf("%d", result);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=2e5+10,MOD=1e9+7;
int n,k,ans,l,r;
int main()
{
    cin>>n>>k;
    l=0,r=n;
    for(int i=1,j=n-1;i<=n+1;i++,j--)
    {
        if(i>=k)
            ans=((ll)ans+r-l+1+MOD)%MOD;
        l=((ll)l+i)%MOD,r=((ll)r+j)%MOD;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include <sstream>
#include <iomanip>

using namespace std;

int64_t binary(int64_t bina) {
	int64_t ans = 0;
	for (int64_t i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}

int main() {
	
	int64_t N, M, X;

	vector<int64_t> C;

	cin >> N >> M >> X;
	int64_t A[12][12];


	


	for (int64_t i = 0; i < N; i++) {
		int64_t c;
		cin >> c;
		C.push_back(c);

		for (int64_t j = 0; j < M; j++) {
			
			cin >> A[i][j];
			
		
		}


	}
	

	

	string str;
	string one="1";
	int64_t min_value = 9223372036854775807;
	
	for (int64_t i = 0; i < pow(2, N); i++) {
	
	
		
		vector<int64_t> ability(M);
		int64_t value=0;
		
		for (int j = 0; j < N; j++) {
		
			if (i&1<<j) {
				
				for (int k = 0; k < M; k++) {
					ability[k] += A[j][k];
					
				}
				value += C[j];
				
			}


		}
		int64_t count = 0;
		for (int k = 0; k < M; k++) {
			if (ability[k] >= X)count++;
			
		}
		

		if (count == M) {
			if (min_value > value) {
				min_value = value;
			}


		}
	

	}

	if (min_value == 9223372036854775807) {
		cout << -1;
		return 0;
	}
	else {
		cout << min_value;
		return 0;
	}

	


}

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

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

  int N;
  cin >> N;
  if(N % 2 == 0){
    cout << fixed << setprecision(10);
    cout << 0.5 << endl;
  }
  else{
    cout << fixed << setprecision(10);
    cout << double((N+1)/2) / double(N) << endl;
  }
}

Measured memory_bytes: 892
def main():
    N,W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]

    INF = float('inf')
    dp = [list([INF] * (10 ** 5 + 101)) for _ in range(N)]
    dp[0][wv[0][1]] = wv[0][0]
    dp[0][0] = 0

    for i in range(1,N):
        w = wv[i][0]
        v = wv[i][1]
        for j in range(10 ** 5 + 1):
            sum_v = j + v
            if dp[i-1][j] + w <= W:
                dp[i][sum_v] = min(dp[i-1][sum_v], dp[i-1][j] + w)
            dp[i][j] = min(dp[i][j], dp[i-1][j])
    
    max_v = 0
    for i in range(10 ** 5 + 1):
        if dp[N-1][i] <= W:
            max_v = i
    print(max_v)

if __name__ == "__main__":
    main()

Measured memory_bytes: 297208
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String strA = String.valueOf(a);
    String strB = String.valueOf(b);
    int c = Integer.parseInt(strA + strB);
    
    boolean isSquare = false;
    for(int i=1;i<=400;i++){
      if(i*i==c){
        isSquare = true;
        break;
      }else if(i*i>c){
        break;
      }
    }
    if(isSquare){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 39496
#include <iostream>
#include <algorithm>
#include <utility>
#include <fstream>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

//const double PI = acos(-1);



int main() {
    int n, ans = 0, x, max;
    cin >> n >> x;
    max = x;
    ans++;
    for (int i = 0; i < n - 1; i++) {
        cin >> x;
        if (x >= max) {
            ans++;
            max = x;
        }
    }
    cout << ans;
}



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

int h,n;
int a[1005],b[1005];
int dp[1005][20005];

int main(){

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

    cin>>h>>n;
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        for(int j=0;j<=h+10000;j++){
            if(j+a[i]<=h+10000)dp[i][j+a[i]]=min(dp[i][j+a[i]],dp[i][j]+b[i]);
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    int ans=0x3f3f3f3f;
    for(int i=h;i<=h+10000;i++){
        ans=min(ans,dp[n][i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 78848