akhauriyash/Code-Regression huggingface dataset:
// ConsoleApplication106.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll a, b, num, x, y;
	cin >> a >> b;
	num = a / 0.08;
	while (100)
	{
		x = num * 0.08; y = num * 0.1;
		if (x == a && y == b)
		{
			cout << num; break;
		}
		if (x > a || y > b)
		{
			cout << -1; break;
		}
	
		num++;
	}
}

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

int main() {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int alice=0,bob=0,robot=0;
    for(int i=0;i<101;i++){
        if(i==A){
            alice=1;
        }
        if(i==B){
            alice=0;
        }
        if(i==C){
            bob=1;
        }
        if(i==D){
            bob=0;
        }
        if(alice==1&&bob==1){
            robot+=1;
        }
    }
    cout<<robot<<endl;
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
money = 0
AB = sorted(AB, key=lambda x: x[0])
if M <= AB[0][1]:
  money += AB[0][0] * M
else:
  i = 0
  while M > 0:
    money += AB[i][0] * AB[i][1]
    M -= AB[i][1]
    if M <= 0:
      money += AB[i][0] * M
      break
    i += 1
print(money)

Measured memory_bytes: 29788
N, M = map(int, input().split())
p = [""] * M
S = [""] * M
for i in range(M):
    p[i], S[i] = map(str, input().split())
    p[i] = int(p[i]) - 1

A = [0] * N
Pen = [0] * N

for i, j in zip(p, S):
    if A[i] == 0 and j == "AC":
        A[i] = 1
    elif A[i] == 0 and j == "WA":
        Pen[i] += 1
    elif A[i] == 1:
        continue

penalty = 0
for i in range(N):
    if A[i] == 1:
        penalty += Pen[i]
print(sum(A), penalty)

Measured memory_bytes: 14800
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int N=100001;
constexpr ll mod=1e9+7;

int dp[N];
ull m;
vector<ull> g[N];
ull po[N],hs[N];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	string s; 
	while(q--){
		cin >> s;
		m=0;
		for(char c:s){
			m=m*911+c;
		}
		g[s.size()].push_back(m);
	}
	cin >> s;po[0]=1;
	for(int i=0;i<s.size();i++){
		po[i+1]=911*po[i];
		hs[i+1]=911*hs[i]+s[i];
	}
	vector<int> v;
	for(int i=1;i<=s.size();i++){
		if(g[i].size()){
			v.push_back(i);
			sort(g[i].begin(), g[i].end());
		}
	}
	dp[0]=1;
	for(int i=1;i<=s.size();i++){
		for(int j:v){
			if(j>i)continue;
			int l=0,r=g[j].size();
			ull f=hs[i]-hs[i-j]*po[j];
			while(r-l>1){
				int mi=(l+r)/2;
				if(g[j][mi]<=f)l=mi;
				else r=mi;
			}
			if(g[j][l]==f){
				dp[i]+=dp[i-j];
				if(dp[i]>=mod)dp[i]-=mod;
			}
		}
	}
	printf("%d\n",dp[s.size()]);
}


Measured memory_bytes: 7888
n,m,q=map(int,input().split())
a=[[0 for _ in range(n+1)]for _ in range(n+1)]
for _ in range(m):
  l,r=map(int,input().split())
  a[l][r]+=1
for i in range(n+1):
  for j in range(n):
    a[i][j+1]+=a[i][j]
for i in range(n):
  for j in range(n+1):
    a[i+1][j]+=a[i][j]
for _ in range(q):
  l,r=map(int,input().split())
  print(a[r][r]-a[r][l-1]-a[l-1][r]+a[l-1][l-1])

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

if N[0]%(2*N[1]+1)==0:
 S=int(N[0]/(2*N[1]+1))
else:
 S=int(N[0]/(2*N[1]+1))+1
    
