akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n,k;
int x[MAX];
int dp[10*MAX][2];

int solve(int how,int is){
    if(how<x[0]){
        if(is){
            return 0;
        }
        return 1;
    }

    int &res=dp[how][is];
    if(res!=-1){
        return res;
    }



    if(is){
        res=solve(how-x[0],0);
        for(int i=0;i<n;i++){
            if(how>=x[i]){
               res=max(res,solve(how-x[i],0));
            }
            else{
                break;
            }
        }
    }
    else{
      res=solve(how-x[0],1);
      for(int i=0;i<n;i++){
            if(how>=x[i]){
               res=min(res,solve(how-x[i],1));
            }
            else{
                break;
            }
        }
    }

    return res;


}




int main(){

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

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);




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

    mem(dp,-1);


    int ans=solve(k,1);
    if(ans){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }







     return 0;

}


Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(0, min(b, d) - max(a, c)) << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=map(int,input().split())
b=map(int,input().split())
c=map(int,input().split())
a=sorted(a)
b=sorted(b)
c=sorted(c)

import bisect

m=0
d=[0 for i in range(n)]
for i in range(n):
    y=bisect.bisect_right(c,b[n-1-i])
    m+=n-y
    d[n-1-i]=m

m=0
for i in a:
    x=bisect.bisect_right(b,i)
    try :
        m+=d[x]
    except IndexError:
        pass
    
print(m)


Measured memory_bytes: 104972
from operator import itemgetter

N = int(input())
xyhs = [list(map(int, input().split())) for _ in range(N)]

xyhs.sort(key=itemgetter(2), reverse=True)

lsts = []

xyh = xyhs[0]
for cy in range(101):
    for cx in range(101):
        lsts.append([cx, cy, xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy)]) 

for xyh in xyhs[1:]:
    lst = []
    while len(lsts):      
        p = lsts.pop()
        h = xyh[2] + abs(xyh[0] - p[0]) + abs(xyh[1] - p[1])
        if p[2] == h:
            lst.append(p)
    lsts = lst[:]
    if len(lsts) == 1: break
print(*lsts[0])


Measured memory_bytes: 4592
from functools import reduce

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

left = 0
right = 2
p = a[0]
q = a[1]
r = a[2]
s = reduce(lambda x, y: x + y, a[3:])
temp = right + 1
res_right = abs(s - r)
x = r
y = s
while temp < n - 1:
    x += a[temp]
    y -= a[temp]
    if abs(x - y) < res_right:
        right = temp
        r = x
        s = y
        res_right = abs(x - y)
    if x >= y:
        break
    temp += 1
result = max(p,q,r,s) - min(p,q,r,s)

for i in range(2, n - 2):
    q += a[i]
    r -= a[i]
    if i == right:
        right += 1
        r += a[i + 1]
        s -= a[i + 1]
    res_left = abs(p - q)
    res_right = abs(r - s)
    temp = left + 1
    x = p
    y = q
    while temp < i:
        x += a[temp]
        y -= a[temp]
        if abs(x - y) < res_left:
            left = temp
            p = x
            q = y
            res_left = abs(x - y)
        if x >= y:
            break
        temp += 1
    temp = right + 1
    x = r
    y = s
    while temp < n - 1:
        x += a[temp]
        y -= a[temp]
        if abs(x - y) < res_right:
            right = temp
            r = x
            s = y
            res_right = abs(x - y)
        if x >= y:
            break
        temp += 1
    temp_res = max(p, q, r, s) - min(p, q, r, s)
    if temp_res < result:
        result = temp_res

print(result)

Measured memory_bytes: 24676
func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let max = 10000000000
let line = readIntArray()
let (N, M, K) = (line[0], line[1], line[2])

let A = readIntArray()
let B = readIntArray()

var sum = 0
var sumA: [Int] = []
A.forEach({
    sumA.append($0 + sum)
    sum += $0
})

sum = 0
var sumB : [Int] = []
B.forEach({
    sumB.append($0 + sum)
    sum += $0
})

func findIndex(time: Int) -> Int {
    var left = -1
    var right = sumB.count
    while left < right - 1 {
        let mid = (left + right) / 2
        if sumB[mid] <= time {
            left = mid
        } else {
            right = mid
        }
    }
    return left + 1
}

var count: Int = findIndex(time: K)

for i in 0..<N {
    let time = K - sumA[i]
    if time < 0 {
        break
    }
    let temp: Int = i + 1 + findIndex(time: time)
    if temp > count {
        count = temp
    }
}
print(count)



Measured memory_bytes: 26296
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w, n = sc.nextInt()
  val as = List.fill(n)(sc.nextInt())
  val c = as.zipWithIndex.flatMap{case (a, idx) => List.fill(a)(idx+1)}
  c.sliding(w,w).zipWithIndex.foreach{ case (r0, idx) =>
    val r = if (idx % 2 == 0) r0 else r0.reverse
    println(r.mkString(" "))
  }
}


