akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = INF;
    int N; cin >> N;
    int A[3]; rep(i, 3) cin >> A[i];
    int l[1010];
    rep(i, N) cin >> l[i];
    rep(i, pow(4, N) + 0.5) {
        int bit = i;
        int L[3] = {};
        int cnt = -3;
        rep(j, N) {
            if (bit % 4 != 3) {
                L[bit % 4] += l[j]; 
                cnt++;
            }
            bit /= 4;
        } 
        if (L[0] == 0 || L[1] == 0 || L[2] == 0) continue;
        int tmp = 0;
        rep(j, 3) tmp += abs(L[j] - A[j]);
        ans = min(ans, tmp + cnt * 10);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <algorithm>

int main(){

    long long n;
    
    std::map<long long, long long> m;

    std::cin >> n;

    for(long long i = 0; i < n; ++i ){

        long long tmp;
        std::cin >> tmp;
        m[tmp] += 1;
    }

    auto count = std::count_if(m.begin(), m.end(), [](std::pair<long long, long long> const & x){ return x.second % 2 == 1; });

    std::cout << count << std::endl;

    return 0;

}



Measured memory_bytes: 6528
L = int(input())
for i in range(20):
    if 2**i > L: N = i; break
else: N = 20
M = N*2-2
add_path = []
for i in range(1,N)[::-1]:
    if L-2**(i-1) >= 2**(N-1): add_path.append([i, L-2**(i-1)]); L -= 2**(i-1)
print(N, M+len(add_path))
for i in range(1,N):
    print(i, i+1, 0); print(i, i+1, 2**(i-1))
for i in add_path:
    print(i[0], N, i[1])


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

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

	double point[2][4097];
	point[0][0] = 0; point[1][0] = 0; point[0][4096] = 100; point[1][4096] = 0;
	double root3 = sqrt(3.0);

	for(int i = 0; i < n; i++){
		int step = pow(4.0,6-i);
		int step4 = step / 4;
		double x,y;
		for(int j = 0; j < 4096; j += step){
			point[0][j + step4] = point[0][j] / 3 * 2 + point[0][j + step] / 3;
			point[1][j + step4] = point[1][j] / 3 * 2 + point[1][j + step] / 3;
			point[0][j + step4 * 3] = point[0][j] / 3 + point[0][j + step] / 3 * 2;
			point[1][j + step4 * 3] = point[1][j] / 3 + point[1][j + step] / 3 * 2;


			x = point[0][j + step4] - point[0][j];
			y = point[1][j + step4] - point[1][j];

			point[0][j + step4 * 2] = point[0][j + step4] + x / 2 - y / 2 * root3;
			point[1][j + step4 * 2] = point[1][j + step4] + x / 2 * root3 + y / 2;
		}
	}

	int step = pow(4.0, 6 - n);

	for(int i = 0; i < 4097; i += step)
		cout << fixed << setprecision(8) << point[0][i] << " " << point[1][i] << endl;
	cout << endl;
}

Measured memory_bytes: 1344
/* Kadai2_2
   nabe9393 */

#include <stdio.h>
 
int main(void) {
    int N, A, B;

    //入力受け取り
    scanf("%d", &N);
    scanf("%d", &A);
    B = N*N - A;
    printf("%d\n", B);
    return 0;
}

Measured memory_bytes: 1692
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll DIV = (ll)8e3+7;
const ll MAXN = (ll)8e3+7;


