akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  rep(i,n){
    string s,t,u;
    cin>>s;
    sort(s.begin(),s.end());
    for(int i=0;i<s.size();i++)t+=s[i];
    for(int i=s.size()-1;i>=0;i--)u+=s[i];
    int a=stoi(t);int b=stoi(u);
    cout<<abs(a-b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
int main(void)
{
	int a, b;
	for (;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)break;
		
		if(a<b)
			printf("%d %d\n",a,b);
		else
			printf("%d %d\n",b,a);

	}

	return 0;
}

Measured memory_bytes: 600
import math

a=[0]*5
b=[10]*5
for i in range(5):
    a[i]=int(input().strip())
    r=a[i]%10
    if r!=0:
        b[i]=r
x=b.index(min(b))
num=0
for i in range(5):
    if i!=x:
        num+=math.ceil(a[i]/10)*10
num+=a[x]
print(num)

Measured memory_bytes: 3064
'use strict';
(function(stdin) {

  var inputs  = stdin.toString().trim().split('\n');
  var cols = inputs[0].split(' ');
  var colsNumber = cols.map(Number);
  var Ascending_order = colsNumber.sort(function(a, b){return a > b;}).join(' ');
  
  console.log(Ascending_order);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15528
n = int(input())
h = list(map(int, input().split()))



ans = 0

def list_split(l):
    list_list = []
    start = 0
    for i in range(len(l)):
        # print(start, i)
        if l[i] == 0:
            list_list.append(l[start : i])
            start = i + 1
    list_list.append(l[start : i+1])
    return list_list

def f(lis):
    global ans

    if lis == [0]:
        return 1
    if lis == []:
        return
    # print("list is", lis)
    mini  = min(lis)
    ans+=mini
    for i in range(len(lis)):
        lis[i] -= mini


    list_list = list_split(lis)
    # print(list_list)
    for l in list_list:
        # print("f に　", l , "を入れます")
        f(l)


# print(list_split([1, 0, 1, 2, 0, 3, 0, 2, 3, 0, 1, 0]))

f(h)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a[N];
    int min=1000;
    int max=0;
    for(int i=0;i<N;i++){
     cin>>a[i];
    if(min>=a[i]){
        min=a[i];
    }
    if(max<=a[i]){
        max=a[i];
    }
    }
    cout<<max-min<<endl;
    
    return 0;
    }
    
    

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		long n=fs.nextInt(), x=fs.nextInt(), t=fs.nextInt();
		System.out.println((n+x-1)/x*t);
	}

	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 32608
def rot_n(s, n):
  ts = ''
  alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  for i in range(len(s)):
    idx = alpha.index(s[i])
    idx += n
    if idx > 25:
      idx -= 26
    ts += alpha[idx]
  print(ts)

n = int(input())
s = input()

rot_n(s, n)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    if (a * b) % 2 == 0:
        print('Even')
    else:
        print('Odd')
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def ds(n:int):
    return sum([int(i) for i in str(n)])

def snuke(n:int):
    return n/ds(n)

def cands(n:int):
    ret = []
    nl = len(str(n))
    for i in range(nl):
        ret.append(str(n)[:nl-i-1] + "9"*(i+1))
        
    return ret

k = ni()

# 1から9まで
ans = [i for i in range(1,10)]

# 次の候補
cur = 10
while len(ans) < k:
    cand = cands(cur)
    temp = 10**18
    nex = -1
    for c in cand:
        if snuke(int(c)) <= temp:
            temp = snuke(int(c))
            nex = int(c)
            
    ans.append(nex)
    cur = nex+1
    
for ai in ans[:k]:
    print(ai)

Measured memory_bytes: 3188
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var N = parseInt(input[0],10);
	var A = parseInt(input[1],10);

	var ans = N * N - A;

	console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <cstdio>
#include <algorithm>
#define maxn 200010
using namespace std;
int a[maxn],b[maxn],sum;
int main(){
	int n,m,k,i,j,ans;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=m;i++)scanf("%d",&b[i]);
	i=j=1;
	while(i<=n&&sum+a[i]<=k)sum+=a[i],i++;
	while(j<=m&&sum+b[j]<=k)sum+=b[j],j++;
	i--,j--;
	ans=i+j;
	while(i){
		sum-=a[i],i--;
		j++;
		while(j<=m&&sum+b[j]<=k)sum+=b[j],j++;
		j--;
		ans=max(ans,i+j);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 4772
N, K = map(int,input().split())

C = [0 for _ in range(N)]
ct = N
for i in range(K):
  d = input()
  A = list(map(int, input().split()))
  for a in A:
    if C[a-1] == 0:
      C[a-1] += 1
      ct -= 1

print(ct)



Measured memory_bytes: 9188
A = []
A += map(int, input().split())
A += map(int, input().split())
A += map(int, input().split())
N = int(input())
for _ in range(N):
    b = int(input())
    try:
        A[A.index(b)] = 0
    except ValueError:
        pass
res = (
    (A[0]+A[1]+A[2])*(A[3]+A[4]+A[5])*(A[6]+A[7]+A[8])*
    (A[0]+A[3]+A[6])*(A[1]+A[4]+A[7])*(A[2]+A[5]+A[8])*
    (A[0]+A[4]+A[8])*(A[2]+A[4]+A[6])
)
print("Yes" if res == 0 else "No")


Measured memory_bytes: 9160
#!/usr/bin/ruby
#encoding: utf-8

a,b,k = gets.split.map(&:to_i)

g = a.gcd(b)
div = []

(1..g).each do |i|
  if g%i == 0 then 
    div.push(i)
  end
end

div.sort!.reverse!

puts div[k-1]


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define int long long int
#define MAXN 1000000007
#define endl '\n'
using namespace std;

void solve(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int cnt1 = 0, cnt2 = 0;
    while(a > 0){
        a -= d;
        cnt1++;
    }
    while(c > 0){
        c -= b;
        cnt2++;
    }
    cout << ((cnt1>=cnt2)?"Yes":"No");
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String word = sc.nextLine();
        int count = 0;
        while(true){
            String text = sc.nextLine();
            if(text.equals("END_OF_TEXT")){
                break;
            }
            String[] t = text.split(" ");
            for(String t_word:t){
                if(t_word.equalsIgnoreCase(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N, x;
    cin >> N >> x;

    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    sort(begin(a),end(a));

    i64 ans=0,sum=0;
    bool f=true;
    rep(i,0,N){
        if(sum+a[i]>x){
            f=false;
            break;
        }
        sum+=a[i];
        ++ans;
    }

    if(sum!=x and f) --ans;

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

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

int main() {
  int n;
  cin >> n;
  vector<int> xs(n), ys(n);
  vector<int> zs(n), ws(n);
  rep(i, n) {
    cin >> xs[i] >> ys[i];
    zs[i] = xs[i] + ys[i];
    ws[i] = xs[i] - ys[i];
  }
  sort(zs.begin(), zs.end());
  sort(ws.begin(), ws.end());
  cout << max(zs[n - 1] - zs[0], ws[n - 1] - ws[0]) << endl;
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  //string s;
  //cin >> s;
  vector<char> s(n);
  rep(i, n) cin >> s[i];
  ll count = 0;
  rep(i, n-2) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
m = (1, 0)
for i in range(1, n+1):
    j = 0
    ii = i
    while ii % 2 == 0:
        ii /= 2
        j += 1
    if m[1] < j:
        m = (i, j)
print(m[0])


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  YORN(a<= x && x <= a+b);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		long power = 1;
		long t = (long)(Math.pow(10, 9) + 7);
		
		n = sc.nextInt();
		
		sc.close();
		for(int i = 1; i <= n; ++i) {
			power *= (i % t);
			power %= t;
		}
		
		System.out.println(power);
		
	}

}


Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define sz size()
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}
int ctoi(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 0;
}




int main(void) {
	int a, b; cin >> a >> b;
	for (int i = 1; i < 4; i++) {
		if (i != a && i != b) {
			cout << i << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define int             long long int
#define eb             emplace_back

static const int maxn = 3e5 + 5;

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


      int n;
      cin >> n;
      int zero = 0;
      int xorSum = 0;
      vector <int> vec;
      set <int> myset;
      for (int i = 0; i < n; i++)
      {
            int x;
            cin >> x;
            xorSum ^= x;
            zero += x == 0;
            vec.push_back(x);
            myset.insert(x);
      }
      if (zero == n)
      {
            cout << "Yes" << endl;
            return 0;
      }
      if (n & 1)
      {
            cout << (xorSum == 0 ? "Yes" : "No") << endl;
            return 0;
      }
      if (xorSum > 0)
      {
            cout << "No" << endl;
            return 0;
      }
      if (zero & 1)
      {
            cout << "No" << endl;
            return 0;
      }
      if (zero > 0)
      {
            if (myset.size() == 2) cout << "Yes" << endl;
            else cout << "No" << endl;
      }
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

ll p (ll a,ll b){
	if(b==0)return a;
	return a*p(a,b-1);
}
int main(void){
	ll N;
	cin >> N;
	ll K = 0;
	ll T = N;
	while(T){
		K++;
		T/=10;
	}
	
	if(K==1){
		cout << N << endl;
		return 0;
	}
	ll ans = 9*(K-1);
	for(int i=0;i<=10;i++){
		if( (i+1)*p(10,K-2)-1 <= N){
			ans = i+9*(K-1);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};



int main(){
    
	int n,m,X,Y;
	scanf("%d%d%d%d",&n,&m,&X,&Y);
	vector<int> x(n);
	vector<int> y(m);
	for(int i=0;i<n;++i){
		scanf("%d",&x[i]);
	}

	for(int i=0;i<m;++i){
		scanf("%d",&y[i]);
	}

	int mn=*min_element(all(y));
	int mx=*max_element(all(x));

	bool ok=1;
	for(int z=X+1;z<=Y;++z){
		if(z>mx&&z<=mn){
			ok=0;
			break;
		}
	}

	if(!ok) puts("No War");
	else puts("War");

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

 
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>ball(n,1);
	vector<bool>pos(n,false);
	pos[0]=true;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--;y--;
		ball[x]--;ball[y]++;
		if(pos[x]){
			pos[y]=true;
			if(ball[x]==0){
				pos[x]=false;
			}
		}
	}
	int cnt=0;
	rep(i,n){
		if(pos[i]&&ball[i]>0){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}


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

int n,t,m[1000],l[1000],k[1000];

bool check(int x){
  int c[1001]={},used[1000]={},cnt=n;
  for(int i=0;i<t;i++,x+=c[i])
    for(int j=0;j<n&&x;j++){
      if(used[j])continue;
      if(i+m[j]>t)return 0;
      if(i%(l[j]+k[j])<=l[j])c[i+m[j]]++,cnt--,used[j]=1,x--;
    }
  return !cnt;
}

int main(){
  while(scanf("%d%d",&n,&t),n){
    for(int i=0;i<n;i++)scanf("%d%d%d",&m[i],&l[i],&k[i]);
    int ans=0;
    for(int i=1;i<=n&&!ans;i++)if(check(i))ans=i;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3144
import Data.List
main=do
    s<-getLine
    putStrLn $ f s
f s = if (fn `xor` fs) && (fw `xor` fe) then "Yes" else "No"
    where
        fn = 'N' `elem` s
        fw = 'W' `elem` s
        fs = 'S' `elem` s
        fe = 'E' `elem` s
xor a b
    | a && b = True
    | not a && not b = True
    | otherwise = False

Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            StringBuilder sb = new StringBuilder();
            int n = s.length();
            for (int i = 0; i < n; i++) {
                char charAt = s.charAt(i);
                if (charAt != 'x') {
                    sb.append(charAt);
                }
            }
            if (!is(sb)) {
                System.out.println(-1);
                return;
            }

            int count = 0;
            for (int l = 0, r = n - 1; l < r;) {
                char cl = s.charAt(l);
                char cr = s.charAt(r);
                if (cl == cr) {
                    l++;
                    r--;
                    continue;
                }
                if (cl == 'x') {
                    l++;
                    count++;
                    continue;
                }
                if (cr == 'x') {
                    r--;
                    count++;
                    continue;
                }
            }

            System.out.println(count);
        }
    }

    private static boolean is(StringBuilder sb) {
        int n = sb.length();
        for (int i = 0; i < n; i++) {
            if (sb.charAt(i) != sb.charAt(n - 1 - i)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 26292
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      int n,m,r,q;
      while(cin>>n>>m&&n&&m){
            vector<P> V[10000];
            int ps[n];
            REP(i,n)ps[i]=-1;
            cin>>r;
            REP(i,r){
                  int a,b,c,d;
                  scanf("%d%d%d%d",&a,&b,&c,&d);b--;c--;
                  if(d==1)ps[b]=a;
                  else V[c].PB(MP(ps[b],a));
            }
            cin>>q;
            REP(i,q){
                  vector<P> VV;
                  int a,b,c;
                  scanf("%d%d%d",&a,&b,&c);c--;
                  REP(j,V[c].size()){
                        P p=V[c][j];
                        if(b<p.first||p.second<a)continue;
                        if(p.first<a){
                              if(p.second<=b)VV.PB(MP(a,p.second));
                              else VV.PB(MP(a,b));
                        }else{
                              if(p.second<=b)VV.PB(MP(p.first,p.second));
                              else VV.PB(MP(p.first,b));
                        }
                  }
                  sort(ALL(VV));
                  int s=0,e=0,ans=0;
                  //REP(i,VV.size())cout<<VV[i].first<<" "<<VV[i].second<<endl;
                  REP(j,VV.size()){
                        if(j==0){
                              s=VV[j].first;
                              e=VV[j].second;
                              continue;
                        }
                        if(e>=VV[j].first){
                              e=max(e,VV[j].second);
                        }else{
                              ans+=(e-s);
                              s=VV[j].first;
                              e=VV[j].second;
                        }
                        //cout<<s<<" "<<e<<endl;
                  }
                  ans+=(e-s);
                  cout<<ans<<endl;
            }
      }
}

Measured memory_bytes: 1488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	char c;

	std::cin >> c;

	printf("%c\n", c + 1);

	return 0;
}


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>

int main() {
	double t, x;
	::std::cin >> t >> x;
	::std::cout << t / x << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3636
/*
    Author: Shivam Shukla
    Title : DP_G_Modified.cpp
    Date : 27/08/2020   >> 00:54:32
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}

int32_t dfs(int v, vc(vl)& g, vc(int)& dp) {
    if (dp[v] != -1)
        return dp[v];

    int mx = 0;
    trv(i, g[v]) 
        mx = max(mx, 1 + dfs(i, g, dp));
    dp[v] = mx;
    return dp[v];        
}

int32_t longestPath(vc(vl)& g) {
    int n = sz(g), mx = -INF(int);
    vc(int) dp(n, -1); 
    repa(i, n) 
        dfs(i, g, dp);
    return *max_element(all(dp));    
}  

int32_t main(int argc,char** argv){
    fastio();
    auto tstart= clock();
 
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      freopen("error.txt","w",stderr);
    #endif   

    int n, m; cin >> n >> m;
    vc(vl) g(n); repa(i, m) {
        int s, d; cin >> s >> d;
        s--, d--;
        g[s].emplace_back(d);
    }

    cout << longestPath(g) << endl;

    cerr << setprecision(2) << fixed<<"Time elapsed: " << (double)(clock() - tstart)/CLOCKS_PER_SEC << endl; 
    return 0; 
}

Measured memory_bytes: 11808
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int N[] = {0,1,5,3};
    int E[] = {0,4,5,2};
    int W[] = {0,2,5,4};
    int S[] = {0,3,5,1};
    int R[] = {1,2,3,4};
    int L[] = {1,4,3,2};

    int* move[256];
    move['N'] = N;
    move['E'] = E;
    move['W'] = W;
    move['S'] = S;
    move['R'] = R;
    move['L'] = L;

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int dice[] = {1,2,3,5,4,6};
        int ret = dice[0];
        for(int i=0; i<n; ++i){
            string s;
            cin >> s;
            char c = s[0];
            int tmp = dice[move[c][0]];
            for(int i=1; i<4; ++i)
                dice[move[c][i-1]] = dice[move[c][i]];
            dice[move[c][3]] = tmp;
            ret += dice[0];
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

string s;

bool isDigit(char c)
{
	return (c >= '0' && c <= '9');
}
int parseNumber(string &s, int &pos)
{
	int ret = 0;
	while(1){
		if(isDigit(s[pos])) ret *= 10, ret += s[pos]-'0';
		else break;
		pos++;
	}
	return ret;
}
int parseExp(string &s, int &pos);
int parseFactor(string &s, int &pos)
{
	if(s[pos] == '('){
		pos++;
		int ret = parseExp(s, pos);
		pos++;
		return ret;
	}
	else if(isDigit(s[pos])) return parseNumber(s, pos); 
}
int parseTerm(string &s, int &pos)
{
	int ret = 1;
	ret *= parseFactor(s, pos);
	while(1){
		if(s[pos] == '*'){
			pos++;
			ret *= parseFactor(s, pos);
		}
		else if(s[pos] == '/'){
			pos++;
			ret /= parseFactor(s, pos);
		}
		else break;
	}
	return ret;
}
int parseExp(string &s, int &pos)
{
	int ret = 0;
	ret += parseTerm(s, pos);
	while(1){
		if(s[pos] == '+'){
			pos++;
			ret += parseTerm(s, pos);
		}
		else if(s[pos] == '-'){
			pos++;
			ret -= parseTerm(s, pos);
		}
		else break;
	}
	return ret;
}

int main(void)
{
	int T;
	cin >> T;
	for(int t = 0; t < T; t++){
		cin >> s;
		int pos = 0;
		cout << parseExp(s, pos) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 2996
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;


int n;
int count = 1;
map<vector<int>, int> permutationMap;

void MakePermutation(int index, set<int> usedNumber, vector<int> permutation) {

    if(index == n) {
        permutationMap.emplace(permutation, count++);
        /*
        for(int i = 0; i < n; i++)
            cout << permutation[i] << " ";
        cout << endl;
        */

        return;
    }


    for(int i = 1; i <= n; ++i) {
        if(usedNumber.find(i) != usedNumber.end())
            continue;

        usedNumber.insert(i);
        permutation[index] = i;
        MakePermutation(index + 1, usedNumber, permutation);
        usedNumber.erase(i);
    }

}



int main() {


    cin >> n;

    set<int> usedNumber;
    vector<int> permutation(n);

    vector<int> p1, p2;

    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        p1.push_back(a);
    }

    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        p2.push_back(a);
    }

    MakePermutation(0, usedNumber, permutation);

  //  cout << endl;
    cout << abs(permutationMap[p1] - permutationMap[p2]) << endl;

    return 0;

}



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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

}

void mysol()
{
	int x, leg; cin >> x >> leg;
	if (leg & 1 or x > leg / 2)
	{
		cout << "No";
		return;
	}
	int ani = leg / 2;
	int f = 0;
	while (ani >= 0)
	{
		if (f + ani == x)
		{
			cout << "Yes";
			return;
		}
		f++;
		ani -= 2;
	}
	cout << "No";


}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << max({2 * a - 1, 2 * b - 1, a + b}) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 100000001;

int v[MAX_N];

string solve(int N){
  if(N == 1) return "deficient number";
  int S = 1;
  double sq = sqrt(N);
  for(int i = 2; i < sq; i++) if(N % i == 0) S += i + N / i;
  if(sq == (int)sq) S += (int)sq;
  if(N > S) return "deficient number";
  else if(N < S) return "abundant number";
  return "perfect number";
}

int main() {
  int N;
  while(scanf("%d", &N) && N) printf("%s\n", solve(N).c_str());
  return 0;
}

Measured memory_bytes: 1188
n = gets.to_i
a = gets.split(' ').map(&:to_i)
def counter(n, a)
  count = 0
  loop {
    n.times do |i|
      return count if a[i].odd?
      a[i] = a[i] / 2
    end
    count += 1
  }
end

puts counter(n, a)

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

long long gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    if (b > 0)
        return gcd(b, a % b);
}

int main()
{
    // つけてみたver
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    long long N, X;
    cin >> N >> X;
    long long x[N + 1];
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    x[N] = X;
    sort(x, x + N + 1); // 昇順にソート

    long long diff[N];
    for (int i = 1; i <= N; i++)
    {
        diff[i - 1] = x[i] - x[i - 1];
    }
    long long res = 0;
    for (int i = 0; i < N; i++)
    {
        res = gcd(res, diff[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"IMPOSSIBLE"<<endl;return 0;}
//template
bool dp[1000][10002];
//main
signed main(){
  int N;cin>>N;
  std::vector<int> parent(N,0),son(N,0),x(N);
  for(int i=1;i<N;i++)cin>>parent[i];
  for(int i=0;i<N;i++)parent[i]--;
  for(int i=0;i<N;i++)cin>>x[i];
  for(int i=1;i<N;i++)son[parent[i]]++;
  queue<int> que; for(int i=0;i<N;i++)if(son[i]==0)que.push(i);
  typedef pair<int,int> P;
  std::vector<P> v[N];
  while(que.size()){
    int g=que.front();que.pop();//cout<<g<<" ";
    int si=v[g].size();
    for(int i=0;i<=si;i++)for(int j=0;j<=5000;j++)dp[i][j]=0;
    dp[0][0]=1;
    int sum=0;
    for(int i=0;i<si;i++){
      sum+=v[g][i].first+v[g][i].second;
      for(int j=0;j<=5000;j++){
        if(!dp[i][j])continue;
        dp[i+1][j+v[g][i].first]=1;
        dp[i+1][j+v[g][i].second]=1;
      }
    }
    int check=-1;
    for(int i=0;i<=5000;i++){
      if(!dp[si][i])continue;
      if(i<=x[g])check=max(check,i);
      if(sum-i<=x[g])check=max(check,sum-i);
    }
    //cout<<check<<endl;
    if(check==-1)fin
    if(parent[g]==-1){cout<<"POSSIBLE"<<endl;return 0;}
    v[parent[g]].push_back(P(x[g],sum-check));
    if(v[parent[g]].size()==son[parent[g]])que.push(parent[g]);
  }
}


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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i=0; i<N; i++){
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 9596
N = int(input())
A = list(map(int, input().split()))

ans = set()
cnt = 0
for a in A:
    if a >= 3200:
        cnt += 1
    else:
        ans.add(a // 400)

mx = len(ans) + cnt
mi = max(1, len(ans))

print(mi, mx)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int a,b,c,d,e,f=0;
while(1){
scanf("%d %d",&a,&b);
if(a==0&&b==0)
break;
for(c=1;c<=a;c++){
for(d=c+1;d<=a;d++){
for(e=d+1;e<=a;e++){
if(c+d+e==b)
f++;
}
}
}
printf("%d\n",f);
f=0;
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

int inverse(int a){
	return power(MOD(a), p - 2);
}

int *fact, *fact_inv;

int comb(int N, int k){
	return MOD(fact[N] * MOD(fact_inv[N - k] * fact_inv[k]));
}

signed main(){
	int N, A, B, C, i, j, k;
	scanf("%lld%lld%lld%lld", &N, &A, &B, &C);
	A = MOD(A * inverse(100));
	B = MOD(B * inverse(100));
	C = MOD(C * inverse(100));
	A = MOD(A * inverse(1 - C));
	B = MOD(B * inverse(1 - C));
	C = inverse(1 - C);
//	printf("(A, B, C) = (%lld, %lld, %lld)\n", A, B, C);
	fact = (int *)malloc(sizeof(int) * (2 * N + 1));
	fact[0] = 1;
	for(i = 1; i <= 2 * N; i++){
		fact[i] = MOD(i * fact[i - 1]);
	}
	fact_inv = (int *)malloc(sizeof(int) * (2 * N + 1));
	for(i = 0; i <= 2 * N; i++){
		fact_inv[i] = inverse(fact[i]);
	}
/*	for(i = 0; i <= 2 * N; i++){
		printf("%lld, %lld\n", fact[i], fact_inv[i]);
	}
*/	int ans = 1, now = 1;
	for(k = 1; k < 2 * N - 1; k++){
		now = MOD(now * (A + B));
		if(k >= N){
			now = MOD(now - MOD(comb(k - 1, N - 1) * MOD(power(A, N) * power(B, k - N))));
			now = MOD(now - MOD(comb(k - 1, N - 1) * MOD(power(A, k - N) * power(B, N))));
		}
		ans = MOD(ans + now);
	}
	ans = MOD(ans * C);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
n=int(input())
xy=[]
for i in range(n):
    xy.append([int(j) for j in input().split()])
ans=0
import itertools
for l in itertools.permutations("01234567"[:n]): 
    for i in range(n-1):
        x=xy[int(l[int(i)])][0]-xy[int(l[int(i+1)])][0]
        y=xy[int(l[int(i)])][1]-xy[int(l[int(i+1)])][1]
        ans+=((x)**2+(y)**2)**0.5
import math
print(ans/(math.factorial(n)))


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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    long l = s.size();
    long n = l+1;

    vector<long> a(n), b(n);
    {
        long c = 0;
        for(int i=0; i<l; i++)
            if(s[i] == '<')
                a[i+1] = ++c;
            else
                c = 0;
    }
    {
        long c = 0;
        for(int i=0; i<l; i++)
            if(s[l-1-i] == '>')
                b[l-1-i] = ++c;
            else
                c = 0;
    }

    long sum = 0;
    for(int i=0; i<n; i++)
        sum += max(a[i], b[i]);

    cout << sum << endl;
}


Measured memory_bytes: 8708
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N, M, K = map(int, input().split())

    fs = tuple(set() for _ in range(N))
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())
        fs[a].add(b)
        fs[b].add(a)

    bs = tuple(set() for _ in range(N))
    for _ in range(K):
        a, b = (int(x) - 1 for x in input().split())
        bs[a].add(b)
        bs[b].add(a)

    roots = [-1] * N
    for v in range(N):
        if ~roots[v]: continue
        roots[v] = v
        dq = deque()
        dq.append(v)
        while dq:
            v = dq.popleft()
            r = roots[v]
            for u in fs[v]:
                if ~roots[u]: continue
                roots[u] = r
                dq.append(u)

    sizes = [0] * N
    for r in roots:
        sizes[r] += 1

    ans = []
    for v in range(N):
        r = roots[v]
        res = sizes[r] - 1 - len(fs[v]) - sum(1 for u in bs[v] if roots[u] == r)
        ans.append(res)

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81108
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

int N,M;
  cin>>N>>M;
  int sum=0;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
    sum+=vec[i];
  }
  int counter=0;
  for(int i=0;i<N;i++){
    if(vec[i]>=(double)sum/(4*M)){
      counter++;
    }
  }
   // cout<<counter<<endl;
    
if(counter>=M){
  cout<<"Yes"<<endl;
}else{
  cout<<"No"<<endl;
}

  
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;

int get_gcd(int a, int b){
	int q;

//	printf("%d, %d\n", a, b);
	if(a < b){
		int tmp = a;
		a = b;
		b = tmp;
	}
	q = a % b;

	while(q!=0){
		a = b;
		b = q;
		q = a % b;
	}
	return b;

}

int main(int argc, char* argv[])
{
	int KK;

	scanf("%d", &KK);

	int y1, y2;
	int N=0;
	for(int i=1; i<KK+1; i++){
		for(int j=1; j<KK+1; j++){
			for(int k=1; k<KK+1; k++){
				y1 = get_gcd(i, j);
				y2 = get_gcd(y1, k);
//				printf("%d\n", y2);
				N += y2;
			}
		}
	}
printf("%d", N);
	return 0;
}





Measured memory_bytes: 3824
/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e6 + 5;

int n;
int cnt[30],flag[30];
ll ans;
string s[MAXN];

namespace Trie{
    int tot = 1;
    int trie[MAXN][26],d[MAXN][26];

    void Insert(string s){
        int len = s.length();
        int now = 1;
        int pre[26];
        memset(pre,0,sizeof(pre));
        for(int i = 0;i < len;i++){
            int ch = s[i] - 'a';
            if(!trie[now][ch])
                trie[now][ch] = ++tot;
            now = trie[now][ch];
            d[now][ch] += 1;
            if(pre[ch])
                d[pre[ch]][ch] -= 1;
            pre[ch] = now;
        }
    }

    void dfs(int u){
        for(int i = 0;i < 26;i++){
            int v = trie[u][i];
            if(v){
                dfs(v);
                for(int j = 0;j < 26;j++)
                    d[u][j] += d[v][j];
            }
        }
        //cout << u << " : " << d[u][0] << " " << d[u][1] << endl;
    }

    int Query(string s){
        int len = s.length();
        int now = 1;
        for(int i = 0;i < len - 1;i++){
            int ch = s[i] - 'a';
            now = trie[now][ch];
        }
        int res = 0;
        for(int i = 0;i < 26;i++){
            if(trie[now][i]){
                //cout << trie[now][i] << " " << d[trie[now][i]][s.back() - 'a'] << endl;
                res += d[trie[now][i]][s.back() - 'a'];
            }
        }
        return res;
    }
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> s[i];
        reverse(s[i].begin(),s[i].end());
        Trie::Insert(s[i]);
    }
    Trie::dfs(1);
    for(int i = 1;i <= n;i++){
        //cout << s[i] << " : " << Trie::Query(s[i]) - 1 << endl;
        ans += Trie::Query(s[i]) - 1;
    }
    cout << ans << endl;
    return 0;
}

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

#define _ << " " <<
#define tr(x) cout << #x _ x endl
#define fi first
#define se second

#ifdef _WIN32
#define LD "%I64d"
#else
#define LD "%ld"
#endif

using namespace std;

typedef long long ll;

int a, b;

int read() {
    if (scanf("%d %d", &a, &b) < 2) {
        return 0;
    }
    return 1;
}

void solve() {
    if (a == b) {
        if (a == 0) {
            printf("Zero\n");
        }
        else {
            printf((a < 0) ? "Negative\n" : "Positive\n");
        }
    }
    else if (a <= 0 && b >= 0) {
        printf("Zero\n");
    }
    else if (a < 0 && b < 0) {
        int d = abs(b - a) + 1;
        if (d & 1) {
            printf("Negative\n");
        }
        else {
            printf("Positive\n");
        }
    }
    else if (a > 0 && b > 0) {
        printf("Positive\n");
    }
}

int main(int argc, char *argv[]) {
    while (read()) {
        solve();
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, cnt[100100], p = 998244353;
typedef long long ll;
int main(void) {
	scanf("%d", &n);
	int x; scanf("%d", &x);
	if (x != 0) {
		printf("0\n");
		return 0;
	}
	cnt[0] = 1;

	for (int i = 1; i < n; i++) {
		scanf("%d", &x);
		cnt[x]++;
	}
	
	if (cnt[0] != 1) {
		printf("0\n");
		return 0;
	}

	while (cnt[n] == 0) n--;

	ll ans = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < cnt[i + 1]; j++) {
			ans *= cnt[i];
			ans %= p;
		}
	}
	
	printf("%lld\n", ans);
}

Measured memory_bytes: 512
from copy import deepcopy
h, w, k = map(int, input().split())
c = []
for i in range(h):
    c.append(list(input()))
ans = 0
for mask_row in range(2 ** h):
    for mask_col in range(2 ** w):
        c_copy = deepcopy(c)
        for row in range(h):
            if mask_row & (1 << row):
                for col in range(w):
                    c_copy[row][col] = '.'
        for col in range(w):
            if mask_col & (1 << col):
                for row in range(h):
                    c_copy[row][col] = '.'
        black = 0
        for row in range(h):
            for col in range(w):
                if c_copy[row][col] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9216
#[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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        t: f64,
        a: f64,
        h: [usize; n],
    }
    let temp = h.iter().map(|&hi| t - hi as f64 * 0.006).collect::<Vec<_>>();
    let mut min_index = 0;
    for i in 1..n {
        if (a - temp[min_index]).abs() > (a - temp[i]).abs() {
            min_index = i;
        }
    }
    println!("{}", min_index + 1);
}


Measured memory_bytes: 4352