Measured memory_bytes: 61936
import itertools

H, W, K = input().split()
a = [list(input()) for l in range(int(H))]

h_l = [i for i in range(int(H))]
w_l = [i for i in range(int(W))]

re_h = []
re_w = []
for n in range(len(h_l)+1):
    for comb in itertools.combinations(h_l, n):
        re_h.append(list(comb))
for n in range(len(w_l)+1):
    for comb in itertools.combinations(w_l, n):
        re_w.append(list(comb))
sum_c = 0
for r_h in re_h:
    for r_w in re_w:
        nokori_h = list(set(h_l) - set(r_h))
        nokori_w = list(set(w_l) - set(r_w))
        count = 0
        for no_h in nokori_h:
            for no_w in nokori_w:
                if a[no_h][no_w] == "#":
                    count += 1
        if count == int(K):
            sum_c += 1
print(sum_c)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

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

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

int main(void) {
	int n, t[110000], x[110000], y[110000];
	cin >> n;
	t[0] = 0, x[0] = 0, y[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	bool flag = true;
	int d, dist;
	for (int i = 0; i < n; i++) {
		d = t[i+1] - t[i];
		dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
		if (d < dist || d % 2 != dist % 2) {
			flag = false;
			break;
		}
	}
	(flag) ? puts("Yes") : puts("No");
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<queue>

using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<pis,int> tri;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

int main(){
	int n,m,p;
	string s;
	tri t;
	vector<tri>::iterator po;
	pis pi;
	vector< tri > v;
	scanf("%d",&n);
	rep(i,n){
		cin >> s;
		cin >> m;
		pi = make_pair(s.length(),s);
		po = lower_bound(v.begin(),v.end(),make_pair(pi,0));
		if(po != v.end() && po->first.second == s)po->second += m;
		else v.insert(po,make_pair(pi,m));
	}
	rep(i,v.size())printf("%s %d\n",v[i].first.second.c_str(),v[i].second);
	return 0;
}

Measured memory_bytes: 1272
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, col[9] = {};
	scanf("%d", &n);
	REP(i, 0, n){
		int a;
		scanf("%d", &a);
		col[std::min(a/400, 8)]++;
	}
	int cnt = 0;
	REP(i, 0, 8) cnt += !!col[i];
	printf("%d %d\n", std::max(cnt, 1), cnt+col[8]);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;

    map<ll, ll> mp;
    ll ans = 0;
    ll sum = 0;
    rep(i, n){
        ll a;
        cin >> a;
        sum += a;
        if(sum % m == 0)ans++;

        if(mp.count(sum % m) > 0){
            ans += mp[sum % m];
            mp[sum % m]++;
        }
        else {
            mp[sum % m] = 1;
        }
    }

    cout << ans << endl;
}

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

int main() {

    bool all10 = true;

    int N;
    cin >> N;
    int min = 101;
    int result = 0;
    int s[N];
    for(int i=0;i<N;i++){

        cin >> s[i];

        if(s[i]%10!=0){
            all10 = false;
        }

        if(s[i]<=min){
            min = s[i];
        }

        result += s[i];

    }

    sort(s,s+N);

    if(all10==true){
        cout << 0 << endl;
    }else{
        if(result%10 == 0){
            int j=0;
            while(result%10==0){
                if(s[j]%10!=0){
                    result-=s[j];
                }
                j++;
            }
        }

     
        cout << result << endl;
    }


}

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

typedef long long ll;

ll calcComb(int a, int b);
ll mod = 1000000007;
ll modpow(ll a, int p);

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

    ll ans;
    for (int i = 1; i <= K ; i++)
    {
        ans = calcComb(N-K+1, i);
        ans %= mod;
        ans *= calcComb(K-1, i-1);
        ans %= mod;
        if (N - K + 1 < i) ans = 0;
        cout << ans << endl;
    }
}

//aCb
ll calcComb(int a, int b){
    if (b > a-b) return calcComb(a,a-b);
    ll ansMul =1;
    ll ansDiv =1;
    for(int i = 0; i < b; i++)
    {
        /* code */
        ansMul *= (a-i);
        ansDiv *= (i+1);
        ansMul %= mod;
        ansDiv %= mod;
    }
    //ansDivの逆元を使う。
    ll ans = ansMul * modpow(ansDiv, mod -2) % mod;
    return ans;
}


//aのp乗を求めるアルゴリズム
//p=62>31>30>15>14>7>6>3>2>1>0
//計算量はO(logp)になる。
ll modpow(ll a, int p){
    if (p == 0) return 1;
    if (p%2 == 0){
        //p even
        int halfP = p/2;
        ll half = modpow(a, halfP);
        //a^(p/2)をhalfとしてhalf*halfを計算
        return half * half % mod;
    }
    else {
        return a * modpow(a, p-1) % mod; 
    }
}

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