print(S)    

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
char h[3]={" \n"};
int main()
{
int w[3],x;
for(int j=0;j<2;j++){
 memset(w,0,sizeof(w));
 for(int i=0;i<10;i++){
 scanf("%d",&x);
 if(x>w[0]){w[2]=w[1]; w[1]=w[0]; w[0]=x;}
 else if(x>w[1]) {w[2]=w[1]; w[1]=x;}
 else if(x>w[2]) w[2]=x;
 }
 printf("%d%c",w[0]+w[1]+w[2],h[j]);
}
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
struct sd {
	long long x,y;
	bool operator < (const sd &A) const {return x<A.x;}
}t[200005];
long long n1x,n2x,n1y,n2y,m1,m2,ans;
int main() {
	scanf("%d",&n);for(int i=1;i<=n;++i) scanf("%lld%lld",&t[i].x,&t[i].y);
	sort(t+1,t+1+n);
	n1x=t[1].x;n2x=t[1].x;n1y=t[1].y;n2y=t[1].y;m1=n1x+n1y;m2=-n1x+n1y;
	for(int i=2;i<=n;++i) {
		ans=max(ans,max(abs(n1x-t[i].x)+abs(n1y-t[i].y),abs(n2x-t[i].x)+abs(n2y-t[i].y)));
		if(m1>t[i].x+t[i].y) {m1=t[i].x+t[i].y;n1x=t[i].x;n1y=t[i].y;}
		if(m2<t[i].y-t[i].x) {m2=t[i].y-t[i].x;n2x=t[i].x;n2y=t[i].y;}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;




int main() {
	char x, y;
	cin >> x >> y;
	if (x < y) cout << "<" << endl;
	else if (x > y) cout << ">" << endl;
	else cout << "=" << endl;

	return 0;
}


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

int main(){
  char a , b;
  cin >> a >> b;
  if ( a == 'H' && b == 'H') cout << 'H' << endl;
  if ( a == 'H' && b == 'D') cout << 'D' << endl;
  if ( a == 'D' && b == 'H') cout << 'D' << endl;
  if ( a == 'D' && b == 'D') cout << 'H' << endl;
  return 0;
}

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 305
int n,K,Md;
int dp[MN][MN];
int tmp[MN][MN];
int C[MN][MN];

#define _A(x,y) (x)=((x)+(y))%Md
#define _S(x,y) (x)=((x)-(y)+Md)%Md
#define S(x,y) ((x)-(y)+Md)%Md
#define A(x,y) ((x)+(y))%Md
#define M(x,y) (1ll*(x)*(y))%Md

int main(){
	read(n);read(K);read(Md);
	C[0][0]=1;
	for(int i=1;i<MN;++i){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;++j){
			C[i][j]=A(C[i-1][j],C[i-1][j-1]);
		}
	}
	for(int i=0;i<=K;++i)tmp[1][i]=i+1,dp[1][i]=1;
	for(int i=2;i<=n+1;++i){
		for(int j=0;j<=K;++j){
			for(int k=1;k<i;++k){
				_A(dp[i][j],M(M(dp[i-k][j],C[i-2][k-1]),S(tmp[k][K],tmp[k][j])));
			}
		}
		tmp[i][0]=dp[i][0];
		for(int j=1;j<=K;++j){
			tmp[i][j]=A(tmp[i][j-1],dp[i][j]);
		}
	}
	printf("%d",dp[n+1][0]);
	return 0;
}


Measured memory_bytes: 1280
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var ABCDEF = Sarray();
            var A = ABCDEF[0];
            var B = ABCDEF[1];
            var C = ABCDEF[2];
            var D = ABCDEF[3];
            var E = ABCDEF[4];
            var F = ABCDEF[5];
            var Amax = F / (A * 100);
            var Bmax = F / (B * 100);
            var ansW = 0L;
            var ansS = 0L;
            var ansN = 0d;

            var Ws = new long[(Amax + 1) * (Bmax + 1)];
            for (var a = 0; a <= Amax; ++a)
            {
                for (var b = 0; b <= Bmax; ++b)
                    Ws[a * Bmax + b] = a * A * 100 + b * B * 100;
            }
            Ws = Ws.Distinct().ToArray();
            Array.Sort(Ws);
            var Smax100 = F * E;
            var Cmax = Smax100 / C / 100;
            var Dmax = Smax100 / D / 100;
            var Ss = new long[(Cmax + 1) * (Dmax + 1)];
            for (var c = 0; c <= Cmax; ++c)
            {
                for (var d = 0; d <= Dmax; ++d)
                    Ss[c * Dmax + d] = c * C + d * D;
            }
            Ss = Ss.Distinct().ToArray();
            Array.Sort(Ss);
            foreach (var w in Ws)
            {
                if (F <= w) break;
                var s = Min(F - w, w * E / 100);
                var n = ~Array.BinarySearch(Ss, s, new lb<long>());
                if (n <= 0) continue;

                var ss = Ss[Min(n, Ss.Length - 1)];
                if (s < ss) ss = Ss[n - 1];
                if (ansS * (w + ss) <= ss * (ansW + ansS))
                {
                    ansW = w;
                    ansS = ss;
                }
            }
            WriteLine($"{ansW + ansS} {ansS}");
        }
        public class lb<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 <= x.CompareTo(y) ? 1 : -1;
        }
    }
}

