akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
inline int $(){
    register int x = 0;register char ch = getchar();
    while(!isdigit(ch))ch = getchar();
    for(;isdigit(ch);ch = getchar())x = (x << 1) + (x << 3) + (ch ^ 48);
    return x;
}
#define MAXN 100010
#include<set>
#include<map>
#include<queue>
std::set<int> next[MAXN];
std::map<std::pair<int, int>, int> M;
std::queue<std::pair<int, int> > Q;
int n = $();
int p[MAXN];
inline int find(int x){return x == p[x] ? x : p[x] = find(p[x]);}
int main(){
    for(int i = 1;i <= n;i++)p[i] = i;
    for(int i = 2;(i >> 1) < n;i++){
        int x = $(), y = $();
        if(x > y)std::swap(x, y);
        next[x].insert(y);next[y].insert(x);
        if(++M[std::make_pair(x, y)] == 2)Q.push(std::make_pair(x, y));
    }
    for(int i = 1;i < n;i++){
        register int x = 0, y = 0;
        while(x == y){
            if(Q.empty())return puts("NO"), 0;
            x = find(Q.front().first), y = find(Q.front().second);
            Q.pop();
        }
        if(next[x].size() > next[y].size())std::swap(x, y);
        p[x] = y;
        for(auto i : next[x]){
            if(find(i) == y)continue;
            next[y].insert(find(i));
            std::pair<int, int> add = std::make_pair(std::min(find(i), y), std::max(find(i), y));
            if(++M[add] == 2)Q.push(add);
        }
        next[y].erase(x);
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 46080
def main
  s_ar = STDIN.gets.chomp.split('').sort

  if s_ar.uniq.length == 1
      puts "No"
      return
  end

  s_ar.each_slice(2) do |a|
    if a[0] != a[1]
      puts "No"
      return
    end
  end
  puts "Yes"
end

main

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> a(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	int x = 0;
	int y = 0;
	int z = 0;
	rep (i, N){
		x += (a[i] % 4 == 0);
		y += ((a[i] % 4 != 0) && (a[i] % 2 != 0));
		z += ((a[i] % 4 != 0) && (a[i] % 2 == 0));
	} // end rep

	bool ok = (x >= y + (z % 2) - 1);
	cout << (ok ? "Yes" : "No") << endl; 

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <tuple>
#include <set>
#include <queue>

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

  int c[10][10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      std::cin >> c[i][j];
    }
  }

  std::vector<int> nlength(10);
  std::set<int> searched;
  std::priority_queue<std::tuple<int, int>> pq;
  pq.push(std::make_tuple(0, 1));
  while(pq.size() > 0){
    int num,length;
    std::tie(length,num) = pq.top();
    pq.pop();
    if(searched.count(num) > 0) continue;
    searched.insert(num);
    nlength[num] = length;
    for(int i = 0; i < 10; i++){
      if(searched.count(i) > 0) continue;
      pq.push(std::make_tuple(length-c[i][num],i));
    }
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int A;
      std::cin >> A;
      if(A == -1) continue;
      ans += -nlength[A];
    }
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
import sys
from collections import defaultdict

input = sys.stdin.readline


def calc_prime_factors(n, count=False):
    """Trial division"""
    factors = []
    # factor: 2
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    # factor: 3, 5, 7, 11, ...
    f = 3
    root_n = int(n ** 0.5) + 1
    while f <= root_n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        factors.append(n)
    return factors


def main():
    N = int(input())

    n_factor = defaultdict(int)
    for n in range(1, N + 1):
        factors = calc_prime_factors(n)
        for f in factors:
            n_factor[f] += 1

    n_factor = list(n_factor.values())
    n_factor.sort()
    ans = 0

    # 75 = 3 x 3 x 5 : (2, 4, 4)
    A, B = 0, 0
    for n in n_factor:
        if 2 <= n <= 3:
            A += 1
        elif 4 <= n:
            B += 1
    ans += A * B * (B - 1) // 2 + B * (B - 1) * (B - 2) // 6 * 3

    # 75 = 3 x 25 : (2, 24)
    A, B = 0, 0
    for n in n_factor:
        if 2 <= n <= 23:
            A += 1
        elif 24 <= n:
            B += 1
    ans += A * B + B * (B - 1)

    # 75 = 5 x 15 : (4, 14)
    A, B = 0, 0
    for n in n_factor:
        if 4 <= n <= 13:
            A += 1
        elif 14 <= n:
            B += 1
    ans += A * B + B * (B - 1)

    # 75 = 75 : (74,)
    A = 0
    for n in n_factor:
        if 74 <= n:
            A += 1
    ans += A

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9684
gets.to_i.times do
  log = gets.chomp
  cars = log.scan /[a-z]/
  arrows = log.scan /[^a-z]+/

  train = cars[0]
  cars.each_cons(2).with_index do |car_comb, index|
    if arrows[index] == '->' then
      train << car_comb[1] if train[-1] == car_comb[0]
    else
      train = car_comb[1] + train if train[0] == car_comb[0]
    end
  end
  puts train
end

Measured memory_bytes: 6124
while n = gets.to_i
  break if n == 0
  arr = []
  n.times{|i|
    arr << gets.split(",").map(&:to_f)
  }
  arr.sort!
  max = []
  min = []
  n.times{|i|
    (i+1).upto(n-1){|j|
      del = (arr[j][1] - arr[i][1]) / (arr[j][0] - arr[i][0])
      max[i] ||= [del, j]
      min[i] ||= [del, j]
      max[i] = [del, j] if max[i][0] < del
      min[i] = [del, j] if min[i][0] > del
    }
  }
  used = [0]
  i = 0
  loop do
    i = max[i][1]
    used << i
    break if i == n - 1
  end
  i = 0
  loop do
    i = min[i][1]
    break if i == n - 1
    used << i
  end
  p n - used.size
end

Measured memory_bytes: 8640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
  int N, minCnt = 1000;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    int A, cnt = 0;
    cin >> A;
    while (A % 2 == 0)
    {
      A /= 2;
      cnt++;
    }
    if (minCnt > cnt)
      minCnt = cnt;
  }
  cout << minCnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int a,b,c,p=0,q=0;
 
    while(scanf("%d,",&a)!=EOF){
            scanf("%d,%d",&b,&c);
            if(a==b)p++;
            else if(a*a+b*b==c*c)q++;
    }
    printf("%d\n%d\n",q,p);
 
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll d[4][111111];
  d[2][0]=d[3][0]=1;
  REP(i,1,111111) {
    d[2][i]=(d[2][i-1]*2)%MAX;
    d[3][i]=(d[3][i-1]*3)%MAX;
  }
  string s;
  R s;
  ll ans=0,a=0,c=0,x=0,y=0;
  rep(i,s.size()) {
    if(s[i]=='C') c++;
    if(s[i]=='?') y++;
  }
  rep(i,s.size()) {
    if(s[i]=='C') c--;
    if(s[i]=='?') y--;
    if(s[i]=='B'||s[i]=='?') {
      ans+=a*d[3][x]%MAX*c%MAX*d[3][y]%MAX;
      if(x) ans+=x*d[3][x-1]%MAX*c%MAX*d[3][y]%MAX;
      if(y) ans+=a*d[3][x]%MAX*y%MAX*d[3][y-1]%MAX;
      if(x&&y) ans+=x*d[3][x-1]%MAX*y%MAX*d[3][y-1]%MAX;
      ans%=MAX;
    }
    if(s[i]=='A') a++;
    if(s[i]=='?') x++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void Insetion(int A[],int n,int g)
{
    for(int i=g;i<n;++i)
    {
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v)
        {
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void shell(int A[],int n)
{
    for(int h=1;;)
    {
        if(h>n)
        {
            break;
        }
        G.push_back(h);
        h=3*h+1;
    }
    for(int i=G.size()-1;i>=0;i--)
    {
        Insetion(A,n,G[i]);
    }
}

int main()
{
    cin>>n;
    for(int i=0;i<n;++i)
    {
        scanf("%d",&A[i]);
    }
    cnt=0;

    shell(A,n);

    cout<<G.size()<<endl;

    for(int i=G.size()-1;i>=0;i--)
    {
        printf("%d",G[i]);
        if(i)
        {
            printf(" ");
        }
    }

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

    for(int i=0;i<n;++i)
    {
        printf("%d\n",A[i]);
    }

    return 0;
}


Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int H, W;cin>>H>>W;
	if(min(H,W)>1) cout << H*W-(H*W)/2;
	else cout<<1;
}


Measured memory_bytes: 256
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)*}
    };
}

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

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

