akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author houghstc
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>
#include <climits>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

const int MOD = 1e9+7;

class BSubstring {
public:
    void solve(std::istream& in, std::ostream& out) {
        string s, t;
        in >> s >> t;

        int ls = s.size(), lt = t.size();
        int res = INT_MAX;
        for(int i = 0; i+lt-1 < ls; ++i)
        {
            int cnt = 0;
            for(int j = 0; j < lt; ++j)
            {
                cnt += s[i+j] != t[j];
            }
            res = min(res, cnt);
        }
        out << res << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    BSubstring solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3620
s=input()
judge=True
if "W" in s:
    if "E" not in s: judge=False
if "E" in s:
    if "W" not in s: judge=False
if "S" in s:
    if "N" not in s: judge=False
if "N" in s:
    if "S" not in s: judge=False
print("Yes") if judge else print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll n;
    cin >> n;
    if(n & 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    for(ll i = 10; i <= n; i*=5){
        ans += n / i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	string s,t; cin >> s >> t;
	rep(i,n){
		cout << s[i] << t[i];
	}
	cout << endl;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    double ans=0;
    rep(i,n){
        double x;
        string u;
        cin>>x>>u;
        if(u=="JPY")ans+=x;
        else ans+=x*380000.0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::*;
use std::i32;
use std::io::{self, Read};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n: usize = sc.read().unwrap();
    let ws: Vec<i32> = sc.read_vec(n).unwrap();
    // println!("{:?}", ws);

    // ww[i] = ws[0] ~ ws[i] の和
    let mut ww = Vec::with_capacity(n);
    ww.push(ws[0]);
    for i in 1..n {
        let wwp = ww[i - 1];
        ww.push(wwp + ws[i]);
    }
    // println!("{:?}", ww);

    // wp[i] = ws[i] で分割したときの差
    let mut wp = Vec::with_capacity(n);
    wp.push(1000000); // wp[0] は対象外
    for i in 1..n {
        // let wpi = ww[i - 0] - (ww[n - 1] - ww[i - 1]);
        let wpi = (ww[n - 1] - ww[i - 1] * 2).abs();
        wp.push(wpi);
    }
    // println!("{:?}", wp);

    println!("{}", wp.iter().min().unwrap());
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


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

int main(){
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  vector<double> temp(n);
  for (int i=0 ; i<n ; i++){
    cin >> h.at(i);
    temp.at(i) = t - h.at(i)*0.006;
  }
  
  double min = abs(temp.at(0) - a);
  int ans = 1;
  for (int i=1 ; i<n ; i++){
    if (abs(temp.at(i) - a) < min){
      min = abs(temp.at(i) - a);
      ans = i+1;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
//#pragma comment(linker, "/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

ll n,a,b;
void solve()
{
    slla(n),slla(a),slla(b);
    if(a+b-1>n || a*b<n)
    {
        cout<<-1<<endl;
        return;
    }
    while(n>0)
    {
        int x = min(a,n-b+1);

        for(int i = n-x+1;i<=n;i++)
        {
            cout<<i<<" ";
        }
        n-=x;
        b--;
    }
}

int main(){

    solve();
    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int n, a[100][100];

int prim(){
  int sum = 0, minv, u, d[100], p[100], c[100], i, j;

  for(i = 0; i < n; i++){
    d[i] = 1000000;
    p[i] = -1;
    c[i] = 0;
  }

  d[0] = 0;
  
  while(1){
    minv = 1000000;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && c[i] != 2){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    c[u] = 2;
    for(j = 0; j < n; j++){
      if(c[j] != 2 && a[u][j] != 1000000){
	if(d[j] > a[u][j]){
	  d[j] = a[u][j];
	  p[j] = u;
	  c[j] = 1;
	}
      }
    }
  }
  for(i = 0; i < n; i++){
    if(p[i] != -1) sum += a[i][p[i]];
  }
  return sum;
}

int main(){

  int m, i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &m);
      if(m == -1) a[i][j] = 1000000;
      else a[i][j] = m;
    }
  }
  printf("%d\n", prim());
  
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
int main(void){
    char buf[1000];
    scanf("%s",buf);
    int flg=0;
    for(int i=0;i<3;i++){
        if(buf[i]==55)flg=1;
    }
    if(flg==1){printf("Yes\n");}else{printf("No\n");}
    //printf("%d\n",buf[2]);
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll ch[10][10];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll now=i;
		ll b=now%10;
	//	cout << now/10<<" ";
		while((now/10)!=0){
			now/=10;
		}
		ll a=now;
		ch[a][b]++;
	//	cout << i<< " "<< a<<" "<< b<<endl;
	}
	ll cnt=0;
	for(ll i=1;i<10;i++){
		for(ll j=1;j<10;j++){
			cnt+=ch[i][j]*ch[j][i];
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

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

int main() {
  vector<int> vec(6);
  int city;
  for (int i=0; i<6; i++){
    cin >> city;
    vec.at(i) = city;
  }
  sort(vec.begin(), vec.end());
  
  bool flag = true;
  
  for (int i=0; i<4; i++){
    if(vec.at(i) == vec.at(i+2)){
      flag = false;
      cout << "NO" <<endl;
      break;
    }
  }
  if (flag){
    cout << "YES" <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define N 505
using namespace std;
int a[N],head[N],vet[N<<1],Next[N<<1],num;
int Max[N],x,y,n,Maxdpt,vis[N];
ll ans1,ans2;
void add(int x,int y){
	Next[++num]=head[x];
	head[x]=num;
	vet[num]=y;
}
bool find(int v,int u,int last){
	if (v==u){
		a[++num]=v;
		return 1;
	}
	for (int i=head[v];i;i=Next[i]){
		if (vet[i]==last) continue;
		if (find(vet[i],u,v)){
			a[++num]=v;
			return 1;
		}
	}
	return 0;
}
void dfs(int x,int last,int dpt){
	Maxdpt=max(Maxdpt,dpt);
	int tot=0;
	for (int i=head[x];i;i=Next[i]){
		if (vis[vet[i]]||vet[i]==last) continue;
		tot++;
		dfs(vet[i],x,dpt+1);
	}
	Max[dpt]=max(Max[dpt],tot);
}
void dfs1(int x,int last,int dpt){
	Maxdpt=max(Maxdpt,dpt);
	int tot=0;
	for (int i=head[x];i;i=Next[i]){
		if (vis[vet[i]]||vet[i]==last) continue;
		dfs(vet[i],x,dpt+1);
	}
	if (tot==0) ans2++;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	ll res1=(1ll<<64)-1,res2=(1ll<<64)-1;
	for (int v=1;v<=n;v++){
		for (int i=1;i<=n+1;i++) Max[i]=0;
		Maxdpt=0;
		dfs(v,0,1);
		ans1=Maxdpt,ans2=1;
		for (int i=1;i<Maxdpt;i++) ans2*=Max[i];
		if (ans1<res1||ans1==res1&&ans2<res2){
			res1=ans1;
			res2=ans2;
		}
	}
	for (int v=1;v<n;v++)
	for (int u=v+1;u<=n;u++){
		num=0;
		ans1=0,ans2=2;
		find(v,u,0);
		for (int i=1;i<=n;i++) vis[i]=0;
		for (int i=1;i<=num;i++) vis[a[i]]=1;
		for (int i=1;i<=n+1;i++) Max[i]=0;
		Maxdpt=0;
		dfs(v,0,1);
		dfs(u,0,1);
		ans1+=Maxdpt; 
		for (int i=1;i<Maxdpt;i++) ans2*=Max[i];
		for (int i=2;i<=num/2;i++){
			for (int i=1;i<=n+1;i++) Max[i]=0;
			Maxdpt=0;
			dfs(a[i],0,1);
			dfs(a[num-i+1],0,1);
			ans1+=Maxdpt;
			ll tmp=2;
			for (int i=1;i<Maxdpt;i++) tmp*=Max[i];
			if (Maxdpt>1) ans2+=tmp;
		}
		if (num%2==1){
			Maxdpt=0;
			dfs1(a[num/2+1],0,1);
			if (Maxdpt==1) ans2--;
			ans1+=Maxdpt;
		}
		if (ans1<res1||ans1==res1&&ans2<res2){
			res1=ans1;
			res2=ans2;
		}
	}
	cout<<res1<<' '<<res2<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner s=new Scanner(System.in);
    long  n=s.nextLong();
    long ans=0;
    int i=(int)Math.sqrt(n);
    for(;i>=1;i--)
    {
       if(n%i==0)
       {
         ans=i+n/i-2;
       System.out.println(ans);
       break;
       }
    }
      }
}

Measured memory_bytes: 23636
#include <stdio.h>
long long d[11][21][156];
int main() {
	d[0][0][0] = 1;
	for (int i = 1; i <= 10; i++) {
		for (int j = 0; j < 20; j++) {
			for (int k = j + 1; k <= 20; k++) {
				for (int s = 0; s <= 155 - k; s++)
					d[i][k][s + k] += d[i - 1][j][s];
			}
		}
	}
	int N, K, S;
	while (scanf("%d%d%d", &N, &K, &S), N) {
		long long res = 0;
		for (int i = 1; i <= N; i++) res += d[K][i][S];
		printf("%lld\n", res);
	}
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int i,j,ans,n,size,bicho,flag;
 string s;
  int a,b,c,d;
  c=0;d=0;
  a=0;b=0;bicho=0;
  cin >> n;
  for(i=0;i<n;i++)
  {
   cin >> s;
    size=s.size();
    if(s.at(0)=='B')
      b++;
    if(s.at(size-1)=='A')
      a++;
    if(s.at(0)=='B'&&s.at(size-1)=='A')
      d++;
    
    for(j=0;j<size-1;j++)
    {
     if(s.at(j)=='A'&&s.at(j+1)=='B')
       c++;
    }
    
     
    
  }

  
  if(b>=a)
    ans=a;
  if(a>b)
    ans=b;
  if(a==b&&b==d&&d>0)
    ans=ans-1;

  cout << ans+c << endl;
  
  
}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	while(n >= 4){
		if(!(n % 4) || !(n % 7)){
			puts("Yes");
			return 0;
		}
		else if(n > 4)	n -= 4;
		else if(n > 7)	n -= 7;
	}
	puts("No");
	return 0;
}


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

void Main() {
  long long a, b, k;
  cin >> a >> b >> k;
  long long aa;
  aa = max(a - k, (long long)0);
  k -= (a - aa);
  b = max(b - k, (long long)0);
  cout << aa << " " << b << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

    int max=-100,goukei=0,s_size=s.size();

    for(int i = 0;i < s_size;i++){
        if(s.at(i) == 'I')
            goukei++;
        else
            goukei--;

        if(goukei > max)
            max = goukei;
    }

    if(max >= 0)
        cout << max << endl;
    else
        cout << 0 << endl;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 998244353,N = 1001000;
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
ll fac[N],ifac[N],n,k;
ll C(int n,int m){
	if(m>n||m<0) return 0;
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main(){
	read(n);read(k);
	if(k<n){puts("0");return 0;}
	fac[0]=1;
	for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
	ifac[1000000]=fp(fac[1000000],mod-2);
	for(int i=1000000;i;i--) ifac[i-1]=ifac[i]*i%mod;
	ll ans=0;
	for(int i=0;i<=k/2;i++){
		if(i==k-i)
			ans=(ans+C(k-1,i-1)-C(k-1,i-1-(i-n+1)))%mod;
		else
			ans=(ans+C(k,i)-C(k,i-(k-i-n+1)))%mod;
	}
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 15872
package main

import (
  "fmt"
  "time"
)

func main() {
  var a,b,c,d,k int
  loc, _ := time.LoadLocation("Asia/Tokyo")

  fmt.Scanf("%d%d%d%d%d", &a,&b,&c,&d,&k)
  
t1 := time.Date(2020, 1, 1, a, b, 0, 0, loc)
t2 := time.Date(2020, 1, 1, c, d, 0, 0, loc)
  t3:= t2.Add(time.Duration(-k) * time.Minute)
  t4:= t3.Sub(t1)
	fmt.Println(t4.Minutes())
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 55556
int vis[N],a[N],b[N];
int s[60],flag;
void dfs(int x,int y,int z,int l,int r)
{
    if(y==4)
    {
        if(vis[z+a[r]]==0)
            flag=0;
        return;
    }
    if(x>=l)
        return;
    int i;
    for(i=x;i<l;i++)
    {
        if(flag==0)
            return;
        dfs(i+1,y+1,z+a[i],l,r);
    }
}
int main()
{
    int i,j,k,tot,n;
    memset(vis,0,sizeof(vis));
    tot=0;
    for(i=2;i<=55555;i++)
    {
        if(vis[i]==0)
            a[tot++]=i;
        for(j=0;j<tot&&i*a[j]<=55555;j++)
        {
            vis[i*a[j]]=1;
            if(i%a[j]==0)
                break;
        }
    }
    k=0;
    for(i=0;i<tot;i++)
    if(a[i]%5==1)
        b[k++]=a[i];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        if(i)
            printf(" ");
        printf("%d",b[i]);
    }
    printf("\n");
    return 0;
}


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

int main() {
  for (int i = 1; i <= 10000; i++) {
    int x;
    std::cin >> x;
    if (x == 0) {
      break;
    } else {
      std::cout <<"Case " << i << ":" << " " << x << std::endl;
    }
  }
  return 0;
}



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

int main(){
    long long a,b,x,cnt=0;
    cin>>a>>b>>x;

    long long fa,fb;
    fa=((a-1)/x)+1;
    fb=(b/x)+1;
    if(a==0){
        cout<<fb<<"\n";
    }else {
        cout<<fb-fa<<"\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	string S;
	string T;

	cin >> S >> T;

	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAXN (int)(1e5+1)
using namespace std;
vector<int>adj[MAXN];
bool visited[MAXN];
int indegree[MAXN];
int dist[MAXN];
void dfs(int u)
{
	visited[u]=true;
	for(auto v:adj[u])
	{
		dist[v]=max(dist[v],dist[u]+1);
		indegree[v]--;
		if(indegree[v]==0)
			dfs(v);
	}
}
int main()
{
	fastio;
	int n,m,x,y;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		indegree[y]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(!visited[i]&&indegree[i]==0)
		{
			dfs(i);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=max(ans,dist[i]);
	cout<<ans<<endl;			
}

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

int main() {
	ll n,ind;
	double ans=0;
	cin >> n;
  pair<double,double>xys;
	vector<pair<double,double>>xy(n);
	vector<int>index(n);
	rep(i,n) cin >> xy.at(i).first >>  xy.at(i).second;
  rep(i,n) index.at(i)=i;
	do{
	  ind=0;
		for	(auto x:index){
       if(ind==0){
         xys=xy.at(x);
         ind++;
       }
       else{
       		ans+=sqrt((xy.at(x).first-xys.first)*(xy.at(x).first-xys.first)+(xy.at(x).second-xys.second)*(xy.at(x).second-xys.second));
			 		xys=xy.at(x);
			 }	
		}	
	}while(next_permutation(index.begin(),index.end()));
	rep(i,n) ans/=((double)i+1.0);
	cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int n,k;
  cin >> n >> k;
  ll sum = 1;
  REP(i,n){
    if(sum+k >= sum*2){
      sum = sum*2;
    }
    else{
      sum = sum+k;
    }
  }
  cout << sum << endl;
  return 0;
}


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


int main(){
	int i,j,k;
	int A,B,N;
	int sum = 0;
	int t;
	
	scanf("%d",&N);
	scanf("%d",&A);
	scanf("%d",&B);
	
	for(i=1;i<N+1;i++){
		t = i;
		k = 0;
		while(1){
			if (t == 0)break;
			k += (t % 10);//1桁目の数値を足す
			t /=10;//10で割る
		}
		if(k >= A && k <= B){
			sum += i;
		}
	}
	
	printf("%d\n",sum);
	
	
	return 0;
}

Measured memory_bytes: 128
n,m,k = map(int, input().split())

class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

uf = UnionFindVerSize(n)

minus = [0] * n

for _ in range(m):
    a,b = map(int, input().split())
    uf.unite(a - 1,b - 1)
    minus[a - 1] += 1
    minus[b - 1] += 1

for _ in range(k):
    c,d = map(int, input().split())
    if uf.is_same_group(c - 1, d - 1):
        minus[c - 1] += 1
        minus[d - 1] += 1

ans = []
for i in range(n):
    ans.append(uf.get_size(i) - minus[i] - 1)

print(" ".join(map(str, ans)))

Measured memory_bytes: 106272
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<int> bombs[3300000];
signed main(){
	int h,w,m;cin >> h >> w >> m;
	vector<int> tate(h),yoko(w);
	vector<P> res;
	rep(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		res.emplace_back(a,b);
		tate[a]++;
		yoko[b]++;
	}
	int Tate = 0,Yoko = 0;
	rep(i,h)Tate = max(Tate,tate[i]);
	rep(i,w)Yoko = max(Yoko,yoko[i]);
	vector<int> kouhoTate,kouhoYoko;
	rep(i,h){
		if(tate[i] == Tate)kouhoTate.push_back(i);
	}
	rep(i,w){
		if(yoko[i] == Yoko)kouhoYoko.push_back(i);
	}
	int cnt = 0;
	rep(i,m){
		int a = res[i].first,b = res[i].second;
		cnt += (tate[a] == Tate && yoko[b] == Yoko);
	}
	if(kouhoTate.size() * kouhoYoko.size() == cnt)cout << Tate + Yoko - 1 << endl;
	else cout << Tate + Yoko << endl;
	return 0;
}

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

int main()
{
  int b1,b2,b3;
  cin>>b1>>b2>>b3;
  if(b1==1&&b2==1)
    cout<<"Open\n";
  else if(b3==1)
    cout<<"Open\n";
  else
    cout<<"Close\n";
  return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>
typedef struct{
	int face[7];
}cube;
int main(void) {
	cube C1;
	int n;
	int a,b;
	for(int i=1;i<7;i++)scanf("%d",&C1.face[i]);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		if((a==C1.face[2]&&b==C1.face[3])||(a==C1.face[3]&&b==C1.face[5])||(a==C1.face[5]&&b==C1.face[4])||(a==C1.face[4]&&b==C1.face[2]))printf("%d\n",C1.face[1]);
		else if((a==C1.face[4]&&b==C1.face[6])||(a==C1.face[6]&&b==C1.face[3])||(a==C1.face[3]&&b==C1.face[1])||(a==C1.face[1]&&b==C1.face[4]))printf("%d\n",C1.face[2]);
		else if((a==C1.face[5]&&b==C1.face[1])||(a==C1.face[1]&&b==C1.face[2])||(a==C1.face[2]&&b==C1.face[6])||(a==C1.face[6]&&b==C1.face[5]))printf("%d\n",C1.face[3]);
		else if((a==C1.face[6]&&b==C1.face[2])||(a==C1.face[2]&&b==C1.face[1])||(a==C1.face[1]&&b==C1.face[5])||(a==C1.face[5]&&b==C1.face[6]))printf("%d\n",C1.face[4]);
		else if((a==C1.face[1]&&b==C1.face[3])||(a==C1.face[3]&&b==C1.face[6])||(a==C1.face[6]&&b==C1.face[4])||(a==C1.face[4]&&b==C1.face[1]))printf("%d\n",C1.face[5]);
		else if((a==C1.face[2]&&b==C1.face[4])||(a==C1.face[4]&&b==C1.face[5])||(a==C1.face[5]&&b==C1.face[3])||(a==C1.face[3]&&b==C1.face[2]))printf("%d\n",C1.face[6]);
	}
	
	return 0;
}


Measured memory_bytes: 2024
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():
    b = readline_s().rstrip()

    if b == 'A':
        ans = 'T'
    elif b == 'T':
        ans = 'A'
    elif b == 'C':
        ans = 'G'
    elif b == 'G':
        ans = 'C'

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

#define int long long

const int maxn = 2e5 + 10;
int n, m, q, tot;

struct Querys {
  int op, u, v;
} Q[maxn];

int par[maxn];

int find(int x) {
  return par[x] == x ? x : par[x] = find(par[x]);
}

void unite(int x, int y) {
  if ((x = find(x)) != ((y = find(y)))) {
    par[x] = y, tot--;
  }
}

signed main() {
  scanf("%lld %lld %lld", &n, &m, &q);
  tot = n;
  rep(i, 1, n) par[i] = i;
  rep(i, 1, q) {
    int u, v, op;
    scanf("%lld %lld %lld", &u, &v, &op);
    Q[i] = Querys{op, ++u, ++v};
    if (!op) unite(u, v);
    if (m == n - 1 && Q[i].op) {
      return puts("No"), 0;
    }
  }
  if (m == n - 1) {
    return puts("Yes"), 0;
  }
  rep(i, 1, q) {
    if (Q[i].op && find(Q[i].u) == find(Q[i].v)) {
      return puts("No"), 0;
    }
  }
  if (m >= n && m <= n - tot + tot * (tot - 1) / 2) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N;
	scanf("%d", &N);
	int*d = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", d + i);
	int res = 0;
	for (int i = 0; i < N; i++)for (int j = i + 1; j < N; j++) {
		res += d[i] * d[j];
	}
	printf("%d", res);

	return 0;
}

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

const int N = 100 * 1000 + 5;

int deg[N];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		deg[u]++;
		deg[v]++;
	}
	bool b = true;
	for (int i = 1; i <= n; i++) {
		if (deg[i] % 2 == 1) {
			b = false;
		}
	}
	if (b) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>


int main(){

  int n, q;
  long S[10001], T[501];

  int i,j;
  int c; //counter

  scanf( "%d\n", &n );

  for( i=0; i<n; i++ )
    scanf( "%ld", &S[i] );

  scanf( "%d\n", &q );
  
  for( i=0; i<q; i++ )
    scanf( "%ld", &T[i] );


  c=0;
  for( i=0; i<q; i++ ){
    for( j=0; j<n; j++ ){
      if( S[j] == T[i] ){
        c++;
        break;
      }
    }
  }


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

  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
  string a, b;
  cin >> a >> b;

  bool result = false;
  int n = a.size();

  for (int i = 0; i < n; i++) {
    bool isOk = true;
    for (int j = 0; j < n; j++) {
      if (a[j] != b[(i + j) % n]) isOk = false;
    }
    if (isOk) result = true;
  }

  cout << (result ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N; cin >> N;
    map <string,int> M;
    vector <string> S(N);
    rep(i,N) cin >> S[i];
    sort(S.begin(),S.end());
    
    int num=0;
    rep(i,N){
        M[S[i]]++;
        num=max(num,M[S[i]]);
    }
    
    rep(i,N){
        if (num==M[S[i]]) cout << S[i] << endl;
        M[S[i]]=0;
    }
    
}

Measured memory_bytes: 26752
#include<iostream>
#include<set>
#include<map>
#include<vector>

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::multiset<int> m;
    std::map<int, int> map;
    int key;
    for(int i = 0; i < n; i++){
	std::cin >> a[i];
	key = i + a[i];
	if(map.find(key) == map.end()){
	    map[key] = 1;
	}else{
	    map[key]++;
	}
    }
    long long ans = 0;
    for(int i = n-1; i >= 1; i--){
	key = i - a[i];
	if(map.find(key) != map.end() && map[key] != 0){
	    int key2 = i + a[i];
	    map[key2] -= 1;
	    ans += map[key];
	}
    }
    std::cout << ans << std::endl;
    return 0;
}



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

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

	int a[n + 1], b[n + 1], c[n + 1];
	c[n] = 0;
	c[n - 1] = 0;

	c[0] = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	int takahashi = 0;
	int prev = -10;
	for (int i = 0; i < n; i++) {
		int cur = a[i] - 1;
		takahashi += b[cur];
		//cout << "cur:" << cur << " " << b[cur] << endl; 
		
		if (prev + 1 == cur) {
			takahashi += c[cur - 1];
			//cout << "a:" << c[cur] << endl;
		}
		
		prev = cur;
	}

	cout << takahashi << endl;

	return 0;
}

Measured memory_bytes: 888
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
N,M = map(int,input().split())    
uf = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)
    
root = uf.roots()
print( max(uf.size(r) for r in root) )

Measured memory_bytes: 82800
import numpy as np

def main():
    n,m,q=map(int,input().split())
    lst=np.zeros((n,n),dtype=int)

    for _ in range(m):
        s,t=map(int,input().split())
        lst[s-1][t-1]+=1
    lst=lst.cumsum(axis=1)[::-1].cumsum(axis=0)[::-1]

    for _ in range(q):
        s,t=map(int,input().split())
        print(lst[s-1][t-1])

main()

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

int n,a[110],ans=1;

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=1;i<n;i++) if(a[i]!=a[i-1]) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String []args) {
        Scanner scn= new Scanner(System.in);
        int x= scn.nextInt();
        int n=scn.nextInt();
        int []arr= new int[n];
        HashSet<Integer> map= new HashSet<>();
        for(int i=0;i<n;i++){
            arr[i]=scn.nextInt();
            map.add(arr[i]);
        }
        int diff=0;
        while(true){
            int no=x-diff;
            if(!map.contains(no)){
                System.out.println(no);
                return;
            }
            no=x+diff;
            if(!map.contains(no)){
                System.out.println(no);
                return;
            }
            diff++;
        }
    }
}

Measured memory_bytes: 26972
(* 配列版素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  (* 破壊的操作であるため注意 *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end

module WeightedGraph
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  (*
   * HashtblやMapを用いているとプリム法と大差ない計算時間になってしまうため，
   * より汎用的な実装が欲しければそちらを当たること
   *)
  val kruskal :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない
       ソートにList.sortを使っているせいでデータ構造が固定されており，あまり良くない… *)
    (int * int * Weight.t) church_list ->
    (* 最小全域木に含まれる辺のリスト
       畳み込む関数と初期値まで与えられて初めて計算を開始するので，
       最小全域木に対して色々な操作をしたい場合は，
       一度リストにして覚えておくとよい．
       最小全域木の重さの和だけ欲しいとか一回しか使わない場合は，
       直接畳み込む関数と初期値を与えるとdeforestationになっていい感じ． *)
    (int * int * Weight.t) church_list
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let kruskal n es =
    { fold = fun f init ->
      let uf = UnionFind.make n in
      let n, k = es.fold (fun x (i, k) -> (i + 1, fun a -> a.(i) <- x; k a)) (0, fun _ -> ()) in
      let a = Array.make n (Obj.magic ()) in
      k a;
      Array.fast_sort (fun (_, _, w) (_, _, w') -> Weight.compare w w') a;
      Array.fold_left (fun acc (u, v, w) ->
        let c = UnionFind.find uf u in
        let d = UnionFind.find uf v in
        if UnionFind.Class.compare c d = 0
        then acc
        else (UnionFind.unite uf c d; f (u, v, w) acc)) init a }
end
 
module Int = struct
  type t = int
  let compare = compare
end
 
module G = WeightedGraph (Int)
 
let () =
  let n = Scanf.scanf "%d\n" @@ fun n -> n in
  let xys = Array.to_list @@ Array.init n @@ fun i ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y, i in
  let xedges =
    List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, x' - x) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  let yedges =
    List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, y' - y) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  Printf.printf "%d\n" @@
  (G.kruskal n { G.fold = fun f acc -> List.fold_right f xedges @@ List.fold_right f yedges acc }).G.fold (fun (_, _, d) -> ( + ) d) 0


Measured memory_bytes: 34816
/**
*    created: 30.06.2020 14:31:04
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import bisect

def main():
	s,c=MI()

	ans=min(s,c//2)

	c-=s*2

	if c>0:
		ans+=c//4

	print(ans)





if __name__ == "__main__":
	main()


Measured memory_bytes: 9192
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=3e5+35;
  const int M=1005;
 

 void doit()         
 {
   int k,a,b; cin>>k>>a>>b;

   for(int i=1;i<=1000;++i)
    if(i*k>=a&&i*k<=b)
    {
       cout<<"OK"; return;
    }

    cout<<"NG";
 }

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


   int tc=1;                         
 //   cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }

 return 0; 
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;

int main() {
    long long n, m; cin >> n >> m;
    if (n * 2 > m) {
        cout << m / 2 << endl;
    }
    else {
        llint ans = n + (m - 2 * n) / 4;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
	int n; cin >> n;
	vector<pair<int,int>> a(n);
	vector<int> idx(n);

	for(int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		a[i].first--, a[i].second--;
		idx[a[i].second] = i;
	}
	sort(a.begin(), a.end());
	atcoder::dsu uf(n);
	set<int> st;


	for(int i = 0; i < n; i++) {
		int y = a[i].second;

		st.insert(y);
		auto itr = st.lower_bound(y);
		int nin;
		while(true){
			nin = *itr;
			uf.merge(idx[*itr], idx[y]);
			itr = st.erase(itr);
			if(itr == st.begin())break;
			itr--;
		}
		st.insert(nin);
	}

	for(int i = 0; i < n; i++) {
		cout << uf.size(i) << '\n';
	}

}

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

d_from_u = [float('inf') for _ in range(N)]
d_from_v = [float('inf') for _ in range(N)]
d_from_u[u] = 0
d_from_v[v] = 0
#print(tonari)

now = [u]
d = 0
while now:
  d += 1
  nextvisit = []
  for n in now:
    for t in tonari[n]:
      if d_from_u[t] > d:
        d_from_u[t] = d
        nextvisit.append(t)
  now = nextvisit

now = [v]
d = 0
while now:
  d += 1
  nextvisit = []
  for n in now:
    for t in tonari[n]:
      if d_from_v[t] > d:
        d_from_v[t] = d
        nextvisit.append(t)
  now = nextvisit

#print(d_from_u)
#print(d_from_v)

distance = []
for U, V in zip(d_from_u, d_from_v):
  distance.append((U, V))

distance.sort(key = lambda x: x[1])

#print(distance)
ans = 0
while distance:
  d = distance.pop()
  if d[0] < d[1]:
    ans = d[1] - 1
    break
print(ans)

Measured memory_bytes: 40492
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    int num, yen;
    cin >> num >> yen;

    for (int i = 0; i <= num; i++)
    {
        for (int t = 0; i+t <= num; t++)
        {
            if (i*1000 + t*5000 + (num-i-t)*10000 == yen)
            {
                cout << (num-i-t) << endl;
                cout << t << endl;
                cout << i << endl;
                return 0;
            }
            
        }
        
    }
    cout << "-1 -1 -1" << endl;
    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<cstring>
#define INF 1000000000
using namespace std;
string x;
int main(){
    cin>>x;
    if(x=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
}

Measured memory_bytes: 3596
<?php
  
  $a = fgets(STDIN);
  
  $num = (int) $a;

  $ans = [];
  
  for($i=1; $i<=$num; $i++)
  {
 
    if ($i % 15 == 0) {
      
    }elseif( $i % 5 == 0){
      
    }elseif( $i % 3 ==  0 ){
      
    }else{
      array_push($ans,$i);
    }
  }  
  echo array_sum($ans);
  

Measured memory_bytes: 49648
n = int(input())
A = [int(input()) for i in range(n)]

B = []

for a in A:
    if a % 10 != 0:
        B.append(a)

ans = sum(A)
if ans % 10 == 0 and len(B) != 0:
    ans -= min(B)
elif ans % 10 == 0 and len(B) == 0:
    ans = 0
    

print(ans)

Measured memory_bytes: 3064
from bisect import (
    bisect_left,
    bisect_right
)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    a.sort()
    c.sort()

    ans = 0
    for target in b:
        ans += bisect_left(a, target) * (len(c) - bisect_right(c, target))
    print(ans)

main()


Measured memory_bytes: 22720
from fractions import gcd
import copy

n = int(input())
a_list = list(map(int, input().split()))

ans_list = []
l_list = [0]*(n+1)
r_list = [0]*(n+1)

for i in range(n):
    l_list[i+1] = gcd(l_list[i], a_list[i])
    r_list[n-i-1] = gcd(r_list[n-i], a_list[n-i-1])

ans_list = []
for j in range(n):
    ans_list.append(gcd(l_list[j], r_list[j+1]))

#print(ans_list)

print(max(ans_list))


Measured memory_bytes: 16144
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int a,b,i=0;
    string op;
    vector<int> vec;
    while(1){ 
        cin>>a>>op>>b;
        if(op.compare("?")!=0){
            if(op.compare("+")==0){
                vec.insert(vec.begin()+i,a+b); 
            }
            else if(op.compare("-")==0){
                vec.insert(vec.begin()+i,a-b);               
            }
            else if(op.compare("*")==0){
                vec.insert(vec.begin()+i,a*b);
           }   
            else{
                vec.insert(vec.begin()+i,a/b);    
            }
        }
        else{
            break;
        } 
        i++;
    }
    for(i=0; i<vec.size(); i++){
        cout<<vec[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int n,i;
	cin >> n;
	i = n;

	for (;;) {
		
		if (i == 111 || i == 222 || i == 333 || i == 444 || i == 555 || i == 666 || i == 777 || i == 888 || i == 999) {
			cout << i << endl;
			break;
		}
		i++;
	}

}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]
L = defaultdict(list)
for i, s in enumerate(S):
    s = "".join(sorted(s))
    L[s].append(i)
num = 0
for x in L.values():
    num += sum(range(len(x)))
print(num)


Measured memory_bytes: 37668