Measured memory_bytes: 31804
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, X;
    read(N, X);
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        read(L[i]);
    }
    int sum = 0;
    int ans = 1;
    for(int i = 0; i < N; i++){
        sum += L[i];
        if(sum <= X) {
            ans++;
        }
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
import Foundation

precedencegroup PowerPrecedence {
    higherThan: MultiplicationPrecedence
}
infix operator ^^: PowerPrecedence
func ^^(radix: Int, power: Int) -> Int {
    Int(pow(Double(radix), Double(power)))
}

let abc = readLine()!
    .split(separator: " ")
    .map { Int($0)! }
let a = abc[0]
let b = abc[1]
let c = abc[2]
let limit = Int(readLine()!)!
var result = false

LOOP:
for i in 0..<limit {
    for j in i..<limit {
        let r = a * 2 ^^ i
        let g = b * 2 ^^ (j - i)
        let b = c * 2 ^^ (limit - j)
        if b > g && g > r {
            result = true
            break LOOP
        }
    }
}

print(result ? "Yes" : "No")


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector< vector<int> > dp(n, vector<int>(2, n));
    dp[0][0] = (s[0] == '#');
    dp[0][1] = (s[0] == '.');

    for (int i = 1; i < n; i++) {
        dp[i][0] = dp[i - 1][0] + (s[i] == '#');
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + (s[i] == '.');
    }

    cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
    return 0;
}

Measured memory_bytes: 11412
import java.util.*; 

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

    	System.out.println(b);
    }
}



Measured memory_bytes: 22096
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include <cmath>
using namespace std;

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

static const int MAX = 100005;
static const int INFTY = (1 << 20);

int N;
int ans;

signed main() {
	cin >> N;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 16; j++) {
			if (i * 4 + j * 7 == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

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

namespace ConsoleApplication27
{
    class Program
    {
        static void Main()
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] > a[1]) Console.WriteLine("a > b");
            else if (a[0] == a[1]) Console.WriteLine("a == b");
            else Console.WriteLine("a < b");
        }
    }
}