int main(){
	int n, m;
	while(cin >> n >> m){
		string s1 = "", s2 = "";
		for(int i = 1; i <= n; i++)
			s1 += m + '0';
		for(int i = 1; i <= m; i++)
			s2 += n + '0';		
		cout << min(s1, s2) << endl;
	}	
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    var has = false 
    for(c in s) {
        if(c == '7') {
            has = true 
            break
        }
    }
    if(has) {
        println("Yes")
    } else {
        println("No")
    }


}

Measured memory_bytes: 36296
#include<stdio.h>
#include<string.h>

int main(void)
{
   int a=0, b=0, c=0, d=0, i;
   char s[100001];

   scanf("%s",s);

   for(i=0;i<strlen(s);i=i+2){
      if(s[i]=='0')
         a++;
      else
         b++;
      if(s[i+1]=='0')
         c++;
      else if(s[i+1]=='1')
         d++;
   }

   if(a+d>b+c)
      printf("%d\n",b+c);
   else
      printf("%d\n",a+d);
   return 0;
}

Measured memory_bytes: 1824
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
  string s;
  int Q;
  
  int T, F;
  char C;
  cin >> s >> Q;
  int re = false;
  
  string pre = "";
  for (int i=0; i<Q; ++i) {
    cin >> T;
    if (T == 1) {
      re = !re;
    } else {
      cin >> F >> C;
      if ((F == 1 && !re) || (F == 2 && re)) {
        pre += C;
      } else {
        s += C;
      }
    }
  }
  if (!re) {
    reverse(pre.begin(), pre.end());
    pre += s;
    cout <<  pre << endl;
  } else {
    reverse(s.begin(), s.end());
    s += pre;
    cout << s << endl;
  }
}

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

int main(void) {

	set<int> s;
	
	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;

	return 0;
}

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

const static int MOD = 1e9 + 7;