fn main() {
    input! {
        n: u64,
        k: u64,
        a: [u64; n],
    }

    let mut v = Vec::new();
    for i in 0..64 {
        let digit_sum = a.iter().fold(0, |x, &y| x + ((y >> i) & 1));
        v.push(digit_sum);
    }

    let mut k_rest = k;
    let mut xmax = 0;
    for i in (0..64).rev() {
        if k_rest < (1 << i) {
            continue;
        } else if 2 * v[i] < n {
            xmax += 1 << i;
            k_rest -= 1 << i;
        }
    }

    let ans = a.iter().fold(0, |x, &y| x + (y ^ xmax));
    //println!("{}", xmax);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
//#define int  long long 
using namespace std;
int n, k, ans;
signed main()
{
	while(~scanf("%d%d", &n, &k))
	{
		for (int i = 0; i < n; i++)	scanf("%*d");
		n--, k--;
		ans = n / k;
		if (n % k)	ans++;
		printf("%d\n", ans);
	}

}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 100010
int n;
int px[N], py[N], pz[N];
int a[N];
int f[N], st[N], ed[N], ne[N];
int b[N]; // index
int ib[N];
ll S[N];
ll ad[N];

int cmp(int x, int y) {
	return pz[x] < pz[y];
}

int fa(int x) {
	if (f[x] == x) return x;
	return f[x] = fa(f[x]);
}

int main() {
	cin >> n;
	for (int i = 0; i < n-1; i ++) {
		cin >> px[i] >> py[i] >> pz[i];
		px[i] --;
		py[i] --;
		a[i] = i;
	}
	sort(a, a+n-1, cmp);
	for (int i = 0; i < n; i ++) {
		f[i] = i;
		st[i] = ed[i] = i;
	}
	for (int i = n-2; i >= 0; i --) {
		int x = px[a[i]], y = py[a[i]];
		x = fa(x); y = fa(y);
		if (x > y) swap(x, y);
		f[y] = x;
		ne[ed[x]] = st[y];
		ed[x] = ed[y];
	}
	for (int i = 0, j = 0; i < n; i ++) {
		b[j] = i;
		ib[i] = j;
		j = ne[j];
	}
	for (int i = 0; i < n; i ++) {
		f[i] = i;
		st[i] = ed[i] = i;
	}
	for (int i = n-2; i >= 0; i --) {
		int x = px[a[i]], y = py[a[i]], z = pz[a[i]];
		x = fa(x); y = fa(y);
		if (x > y) swap(x, y);
		int sx = b[ed[x]] - b[st[x]] + 1;
		int sy = b[ed[y]] - b[st[y]] + 1;
		//printf ("P %d %d\n", sx, sy);
		ad[b[st[x]]] += (ll)sy*z;
		ad[b[ed[x]]+1] -= (ll)sy*z;
		ad[b[st[y]]] += (ll)sx*z;
		ad[b[ed[y]]+1] -= (ll)sx*z;
		f[y] = x;
		ne[ed[x]] = st[y];
		ed[x] = ed[y];
	}
	ll cc = 0;
	for (int i = 0; i < n; i ++) {
		cc += ad[i];
		S[ib[i]] = cc;
	}
	for (int i = 0; i < n; i ++) cout << S[i] << endl;
	return 0;
}

Measured memory_bytes: 7168
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
char bef[1000001],aft[10000001],word[100000001];
int main(){
    int n,m;
    while(cin>>n,n){
        for(int i=0;i<n;i++){
            cin>>bef[i]>>aft[i];
        }
        cin>>m;
        for(int i=0;i<m;i++){
            cin>>word[i];
            for(int j=0;j<n;j++){
                if(bef[j]==word[i]){
                    word[i]=aft[j];
                    break;
                }
            }
        }
        cout<<word<<endl;
    }
}

Measured memory_bytes: 3300
N=int(input())

t = list(map(int,input().split()))
v = list(map(int,input().split()))

tl = []
v1 = [0]+v+[0]
ts = 0
for i in range(N+1):
    tl.append([ts,min(v1[i],v1[i+1])])
    if i!=N:
        ts+=t[i]

max_v = []

k = 0
for i in range(2*ts+1):
    mv = 10**27
    if tl[k+1][0]<i/2:
        k+=1
    for j in range(len(tl)):
        mv = min(mv,abs(i/2-tl[j][0])+tl[j][1],v[k])
    max_v.append(mv)
s = 0
for i in range(2*ts):
    s+=max_v[i]+max_v[i+1]

print(s/4)

Measured memory_bytes: 45020
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

const int MAXN = 100+10;
int a[MAXN];
int tot = 0;
void init(){
	memset(a,0,sizeof(a));
	for(int i=0;i<=25;i++){
		for(int j=0;j<=20;j++){
			if(4*i+7*j<=100){
				a[4*i+7*j] = 1;
			}
		}
	}		
}

int main(){
	init();
	int b = 0;
	scanf("%d",&b);
	if(a[b]==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

def solve():
  h,w = (int(i) for i in input().split())
  n = int(input())
  a = list(int(i) for i in input().split())
  query = []
  flag = True
  for i in range(n):
    times = a[i]
    number = i+1
    for j in range(times):
      query.append(number)
  ans = []
  retu = []
  while query:
    nextnumber = query.pop(0)
    if len(retu) < w:
      retu.append(nextnumber)
    else:
      ans.append(retu)
      retu = [nextnumber]
  ans.append(retu)
  for i in range(h):
    if i%2 == 1:
      ans[i] = ans[i][::-1]
  for j in range(h):
    print(*ans[j])
solve()

Measured memory_bytes: 4204
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int main()
{
	fastIO;
	ll n; cin >> n;
	cout <<(n / 500ll) * 1000ll + ((n % 500ll) / 5ll) * 5ll<< endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#define ll long long
using namespace std;
#define rep2(i,a,n) for(int i=a;i<=n;i++)
int main(void){
    // Your code here!
  int a,b;
  int ans=0;
  cin>>a>>b;
  
  cout<<max(ans,a-2*b);
}


Measured memory_bytes: 3164
#include<iostream>

using namespace std;

int HowManyDays(const int, const int, const int);

int main(){
	int y, m, d, n, i;

	cin >> n;

	for(i=0;i<n;i++){
		cin >> y >> m >> d;
		cout << (196470 - HowManyDays(y,m,d)) << endl;
	}

	return 0;
}

int HowManyDays(const int year, const int month, const int day){
	int days = (((year - 1) / 3) * 5) + day - 1;		// 1年1月1日からの経過日数

	// 入力のチェック
	if((month < 1) || (month > 10) || (day < 1) || (day > 20)){
		return 0;
	}

	// 1年の日数
	days += (year - 1) * 195;

	// 1箇月の日数
	if((month % 2) == 0){
		days += (((month / 2) - 1) * 39) + 20;
	}else{
		days += ((month - 1) / 2) * 39;
	}

	// 大の月の補正
	if((year % 3) == 0){
		days += (month - 1) / 2;
	}

	return days;
}

Measured memory_bytes: 1160
let r, g, b, n = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d
let ans = ref 0
let _ =
  for i = 0 to n do
    for j = 0 to n do
      let rest = n - i * r - j * g in
      if rest >= 0 && rest mod b = 0 then incr ans done done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    string w[100];
    bool flag = true;
    for(int i=0; i<n; i++){
        cin >> w[i];
        if(i>0){
            for(int j=0; j<i; j++){
                if (w[i] == w[j]) {
                    flag = false;
                }
            }
            int last = w[i-1].length()-1;
            if(w[i][0] != w[i-1][last]){
                flag = false;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;

#define INF 2000000000
	int main(){
		int n;cin>>n;
		vector<long long> costdp(n+1,INF);
		costdp[0]=0;
		costdp[1]=0;
		vector<int> h(n+1);
		cin>>h[0];
		h[1]=h[0];
		
		rep(i,n-1){
			cin>>h[i+2];
		}//高さの入力調整したので、i番目の高さはh[i]に書かれている
		rep(i,n-1){
			//costdp[2]からcostdp[n]までのコストをcostdpに入れるのでｎ回ループさせる
		int a = abs(h[i+2]-h[i]);
		int b = abs(h[i+2]-h[i+1]);
		costdp[i+2]=min( costdp[i] + a , costdp[i+1] + b);
		}
		cout<<costdp[n]<<endl;
	}


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

int gcd(int n, int m){
	int yan;
	if (m< n){
		yan = m;
		m = n;
		n = yan;
	}
	int r = m%n;
	while (r != 0){
		m = n;
		n = r;
		r = m%n;
	}
	return n;
}
int main(){
	int N, K,M=0;
	int A[100000];
	cin >> N >> K;
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	sort(A, A + N);
	int G = A[0];
	for (int j = 0; j < N; j++){
		G = gcd(G, A[j]);
	}
	if (K%G == 0 && K <= A[N-1]){ cout << "POSSIBLE" << endl; }
	else{ cout << "IMPOSSIBLE" << endl; }
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, x;
    cin>>n>>x;
    ll s = 0;
    int mn = 1e6+1;
    rep(i,0,n-1){
        int tmp;
        cin>>tmp;
        mn = min(mn,tmp);
        s+=tmp;
    }
    x -= s;
    ll ans = n+(x/mn);
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3656
a,b,c,x,y=map(int,input().split())
l=sorted([a,b,c*2])
if l[0]==c*2:
    print(max(x,y)*c*2)
elif l[1]==c*2:
    if l[0]==a:
        print(y*c*2+max((x-y),0)*a)
    else:
        print(x*c*2+max((y-x),0)*b)
else:
    if a+b>=c*2:
        if x>=y:
            print(y*2*c+(x-y)*a)
        else:
            print(x*2*c+(y-x)*b)
    else:
        print(x*a+y*b)

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

const int MAXN = 3e5+10;

int bit[MAXN];
int par[MAXN];
int parent(int i) {
  return par[i] < 0 ? i: (par[i]=parent(par[i]));
}

bool merge(int a, int b) {
  int x = parent(a);
  int y = parent(b);
  if (x==y) {
    if (bit[x]) return false;
    else return bit[x] = 1;
  }
  if (bit[x] && bit[y]) return false;
  bit[x]+=bit[y];
  par[y] = x;
  return 1;
}

int gc=0;
map<pair<int,int>, int> m;
int gid(int r, int c) {
  auto p = make_pair(r,c);
  if (m.count(p)) {
    return m[p];
  }
  else {
    return  m[p] = gc++;
  }
}

int n, h, w;

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n >> h >> w;
  memset(par, -1,sizeof par);
  vector<vector<int>> v;
  for(int i=0;i<n;i++) {
    int r, c, w;
    cin >> r >> c >> w;
    v.push_back({w,r,c});
  }
  sort(v.rbegin(), v.rend());
  ll ans = 0;
  for(auto p: v) {
    if (merge(gid(p[1],0), gid(p[2],1))){
      ans+=p[0];
      //cerr << "ADDING " << p[1] << " " << p[2] << " " << p[0] <<endl;
    }
    //else //cerr << "NOT ADDING " << p[1] << " " << p[2] << " " << p[0] <<endl;
  }
  cout << ans <<endl;
}



Measured memory_bytes: 20144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,k,s=0,a[3];
	scanf("%d %d %d\n%d",&a[0],&a[1],&a[2],&k);
	sort(a,a+3);
	for(i=0;i<k;i++)
	{
		a[2]*=2;
	}
	for(i=0;i<3;i++)
	{
		s+=a[i];
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	cin >> N;

	string s;
	//cin >> s;

	//int A[5]
	//sort(A, A + 5);

	if (0 == N)
	{
		cout << "1" << endl;
	}
	else
	{
		cout << "0" << endl;
	}

}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

// i個目までの品物について考慮したとき
// 重さjで得られる価値の最大値
// オーバーフローに注意
LL dp[110][100010];

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j-w[i] >= 0){
                // ナップサックに入れる
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            }
            // 入れない
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
xyz = [inpl() for i in range(n)]
res = -INF
for bit in itertools.product(range(2),repeat=3):
    tmp = []
    for j in range(n):
        cnt = 0
        for i,b in enumerate(bit):
            if b == 0:
                cnt += xyz[j][i]
            else:
                cnt -= xyz[j][i]
        tmp.append(cnt)
    tmp.sort(reverse=True)
    res = max(res, sum(tmp[:m]))
print(res)

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

typedef long long ll;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,m;
  cin>>n>>m;
  if(n==m)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    set<string> st;
    rep(i, N) {
        string s;
        cin >> s;
        st.insert(s);
    }

    int ans = st.size();
    cout << ans << endl;
}

Measured memory_bytes: 19204
N, K = gets.split.take(2).map(&:to_i)
Ops = N.times.map{gets.split.take(2).map(&:to_i)}
# p Ops.each_with_object([]){|(a, b), r|
#   r << [a]*b
# }.flatten.sort[K-1]
p Ops.sort_by{|a,b| a}.inject(K){|r, (a,b)|
  # p [r, a,b]
  r -= b
  break a if r <= 0
  r
}


Measured memory_bytes: 12664
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll x;
    cin>>n>>m>>x;
    vector<ll> v(m);
    rep(i,m) cin>>v[i];
    rep(i,1000){
        if(i==v[f]){
            if(x<i){
                sum++;
            }else{
                maxi++;
            }
         
            f++;
        }
                   // cout<<i<<" "<<f<<endl;

    }
   // cout<<maxi<<" "<<sum<<endl;
    cout<<min(maxi,sum)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 5050;
int main(){
    int n, q;
    cin >> n >> q;
    while(q--){
        int u, v;
        scanf("%d %d", &u, &v);
        if(n == 1) printf("%d\n", u);
        else{
            while(u != v){
                if(u > v) u = (u + n - 2) / n;
                else v = (v + n - 2) / n;
            }
            printf("%d\n", u);
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int l[N];
  for(int i = 0; i < N ; i++){
  	cin >> l[i];
  }
  sort(l,l+N);
  int ans = 0;
  for(int i = 0; i < K; i++){
  	ans += l[N-1-i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(float,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

	for i in range(2,int(math.sqrt(n))+1):
		if n%i==0:
			return False
	return True


a,b,h,m=input2()
m_new=m/5.0
shita=abs((h+m/60 - m_new))*30
cos_shita= math.radians(shita)
result=a**2+b**2-2*a*b*math.cos(cos_shita)

print(math.sqrt(result))






Measured memory_bytes: 27224
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    map<ll,ll> mp;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        A[i]=a;
        mp[a]++;
    }
    ll res=0;
    for(auto p:mp){
        res+=p.second*(p.second-1)/2;
    }
    for(ll i=0;i<N;i++){
        cout<<res-mp[A[i]]+1<<endl;
    }
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


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

	int n, m,c;
	cin >>n >>m >>c;
	VI b(m);
	ll ans =0;
	rep(i,m) cin >>b[i];
	
	rep(i,n){
		ll sm = c;
		rep(j,m){
			ll a; cin>>a;
			 sm += a * b[j]; 
		}
		//dbg(sm ,c);
		if(sm > 0) ans++;
	}
	cout << ans <<"\n";

	return 0;
}




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

int main()
{
	int n, k, a[100001];
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	int r = k;
	int ans = 0;
	while(r < n) {
		r += k - 1;
		++ans;
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        long N = NextLong();
        long M = NextLong();
        if (Math.Abs(N - M) > 1) { Console.WriteLine(0); return; }
        long Nn = 1, Mm = 1;
        for (int i = 1; i <= N; i++) { Nn *= i; Nn %= INF; }
        for (int i = 1; i <= M; i++) { Mm *= i; Mm %= INF; }
        long ans = (Nn * Mm) % INF;
        Console.WriteLine((N == M ? (ans * 2) % INF : ans));
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

int main(){
    int n,x ;
    cin >> n >> x ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int64_t ans = 0 ;

    if (a.at(0) > x)
    {
        ans += a.at(0) - x ;
        a.at(0) = x ;
    }
    for (size_t i = 0; i < n-1; i++)
    {
        int sum = a.at(i) + a.at(i+1) ;
        if (sum > x)
        {
            ans +=  sum - x ;
            a.at(i+1) = x - a.at(i) ;
        }
        
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
ans = 0
for i in range(1, n):
    ans += (n-1) // i
print(ans)

Measured memory_bytes: 74704
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int hel(string S1, string S2) 
{  
    int n = S1.size(), m = S2.size(); 
    int ans = INT_MAX; 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
   
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
        ans = min(minRemovedChar, ans); 
    } 
    return ans; 
}
int main() {
	string s; 
	string t;
	cin>>s>>t;
	cout<<hel(t,s)<<endl;
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

ll	gcd(ll A, ll B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

ll	lcm(ll A, ll B) {
	ll G=gcd(A, B);
	return A/G*B;
}

int	main() {
	ll X;
	cin >>X;
	double x=360;
	double y=0;
	int I=1;
	int T=X;
	while (x*x+y*y>1.0) {
		double dx=360*cos((double)T*M_PI/180.0);
		double dy=360*sin((double)T*M_PI/180.0);
		x +=dx;
		y +=dy;
		T +=X;
		I++;
	}
	cout <<I <<endl;
	return 0;
}



Measured memory_bytes: 3996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if (a > 9 || b > 9) {
            System.out.println(-1);
        } else {
            System.out.println(a * b);
        }
    }
}


Measured memory_bytes: 21844
use std::vec::Vec;

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

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

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (n, m) = read_touple::<usize>();
    let mut sc = vec![];
    for _ in 0..m {
      let (s, c) = read_touple::<usize>();
      sc.push((s-1, c));
    }
    let num = if n == 1 {
       10
    } else if n == 2 {
       100
    } else {
      1000
    };

    for i in 0..num {
      let xs: Vec<usize> = i.to_string().chars().map(|x| x as usize - '0' as usize).collect();
      //println!("{:?}", xs);
      let mut check = true;
      let d = digit(i);
      for &(s, c) in &sc {
        check = check && get(&xs, s, c);
      }

      if check &&  d == n {
         println!("{}", i);
         return
      }
    }

    println!("-1");
}

fn get(xs: &Vec<usize>, s: usize, c: usize) -> bool {
  if xs.len() <= s {
     return false
  }
    xs[s] == c
}

fn digit(x: usize) -> usize {
    x.to_string().chars().collect::<Vec<_>>().len()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  if (c >= a && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  


  
  return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    count = 0
    if not(n or x):
        break
    for i in range(1, n-1, 1):
        for j in range(i+1, n, 1):
            for k in range(j+1, n+1, 1):
                if i + j + k == x:
                    count += 1
    print(count)

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

int main(){
    int N;
    string S;
    bool b=0;
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> S;
        if (S=="Y") {
            cout << "Four" << endl;
            b=1;
            break;
        }
    }
    if (!b){
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 3608
import java.util.Scanner;
import java.io.InputStreamReader;
import java.io.BufferedReader;
 
class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.nextLine(); // Scanner has functions to read ints, longs, strings, chars, etc.

        System.out.println((char) (s.charAt(0) + 1));
    }
}

Measured memory_bytes: 19924
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

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

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()

	ans := ""
	for i := 0; i < len(s); i++ {
		ans += "x"
	}

	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>

#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)

using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    Ryuga;
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("op.txt","w",stdout);
    #endif    

    string s;
    cin>>s;
    if(s[1]=='R')
        cout<<"ABC";
    else
        cout<<"ARC";
    
}//Goodbye...

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  ll n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  rep(i, n) cin >> t[i];

  sort(t.begin(), t.end());
  ll ans = 0;
  ll people = 0;
  ll min_t = t[0];
  rep(i, n) {
    if (t[i] <= min_t+k && people < c) {
      people++;
    } else {
      ans++;
      min_t = t[i];
      people = 0;
      i--;
    }
  }
  if (people > 0) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <chrono>
#include <queue>
#include <functional>
using namespace std;

struct POINT{
	int x,y;
	
	POINT(int x=0, int y = 0):x(x),y(y){}

	bool operator<(const POINT& r)const {
		return x + y < r.x + r.y;
	}
	POINT operator+(POINT r) {
		return POINT(x + r.x, y + r.y);
	}
};

int cost[50][50];
int status[50][50];

POINT DIR[4];

bool over(POINT p, int H, int W) {
	return p.x<0 || p.x>=H || p.y < 0 || p.y >= W;
}

int H, W;
int GRID[50][50];

void dijkstra(POINT s) {
	for (int i = 0; i < 50; i++)for (int j = 0; j < 50; j++) {
		cost[i][j] = 1e9;
		status[i][j] = 0;
	}

	cost[s.x][s.y] = 0;
	status[s.x][s.y] = 1;

	priority_queue<pair<int, POINT>, vector<pair<int, POINT>>, greater<pair<int, POINT>>> Q;
	Q.push(make_pair(0, s));

	while (Q.size()) {
		POINT p = Q.top().second; Q.pop();

		if (status[p.x][p.y] == -1)continue;
		status[p.x][p.y] = -1;

		for (int k = 0; k < 4; k++) {
			POINT np = p + DIR[k];
			if (over(np, H, W))continue;

			if (GRID[np.x][np.y])continue;

			if (cost[np.x][np.y] > cost[p.x][p.y] + 1) {
				cost[np.x][np.y] = cost[p.x][p.y] + 1;
				status[np.x][np.y] = 1;

				Q.push(make_pair(cost[np.x][np.y], np));
			}
		}
	}
}

int main() {
	DIR[0] = POINT(-1, 0);
	DIR[1] = POINT(0, 1);
	DIR[2] = POINT(1, 0);
	DIR[3] = POINT(0, -1);

	cin >> H >> W;

	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c; cin >> c;
			if (c == '.') {
				GRID[i][j] = 0;
				cnt++;
			}
			else GRID[i][j] = 1;
		}
	}

	dijkstra(POINT());

	if (cost[H - 1][W - 1] == 1e9)cout << -1 << endl;
	else {
		cout << cnt - cost[H - 1][W - 1] - 1 << endl;
	}

	return 0;
}

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

int main() {
  int n;
  cin >>n;
  double clac =0;
  int a;
  for (int i=0;i<n;i++){
    cin>>a;
    clac += 1.0/a;
  }
  double ans =1/clac;
  printf("%.10f\n",ans);
}

Measured memory_bytes: 256
class UnionFind:
    import sys
    sys.setrecursionlimit(100000)

    def __init__(self, n):
        self.parents = [i for i in range(n + 1)]

    def root(self, i):
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.root(self.parents[i])
            return self.parents[i]

    def unite(self, i, j):
        self.parents[self.root(self.parents[i])] = self.root(j)

    def is_unite(self, i, j):
        return self.root(i) == self.root(j)


def solve(N, XYZs):
    uf = UnionFind(N)
    for x, y, z in XYZs:
        uf.unite(x, y)
    return len(set([uf.root(i) for i in range(1, N + 1)]))


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    XYZs = [tuple(map(int, input().split(" "))) for _ in range(M)]
    print(solve(N, XYZs))


Measured memory_bytes: 31348