akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;
 
#define mp make_pair
#define pb push_back
 
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
 
vector<ll> prime;
unordered_map<ll,ll> square;

void genprime() {
	FOR(i,2,100001) {
		bool f = 0;
		F0R(j,prime.size()) {
			if (i % prime[j] == 0) {f = 1; break;}
			if (prime[j]*prime[j]>i) break;
		}
		if (!f) prime.pb(i);
	}
}

pair<ll,ll> fac(ll x) {
	ll x1 = 1, x2 = 1;
	F0R(i,prime.size()) {
		int c = 0;
		while (x % prime[i] == 0) c++, x /= prime[i];
		c %= 3;
		if (c == 1) x1 *= prime[i], x2 *= (prime[i]*prime[i]);
		else if (c == 2) x1 *= (prime[i]*prime[i]), x2 *= prime[i];
		if ((prime[i]*prime[i]*prime[i])>x) break;
	}
	if (square.find(x) == square.end()) x1 *= x, x2 *= (x*x);
	else x1 *= x, x2 *= square[x];
	return mp(x1,x2);
}
 
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	map<pair<ll,ll>,ll> num;
	map<ll,bool> done;
	
	int N; cin >> N;
	genprime();
	for (ll i: prime) square[i*i] = i;
	F0R(i,N) {
		ll x; cin >> x;
		num[fac(x)]++;
	}
	
	ll ans = 0;
	for (auto i: num) {
		if (done[i.f.f]) continue;
		if (i.f.f == i.f.s) ans++;
		else if (num.find(mp(i.f.s,i.f.f)) != num.end()) {
			ans += max(num[mp(i.f.s,i.f.f)],i.s);
			done[i.f.s] = 1;
		} else ans += i.s;
	}
	cout << ans;
}

Measured memory_bytes: 13312
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n+1,0);
  vector<int> d(n+1,0);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  int mx=0;
  rep1(i,n){
      c[a[i-1]]+=1;
      d[b[i-1]]+=1;
  }
  rep1(i,n){
      c[i]+=c[i-1];
      d[i]+=d[i-1];
      mx=max(mx,c[i]-d[i-1]);
  }

  rep1(i,n){
      if(c[i]-c[i-1]+d[i]-d[i-1]>n){
          cout<<"No"<<"\n";
          return 0;
      }
  }
  cout<<"Yes"<<"\n";
  vector<int> res(n);
  rep(i,n){
      res[(i+mx)%n]=b[i];
  }
  rep(i,n)cout<<res[i]<<" ";
  cout<<endl;
  return 0;
}

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N, M;
    cin >> N >> M;
    M *= 2;
    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int lcm = a[0];
    for(int i = 1; i < N; i++) { 
        lcm = lcm * (a[i])/(__gcd(lcm, a[i]));
        if(lcm > M) {
            return cout << 0, 0;
        }
    }
    for(int i = 0; i < N; i++) {
        if(!((lcm/a[i])&1)) {
            return cout << 0, 0;
        }
    }
    cout << ((M/lcm) + 1)/2 << endl;
    return 0;
}



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

typedef long long ll;

const int MN = 1e7 + 12;

int f[MN];

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  for (int i = 2; i < MN; i++) { if (f[i] == 0) {
    for (int j = i; j < MN; j += i)
      f[j] = i;
  } }
  int n; cin >> n;
  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    ll ctr = 1;
    ll k = i;
    while (k > 1) {
      int p = f[k];
      int x = 0;
      while (k % p == 0) {
        k /= p;
        x++;
      }
      ctr *= (x + 1);
    }
    res += i * ctr;
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 42692
n = int(input())
s = [""]*n
t = [0]*n
for i in range(n):
    ts, tt = map(str, input().split())
    s[i] += ts
    t[i] += int(tt)
x = input()

num = -1
for i in range(n):
    if s[i] == x:
        num = i