int main(void){
    int n;
    std::cin >> n;
    std::vector<long long> a(n);
    for(int i = 0; i < n; i++){
	std::cin >> a[i];
    }
    long long x;
    long long ans = 0;
    long long tmp;
    for(long long i = 0; i < 60; i++){
	x = 0;
	for(int j = 0; j < n; j++){
	    long long cur = a[j];
	    if((a[j] >> i) & 1) x++;
	}
	tmp = x * (n - x) % MOD;
	for(int j = 0; j < i; j++){
	    tmp = (tmp * 2) % MOD;
	}
	// std::cout << tmp << std::endl;
	ans = (ans + tmp) % MOD;
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 5552
#include<stdio.h>
main(){
  int a[100],i,max=0;
  for(i=0;i<100;i++)a[i]=0;
  while(scanf("%d",&i)!=EOF)a[i-1]++;
  for(i=0;i<100;i++)if(a[i]>max)max=a[i];
  for(i=0;i<100;i++)if(a[i]==max)printf("%d\n",i+1);
  return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n, m;

int t[100010];
int ans;

int main(void){
	cin>>n>>m;
	for (int i = 0; i < m; i++) {
		int l, r; cin>>l>>r;
		t[l]++;
		t[r + 1]--;
	}

	for (int i = 1; i <= n; i++) {
		t[i] += t[i - 1];
		if (t[i] == m) ans++;
	}
	
	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

int N, X;
vector<int> L;
vector<int> D;

int main() {
  cin >> N >> X;
  L.resize(N + 1);
  D.resize(N + 1);

  int counter = 0;
  for (int i = 0; i < N + 1; i++) {
    int x;
    cin >> x;
    L[i] = x;

    if (i == 0) {
      D[i] = 0;
    } else {
      D[i] = D[i - 1] + L[i - 1];
    }

    if (D[i] <= X) {
      counter++;
    }
  }

  cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

class Restaurant{
    public:
        string s;
        int id, score;
        bool operator<(const Restaurant &re){
            if (re.s == this->s)
                return re.score < this->score;
            else
                return this->s < re.s;
        }
};

int main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<Restaurant> r(n);
    rep(i,n) {
        cin >> r[i].s >> r[i].score;
        r[i].id = i + 1;
    }
    sort(r.begin(), r.end());
    rep(i, n) cout << r[i].id << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <algorithm>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

using namespace std;

int n;
int M[N][N]; // ??£??\??????
int d[N]; // ???????????¢


void bfs()
{
    int i;
    for (i = 0; i < n; i++) {
        d[i] = -1;
    }
    
    int u;
    u = 0;
    d[u] = 0;
    queue<int> q;
    q.push(u);
    
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (i = 0; i < n; i++) {
            if (M[u][i] == 0) continue;
            if (d[i] != -1) continue;
            q.push(i);
            d[i] = d[u] + 1;
        }
    }
    
    for (i = 0; i < n; i++) {
        printf("%d %d\n", i+1, d[i]);
    }
}


int main()
{
    scanf("%d", &n);
    int i, j;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    
    // input graph
    int u, k, v;
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            M[u-1][v-1] = 1;
        }
    }
    
    bfs();
    
    return 0;
}

Measured memory_bytes: 1072
S = input()
if len(S[0::2]) ==  len(S[0::2]) - S[0::2].count('L'):
    if len(S[1::2]) ==  len(S[1::2]) - S[1::2].count('R'):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,dep[330001];
vector<int> w[330001];
int dfs(int u,int p)
{
	int ans=dep[u]=1,id=u;
	for(int v:w[u])
		if(v!=p)
		{
			int x=dfs(v,u);
			if(dep[v]+1>ans)ans=dep[u]=dep[v]+1,id=x;
		}
	return id;
}
int dfs2(int u,int p)
{
	dep[u]=1;
	for(int v:w[u])
		if(v!=p)dep[u]=max(dep[u],dfs2(v,u)+1);
	return dep[u];
}
int main()
{
	cin>>n;
	for(int i=1,a,b;i<n;i++)cin>>a>>b,w[a].push_back(b),w[b].push_back(a);
	int ans=dfs2(dfs(1,0),0);
	cout<<(ans%3==2?"Second\n":"First\n");
}


Measured memory_bytes: 29952
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const ll INF=1e18;

int main() {
  ll n;
  cin>>n;
  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> p(n);
  rep(i,n){
    ll x1,y1,p1;
    cin>>x1>>y1>>p1;
    x[i]=x1;y[i]=y1;p[i]=p1;
  }

  vector<ll> ans(n+1);
  rep(i,n+1)ans[i]=INF;
  vector<vector<ll>> xmin((1<<n), vector<ll>(n));
  vector<vector<ll>> ymin((1<<n), vector<ll>(n));
  rep(i,(1<<n)){
    rep(k,n){//各てん
      ll xnow=abs(x[k]); ll ynow=abs(y[k]);

      rep(j,n){

        if (!((i>>j)&1))continue;
      //  cout<<"j"<<j<<endl;

        xnow=min(xnow,abs(x[k]-x[j]));
        ynow=min(ynow,abs(y[k]-y[j]));

      }
  //    cout<<"i"<<i<<"k"<<k<<endl;
    //  cout<<"xnow"<<xnow<<endl;
    //  cout<<"ynow"<<ynow<<endl;

      xmin[i][k]=xnow;
      ymin[i][k]=ynow;
    }
  }


  rep(i,(1<<n)){
  //  cout<<"i"<<i<<endl;
    ll cnt=0;
    rep(j,n){
      if ((i>>j)&1) cnt++;
    }
  //  cout<<"cnt"<<cnt<<endl;
    for(ll j=i;j>=0;j--){
      j&=i;
  //    cout<<"j"<<j<<endl;
      ll a=0;
      rep(k,n){
        ll temp=min(xmin[i-j][k],ymin[j][k]);
        a+=temp*p[k];
      }

      ans[cnt]=min(ans[cnt],a);
  //    cout<<ans[cnt]<<endl;

    }
  }

rep(i,n+1)cout<<ans[i]<<endl;


}


Measured memory_bytes: 12972
unittest
{
	assert( [ "3", "3 4 6" ].parse.expand.solve == 10 );
	assert( [ "5", "7 46 11 20 11" ].parse.expand.solve == 90 );
	assert( [ "7", "994 518 941 851 647 2 581" ].parse.expand.solve == 4527 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	return tuple( as );
}

auto solve( in long[] as )
{
	auto r = 0L;
	
	foreach( a; as )
	{
		r += a - 1;
	}
	
	return r;
}


Measured memory_bytes: 380
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
const int mp[16]={1,3,5,7,11,15,21,33,35,55,77,105,165,231,385,1155};
const int results[16]={1,0,0,0,0,3,3,3,5,5,7,3,3,3,5,3};
const LL UnUseMethod=4759123141;
const unsigned long ULONG=18446744073709551615U;
int sz=0;LL count[2]={0},Box[10]={0};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
inline LL GCD(LL a,const LL b){return !b?a:GCD(b,a%b);}
inline LL Mult(const LL x,const LL y,const LL mod)
{LL z=x*y-(LL)((long double)x/mod*y+1e-8)*mod;return z<0?z+mod:z;}
inline LL BinaryModularPower(LL base,LL pow,const LL mod)
{
  LL x=1;
  while(pow){if(pow&1){x=Mult(x,base,mod);}base=Mult(base,base,mod);pow>>=1;}
  return x;
}
void Exp(LL x,const LL y)
{count[1]=0;if(!y){return;}while(!(x%y)){count[1]++;x/=y;}count[0]=x;return;}
inline LL Pseudo(const LL x){return (LL)((long double)pow(x,0.5));}
inline int PerfectSquare(const LL x){if(x<0)return 0;else{LL y=Pseudo(x);return x==y*y;}}
inline int PerfectCube(const LL x){LL z=(LL)cbrt(x);return x==z*z*z;}
int MillerRabin(const LL a)
{
  /*http://www.olivierlanglois.net/archive/prime_cpp.htm*/
  if(a==2)return 1;
  if((a&1)==0||a<2)return 0;
  if(PerfectSquare(a))return 0;
  if(PerfectCube(a))return 0;
  static const int pr[7]={2,325,9375,28178,450775,9780504,1795265022};
  LL odd=a-1,k=0,p=1,x;
  while(!(odd&1)){odd>>=1;k++;}
  for(int i=0;i<7;++i)
  {
    p=(LL)(pr[i]%a);
    if(!p)return 1;
    x=BinaryModularPower(p,odd,a);
    if(x==1||x==a-1)return 1;
    for(int j=0;j<k;j++)
    {
      x=BinaryModularPower(x,2,a);
      if(x==a-1)return 1;
    }
  }
  return 0;
}
inline LL PollardRho(const LL n,const LL a)
{
  if(MillerRabin(n))return n;
  if(PerfectSquare(n))return Pseudo(n);
  if(PerfectCube(n))return (LL)cbrt(n);
  LL x=rand()%n,y=x;static LL gcd=1,k=0,i=1;
  while(gcd==1)
  {
    k++;
    x=Mult(x,x,n)+a;if(x>=n)x-=n;
    gcd=GCD(x>y?x-y:y-x,n);
    if(k==i){y=x;i<<=1;}
  }
  if(gcd==n)return PollardRho(n,a+1);
  return gcd;
}
signed main(void)
{
  LL a=0,p=1,q=-1,N=IN();
  if(N<=1)return puts("0"),0;
  Exp(N,2);a=e[count[1]];N=count[0];
  Exp(N,3);a+=e[count[1]];N=count[0];
  while(q*q<=UnUseMethod)
  {
    p+=6,q+=6;
    Exp(N,p);a+=e[count[1]];N=count[0];
    Exp(N,q);a+=e[count[1]];N=count[0];
  }
  if(N<=UnUseMethod){if(N>1){a++;}return printf("%lld\n",a),0;}
  if(MillerRabin(N)){a++;return printf("%lld\n",a),0;}
  srand((unsigned int)time(NULL));
  while(N>=UnUseMethod)
  {
    p=PollardRho(N,0);
    while(!MillerRabin(p))p=PollardRho(N,p);
    Exp(N,p);a+=e[count[1]];N=count[0];
  }
  if(MillerRabin(N)){a++;}return printf("%lld\n",a),0;
}

Measured memory_bytes: 2432
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
tmp = 0
cnt = 0

for i in range(h):
    if ''.join(a[i-tmp]) == '.'*w:
        del a[i-tmp]
        tmp += 1

for i in range(w):
    lst = []
    for j in range(h-tmp):
        lst.append(a[j][i-cnt])
    if ''.join(lst)=='.'*(h-tmp):
        for k in range(h-tmp):
            del a[k][i-cnt]
        cnt += 1

for i in range(h-tmp):
    print(''.join(a[i]))

Measured memory_bytes: 3188
#include <algorithm>
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, m;
vii v[100005];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> m;
  priority_queue<int> que;
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }

  int ans = 0;
  erep(i, 0, m) {
    for (auto x : v[i]) {
      que.push(x);
    }
    if (que.size() == 0) continue;
    ans += que.top(); que.pop();
  }
  cout << ans << endl;
  return 0;
}




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

int main() {
    int a[5];
    while (cin >> a[0], a[0]) {
        for (int i=1; i<5; ++i) {
            cin >> a[i];
        }
        int r = 0, p = 0, s = 0;
        for (int i=0; i<5; ++i) {
            if (a[i] == 1) r ++;
            else if (a[i] == 2) p ++;
            else s ++;
        }
        int res[4];
        if ((0 < r && 0 < p && 0 < s) || r == 5 || p == 5 || s == 5) {
            cout << "3\n3\n3\n3\n3\n";
        } else {
            if (r == 0) {
                res[2] = 1;
                res[3] = 2;
            } else if (p == 0) {
                res[1] = 2;
                res[3] = 1;
            } else if (s == 0) {
                res[1] = 1;
                res[2] = 2;
            }
            for (int i=0; i<5; ++i) {
                cout << res[a[i]] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
using System;

class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    var input = Console.ReadLine().Split(' ');
    int T = int.Parse(input[0]);
    int A = int.Parse(input[1]);
    var list = new int[N];
    double ans = 100000;
    int goal = 0;
    input = Console.ReadLine().Split(' ');
    for(int i = 0; i < N; i++)
    {
      list[i] = int.Parse(input[i]);
      if(ans > Math.Abs(A - (T - list[i] * 0.006)))
      {
        ans = Math.Abs(A - (T - list[i] * 0.006));
        goal = i;
      }
    }
    Console.WriteLine(goal + 1);
  }
}


Measured memory_bytes: 13212
#include <bits/stdc++.h>
using namespace std;
     
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if((a+b) > (c+d))
    cout << "Left" << endl;
  else if((a+b) < (c+d))
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;  
}

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
//using namespace __gnu_pbds;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const int sz = 1e5+5;
const ll cfmod = 998244353;

int main() {
    //clock_t tm = clock();
    fastio;
    ll l,n,r,e,m,q,k,t=0,y,w;string s;
    cin>>n;
    vi a(n,0),b(n,0),c(n,0);
    f(i,0,n)cin>>a[i];
    f(i,0,n)cin>>b[i];
    f(i,0,n-1)cin>>c[i];
    ll ans=0;
    ans=b[a[0]-1];
    f(i,1,n){
        if(a[i]==a[i-1]+1)ans+=c[a[i-1]-1];
        ans+=b[a[i]-1];
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math as mt

num = int(input())
list = []

for i in range(1, num+1):
    for j in range(1, num+1):
        for k in range(1, num+1):
            twoGcd = mt.gcd(i, j)
            threeGcd = mt.gcd(twoGcd, k)
            list.append(threeGcd)
            
print(sum(list))

Measured memory_bytes: 188736
#include<iostream>

using namespace std;

int main () {
    int cnt = 0;
    char A[3];

    cin >> A[0] >> A[1] >> A[2];

    for (int i = 0; i < 3; i++) {
        if (A[i] == '1') cnt++;
    }

    cout << cnt << endl;
}

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

int main() {
  int num, input, index;
  cin >> num;
  index = 1;
  for (int i = 0; i < num; i++) {
    cin >> input;
    if (input == index) index++;
  }
  if (index == 1) {
    cout << -1 << endl;
  } else {
    cout << num - index + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct {

  char suit,value;

}Card;

void bubble(Card A[],int N){
  int i,j;
  Card t;
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j].value<A[j-1].value){
        t=A[j];
        A[j]=A[j-1];
        A[j-1]=t;
      }
    }
  }
}

void selection(Card A[],int N){
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value)minj=j;
    }
    t=A[i];
    A[i]=A[minj];
    A[minj]=t;
  }
}