Measured memory_bytes: 9404
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MAX=100005;
vector<int> llist[MAX];
int c[MAX],d[MAX],v[MAX],ans[MAX];
int dp[MAX][11];
int n,m,q;
void paint(int u,int dist,int color)
{
	if(dp[u][dist]||dist<0) return;
	if(ans[u]==0){
		ans[u]=color;
	} 
	for(int i=0;i<llist[u].size();++i){
		int t=llist[u][i];
		paint(t,dist-1,color);
	}
	dp[u][dist]=1;
}
int main()
{
	int a,b;
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		cin>>a>>b;
		llist[a].push_back(b);
		llist[b].push_back(a);
	}
	cin>>q;
	for(int i=1;i<=q;++i){
		cin>>v[i]>>d[i]>>c[i];
	}
	for(int i=q;i>0;--i){
		paint(v[i],d[i],c[i]);
	}
	for(int i=1;i<=n;++i) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, d, cnt = 0;
	cin >> n >> d;
	vector<vi> v(n + 1, vi(d + 1, 0));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < d; j++) cin >> v[i][j];
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = i + 1; j < n; j++)
		{
			vi a(d + 1, 0);
			for(int k = 0; k < d; k++)
			{
				a[k] = abs(v[i][k] - v[j][k]);
				a[k]*=a[k];
			}
			ll sum = accumulate(a.begin(), a.end(), 0);
			for(int i = 0; i*i <= sum; i++)	if(i*i == sum) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,K;
int arr[11];

bool check(int x){
  while (x!=0){
    if (arr[x%10]==1)
      return false;
    x/=10;
  }
  return true;
}

int main()
{
  int x;
  cin>>N>>K;
  for (int i=0;i<K;i++){
    cin>>x;
    arr[x]=1;
  }
  for (int i=N;;i++){
    if (check(i)){
      cout<<i<<endl;
      return 0;
    }
  }
}

  


Measured memory_bytes: 256
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}



int main() {
    
    fastio;
    string s;
    ll x, k, d;
    cin >> x >> k >> d;
    ll y = abs(x);
    ll a = y / d;
    ll ans;
    if(a > k)
    {
        if(x < 0)
            ans = x+k*d;
        else
            ans = x-k*d;
        
    }
    else
    {
        
        ll ans1;
        if(x < 0)
        {
            ans1 =  x+a*d;
            
            if((a & 1) == (k & 1))
            {
               ans = ans1;
            }
            else
            {
                ans =  ans1+d;
            }

        }
        else
        {
            
            ans1 = x-a*d;

            if((a & 1) == (k & 1))
            {
                ans =  ans1;
                
            }
            else
            {
                ans = ans1-d;
            }
        }
    }
    if(ans < 0)
        cout << -ans;
    else
        cout << ans;
    
    return 0; 

}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int a[N];
int main(){
	//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	int res = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			++res;
			a[i+1] = a[i];
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    map<string, int> mp;

    int N;
    cin >> N;
    string S[N];
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        mp[S[i]] += 1;
    }

    int M;
    cin >> M;
    string T[M];
    for (int i = 0; i < M; i++)
    {
        cin >> T[i];
        mp[T[i]] -= 1;
    }

    string best;
    int bestN;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if (itr->second > bestN)
        {
            bestN = itr->second;
            best = itr->first;
        }
    }

    cout << bestN << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define ll long long int

#define rep(p,q) for(int i = p; i < q;i++)


//6

int main(void) {
	string str;
	cin >> str;
	reverse(str.begin(), str.end());
	cout << str << endl;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int INF = -1;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int H, W;
char maze[50][50];
int step[50][50];

int bfs() {
	queue<P> que;
	que.push(P(0,0));
	step[0][0] = 1;

	while(que.size()){
		P p = que.front(); 
		que.pop();

		if(p.first==W-1 && p.second==H-1) break;

		for(int i=0; i<4; i++){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			if(step[nx][ny] != INF || maze[nx][ny] == '#') continue;

			if(0 <= nx && nx < W && 0 <= ny && ny < H){
				que.push(P(nx,ny));
				step[nx][ny] = step[p.first][p.second] + 1;
			}
		}
	}

	return step[W-1][H-1];
}


int main() {
	cin >> H >> W;
	int white=0;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> maze[j][i];
		}
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(maze[j][i] == '.') white++;
			step[j][i] = INF;
		}
	}
	int res = bfs();
	if(res == INF){
		cout << INF << endl;
	}else{
		printf("%d\n", white-res);
	}
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans = 1;
    bool flag = false;
    bool zero = false;
    cin >> N;
    rep(i, N) {
        ll prev;
        ll temp;
        cin >> temp;
        prev = ans;
        ans *= temp;
        if(prev > ans || ans > 1000000000000000000 || temp > 1000000000000000000 || (temp > 1 && temp >= 1000000000000000000)) {
            flag = true;
        }
        if(temp == 0) zero = true;
    }
    if(zero) cout << 0 << endl;
    else if(flag) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int X = (A); X <= (Y);++X)