print(sum(t[num+1:]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    long long b,n;
    cin>>a>>b>>n;
    long long x=max(n/b*b-1,0ll);
    cout<<max(a*n/b-n/b*a,a*x/b-x/b*a)<<endl;
    return 0;
}

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

using namespace std;

#define MODULO 1000000007

using vi = vector<int>;
using ll = long long;

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

	//cin >> T;

	for (int t = 0; t < T; t++) {
		string s;
		cin >> s;

		if (s[s.size() - 1] == 's') 
		   	s.push_back('e');

		s.push_back('s');

		cout << s << endl;
		
	}

	return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
int n, m;
int par[100010];
int r(int x){ return (x==par[x])?x:(par[x]=r(par[x])); }
priority_queue<int> pq[100010];
bool join(int a, int b){
	a=r(a); b=r(b);
	if(a==b) return 0;
	par[a]=b;
	if(pq[a].size()>pq[b].size()) swap(pq[a], pq[b]);
	while(pq[a].size()){
		pq[b].push(pq[a].top()); pq[a].pop();
	}
	return 1;
}
int pc[100010];
inline void dame(){ puts("Impossible"); exit(0); }
int main()
{
	read(n, m);
	for(int i=0; i<n; ++i){
		par[i]=i;
		int x; read(x);
		pq[i].push(-x);
	}
	for(int i=1; i<=m; ++i){
		int a, b; read(a, b); join(a, b);
	}
	priority_queue<pp> qb;
	int ones = 0;
	int bigs = 0;
	ll ans = 0;
	for(int i=0; i<n; ++i) if(par[i] == i){
		int s = pq[i].size();
		if(s > 1){
			ans += pq[i].top(); pq[i].pop(); ++pc[i];
			if(pq[i].size()){
				qb.emplace(pq[i].top(), i);
			}
			++bigs;
		} else {
			assert(s == 1);
			ans += pq[i].top(); pq[i].pop(); ++pc[i];
			++ones;
		}
	}
	
	if(ones + bigs == 1){ puts("0"); return 0; }
	
	if(bigs == 0){
		if(ones > 2) dame();
		printf("%lld\n", -ans);
		return 0;
	}

	for(int i=0; i<bigs-2+ones; ++i){
		if(qb.empty()) dame();
		int a = qb.top().second; qb.pop();
		ans += pq[a].top(); pq[a].pop();
		++pc[a];
		if(pq[a].size()){
			qb.emplace(pq[a].top(), a);
		}
	}
	printf("%lld\n", -ans);
	return 0;
}


Measured memory_bytes: 8960
def main():
    n, m = map(int, input().split())
    h_list = [0] + list(map(int, input().split()))
    is_good = [True for i in range(n + 1)]
    for i in range(m):
        a, b = map(int, input().split())
        if h_list[a] <= h_list[b]:
            is_good[a] = False
        if h_list[a] >= h_list[b]:
            is_good[b] = False
    print(sum(b for b in is_good[1:] if b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    vector<int> n(4);
    rep(i, 4) cin >> n[i];
    sort(ALL(n));
    if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Integral();
	}
	
	private static void Integral ()
	{
		int d;
		int a = 0;
		int ans = 0;
		Scanner cin = new Scanner (System.in);
		
		while (cin.hasNext()){
			d = cin.nextInt();
			for (int i = 0; i <= 600 - d; i = d * a){
				ans += i * i * d;
				a++;
			}
			System.out.println(ans);
			ans = 0;
			a = 0;
		}
	}
}

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

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

  int sum = 0;

  vector<int> p( N );

  for( int i = 0; i < N; i++ )
    cin >> p.at( i );

  sort( p.begin(), p.end() );

  for( int i = 0; i < K; i++ )
    sum += p.at( i );

  cout << sum << endl;
}

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

int main()
{
	int N;
	cin>>N;
	
	int num;
	
	int X;
	cin>>X;
	bool a[101]={0};
	for(int i=0;i<X;i++){
		cin>>num;
		a[num]=true;
	}
	
		
	int Y;
	cin>>Y;
	bool b[101]={0};
	for(int i=0;i<Y;i++){
		cin>>num;
		b[num]=true;
	}
	
		
	int Z;
	cin>>Z;
	bool c[101]={0};
	for(int i=0;i<Z;i++){
		cin>>num;
		c[num]=true;
	}
	
	int count=0;

	for(int i=1;i<=N;i++){
		if((!a[i]&&c[i])||(b[i]&&c[i])){
			count++;
		}
	}
	
	cout<<count<<endl;
	
	return 0;
}
			

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string n, ret = "Good";
    cin >> n;
    for (int i = 1; i < 4; ++i)
        if (n[i] == n[i-1]) ret ="Bad";
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int d, g, p, c, dp[1003];

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