void display(Card A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%c",A[i].suit,A[i].value);
  }
        printf("\n");
}

int isStable(Card C1[],Card C2[],int N){
  int i;

  for(i=0;i<N;i++){
    if(C1[i].suit!=C2[i].suit)return 0;
  }
  return 1;

      }


int main(){

  Card C1[100],C2[100];
  int i,N;
  char ch;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c %c",&C1[i].suit,&C1[i].value);
  }
  for(i=0;i<N;i++)C2[i]=C1[i];

  bubble(C1,N);
  selection(C2,N);
  display(C1,N);
  printf("Stable\n");
  display(C2,N);
  if(isStable(C1,C2,N)){
    printf("Stable\n");
      }
  else{
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2116
#include <iostream>

using namespace std;

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

    int ans = n*n;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> S(n);
  vector<int> P(n), id(n);
  rep(i, n) {
    cin >> S[i] >> P[i];
    id[i] = i;
  }
  sort(all(id), [&](int i, int j) {
      if(S[i] == S[j]) return P[i] > P[j];
      return S[i] < S[j];
    });
  rep(i, n) cout << id[i]+1 << "\n";
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,b) for(int i=(a);i<=(b);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
const int MOD = 1e9+7;
ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll mul(ll x, ll y) {ll res=0;x%=MOD; 
while(y){ if(y&1)res=(res+x)%MOD; 
x=(2*x)%MOD;y>>=1;}return res;} 

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

//////////////////////////////////////////////////////////////////////////////////////

void solve()
{
    ll n;
    cin>>n;
    n = n%1000;
    cout<<(1000-n)%1000;
}
signed main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0; 
}