int main(void) {
   string S;
   cin>>S;
   ll N = S.size();
   ll center = N/2;
   ll ans = center;
   if (N%2==1) {
      ans++;
      if (S[center]=='1') {
         rep(i,0,N) S[i] = (S[i]=='0')?'1':'0';
      }
      rep(i,1,N-center) {
         // if (S[center+i] != S[center-i]) break; 
         // if (S[center-i]=='1' && center-i == 0) break; 
         if (S[center+i] != '0' || S[center-i] != '0') break; 
         ans++;
      }
   } else {
      rep(i,0,N-center) {
         if (S[center+i] != S[center-i-1]) break;
         if (i!= 0 && S[center+i]!=S[center+i-1]) break;
         ans++;
      }
   }

   cout<<ans<<endl;

   return 0;
}



Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Console.WriteLine(Enumerable.Range(1, (int)Math.Sqrt(N)).Where(elem => N % elem == 0).Select(elem => elem + (N / elem) - 2).Min());
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC166B()
{
	int N, K;
	cin >> N >> K;
	vi S(N);
	for (int i = 0; i < K; ++i)
	{
		int d;
		cin >> d;
		vi A(d);
		for (auto& x : A)
			cin >> x;
		for (int j = 0; j < d; ++j)
		{
			S[A[j] - 1] = 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		if (S[i] == 0)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

int main()
{
	ABC166B();
	return 0;
}


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

int main(){
	int n; scanf("%d", &n);
	
	int f[n+1], p[n+1], c0[n+1], c1[n+1];
	
	for(int i=2;i<=n;++i) scanf("%d", p+i);
	
	for(int i=1,v;i<=n;++i){
		scanf("%d", &v);
		c0[i] = !v, c1[i] = v;
		f[i] = i;
	}
	
	auto find = [&](int x){
		int re = x; 
		while(re != f[re]) re = f[re];
		for(int i=x,k;i!=re;i=k) k = f[i], f[i] = re;
		return re;
	};
	
	using pair = std::pair<double, int>;
	
	std::priority_queue<pair> pq;
	
	#define eps (1e-12)
	
	for(int i=2;i<=n;++i) pq.push({c0[i]/(c1[i]+eps), i});
	
	long long ans = 0;
	
	while(!pq.empty()){
		int x = pq.top().second; pq.pop();
		if(x != find(x)) continue;
		int pa = find(p[x]);
		ans += 1ll*c1[pa]*c0[x];
		f[x] = pa;
		c0[pa] += c0[x], c1[pa] += c1[x];
		if(pa == 1) continue;
		pq.push({c0[pa]/(c1[pa]+eps), pa});
	}
	
	printf("%lld\n", ans);

	return 0;
} 

Measured memory_bytes: 9584
n = int(input())
a = list(map(int, input().split()))

flg = False
res = 0

while True:
  for i in range(n):
    if a[i]%2 == 1:
      flg = True
    a[i] //= 2

  if flg:
    break

  res += 1

print(res)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String akihabara = "AKIHABARA";
		String kihbr = "KIHBR";
		String s = scanner.nextLine();

		int i;
		int j = 0;
		int k = 0;
		for(i = 0; i < s.length(); i++){
			if(
				j+1 < akihabara.length() &&
				akihabara.charAt(j) == 'A' &&
				akihabara.charAt(j) != s.charAt(i)
			) {
				j++;
			}

			if(j >= akihabara.length() || akihabara.charAt(j) != s.charAt(i)) {
				System.out.println("NO");
				return;
			}
			if(s.charAt(i)!='A') {
				if(s.charAt(i) == kihbr.charAt(k)) {
					k++;
				} else {
					System.out.println("NO");
					return;
				}
			}
			
			j++;
		}
		if(k == kihbr.length()) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23124
def main():
    from collections import deque

    N = int(input())
    A = map(int, input().split())

    ans = 0
    dq = deque()
    xor_ = 0
    for x in A:
        while xor_ & x:  # 繰り上がりのため条件を満たせない
            xor_ ^= dq.popleft()
        xor_ ^= x
        dq.append(x)
        ans += len(dq)  # head候補の数
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s,t; cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
    {
        char tmp = s[s.size()-1];
        for (int j = s.size()-1; j > 0; j--)
        {
            s[j] = s[j-1];
        }
        s[0] = tmp;
        //cout << s << endl;
        if (s == t)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

using namespace std;

int main(){
    vector<int> ans;
    long N;
    cin >> N;
    long m = 2;
    for(int i = 0; i <= 40; i++){
        //cout << i << endl;
        if(N%m != 0){
            if(i%2 == 0) N = N-m/2;
            else N = N+m/2;
            ans.push_back(1);
        }else{
            ans.push_back(0);
        }
        m *= 2;
    }
    bool f = false;
    for(int i = 0; i < ans.size(); i++){
        if(ans[ans.size()-1-i] == 1) f = true;
        if(f) {
            cout << ans[ans.size()-1-i];
        }
    }
    if(!f) cout << 0;
    cout << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
S = []
A = [0] * (N + 1)
for i in range(0, M):
  a = input().split()
  S.append(a)
  
ac = 0
wa = 0
for a in S:
  s = int(a[0])
  p = a[1]
  if p == 'WA':
    if A[s] >= 0:
      A[s] += 1
  else:
    if A[s] >= 0:
      wa += A[s]
      A[s] = -1
      ac += 1
      
print(*[ac, wa], sep = ' ')

Measured memory_bytes: 32928
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    int K, T;
    cin >> K >> T;

    priority_queue<int> a;
    for(int i=0;i<T;i++){
        int temp;
        cin >> temp;
        a.push(temp);
    }

    int prev = a.top(); a.pop();
    while(a.size()){
        int next = a.top(); a.pop();
        if(prev > 1){
            a.push(prev - 1);
        }
        prev = next;
    }
    cout << prev - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,m;cin >> n >> m;
    priority_queue<int> que;
    ll sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        que.push(a);
        sum += a;
    }
    rep(i,m){
        int t1 = que.top();
        que.pop();
        int t2 = t1/2;
        que.push(t2);
        sum -= t1 - t2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 892
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInts >>= putStrLn . which "unsafe" "safe" . uncurry (<=) . mp

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    string o, e;
    cin >> o;
    cin >> e;

    rep(i, e.size()) {
        cout << o[i] << e[i];
    }
    if (o.size() != e.size())
       cout << o[o.size() - 1];

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

#define SZ(x) ((int)(x).size())

typedef int64_t int64;
typedef int64_t ll;

using namespace std;


class D {
	string s;
	const int MOD{ 1000000007 };

	inline ll summod(ll a, ll b) { return (a + b) % MOD; }

public:
	D()
	{
		cin >> s;
	}

	void solve()
	{
		vector<vector<ll>> dp(3, vector<ll>(SZ(s) + 1, 0));
		ll tot{ 1 };

		for (int i{ 1 }; i <= SZ(s); i++)
		{
			switch (s[i - 1])
			{
			case 'A' :
				dp[0][i] = summod(tot, dp[0][i - 1]);
				dp[1][i] = dp[1][i - 1];
				dp[2][i] = dp[2][i - 1];
				break;

			case 'B':
				dp[0][i] = dp[0][i - 1];
				dp[1][i] = summod(dp[0][i - 1], dp[1][i - 1]);
				dp[2][i] = dp[2][i - 1];
				break;

			case 'C':
				dp[0][i] = dp[0][i - 1];
				dp[1][i] = dp[1][i - 1];
				dp[2][i] = summod(dp[1][i - 1], dp[2][i - 1]);
				break;

			default:
				dp[0][i] = summod(tot, dp[0][i - 1] * 3);
				dp[1][i] = summod(dp[0][i - 1], dp[1][i - 1] * 3);
				dp[2][i] = summod(dp[1][i - 1], dp[2][i - 1] * 3);
				tot = tot * 3 % MOD;
				break;
			}
		}

		cout << dp[2][SZ(s)] << endl;

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 3584
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

X = int(input())

ans = float('inf')
pos = 0
time = 0
while pos < X:
    time += 1
    pos = (time)*(time+1)//2

diff = pos - X
print(time)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>a>>b>>c;
    if(b*c >=a)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3596
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        for(int i = 0; i < 3; i++){
            if(s.charAt(i) != t.charAt(2 - i)){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35696
#include<iostream>

using namespace std;

int main () {
  int N,K,i,t,j;
  int a[100001];
  int count = 0;
  
  cin >> N >> K;
  
  for (i=0;i<N;i++){
     cin >> a[i];
  }
  
  
  for(i =0 ;i<N;i++){
      if(a[i] >= K){
         count++;
      }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)

memo = [[[0]*201 for _ in range(201)] for _ in range(201)]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def t_gcd(a,b,c):
    d = gcd(a,b)
    e = gcd(c,d)
    res = gcd(d,e)
    memo[a][b][c] = res
    memo[a][c][b] = res
    memo[b][a][c] = res
    memo[b][c][a] = res
    memo[c][b][a] = res
    memo[c][a][b] = res
    return res
ans = 0
K = int(input())
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            if memo[a][b][c] == 0:
                ans += t_gcd(a,b,c)
            else:
                ans += memo[a][b][c]
print(ans)


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

class UnionFind:
    def __init__(self,n):
        self.group=[i for i in range(n)]
        self.size=[1 for i in range(n)]

    def find(self,x):
        if(self.group[x]==x):
            return x
        else:
            return self.find(self.group[x])

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            pass
        elif(self.sizeof(y) > self.sizeof(x)):
            self.group[x] = self.group[y]
            self.size[y] += self.size[x]
            self.size[x]=0
        else:
            self.group[y] = self.group[x]
            self.size[x] += self.size[y]
            self.size[y]=0

    def sizeof(self,a):
        return self.size[self.find(a)]

    def same(self,x,y):
        return self.find(x)==self.find(y)

uf=UnionFind(n)
friends=[0 for _ in range(n)]
blocks=[0 for _ in range(n)]


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

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if(uf.same(c, d)):
        blocks[c]+=1
        blocks[d]+=1

ans=[]
for i in range(n):
    ans.append(uf.sizeof(i) - friends[i] - blocks[i]  - 1)
print(*ans)


Measured memory_bytes: 13348
/*
    coder:xxjAc
    name:Jury Marks
    time：2017/7/13 
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if (a%3==0 || b%3==0 || (a+b)%3==0){
		cout<<"Possible"<<endl;
		return 0;
	}
	cout<<"Impossible"<<endl;
	return 0;
} 

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

int main() {
  int N,odds=0,evens=0,fours=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%4==0){fours++;}
    else if(a%2==0){evens++;}
    else{odds++;}
  }
  if(evens>=1){odds++;}
  if(odds-1>fours){cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
n, m = map(int,input().split())
*a, = [input() for _ in range(n)]
*b, = [input() for _ in range(m)]
print('YNeos'[all(b!=[t[j:j+m] for t in a[i:i+m]]\
                  for i in range(n-m+1) for j in range(n-m+1))::2])

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#define For(i,j,k)  for(int i=j;i<=k;++i)
#define Dow(i,j,k)  for(int i=k;i>=j;--i)
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double db;
const ll maxn = 2e5 + 100;
ll a[maxn];
ll sum[maxn];
int  n;
ull ans;
map<ll,ll>cnt;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		sum[i] = sum[i - 1] + a[i];
		cnt[sum[i]]++;
	}
	for (auto w : cnt)
	{
		ans += (w.second*(w.second - 1)) / 2;
		if (w.first == 0)
			ans += w.second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
// If you want something you've never had, you must be willing to do s
// something you've never done

//  When the going gets tough,  the tough get going
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}

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

const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = 2e9;

signed main() {
    int n;
    cin >> n;
    string s = to_string(n);
    for(int i=0; i<s.length(); i++) {
        if(s[i] == '7'){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

// A telephone line whose bandwidth is 1638 Hz is connected from point A to point B. What will be the channel capacity if signal-to-noise ratio is 22 db?


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

/* O(log n) */
struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v)
      return false;
    if (parent[u] > parent[v])
      swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool issame(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M), Y(M), Z(M);
  UnionFind U(N);
  rep(i, M) {
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;
    Y[i]--;
    U.unite(X[i], Y[i]);
  }

  int ans = 0;
  set<int> s;
  rep(i, N) {
    int r = U.root(i);
    if (s.find(r) == s.end()) {
      ans++;
      s.insert(r);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

class UnionFind {
 public:
  std::vector<int> parent;

  UnionFind(int n) : parent(n, -1) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -parent[root(x)]; }

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) std::swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int a, int b) { return X[a] < X[b]; });
  for (int i = 0; i < N - 1; i++) {
    que.push(
        make_pair(X[idx[i + 1]] - X[idx[i]], make_pair(idx[i], idx[i + 1])));
  }
  vector<int> idy(N);
  iota(idy.begin(), idy.end(), 0);
  sort(idy.begin(), idy.end(), [&](int a, int b) { return Y[a] < Y[b]; });
  for (int i = 0; i < N - 1; i++) {
    que.push(
        make_pair(Y[idy[i + 1]] - Y[idy[i]], make_pair(idy[i], idy[i + 1])));
  }
  UnionFind uf(N);
  int res = 0;
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int d = q.first, u = q.second.first, v = q.second.second;
    if (uf.unite(u, v)) {
      res += d;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pbs(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

int main(){
	int n;cin>>n;
	vector<int> ans(60000);
	reps(x,100)reps(y,100)reps(z,100){
		int t=x*x+y*y+z*z+x*y+y*z+z*x;
		ans[t]++;
	}
	reps(i,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 3528
import Control.Applicative

import Text.Printf
    (printf)
    
solve :: Double -> (Double, Double)

solve r
    = (area, border) where
        area = pi * r ** 2
        border = 2 * pi * r

input :: Read a => IO [a]

input
    = map read.words <$> getLine

output :: (Double, Double) -> String

output (area, border)
    = printf "%.5f %.5f" area border
    
main :: IO ()
    
main
    = do
        [r] <- input
        putStrLn $ output $ solve r

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A[i] = { a, i % 2 };
	}

	sort(A.begin(), A.end());
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 != A[i].second) { ++ans; }
	}
	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 1024
N, M, K = map(int, input().split())
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    F[a].append(b)
    F[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    B[c].append(d)
    B[d].append(c)


D = {}
parent = [-1] * N
visited = [False] * N
for root in range(N):
    if visited[root]:
        continue

    D[root] = set([root])
    stack = [root]
    while stack:
        n = stack.pop()
        visited[n] = True
        parent[n] = root

        for to in F[n]:
            if visited[to]:
                continue
            D[root].add(to)
            stack.append(to)

ans = [0] * N
for iam in range(N):
    group = D[parent[iam]]
    tmp_ans = len(group) - len(F[iam]) - 1
    for block in B[iam]:
        if block in group:
            tmp_ans -= 1
    ans[iam] = tmp_ans

print(*ans, sep=' ')


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

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

    int n,h;cin>>n>>h;

    vector<int> a(n),b(n);
    int maxa=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        maxa=max(maxa,a[i]);
    }

    sort(b.begin(),b.end(),greater<int>());

    int ans=0;

    for(int i=0;i<n;i++)
    {
        if(h<=0)break;
        if(b[i]<maxa)break;
        h-=b[i];
        ans++;
    }

    if(h>0)
    {
        ans+=(h-1)/maxa+1;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3980
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N;
int cnt[114514]={0};
vi a,b,c;
int main(){
	cin>>N;
	rep(i,N){
		int x;
		cin>>x;
		x--;
		a.pb(x);
	}
	rep(i,N){
		int x;
		cin>>x;
		b.pb(x);
	}
	rep(i,N-1){
		int x;
		cin>>x;
		c.pb(x);
	}
	ll ans=0;
	rep(i,N){
		ans+=b[a[i]];
		if(i>0&&a[i]-a[i-1]==1){
			ans+=c[a[i-1]];
		}
	}
	cout<<ans<<endl;

}




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int ban;
	double tai,shin,bmi;
	while(scanf("%d,%lf,%lf",&ban,&tai,&shin)!=EOF)	{
		bmi=tai/(shin*shin);
		if(bmi>=25.0)	{
			printf("%d\n",ban);
		}
	}
	return 0;
}


Measured memory_bytes: 624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var l = ReadInts();
            Array.Sort(l);
            var ans = 0;
            for (int i = 0; i < n*2; i+=2)
            {
                ans += l[i];
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    ll x[100010];
    cin >> N >> K;
    rep(i,0,N){
        cin >> x[i];
    }
    ll ans = 1e12;
    rep(i,0,N-K+1){
        if(x[i] < 0 && x[i+K-1] < 0){
            ans = min(ans, abs(x[i]));
        }else if(x[i] > 0 && x[i+K-1] > 0){
            ans = min(ans, x[i+K-1]);
        }else{
            ll min_num = min(abs(x[i]), x[i+K-1]);
            ll max_num = max(abs(x[i]), x[i+K-1]);
            ll tt = min_num * 2 + max_num;
            ans = min(ans, tt);
        }
    }
    print(ans);
}


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

using namespace std;

#define INF LLONG_MAX
#define ll long long int
#define MP make_pair
#define PF push_front
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define F first
#define S second
#define tr(i,c) for(__typeof(c.begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(i,v) for(__typeof(v.rbegin()) i = (v).rbegin() ; i != (v).rend() ; i++)
#define sint(n); scanf("%d",&n);
#define sll(n); scanf("%lld",&n);
#define pint(n); printf ("%d\n",n);
#define pll(n); printf ("%lld\n",n);
#define sst(n); scanf("%s",n);
#define pst(n); printf ("%s\n",n);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define set(a,b) memset(a, b, sizeof(a))
#define DRT() ll tst;cin>>tst;for(ll test=1;test<=tst;test++)
#define present(c,x) ((c).find(x) != (c).end())

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll MOD = 1000000007;

/*
    Inbuilt GCC compiler functions
    __gcd(x, y)
    
    int __builtin_ffs (int x)    [ Returns one plus the index of the least significant 1-bit of x, or if x is zero, returns zero ]
    int __builtin_ffsll (long long) [ Similar to __builtin_ffs, except the argument type is long long ]
    
    int __builtin_clz (unsigned int x)  [ Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined ]
    int __builtin_clzll (unsigned long long)   [ Similar to __builtin_clz, except the argument type is unsigned long long ]
    
    int __builtin_popcount (unsigned int x)  [ Returns the number of 1-bits in x ]
    int __builtin_popcountll (unsigned long long)  [ Similar to __builtin_popcount, except the argument type is unsigned long long ]
*/


inline void add(ll &x, ll y){x+=y; if(x>=MOD)x-=MOD; if(x<0)x+=MOD;}
inline ll mul(ll x, ll y){ return ((ll)x * y)%MOD;}
ll gcd(ll a, ll b){ if(b)return gcd(b,a%b); return a;}
ll power(ll a ,ll p){ll ret = 1; while(p){if(p&1)ret=mul(ret,a); a=mul(a,a); p/=2;}return ret;}
ll phi(ll n){ ll ret=n; ll i = 2;                    // Counts the positive integers up to a given integer n that are relatively prime to n
    if(n%i==0){ ret-=ret/i; while(n%i==0)n/=i;}
    for(i=3; i*i<=n; i++)if(n%i==0){ ret-=ret/i; while(n%i==0)n/=i;}
    if(n>1)ret-=ret/n;return ret;
}

typedef pair<ll, ll> PLL;
typedef vector<ll> VLL;

int main()
{
    ll n, a[100005];
    cin>>n;
    f(i, 0, n)
    {
        sll(a[i]);
    }
    sort(a, a+n);
    cout<<a[n-1]-a[0]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,i,dig,flag=0;

    scanf("%d",&n);

    while(n!=0)
    {
        dig = n%10;
        n = n/10;

        if(dig==7)
            flag++;
    }

    if(flag>0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

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

int N, W;
int w[111111];
int v[111111];
int dp[111][111111];

signed main() {
  cin >> N >> W;
  repp (i, 1, N+1) {
    cin >> w[i] >> v[i];
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int wi = 0; wi <= W; wi++) {
      chmax(dp[i][wi], dp[i-1][wi]);
      if (wi - w[i] >= 0) {
        dp[i][wi] = max(dp[i][wi], dp[i-1][wi-w[i]] + v[i]);
        chmax(ans, dp[i][wi]);
      }
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}

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

//ll gcd(int a, int b){ return b? gcd(b,a%b) : a ; } 

int main(){
    ll x ;
    cin >> x ;
    ll ans = 0  ;
    ans += x/11 ;
    ans *= 2    ;
    x %= 11     ;
    if( x == 0 )cout << ans  << endl;
    else if( x <= 6 )cout << ans + 1 << endl;
    else cout << ans + 2 << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
 
int main(void){
	int n, k;
	std::cin >> n >> k;
	std::string s;
	std::cin >> s;
	int i;
	//先頭から始めて、進める所まで進む
	for(i=0;i<s.size();i++){
		if(s[i] == '0'){
			if(i == 0 || s[i] != s[i-1])k--;
			if(k < 0)break;
		}
	}
	int ans = i;
	int j=0;
	while(i<s.size()){
		k = 1;
		for(;i<s.size();i++){
			if(s[i] == '0'){
				if(i == 0 || s[i] != s[i-1])k--;
				if(k < 0)break;
			}
		}
		//後ろも進む
		bool zero_found = false;
		for(;j<s.size();j++){
			if(s[j] == '0'){
				zero_found = true;
			}
			else if(zero_found)break;
		}
		ans = std::max(i - j, ans);
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 512
import sys
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=a+op1+b+op2+c+op3+d
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

Measured memory_bytes: 2940
n = int(input())
ta = []
for i in range(n):
    ta.append(input().split())

l_sum = int(ta[0][0])
r_sum = int(ta[0][1])

for i in range(n):
    if int(ta[i][0]) > l_sum and int(ta[i][1]) > r_sum:
        l_sum = int(ta[i][0])
        r_sum = int(ta[i][1])
    elif int(ta[i][0]) <= l_sum and int(ta[i][1]) > r_sum:
        times_num = -(- l_sum // int(ta[i][0]))
        l_sum = int(ta[i][0]) * times_num
        r_sum = int(ta[i][1]) * times_num
    elif int(ta[i][0]) > l_sum and int(ta[i][1]) <= r_sum:
        times_num = -(- r_sum // int(ta[i][1]))
        l_sum = int(ta[i][0]) * times_num
        r_sum = int(ta[i][1]) * times_num
    elif int(ta[i][0]) <= l_sum and int(ta[i][1]) <= r_sum:
        r_times_num = -(- r_sum // int(ta[i][1]))
        l_times_num = -(- l_sum // int(ta[i][0]))
        times_num = max(r_times_num, l_times_num)
        l_sum = int(ta[i][0]) * times_num
        r_sum = int(ta[i][1]) * times_num
print(l_sum + r_sum)



Measured memory_bytes: 3316
mod = 998244353
kaizyo = [1, 1]
for i in range(2, 100005):
    kaizyo.append(kaizyo[-1]*i % mod)

# print(kaizyo[:10])


N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

prime_D = set(D)
prime_D = list(prime_D)
counter = {}

for i in range(len(prime_D)):
    counter[prime_D[i]] = 0

for i in range(len(D)):
    counter[D[i]] += 1  # 数を数えた

counter = sorted(counter.items(), key=lambda x: x[0])

if counter[0][1] > 1:
    print(0)  # 1との距離が0のものがあったらアウト
    exit()

# 距離が2離れているものは定義できない
now = counter[0][0]
for i in range(1, len(counter)):
    if counter[i][0] != (now+1):
        print(0)
        exit()
    now = counter[i][0]

# これですべての例外は弾けた
ans = 1
for i in range(1, len(counter)):
    ans *= counter[i-1][1]**counter[i][1]


print(ans % mod)


Measured memory_bytes: 66368
while True:
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "%":
        print(a % b)



Measured memory_bytes: 5596
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  fmt.Println(maxInt(0, a - b*2))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N,boss;
	cin>>N;
	int A[N+1]={0};
	for(int i=1;i<N;i++){
		cin>>boss;
		A[boss]++;
	}
	for(int i=1;i<N+1;i++)
		cout<<A[i]<<endl;
	
	return 0;
}

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

int main(){
 int N,K;
  cin>>N>>K;
  vector<int> hito(N,0);
for(int i=0;i<K;i++){
  int di=0;
  cin>>di;
  //cout<<"di = "<<di<<endl;
  for(int j=0;j<di;j++){
    int a=0;
    cin>>a;
    hito[a-1]++;
    //cout<<"a = "<<a<<" hito[a] = "<<hito[a-1]<<endl;
  }
}
  int count=0;
  for(int i=0;i<N;i++){
   //cout<<hito[i]<<" "; 
    if(hito[i]==0)count++;
  }
  
  cout<<count<<endl;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    sort(ALL(p));
    int ans = 0;
    rep(i,K) ans += p[i];
    cout << ans << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

int main(){
    int d,t,s;cin>>d>>t>>s;
    int ans=(d+s-1)/s;
    if(ans>t){
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
int i,j,k;
int n,m,l;
double a[100][100],b[100][100];
double c[100][100]={0};

scanf(" %d %d %d",&n,&m,&l);
for(i = 0;i < n;i++){
for(j = 0;j < m;j++){
scanf("%lf",&a[i][j]);
}
}
for(i = 0;i < m;i++){
for(j = 0;j < l;j++){
scanf("%lf",&b[i][j]);
}
}

for(i = 0;i < n;i++){
for(j = 0;j < l;j++){
for(k = 0;k < m;k++){
c[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i = 0;i < n;i++){
for(j = 0;j < l;j++){
printf("%.0f",c[i][j]);
if(j != l-1) printf(" ");
else printf("\n");
}
}
return 0;
}



Measured memory_bytes: 2104
package main

import (
	"fmt"
)

func main() {
	var n, length int
	fmt.Scan(&n)

	total := 0
	maxLength := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&length)
		if maxLength < length {
			total += maxLength
			maxLength = length
		} else {
			total += length
		}
	}

	if maxLength < total {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

vector<int> p;

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

	long long N; cin >> N;
	vector<long long> A(5);
	for (int i = 0; i < 5; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	int tmp = 0;
	if (N % A.at(0) != 0) {
		tmp = 1;
	}
	cout << N / A.at(0) + 5 - 1 + tmp << endl;
}


Measured memory_bytes: 888