int main() {
	scanf("%d %d", &d, &g);
	for (int i = 1; i <= d; i++) {
		scanf("%d %d", &p, &c);
		for (int j = 1000; j >= 0; j--) {
			if (j != 0 && dp[j] == 0) {
				continue;
			}
			for (int k = 0; k < p; k++) {
				dp[j + k] = max(dp[j + k], dp[j] + 100 * k * i);
			}
			dp[j + p] = max(dp[j + p], dp[j] + 100 * p * i + c);
		}
	}
	for (int i = 1; i <= 1000; i++) {
		if (dp[i] >= g) {
			printf("%d\n", i);
			break;
		}
	}
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
int n,m,x[N],y[N],tot,o[N],len,bit[N];
struct node{
	int x,y;
	bool operator < (const node &b)const{
		return x==b.x?y>b.y:x<b.x;
	}
}a[N];
void modify(int x,int v){
	while(x<=len)bit[x]=(bit[x]+v)%mod,x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)res=(res+bit[x])%mod,x^=x&-x;
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&x[i]);
	for(int i=1;i<=m;++i)scanf("%d",&y[i]);
	for(int i=1;i<=n;++i){
		if(x[i]<y[1]||x[i]>y[m])continue;
		int p=upper_bound(y+1,y+m+1,x[i])-y;
		a[++tot]=(node){x[i]-y[p-1],o[++len]=y[p]-x[i]};
	}
	sort(a+1,a+tot+1);sort(o+1,o+len+1);len=unique(o+1,o+len+1)-o-1;
	for(int i=1;i<=tot;++i)
		if(a[i].x!=a[i-1].x||a[i].y!=a[i-1].y){
			int p=lower_bound(o+1,o+len+1,a[i].y)-o;
			modify(p,query(p-1)+1);
		}
	printf("%d\n",(query(len)+1)%mod);
	return 0;
}


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

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

n,k = [int(i) for i in readline().split()]

res = 0
while n:
    n //= k
    res += 1

print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    Int x, y, z;
    Int k;
    cin >> x >> y >> z >> k;
    vector<Int> a(x), b(y), c(z);
    for (Int i = 0; i < x; i++) cin >> a[i];
    for (Int i = 0; i < y; i++) cin >> b[i];
    for (Int i = 0; i < z; i++) cin >> c[i];
    sort(a.begin(), a.end(), greater<Int>());
    sort(b.begin(), b.end(), greater<Int>());
    sort(c.begin(), c.end(), greater<Int>());
    priority_queue<tuple<Int, Int, Int, Int>> q;
    q.push(make_tuple(a[0] + b[0] + c[0], 0, 0, 0));
    map<tuple<Int, Int, Int>, Int> mp;
    // mp[make_tuple(0, 0, 0)]++;
    Int cnt = 0;
    while (cnt < k) { 
        tuple<Int, Int, Int, Int> t = q.top();
        q.pop();
        Int p1 = get<1>(t);
        Int p2 = get<2>(t);
        Int p3 = get<3>(t);
        if (mp[make_tuple(p1, p2, p3)] > 0) continue;
        dump(get<0>(t));
        cnt++;
        mp[make_tuple(p1, p2, p3)]++;
        if (p1 < x - 1) {
            q.push(make_tuple(a[p1 + 1] + b[p2] + c[p3], p1 + 1, p2, p3));
        }
        if (p2 < y - 1) {
            q.push(make_tuple(a[p1] + b[p2 + 1] + c[p3], p1, p2 + 1, p3));
        }
        if (p3 < z - 1) {
            q.push(make_tuple(a[p1] + b[p2] + c[p3 + 1], p1, p2, p3 + 1));
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll x,y;
    cin >> x >> y;
    cout << x*y << " " << 2*(x+y) << endl;
    return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) cin >> p[i];
	for (int i = 0; i < n - 1; ++i) {
		if (p[i] > p[i + 1]) {
			int tmp = i + 1;
			for (int j = i + 1; j < n; ++j)
				if (p[j] < p[tmp]) tmp = j;
			swap(p[i], p[tmp]);
			break;
			cout << i << " " << tmp << endl;
		}
	}
	bool flag = true;
	for (int i = 0; i < n - 1; ++i)
		if (p[i] > p[i + 1]) flag = false;
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int mh(pii a, pii b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pii> P(n);
	for (int i = 0; i < n; i++) {
		cin >> P[i].first >> P[i].second;
	}
	vector<pair<int, pii>> A, B;
	for (int i = 0; i < n; i++) {
		int sum = P[i].first + P[i].second;
		A.push_back({sum, P[i]});
		int diff = P[i].first - P[i].second;
		B.push_back({diff, P[i]});
	}
	sort(all(A));
	sort(all(B));
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, mh(P[i], A.front().second));
		ans = max(ans, mh(P[i], A.back().second));
		ans = max(ans, mh(P[i], B.front().second));
		ans = max(ans, mh(P[i], B.back().second));
	}
	cout << ans << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}

	sort(a, a+n);
	double ans=a[0];
	for (int i = 1; i < n; i++){
		ans = (ans+a[i])/2;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int cont=0,t;
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(b>c)
    {
        t=b;
        b=c;
        c=t;
    }
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
     while(b<c)//b==c
      {
          b++;
          a++;
          cont++;
      }
        while(a<b)//a==b||a==b+1
        {
            a=a+2;
            cont++;
        }
        if(a==b)
        printf("%d\n",cont);
        if(a==b+1)
        {
            b++;
            c++;
            cont++;
            printf("%d\n",cont);
        }
    return 0;
}