Measured memory_bytes: 3612
from collections import defaultdict as DD
import numpy as np
N = int(input())
v = list(map(int, input().split()))

E = DD(int)
O = DD(int)
E[-1] = 0
O[-1] = 0
for i in range(N):
  if i % 2 == 1:
    E[v[i]] += 1
  else:
    O[v[i]] += 1

NE = np.array(sorted(E.items(), key=lambda x: x[1], reverse = True))
NO = np.array(sorted(O.items(), key=lambda x: x[1], reverse = True))

#print (NE)
#print (NO)
ans = 0
if NE[0][0] == NO[0][0]:
  if len(NE) == 2 and  len(NO) == 2:
    ans = NE[0][1]
  else:
      ans = min(sum(NO[:,1]) - NO[1][1] + sum(NE[1:,1]), sum(NE[:,1]) - NE[1][1] + sum(NO[1:,1]))
else:
  ans = sum(NE[1:,1]) + sum(NO[1:,1])
print (ans)

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

int main() {
  int N,x;
  cin >> N;
  x = N%10 + ((N%100) / 10) + ((N%1000) / 100 ) + ((N%10000) / 1000) + ((N%100000) / 10000) + ((N%1000000) / 100000) + ((N%10000000)/1000000)+((N%1000000000) / 10000000);
  if(N%x == 0)
    cout << "Yes" << endl;
    
  if(N%x != 0){
    cout << "No" << endl;
  }
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1 and b!=1){
		cout<<"Alice"<<endl;
	}else if(b==1 and a!=1){
		cout<<"Bob"<<endl;
	}else{
		if(a==b){
			cout<<"Draw"<<endl;
		}else if(a>b){
			cout<<"Alice"<<endl;
		}else{
			cout<<"Bob"<<endl;
		}
	}
}