#define _rep2(X, Y) for (int X = 0; X < (Y); ++X)
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int X = (Y-1); X >= 0; --X)
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N, K;
bool has_candy[MAX_N];

int main() {
    cin >> N >> K;
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            has_candy[--a] = true;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (!has_candy[i]) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{

    int n;
    long long sum=0;
    cin>>n;
    int b[n];
    int a[n+1];
    b[0]=0;
    a[0]=0;
    for(int i=1; i<=n-1; i++)
        cin>>b[i];

    a[n]=b[n-1];
    sum+=a[n];
    for(int i=n-1; i>=2; i--)
    {

       int l=min(b[i],b[i-1]);
      // a[i]=min(l,[b[i]);
        sum+=l;


    }
    sum+=b[1];
    cout<<sum<<endl;





}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    multiset<ll> s, t;

    REP(i, (1 << n)){
        ll a;
        cin >> a;
        s.insert(-a);
    }

    auto itr = s.begin();
    t.insert(*itr);
    s.erase(itr);

    REP(i, n){
        vector<ll> u;
        for(auto e : t){
            auto itr = s.upper_bound(e);
            if(itr == s.end()){
                cout << "No" << endl;
                return 0;
            }
            u.push_back(*itr);
            s.erase(itr);
        }
        for(auto e : u){
            t.insert(e);
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 14068
//  Created by conan1024hao on 2019/11/19.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;
    cin>>a>>b;
    if(b%a==0)
        cout<<a+b<<endl;
    else
        cout<<b-a<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

bool solve(string s) {
    vector<int> v;
    rep (i, s.size()) {
        if (s[i] == '(') v.push_back(1);
        if (s[i] == '[') v.push_back(2);
        if (s[i] == ')') {
            if (v.empty() || v.back() != 1) return false;
            v.pop_back();
        }
        if (s[i] == ']') {
            if (v.empty() || v.back() != 2) return false;
            v.pop_back();
        }
    }
    return v.empty();
}

int main() {
    for (;;) {
        string s;
        while (s.size() == 0 || s[s.size()-1] != '.') {
            string buf;
            getline(cin, buf);
            s += buf;
        }
        if (s == ".") return 0;
        puts(solve(s) ? "yes" : "no");
    }
}

Measured memory_bytes: 892
#include <stdio.h>
int main() {
	long long int m, n, w, h, p, q;
	scanf("%lld", &m);
	for (w = 1; w <= 3500; w++)
	{
		for (n = 1; n <= 3500; n++)
		{
			p = m*n*w;
			q = 4 * n*w - m*w - m*n;
			if (q > 0 && p % q == 0)
			{
				h = p / q;
				printf("%lld %lld %lld", h, n, w);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#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(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll  n,a,b;
    cin >> n >> a >> b;
    if (a==0) cout << 0 << endl;
    else cout << (n/(a+b))*a + min(a, n%(a+b)) << endl;
}




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

int main() {
	int a[51] = {}, n, x, y;
	cin >> n >> x;
	while(cin >> x >> y){
		a[x]++;
		a[y]++;
	}
	for(int i = 1;i<=n;i++){
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,num,ans,a[100005];
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1,a + n + 1);
	for(int i = 1; i <= n + 1; i++)
		if(a[i] != a[i - 1]) {
			if(num >= a[i - 1])
				ans += num - a[i - 1];
			else
				ans += num;
			num = 1;
		} else
			num++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
# 二分探索（応用）


def loading(pack_list, k, q):

    truck = 0
    idx = 0
    for pack in pack_list:
        if pack > q:
            return False

        if truck + pack > q:
            idx += 1
            truck = 0

        truck += pack

    if truck > 0:
        idx += 1

    return False if idx > k else True


if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]

    pack = []

    for _ in range(n):
        pack.append(int(input()))

    min = 0
    max = int(1E20)
    # min = sum(pack) // n
    # max = sum(pack)

    q = (max + min) // 2

    res = loading(pack, k, q)

    while min + 1 != max:
        min, max = [min, q] if res else [q, max]
        q = (max + min) // 2

        res = loading(pack, k, q)

    print(max)



Measured memory_bytes: 9580
import sys
import math
def is_prime(num):
    if num < 2:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        for prime in range(2, num_sqrt + 1):
            if num % prime == 0:
                return False
                break
        return True

def main():
    x = int(input())
    i = x
    while True:
        if is_prime(i) == True:
            print(i)
            sys.exit()
        i = i + 1


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
from collections import defaultdict
from collections import deque
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

R,G,B,n = readInts()
ans = 0
for r in range(n//R+2):
	for g in range(n//G+2):
		t = n-(r*R+g*G)
		if t%B==0 and t>=0:
			ans+=1

print(ans)

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

int main() {
    int n, l;
    cin >> n >> l;
    string s[n];
    rep(i, n) cin >> s[i];
    while(1){
        bool check = false;
        rep(i, n-1){
            string a = s[i];
            string b = s[i+1];
            if(a+b > b+a){
                s[i] = b;
                s[i+1] = a;
                check = true;
            }
        }
        if(!check)break;
    }
    rep(i, n) cout << s[i];

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int a,b,c,i,N;
N=0;
scanf("%d %d %d", &a, &b, &c);
 for(i=a;i<=b;i++){
     if(c%i==0){
         N++;
     }
 }

printf("%d\n",N);
    return 0;
}


Measured memory_bytes: 2100
n=int(input())
t,x,y=0,0,0
for _ in range(n):
  nt,nx,ny=map(int,input().split())
  if abs(nx+ny-x-y)%2!=(nt-t)%2 or abs(nx+ny-x-y)>nt-t:
    print('No')
    break
  else:t,x,y=nt,nx,ny
else:print('Yes')

Measured memory_bytes: 9096
package main

import (
	"fmt"
	"sort"
)

func isUniq(a []string) bool {
	sort.Strings(a)
	for i := 1; i < len(a); i++ {
		if a[i-1] == a[i] {
			return false
		}
	}
	return true
}

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

	w := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&w[i])
	}

	for i := 0; i < n-1; i++ {
		if w[i][len(w[i])-1] != w[i+1][0] {
			fmt.Println("No")
			return
		}
	}

	if !isUniq(w) {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define vii vector <int>
#define vll vector <long long>
#define pii pair <int, int>
#define repDown(i,a,n) for(int i=n;i>a;i--)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define max(a,b,c) max(c, min(a,b))
#define min(a,b,c) min(c, min(a,b))
ll mod=1000000007;
using namespace std;
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
void printll(vector <ll> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}

int main(){
/////////////////////////////////////////////////////////////////////
//	ios_base::sync_with_stdio(false);
//	cin.tie(nullptr);
//	cout.tie(nullptr);
//	cerr.tie(nullptr);
//For fast IO
///////////////////////////////////////////////////////////////////// 

	ll a, b;
	cin>>a>>b;
	if(a>b) cout<<-1<<endl;
	else {
	
	rep(i, 1, 100000) {
	double d1=0.08*(double)i, d2=0.1*(double)i;
	if(floor(d1)==a && floor(d2)==b){
		 cout<<i<<endl;
		 exit(0);
	}
	
}
	cout<<-1<<endl;
}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    vector<int> cand;
    for (int i = 1; i <= sqrt(sum) + 1; ++i) {
        if (sum % i == 0) {
            cand.push_back(i);
            cand.push_back(sum / i);
        }
    }

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

    vector<int> b(n);
    for (int d : cand) {
        int rsum = 0;
        for (int i = 0; i < n; ++i) {
            b[i] = a[i] % d;
            rsum += b[i];
        }
        sort(b.begin(), b.end(), greater<int>());
        int opcnt = 0;
        for (int i = 0; i < rsum / d; ++i) {
            opcnt += d - b[i];
        }

        if (opcnt <= k) {
            cout << d << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

const int maxn = 100005;

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

    // 建立红组与白组
    int red_list[maxn];
    int white_list[maxn];
    for (int i = 1; i <= n; i++) {
        if (i == 1) {
            red_list[i] = 1;
            white_list[i] = 0;
        }
        if (i > 1) {
            red_list[i] = 0;
            white_list[i] = 1;
        }
    }

    // m次输入
    while (m--) {
        int x, y;
        scanf("%d%d", &x, &y);

        if (red_list[x]) {
            // 若出发点为红
            red_list[x]--;
            red_list[y] += white_list[y] + 1;
            white_list[y] = 0;
        } else {
            // 若出发点为白
            white_list[x]--;
            if (red_list[y]) {
                red_list[y]++;
            } else {
                white_list[y]++;
            }
        }
    }

    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (red_list[i]) {
            count++;
        }
    }
    printf("%d\n",count);
    return EXIT_SUCCESS;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

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

  int64 n, k;
  cin >> n >> k;

  int64 s = 0;
  for (int64 i = k; i <= n + 1; i++) {
    int64 l = (i - 1) * i / 2;
    int64 u = ((n - i + 1) + n) * i / 2;
    // cout << u - l + 1 << endl;
    s += u - l + 1;
    s %= P;
  }

  cout << s << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
	int A,B,T;
	scanf("%d %d %d",&A,&B,&T);
	int a=A;
	int N=0;
	while(A<=(T+0.5)){

		N+=B;
		A = A + a;
	}

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

Measured memory_bytes: 128
import std;

alias Book = Tuple!(int, "cost", int[], "ss");

int calc(int x, Book[] books) {
    int p = cast(int)books.length;
    int n = cast(int)books[0].ss.length;

    int ans = int.max;
    for (int i = 0; i < (1 << p); i++) {
        int cost = 0;
        auto ss = new int[n];
        for (int j = 0; j < p; j++) {
            if (i & (1 << j)) {
                cost += books[j].cost;
                foreach (k, s; books[j].ss) {
                    ss[k] += s;
                }
            }
        }

        if (ss.all!(e => e >= x)) {
            ans = min(ans, cost);
        }
    }
    return ans == int.max ? -1 : ans;
}

void main() {
    int n, m, x; scan(n, m, x);
    Book[] books;
    foreach (_; 0..n) {
        auto t = readints;
        books ~= Book(t[0], t[1..$]);
    }
    writeln(calc(x, books));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acosl(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

// int main(){
//     srand(time(0));
//     int n;
//     cin >> n;
//     vector<P> ps(n);
//     for(int i = 0; i < n; ++i){
//         ld x,y;
//         cin >> x >> y;
//         ps[i] = P(x,y);
//     }

//     printf("%.2lf\n", (double)smallest_enclosing_disc(ps).rad*2);
// }

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

    vector<P> xy(N);
    rep (i, N) {
      ld x, y;
      cin >> x >> y;
      xy[i] = P(x, y);
    }

    ld ans = smallest_enclosing_disc(xy).first;

    std::cout << fixed << setprecision(30) << ans << '\n';

}

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

k = int(input())

count=0
while True:
    if b>a:
        break
    count+=1
    b=b*2
#print(b)
while True:
    if c>b:
        break
    count+=1
    c=c*2

if count <= k:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

bool ok(int n) {
  return 1 <= n && n <= 9;
}

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int a, b; cin >> a >> b;
  if (ok(a) && ok(b)) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n, m; cin >> n >> m;
	vvi a(n, vector<int>(m));
	REP(i, n) REP (j, m) cin >> a[i][j];
	vi b(m);
	REP(i, m) cin >> b[i];
	REP(i,n) {
		int sum = 0;
		REP(j,m) {
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
}

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



Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0,h,w;
struct edge {
    int from, to, d;
    edge(int from, int to, int d) :
        from(from),to(to),d(d){}
};
bool operator <(const edge& e1, const edge& e2) {
    if (e1.d != e2.d) return e1.d < e2.d;
    return e1.from < e2.from;
}struct UnionFind {
    vector<int> par;
    UnionFind(int n):par(n,-1){}
    void inti(int n) { par.resize(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }bool unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y)return 0;
        if (par[x] > par[y])swap(x, y);
        par[x] += par[y]; par[y] = x;
        return 1;
    }int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    int n, m, k, a, b, c, ans = 0, cnt; cin >> n;
    priority_queue<edge> pq; UnionFind uf(n); cnt = n;
    vector<pair<int, int>> v, w;
    rep(i, n) {
        cin >> a >> b; v.push_back({ a,i });
        w.push_back({ b,i });
    }sort(ALL(w)); sort(ALL(v));
    rep(i, n-1) {
        pq.push(edge(w[i].second, w[i + 1].second, (w[i+1].first-w[i].first)*-1));
        pq.push(edge(v[i].second, v[i + 1].second, (v[i+1].first-v[i].first)*-1));
    }
    while (!pq.empty()) {
        edge e = pq.top(); pq.pop();
        if (uf.unite(e.from, e.to)) {
            ans -= e.d; 
        }
    }cout << ans << endl;
}

Measured memory_bytes: 9012
import collections
 
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))

cd = collections.Counter(d)
ct = collections.Counter(t)

flg = True
for k in ct.items():
  if k[1] > cd[k[0]]:
    flg = False

print('YES' if flg else 'NO')

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

int main(){
  int x,S[99],top=0,ans=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      ans=S[top-2]+S[top-1];
      top--;
      S[top-1]=ans;
    } else if ( s[0] == '-' ){
       ans=S[top-2]-S[top-1];
       top--;
       S[top-1]=ans;
    } else if ( s[0] == '*' ){
       ans=S[top-2]*S[top-1];
       top--;
       S[top-1]=ans;
    } else {
       x = atoi(s);
       S[top]=x;
       top++;
    }
  }
  printf("%d\n",S[top-1]);

  return 0;
}

Measured memory_bytes: 548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<ctype.h>
#include<limits.h>
#include<set>
#include<iostream>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    set<int>se;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(se.count(x))
            se.erase(x);
        else
            se.insert(x);
    }
    cout<<se.size()<<endl;
    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

int main(void){
  int X, Y;
  cin >> X >> Y;
  cout << X + Y/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int main(){
  ll N; cin>>N;
  ll r = pow(10,12)+1;
  ll temp;
  for(int i=sqrt(N)+1;i>0;--i){
    if(N%i==0){
      r = i+N/i-2;
      break;
    }
  }
  cout << r;
}

Measured memory_bytes: 384
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

temp=[a,b,c,d,e]
temp.sort()
mini=temp[0]

ans=int(n//mini+5)
if mini==1:
    print(ans-1)
else:
    print(ans)

Measured memory_bytes: 3064