Measured memory_bytes: 128
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 13-Sep-2020 18:02:35
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    long long a, b, c, d;
    Int(a, b); Int(c, d);

    long long res = max({a * c, a * d, b * c, b * d});

    cout << res << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0; //Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	k, s := getInt(), getInt()
	m := min(k, s)

	ans := 0
	for x := 0; x <= m; x++ {
		for y := 0; y <= m; y++ {
			z := s - (x + y)
			if (z >= 0) && (z <= k) {
				ans++
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


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

typedef long long s64;

int main()
{
	//freopen("1.in","r",stdin);
	s64 n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	s64 del=b-a;
	--n;
	for(s64 x=0;x<=n;++x)
	{
		s64 y=n-x;
		if(x*d-y*c>=del&&x*c-y*d<=del)
		{
			puts("YES");
			exit(0);
		}
	}
	puts("NO");
}

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

int main(){

    int banco,pessoa,espaco,total;

    scanf("%d %d %d",&banco,&pessoa,&espaco);

    total=(banco-espaco)/(pessoa+espaco);


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


    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      mut s: chars,
    }
    let mut s: Vec<usize> = s.into_iter().map(|c|c.to_digit(10).unwrap() as usize).collect();
    let n = s.len();
    let mut ss = s.clone();
    let mut cnt = 0;
    for i in 1..n {
        if ss[i] == ss[i-1] {
            ss[i] = 1 - ss[i-1];
            cnt += 1;
        }
    }
    let mut ss = s.clone();
    ss[0] = 1 - ss[0];
    let mut cnt2 = 1;
    for i in 1..n {
        if ss[i] == ss[i-1] {
            ss[i] = 1 - ss[i-1];
            cnt2 += 1;
        }
    }
    println!("{}", min(cnt, cnt2));
}


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

int main()
{
	int a[3][3];
	rep(i, 3)
	rep(j, 3)
		cin >>a[i][j];
	int n;
	cin >> n;
	vector<int> b;
	b.resize(n);
	rep(i, n)
		cin >> b[i];


	bool x[3][3];
	rep(i, 3)
	rep(j, 3)
		x[i][j] = false;
	
	rep(i, 3)
	rep(j, 3)
	rep(k, n)
	{
		//cout << a[i][j] << '=' << b[k] <<':'<< (a[i][j] == b[k])<<endl;
		if (a[i][j] == b[k])
			x[i][j] = true;
	}

	//cout<<x[0][0]<<x[0][1]<<x[0][2]<<endl;
	//cout<<x[1][0]<<x[1][1]<<x[1][2]<<endl;
	//cout<<x[2][0]<<x[2][1]<<x[2][2]<<endl;
	if(
		(x[0][0]&&x[0][1]&&x[0][2])||//最上部
		(x[1][0]&&x[1][1]&&x[1][2])||//中央ヨコ
		(x[2][0]&&x[2][1]&&x[2][2])||//最下部
		(x[0][0]&&x[1][0]&&x[2][0])||//最左
		(x[0][1]&&x[1][1]&&x[2][1])||//中央タテ
		(x[0][2]&&x[1][2]&&x[2][2])||//最右
		(x[0][0]&&x[1][1]&&x[2][2])||//／
		(x[0][2]&&x[1][1]&&x[2][0])  //＼
	)cout<<"Yes"<<endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=300010;
const int maxn=300000;
//const int N=20;
//const int maxn=10;
const int mod=998244353;
int a[N][2],sa[N][2],b[N][2],sb[N][2];
int cj[N],inv[N];
char s[N];
int ans;

int power(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod){
		if(y&1)	ret=1ll*ret*x%mod;
	}
	return ret;
}

int C(int n,int m){
	return 1ll*cj[n]*inv[m]%mod*inv[n-m]%mod;
}

int calc(int n,int m){
	if(n==0&&m==0)	return 1;
	if(n==0)	return 0;
	if(m==0)	return 1;
	return C(n+m-1,m);
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n,m;int i,j,now;
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);rep(i,1,n)	a[i][0]=s[i]=='1';
	scanf("%s",s+1);rep(i,1,n)	a[i][1]=s[i]=='1';
	scanf("%s",s+1);rep(i,1,m)	b[i][0]=s[i]=='1';
	scanf("%s",s+1);rep(i,1,m)	b[i][1]=s[i]=='1';
	rep(i,1,n)	rep(j,0,1)	sa[i][j]=sa[i-1][j]+a[i][j];
	rep(i,1,m)	rep(j,0,1)	sb[i][j]=sb[i-1][j]+b[i][j];
	rep(i,1,n)	
	cj[0]=1;rep(i,1,maxn)	cj[i]=1ll*cj[i-1]*i%mod;
	inv[maxn]=power(cj[maxn],mod-2);inv[0]=1;
	for(i=maxn-1;i;i--)	inv[i]=1ll*inv[i+1]*(i+1)%mod;
	now=0;
	rep(i,1,n){
		if(a[i][0]+a[i][1]==0)	continue;
		now=(now+calc(sb[m][0],sa[i-1][0]+sa[i-1][1]))%mod;
		ans=(ans+1ll*now*(a[i][0]+a[i][1])*calc(sb[m][1],sa[n][0]+sa[n][1]-sa[i][0]-sa[i][1]))%mod;
		now=1ll*now*(a[i][0]+a[i][1])%mod;
	}
	now=0;
	rep(i,1,m){
		if(b[i][0]+b[i][1]==0)	continue;
		now=(now+calc(sa[n][0],sb[i-1][0]+sb[i-1][1]))%mod;
		ans=(ans+1ll*now*(b[i][0]+b[i][1])*calc(sa[n][1],sb[m][0]+sb[m][1]-sb[i][0]-sb[i][1]))%mod;
		now=1ll*now*(b[i][0]+b[i][1])%mod;
	}
	if(sa[n][0]+sa[n][1]+sb[m][0]+sb[m][1]==0)	ans=1;
	printf("%d",ans);
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 10368
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>
 
using namespace std;

const int N=110;
int n;
int s[N];

int main()
{
    int sum=0;
    scanf("%d",&n);
    for (int i=0;i<n;i++) {
        scanf("%d",s+i);
        sum+=s[i];
    }
    sort(s,s+n);
    if (sum%10!=0) {
        printf("%d\n",sum);
        return 0;
    }
    bool flag=true;
    for (int i=0;i<n;i++) {
        if (s[i]%10!=0) {
            sum-=s[i];
            flag=false;
            break;
        }
    }
    if (flag) printf("0\n");
    else printf("%d\n",sum);
}

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

const int MOD = (int) 1e9 + 7;

long long dp[669][2002], fp[669][2002];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int s;
    cin >> s;

    long long ans = 0;
    
    dp[0][0] = 1;

    for (int i=0; i<=s; i++)
        fp[0][i] = 1;
    
    for (int i=1; i<=s/3; i++)
        for (int j=3; j<=s; j++)
        {
            dp[i][j] = fp[i-1][j-3];
            fp[i][j] = (dp[i][j] + fp[i][j-1]) % MOD;
        }

    for (int i=1; i<=s/3; i++)
        ans += dp[i][s];

    cout << ans % MOD << "\n";
    return 0;
}


Measured memory_bytes: 24372
def main():
  import sys
  M=10**9+7
  r1,c1,r2,c2=map(int,sys.stdin.buffer.readline().split())
  n=r2+c2+2
  val=1
  fac=[val]
  append=fac.append
  for i in range(1,n+1):
    val=val*i%M
    append(val)
  pr1=pow(fac[r1],M-2,M)
  pc1=pow(fac[c1],M-2,M)
  pr2=pow(fac[r2+1],M-2,M)
  pc2=pow(fac[c2+1],M-2,M)
  print((fac[r2+c2+2]*pr2*pc2-fac[r2+c1+1]*pr2*pc1-fac[r1+c2+1]*pr1*pc2+fac[r1+c1]*pr1*pc1)%M)
main()

Measured memory_bytes: 82220
#include <bits/stdc++.h>
#define nmax 100005

using namespace std;

vector <int> g[nmax];
bool visited[nmax]={};

void dfs(int u){
    visited[u]=1;
    for(auto v:g[u]){
        if(!visited[v]){
            dfs(v);
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    while(m--){
        int u,v,z;
        cin >> u >> v >> z;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(!visited[i]){
            dfs(i);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8960
# -*- coding: utf-8 -*-
a = int(input())
# スペース区切りの整数の入力
members = input().split()
a = []
count = 0

for member in members:
    if(member not in a):
        a.append(member)
        count += 1
if(count == 3):
    print("Three")
elif(count == 4):
    print("Four")


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

int main()
{
  int N,Q;
  string S;
  cin>>N>>Q;
  int sum[100000];
  cin>>S;
   int pointer = 0;
  for(int i = 0;i<S.length();i++)
  {
    if(i<1)
    {
      	sum[i] = 0;
    }else{
      if(S[i -1] == 'A' && S[i] == 'C')
      {
        sum[i] = sum[i - 1] + 1;
      }else{
        sum[i] = sum[i -1];
      }
    }
    
  }
  for(int i = 0;i<Q;i++)
  {
    int l,r;
    cin>>l>>r;
    cout<<sum[r -1] - sum[l -1]<<endl;
  }
}

Measured memory_bytes: 1408
<?php

while (true) {
    if (feof(STDIN)) {
        break;
    }
    $field = array();
    for ($i = 0; $i < 12; $i++) {
        $field[] = str_split(rtrim(fgets(STDIN)));
    }
    fscanf(STDIN, '');

    $c = 0;
    for ($i = 0; $i < 12; $i++) {
        for ($j = 0; $j < 12; $j++) {
            if ($field[$i][$j] === '1') {
                dfs($field, array($i, $j));
                $c++;
            }
        }
    }

    echo $c . PHP_EOL;
}

function dfs(&$field, $s) {
    $stack = array($s);
    $dx = array(1, -1, 0, 0);
    $dy = array(0, 0, 1, -1);
    while (count($stack)) {
        $node = array_pop($stack);
        $field[$node[0]][$node[1]] = '0';
        for ($i = 0; $i < 4; $i++) {
            $nx = $node[1] + $dx[$i];
            $ny = $node[0] + $dy[$i];
            if (!isset($field[$ny][$nx]) || $field[$ny][$nx] === '0') {
                continue;
            }
            $stack[] = array($ny, $nx);
        }
    }
}

Measured memory_bytes: 7256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    long long x, y;
    cin >> x >> y;
    int i = 0;
    while (x <= y) {
        x *= 2;
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
    static void Main(string[] args)
    {
        // ���̓t�F�[�Y
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        int X = int.Parse(input[2]);
        int Y = int.Parse(input[3]);
        string[] xpoint = Console.ReadLine().Split(' ');
        string[] ypoint = Console.ReadLine().Split(' ');

        int maxX = X, minY = Y;
        for (int i = 0; i < N; i++)
        {
            int x = int.Parse(xpoint[i]);
            if (x > maxX)
                maxX = x;
        }

        for (int i = 0; i < M; i++)
        {
            int y = int.Parse(ypoint[i]);
            if (y < minY)
                minY = y;
        }

        bool ret = false;
        // X��Y��Z��S�T��
        for (int z = X + 1; z <= Y; z++)
        {
            if (maxX < z && minY >= z)
            {
                ret = true;
                break;
            }
        }

        //�o��
        //Console.WriteLine(ret);
        if (ret)
            Console.WriteLine("No War");
        else
            Console.WriteLine("War");
    }

}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

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

  int ans = 1;
  FOR(i, 2, X)
  {
    int num = i;
    while (num <= X)
    {
      num *= i;
    }
    num /= i;
    if (num != i)
      ans = max(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n,d;cin>>n>>d;
  d=d*2+1;
  if(n%d==0){
    cout<<n/d<<endl;
  }
  else{
    cout<<n/d+1<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
list_ = [input().split()+[i] for i in range(1, n+1)]
for i in range(n):
    list_[i][1] = int(list_[i][1])
list_.sort(key=lambda x: (x[0],-x[1]))
for i in list_:
    print(i[2])

Measured memory_bytes: 3060
import Control.Monad

cut :: Int -> Int -> Int -> Int -> [String] -> [String]
cut x y w h ss = take h . drop y $ map (take w . drop x) ss

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  ns <- replicateM n getLine
  ms <- replicateM m getLine
  let nw = length $ head ns
  let nh = length ns
  let mw = length $ head ms
  let mh = length ms
  let result = (not . null) $ filter (==True) [cut x y mw mh ns == ms | x <- [0..nw-mw], y <- [0..nh-mh]]
  putStrLn $ if result then "Yes" else "No"


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

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

const ll MOD = 1000000007;

int main(){
    ll n; cin >> n;
    ll ans = 0;
    rep(i,n) ans += (i+1)*(n-i);
    rep(i,n-1){
        ll u, v; cin >> u >> v;
        if(u > v) swap(u,v);
        ans -= u*(n-v+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int r, c; cin >> r >> c;
	vector<vector<int>> m(r + 1, vector<int>(c + 1,0));
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c;j++) {
			cin >> m[i][j]; cout << m[i][j] << " "; m[i][c] += m[i][j]; m[r][j] += m[i][j];
		}
		m[r][c] += m[i][c];
		cout << m[i][c] << endl;
	}
	for (int j = 0; j < c;j++) {
		cout << m[r][j] << " ";
	}
	cout << m[r][c] << endl;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <algorithm>
using namespace std;
int n, q, c, e, d[111111]; long long t, x[111111], y[111111];
int main() {
	scanf("%d%lld%d", &n, &t, &q);
	for (int i = 0; i < n; i++) scanf("%lld%d", x + i, d + i);
	for (int i = 1; i < n; i++) if (d[i] - d[i - 1] == 1) y[c++] = (x[i - 1] + x[i]) / 2;
	for (int i = 0; i < q; i++) {
		scanf("%d", &e); e--;
		int ptr = lower_bound(y, y + c, x[e]) - y;
		long long ret = x[e] + t * (d[e] * -2 + 3);
		if (d[e] == 1) { if (ptr != c) ret = min(ret, y[ptr]); }
		else if (--ptr != -1) ret = max(ret, y[ptr]);
		printf("%lld\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3952
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {


    public void solve() throws IOException {
        char c[] = nextToken().toCharArray();
        int n = c.length;
        int gMax = Integer.MAX_VALUE;
        for (int i = 0; i < 26; i++) {
            int max = 0;
            int cnt = 0;
            for (int j = 0; j < n; j++) {
                if(c[j] - 'a' != i){
                    cnt++;
                }else{
                    max = Math.max(max, cnt);
                    cnt = 0;
                }
            }
            if(cnt <= max){
                gMax = Math.min(gMax, max);
            }else{
                gMax = Math.min(gMax, cnt);
            }
        }
        out.print(gMax);
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("queue.in"));
//            out = new PrintWriter(new File("queue.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 200000
#define BIRTHDAY 1009

typedef struct hash{
	int num;
	struct hash *next;
}hash;

void append(hash**, int);
void search(hash**, int);
void clean(hash**);
void possible();

int a_list[MAX_NUM] = {0};
int a_index = 0;
hash *hash_list[BIRTHDAY] = {NULL};

int main(void){
	int N, M;
	int a, b;
	int i;
	hash *p;

	scanf("%d %d", &N, &M);
	for(i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1){
			append(hash_list, b);
		}
		if(b == N){
			a_list[a_index++] = a;
		}
	}

	for(i=0; i<a_index; i++){
		search(hash_list, a_list[i]);
	}

	clean(hash_list);
	printf("IMPOSSIBLE");
	return 0;
}

void append(hash **list, int num){
	hash *p, *tmp;
	hash *item;
	tmp = NULL;

	for(p = list[num%BIRTHDAY]; p != NULL && p->num < num; p = p->next)
		tmp = p;

	item = (hash*)malloc(sizeof(hash));
	item->num = num;
	item->next = p;
	if(tmp == NULL)
		list[num%BIRTHDAY] = item;
	else
		tmp->next = item;
}

void search(hash **list, int num){
	hash *p;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num <= num; p = p->next){
		if(p->num == num)
			possible();
	}
}

void possible(){
	clean(hash_list);
	printf("POSSIBLE");
	exit(0);
}

void clean(hash **list){
	int i;
	hash *p, *tmp;
	for(i = 0; i < BIRTHDAY; i++){
		for(p = list[i]; p != NULL; p = p->next){
			tmp = p;
			free(tmp);
		}
	}
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> list = new List<string>();

            string input;
            while ((input = Console.ReadLine()) != "0 0")
            {
                string[] s = input.Split(' ');
                int month = int.Parse(s[0]);
                int date = int.Parse(s[1]);

                int total = 0;
                for (int i = 1; i <= month; i++)
                {
                    if (i != month)
                    {
                        total += DateTime.DaysInMonth(2004, i);
                    }
                    else
                    {
                        total += date;
                    }
                }

                list.Add(GetDay(total));

            }

            foreach (string st in list)
            {
                Console.WriteLine(st);
            }

        }

        static string GetDay(int total)
        {
            string day = "";

            switch (total % 7)
            {
                case 0:
                    day = "Wednesday";
                    break;
                case 1:
                    day = "Thursday";
                    break;
                case 2:
                    day = "Friday";
                    break;
                case 3:
                    day = "Saturday";
                    break;
                case 4:
                    day = "Sunday";
                    break;
                case 5:
                    day = "Monday";
                    break;
                case 6:
                    day = "Tuesday";
                    break;
            }

            return day;
        }
    }
}

Measured memory_bytes: 5436
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();

        boolean valid = false;
        for (int i = 1; i <= 9; ++i)
            if (n % i == 0 && n / i <= 9) {
                valid = true;
                break;
            }
        writer.println(valid ? "Yes" : "No");
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 20820
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int n;
	int t,a;
	cin >> n;
	cin >> t >> a;
	int h[n];
	rep(i,n){
		cin >> h[i];
	}

	double ans[n];

	rep(i,n){
		ans[i]=abs((t-h[i]*0.006)-a);
	}
	int index;
	double num=pow(10,9);
	rep(i,n){
		if(ans[i]<num){
			index=i;
			num=ans[i];
		}
	}
	cout << index+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    vector<double> a(n);
    for (int i = 0; i < n; ++i) {
        a[i] = v[i];
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            a[i] = max(a[i], a[j]+sqrt(4*v[i]*v[j]));
        }
    }
    double ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, a[i]+v[i]);
    }
    printf("%.8lf", ans);
    return 0;
}


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


void sort(int x[],int num){
    int ret[num];
    int count=0;
    bool flag=false;
    for(int i=0;i<num;i++){
        ret[i]=x[i];
        for(int j=0;j<=i;j++){
            if(ret[i]==ret[j])
                count++;
        }
        if(count>1)
            ret[i]=393939;
        count=0;
    }
    memcpy(x,ret,num*sizeof(int));
}


int main(){
    int* array1,*array2,*array3;
    int n,q,counter=0;
    int left=0;
    int right;
    int mid;
    int l=0;

    scanf("%d",&n);
    array1=malloc(sizeof(int)*n);
    for(int i=0;i<n;i++){
        scanf("%d",&array1[i]);
    }
    //sort(array1,n);

    scanf("%d",&q);
    array2=malloc(sizeof(int)*q);
    for(int j=0;j<q;j++){
        scanf("%d",&array2[j]);
    }

    /*for(int k=0;k<n;k++){
        if(array1[k]!=393939){
            array3[l]=array1[k];
            //printf("%d ",array3[l]);
            l++;
        }
    }*/

    for(int m=0;m<q;m++){
        left=0;
        right=n;
        while(left<right){
            mid=(left+right)/2;
            if(array1[mid]==array2[m]){
                counter++;
                break;
            }
            else if(array2[m]<array1[mid])
                right=mid;
            else
                left=mid+1;
        }
    }
    printf("%d\n",counter);
    return 0;
}



Measured memory_bytes: 2296
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int N;
  scanf("%d",&N);
  char s[N+1][11];
  for(int i=0;i<N;i++){	
    scanf("%s",s[i]);
  }
  if(N==1){
    printf("%s",s[0]);
    return 0;
  }
  
  qsort(s,N,sizeof(char)*11,strcmp);
  
 /* for(int i=0;i<N;i++){	
    printf("%s\n",s[i]);
  }*/
 int max=-1;
  int anser[N+1];
  for(int i=0;i<N;i++){
     anser[i]=1;
    }
  for(int i=0;i<N-1;i++){
    if(strcmp(s[i],s[i+1])==0){
      anser[i+1]=anser[i]+1;
    }
    if(anser[i+1]>max)max=anser[i+1];
  }
  
 /* for(int i=0;i<N;i++){
      printf("%d\n",anser[i]);
    }
  */
 for(int i=0;i<N;i++){
    if(anser[i]==max){
      printf("%s\n",s[i]);
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 4808
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int x, b, p, ats;
long long pap;

int main() {
    scanf("%d", &x);

    if (x == 1) {
        printf("1\n");
        return 0;
    }

    for (int i = 2; i <= (int)sqrt(x); i++) {
        pap = (long long)i;
        while (pap <= (long long) x) {
            ats = max(ats, (int)pap);
            pap *= (long long) i;
        }
    }

    printf("%d\n", ats);
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	ans = 0
	for i in range(1,n+1):
		if(i%3!=0 and i%5!=0):
			ans+=i
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 9096
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(n):
    if b[i] in a1:
        a1[a1.index(b[i])] = 500
    elif b[i] in a2:
        a2[a2.index(b[i])] = 500
    elif b[i] in a3:
        a3[a3.index(b[i])] = 500
    else:
        pass

#print(a1,a2,a3)
ver = [a1[i]+a2[i]+a3[i] for i in range(3)]
hor = [sum(a1),sum(a2),sum(a3)]
dia = [a1[0]+a2[1]+a3[2],a3[0]+a2[1]+a1[2]]

if max(max(ver),max(hor),max(dia)) == 1500:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type cxcyh struct {
	CX int
	CY int
	H  int
}

type xyh struct {
	x int
	y int
	h int
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	N := readInt()
	XYH := make([]xyh, 0, N)
	n := -1
	for i := 0; i < N; i++ {
		x := readInt()
		y := readInt()
		h := readInt()
		XYH = append(XYH, xyh{x, y, h})
		if h != 0 {
			n = i
		}
	}

	q := make([]cxcyh, 0, 101*101)
	for cx := 0; cx <= 100; cx++ {
		for cy := 0; cy <= 100; cy++ {
			H := XYH[n].h + abs(XYH[n].x-cx) + abs(XYH[n].y-cy)
			q = append(q, cxcyh{cx, cy, H})
		}
	}

	for i := 0; i < len(XYH); i++ {
		nq := make([]cxcyh, 0, len(q))
		for j := 0; j < len(q); j++ {
			if XYH[i].h == max(q[j].H-abs(XYH[i].x-q[j].CX)-abs(XYH[i].y-q[j].CY), 0) {
				nq = append(nq, q[j])
			}
		}
		q = nq
	}

	fmt.Printf("%d %d %d\n", q[0].CX, q[0].CY, q[0].H)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 2308