Measured memory_bytes: 384
def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

x=int(input())

A=get_sieve_of_eratosthenes_new(10**5+1000)
for i in range(0,len(A)):
    if A[i]>=x:
        print(A[i])
        break

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

using namespace std;

const long long MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> dp(n + 2, 0);
  dp[n] = n;
  if(n > 1)
  dp[n - 1] = (n * n) % MOD;
  if(n > 2)
  dp[n - 2] = ((2 * n - 1) * n) % MOD;
  for(long long i = n - 3, cur = n - 1; i >= 1; i--)
  {
    (cur += dp[i + 3] + MOD - 1) %= MOD;
    (dp[i] += (n - 1) * (n - 1)) %= MOD;
    (dp[i] += dp[i + 1]) %= MOD;
    (dp[i] += cur) %= MOD;
  }
  cout << dp[1] << endl;
  return 0;
}


Measured memory_bytes: 8064
defnum=999999999

def parse_input(line):
    [one, lname, eq, scale, rname] = line.split()
    exp=int( scale.split("^")[-1] )
    return lname, exp, rname

while(1):
    N=int(raw_input())
    if N==0: break
    L=[]
    names=[]
    for i in range(N):
        [lname, exp, rname]=parse_input(raw_input())
        names += [lname, rname]
        L.append([lname, rname, exp])
    names=sorted(set(names))
    m=len(names)
    A=[[defnum if i!=j else 0 for i in range(m)] for j in range(m)]
    ans="Yes"
    for l in L:
        li,ri = [names.index(name) for name in l[:2]]
        exp=l[2]
        #add
        if A[li][ri] == defnum:
            A[li][ri] = exp
            A[ri][li] = -exp
            for ab in[ [li,ri], [ri,li] ]:
                a,b=ab
                for y in range(m):
                    for x in range(m):
                        if A[y][a]!= defnum and A[b][x]!=defnum:
                            A[y][x] = A[y][a]+A[a][b]+A[b][x]
                            A[x][y] = -A[y][x]
        else:
            if A[li][ri]!=exp:
                ans="No"
                break
#    print names
#    for al in A:
#        print al
    print ans



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

using namespace std;

int main(){
  string a,b;
  cin>>a>>b;
  int ans=0;
  if(a[0]==b[0]) ans++;
  if(a[1]==b[1]) ans++;
  if(a[2]==b[2]) ans++;
  
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int x = x2 -x1;
        int y = y2 -y1;

        System.out.print(x2 - y + " ");
        System.out.print(y2 + x + " ");
        System.out.print(x1 - y + " ");
        System.out.println(y1 + x + " ");
        
    }
}


Measured memory_bytes: 22868
#include<stdio.h>
int main(void){
int a,b;
int num=1000;
scanf("%d %d",&a,&b);
if(-num<=a&&a<=num&&-num<=b&&b<=num){
if(a>b)
printf("a > b\n");
else if(a==b)
printf("a == b\n");
else
printf("a < b\n");
}
return 0;
}

Measured memory_bytes: 580
n=[int(i) for i in input().split()]
#print(n)
a=n.count(1)
b=n.count(9)
c=n.count(7)
d=n.count(4)
if a==1 and b==1 and c==1 and d==1:
  print('YES')
else:
  print('NO')

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

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

    double answer = 0.0;
    if(N%2 == 0){
        answer = 1.0/2.0;
        cout << fixed << setprecision(10) << answer << endl; 
    }
    else{
        answer = (N/2 + 1) / (double)N;
        cout << fixed << setprecision(10) << answer << endl; 
    }

}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力受け取ってやる
            string[] rawinput = Console.ReadLine().Split(' ');

            int A =int.Parse(rawinput[0]);int B = int.Parse(rawinput[1]);

            int add = A + B;int subtract = A - B;int maultiply= A * B;

            int[] input = {add,subtract,maultiply};
            Console.WriteLine(input.Max());

            

        }
    }
}


Measured memory_bytes: 13268
def main():
	n = int(input())

	if n <= 104:
		print(0)
	elif n <= 134:
		print(1)
	elif n <= 164:
		print(2)
	elif n <= 188:
		print(3)
	elif n <= 194:
		print(4)
	else:
		print(5)


if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long LL;

int main() {
  int N;
  cin >> N;
  vector<int> input(N);
  for (int i = 0; i < N; i++) cin >> input[i];
  sort(input.begin(), input.end());

  int val = input[N / 2] - input[N / 2 - 1];
  cout << val << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
ll n,m,q,l[N],r[N],cnt[505][505],prfx[505][505];
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    cin>>n>>m>>q;
    for(ll i=1;i<=m;i++)cin>>l[i]>>r[i],cnt[l[i]][r[i]]++;
    for(ll i=1;i<=n;i++)for(ll j=1;j<=n;j++)prfx[i][j]=prfx[i][j-1]+cnt[i][j];
    for(ll i=1;i<=q;i++){
        ll ans=0,p,q;cin>>p>>q;
        for(ll j=p;j<=q;j++)ans+=prfx[j][q]-prfx[j][p-1];
        cout<<ans<<"\n";
    }
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n,k;
  cin>>n>>k;
  int ans=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    ans+=x<abs(x-k)?2*x:2*abs(x-k);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#endif
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <array>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)
#define ar array

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int k;
	cin >> k;
	vector<bool> seen(k, false);
	int cm = 0;
	for (int i = 0;; i++) {
		cm = (cm * 10 + 7) % k;
		if (cm == 0) {
			cout << i + 1;
			return 0;
		}
		if (seen[cm]) {
			cout << -1;
			return 0;
		}
		seen[cm] = true;
	}
	return 0;
}

Measured memory_bytes: 3728
def b169(n, alist):

    ans = 1
    for i in alist:
        if i == 0:
            return 0

    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

Measured memory_bytes: 21520
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << a / __gcd(a, b) * b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int max(int x,int y){
    if(x>y) return x;
    else return y;
}
int main(void){
    int n,i,m1=0,m2=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(m1<a[i]){
            m2=m1;
            m1=a[i];
        }
        else if(m2<a[i]) m2=a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]==m1) printf("%d\n",m2);
        else printf("%d\n",m1);
    }
    return 0;
}

Measured memory_bytes: 2304
a,b,k=map(int,input().split())
c=a+(k-1)
for i in range(a,a+k):
    if i<=b:
        print(i)
    else:
        break
if c<b:
    if b-(k-1)<=c:
        for i in range(c+1,b+1):
            print(i)
    else:
        for i in range(b-(k-1),b+1):
            print(i)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char st[21000];
bool bk=false,bo=false;
int x,y;
int main()
{
	scanf("%s",st);
	for(int i=0;i<strlen(st);i++)
	{
		if(st[i]=='C')
		{
			bk=true;
			x=i;
		}
		if(st[i]=='F' && x<i)
		{
			bo=true;
			break;
		}
	}
	if(bk==true && bo==true)
	{
		printf("Yes\n");
	}
	else printf("No\n");
 	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    print(min((N - A), (B - 1), (B - (A - 1) - 1) // 2 + A, ((N - A) - (N - B) - 1) // 2 + (N - B + 1)))

Measured memory_bytes: 3060
n,a=map(int,input().split())
X=[int(i) for i in input().split()]
DP=[[[0 for i in range(50*n+1)] for i in range(n+1)] for i in range(n+1)]
DP[0][0][0]=1
for i in range(1,n+1):
  for j in range(i+1):
    for s in range(50*j+1):
      DP[i][j][s]=DP[i-1][j][s]+DP[i-1][j-1][s-X[i-1]]
ans=0
for j in range(1,n+1):
  ans+=DP[n][j][j*a]
print(ans)

Measured memory_bytes: 65484
N=int(input())
for i in range(N):
    a,b,c=map(int,input().split())
    if a*a==b*b+c*c:
        print("YES")
    elif b*b==a*a+c*c:
        print("YES")
    elif c*c==a*a+b*b:
        print("YES") 
    else:
        print("NO")


Measured memory_bytes: 5596
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		while(true) {
			int H=sc.nextInt();
			int W=sc.nextInt();
			
			if(H==0&&W==0) {
				break;
			}
			
			for(int t=0;t<W;t++) {
				System.out.print("#");
			}
			System.out.println();//一行目
			
			for(int a=0;a<H-2;a++) {
				System.out.print("#");
				for(int b=0;b<W-2;b++) {
						System.out.print(".");
				}
				System.out.print("#");
				System.out.println();
			}//２～（H-1）行目
			
			for(int n=0;n<W;n++) {
				System.out.print("#");
			}
			System.out.println();//H行目
			
			System.out.println();//次のフレームとの間に１行開けるため。
			
		}
	}
	
}



Measured memory_bytes: 37164
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, k;
string s;
int main() {
  cin >> n >> k >> s;
  s[k - 1] -= 'A' - 'a';
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256