akhauriyash/Code-Regression huggingface dataset:
n,m,x=[int(i) for i in input().split()]

books=[]

for i in range(n):
    books.append([int(i) for i in input().split()])


# ==================================================-
# 整数を２進数に変換
def get_conbination(i,length):
    return format(i, '#0'+str(length+2)+'b')[2:]

min_cost=100000000000000
for i in range(2**n):
    rikai=[0]*m
    select=get_conbination(i,n)
    cost=0
    for j in range(n):
        if select[j] == "1":
            for k in range(m):
                rikai[k]+=books[j][k+1]
            cost+=books[j][0]
    if min(rikai)>=x:
        min_cost=min(min_cost,cost)

if min_cost==100000000000000:
    print(-1)
else:
    print(min_cost)


Measured memory_bytes: 9140
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(" ");
        	int a = Int32.Parse(input[0]);
        	int b = Int32.Parse(input[1]);
            //出力
            Console.WriteLine((a * b).ToString());
        }
    }
}


Measured memory_bytes: 27524
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for(int i = (int)(n-1); i > -1; i--)


ull MOD = 1000000007;


int calculateScore(char hand, const int *scores){
    switch(hand){
        case 's':
        return scores[0];
        
        case 'p':
        return scores[1];

        default:
        return scores[2];
    }
}

int battle(char expectedHand, char previousHand, const int *scores){
    if( expectedHand == previousHand){
        return 0;
    }
    return calculateScore(expectedHand, scores);
}


int main(){
    int n,k;
    int scores[3];
    ll ans = 0;
    string t;
    cin >> n >> k;
    rep(i,3){
        cin >> scores[i];
    }
    cin >> t;
    char memo[n];
    memset(memo, 0, sizeof(memo));
    rep(i,n){
        if(i < k){
            memo[i] = t[i];
            ans += calculateScore(t[i], scores);
            continue;
        }
        ll score = battle(t[i], memo[i-k], scores);
        if( score == 0 ) continue;
        memo[i] = t[i];
        ans += score; 
    }

    cout << ans << endl;
}



Measured memory_bytes: 512
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a / (b + 1), a, b])

    shopsA0.sort()
    shops.sort(reverse=True)


    DP = [t+10] * 30
    DP[0] = 0

    for _, a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 63328
# Aizu Problem 00140: Bus Line
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def bus_line(a, b):
    line = []
    if max(a, b) <= 5:
        if a < b:
            return list(range(a, b + 1))
        else:
            return list(range(a, b - 1, -1))
    if a <= 5:
        # stop must be in circle:
        return list(range(a, b + 1))
    if b <= 5:
        # start must be in circle:
        return list(range(a, 10)) + list(range(5, b - 1, -1))
    # at this point both start and stop are in circle:
    if a < b:
        return list(range(a, b + 1))
    else:
        return list(range(a, 10)) + [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5] + \
               list(range(6, b + 1))

    
n = int(input())
for __ in range(n):
    a, b = [int(_) for _ in input().split()]
    print(' '.join([str(_) for _ in bus_line(a, b)]))

Measured memory_bytes: 8132
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class v:
    def __init__(self, f):
        self.f = f
        self.v = None
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def f(S):
    for s, t in zip(S, S[::-1]):
        if s != t:
            return False
    return True

def main():
    L = int(input())
    print(L ** 3 / 27)
            

if __name__ == "__main__":
    main()

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

int main()
{
    int a = 1000;
    int b = 5000;
    int c = 10000;
    int n = 0;
    int y = 0;
    cin >> n >> y;

    for (int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n - i; ++j) {
            int k = n - i - j;
            if (a * i + b * j + c * k == y) {
                cout << k << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

using namespace std;


int main()
{
	const int LIMIT = 200000;
	char S[LIMIT];
	char T[LIMIT];

	cin >> S;
	cin >> T;
	int count = 0;
	for (int i = 0; S[i] && i < LIMIT; i++){
		if (S[i] != T[i]) count++;
	}
	cout << count << endl;

}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int main() {
	int a;
	scanf( "%d", &a );
	int ans = 0;
	while ( a > 1 ) {
		ans++;
		a = a / 3 + !!( a % 3 );
	}
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

/*
考察
abceee
とかの時、
aをとるかで*2
bをとるかで*2
cをとるかで*2
してく。
（なにもとらない、いわば空集合みたいなやつは考えないからあとで1引けばいい。）
eのときだけ、*(eの登場回数+1)
すればよくて、これはeのどれかをとる。もしくはとらない(+1)
おしまい。
 */
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> count(27,0);
    rep(i,n){
        int tmp=s[i]-'a';
        count[tmp]++;
    }
    ll ans=1;
    rep(i,26){
        ans=ans*(count[i]+1)%mod;
    }
    ans=(ans-1)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""


import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


# ABC 100 B Ringo's Favorite Numbers
def abc100b():
    D, N = getIntList()
    if N % 100 == 0:
        return (N+1) * 100**D  # WA N==100のとき正しくない 101*100**D
    else:
        return N * 100**D  # WA N==100のとき正しくない 101*100**D


debug = False  # True False
print(abc100b())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int N;
long long h[100010];
long long dp[100010];

int main()
{
  int N;
  cin >> N;
  for(int i=0;i<N;i++)
  {
    cin >> h[i];
  }
  for(int i=0;i<N;i++)
  {
    dp[i] = INF;
  }
  dp[0] = 0;
  for(int i=1;i<N;i++)
  {
    chmin(dp[i],dp[i-1] + abs(h[i]- h[i-1]));
    if(i>1)
    {
      chmin(dp[i],dp[i-2]+abs(h[i] - h[i-2]));
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int c[300];
vector<int> d;
int a[10000000],b[10000000];

void f(int n){
  fill(a,a+1000000,inf);
  fill(b,b+1000000,inf);
  a[0]=b[0]=0;
  rep(i,1000000){
    FOR(j,1,300){
      if(i+c[j]>=1000000)break;
      a[i+c[j]]=min(a[i+c[j]],a[i]+1);
    }
  }
  rep(i,1000000){
    FOR(j,1,d.size()){
      if(i+d[j]>=1000000)break;
      b[i+d[j]]=min(b[i+d[j]],b[i]+1);
    }
  }




}

void g(int n){
  cout<<a[n]<<' '<<b[n]<<endl;
}


int main(){
  d.push_back(0);
  for(int i=1;i<200;i++){
    c[i] = (i*(i+1)*(i+2))/6;
  
   if(c[i]%2){
     d.push_back(c[i]);
   }
  }

  f(1000000);

  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    g(n);
  }

  return 0;
}


Measured memory_bytes: 10924
import java.util.Scanner;

public 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();
    int work = 0;
    
    //AとBを入れ替え
    work = A;
    A = B;
    B = work;
    
    //AとCを入れ替え
    work = A;
    A = C;
    C = work;
    
    System.out.println(A + " " + B + " " + C);
  }
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<string> str(s.size());
    rep(i, s.size()) str[i] = s.substr(i, 1);
    
    string now = str[0];
    int cnt = 1;
    for (int i = 1; i < str.size(); i++) {
        if (str[i] != now) {
            cnt++;
            now = str[i];
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 5760
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/



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

const int INF=(long long)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;
int sz=262144;complex<double> y[262160],A[262160],B[262160];
#define int long long

void dft(complex<double> *x,bool inv);
#define P pair<int,int>





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

    int k,n;cin >>k>>n;
    vector<int> a(n);
    rep(i,n)cin >>a[i];
    int ma=0;
    rep(i,n-1)ma=max(ma,a[i+1]-a[i]);
    ma=max(ma,a[0]+k-a[n-1]);
    cout << k-ma<<endl;
}

void dft(complex<double> *x,bool inv){
    for(int i=sz>>1;i>=1;i>>=1){
        complex<double> zeta=polar(1.0,2.0*acos(-1)*i/sz*(inv?-1.0:1.0)),now=1;
        for(int j=0;2*j<sz;j+=i){//i飛ばし
            rep(k,i) {
                y[k+j]=x[2*j+k]+now*x[2*j+i+k];
                y[j+k+(sz/2)]=x[2*j+k]-now*x[2*j+i+k];//sz/2以上のやつ。原点対称を利用
            }
            now*=zeta;
        }
        rep(i,sz)x[i]=y[i];//探索の区間の幅を狭める前にこぴー
    }

    if(inv)rep(i,sz)x[i]/=sz;

}

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

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

    int n, ans = 0; cin>>n;
    for(int i = 1, x; i<=n; i++){
        cin>>x;
        if(x%2==1 && i%2==1) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
typedef long long ll;

//参考 htps://code3kaku.hatenablog.com/entry/2018/12/04/223000

int N;
int ans = 0;
  
// 3, 5, 7を組み合わせて作れる数値を全探索
void dfs(ll x, bool flag3, bool flag5, bool flag7) {
  if (x > N) return;
  // 3, 5, 7をすべて含むならansに+1
  if (flag3 && flag5 && flag7) ans++;
  
  dfs(10 * x + 3, true, flag5, flag7);
  dfs(10 * x + 5, flag3, true, flag7);
  dfs(10 * x + 7, flag3, flag5, true);
}
  
int main() {
  // 入力
  cin >> N;
  
  // 深さ優先探索
  dfs(0, 0, 0, 0);
  
  // 出力
  cout << ans << endl;
}

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

int main(){
  int n,a,b,l,k;
  cin >> n;
  while(n--){
    cin >> a >> b;

    if((a<0&&b<0) || (a>0&&b>0)){
      if(a<0){a=-a; b=-b; swap(a,b);}
      l = 0;
      while(a<b){
	k = __builtin_ctz(a);
	while(a > b - (1<<k))k--;
	a += 1<<k;
	l++;
      }
      cout << l << endl;
    }else cout << __builtin_popcount(-a) + __builtin_popcount(b) << endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define mem(a)           memset(a,0,sizeof a) ;
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                 ll;
typedef pair<ll,ll>                   PII;
bool compare(const PII a, const PII b)
{
    return a.F < b.F;
}
int main()
{
    //IOS
    // READ("0test.txt");
    // WRITE("0out.txt") ;
    int a , b ;
    cin >> a >> b;
    int mx = max(a,b);
    int mn  = min(a,b);
        while(mx--){
            cout<<mn;
        }
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

vector<vector<pair<int, int>>> G;
void dfs(int v, int p, int pc, vector<int> &res){
    int color=1;
    if(color==pc) color++;
    for(auto e : G[v]){
        if(e.F==p) continue;
        res[e.S]=color;
        dfs(e.F, v, color, res);
        color++;
        if(color==pc)color++;
    }
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    G.resize(N);
    rep(i,N-1){
        int a;
        int b;
        cin >> a;
        cin >> b;
        a--;
        b--;
        G[a].push_back(make_pair(b, i));
        G[b].push_back(make_pair(a, i));
    }
    int max_color=0;
    rep(i,N) chmax(max_color, int(G[i].size()));
    vector<int> res(N-1, -1);
    dfs(0, -1, -1, res);
    cout << max_color << endl;
    rep(i,N-1){
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int a,b,c,d,k;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> k;
    int i = 101,count = 0;
    while(count != k) {
        i--;
        c = a%i;
        d = b%i;
        if(c == 0 && d == 0) count++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

ll = [[int(x) for x in input().split()] for y in range(3)]

n = int(input())

for i in range(n):
    b = int(input())
    for ii in range(3):
        if b in ll[ii]:
            ll[ii][ll[ii].index(b)] = 0

for i in range(3):
    if ll[i][0] == ll[i][1] == ll[i][2] == 0:
        print("Yes")
        sys.exit()
    if ll[0][i] == ll[1][i] == ll[2][i] == 0:
        print("Yes")
        sys.exit()

if ll[0][0] == ll[1][1] == ll[2][2] == 0 or ll[0][2] == ll[1][1] == ll[2][0] == 0:
    print("Yes")
    sys.exit()

print("No")


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);

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

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(0); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;--b;}a*=a;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
bool a[1000005]; vl v;
void seive(){
    ll mx=sqrt(1000005),ii,jj;
    for(ii=3;ii<=mx;ii+=2)
        if(!a[ii])
            for(jj=ii*ii;jj<1000004;jj+=2*ii) a[jj]=true;
    v.pb(2);
    for(ii=3;ii<1000004;ii+=2)if(!a[ii]) v.pb(ii);
}



void _case()
{
    ll n,i,ans=0,y;
    cin>>n;
    y=sz(v);
    map<ll,ll> m;
    m[1]++;
    for(i=0;i<y and v[i]<=n;i++){
        if(n%v[i]==0){
            ll cnt=0,j=v[i];
            while(n%j==0){
                cnt++;
                n/=j;
            }
            ans+=(-1+sqrt(1+8*cnt))/2;
        }
    }
    if(!m[n]) ans++;
    cout<<ans el;
}

main()
{
    seive();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 5124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt(), h = scanner.nextInt();
			if (w == 0 && h == 0)
				break;
			for (int i = 0; i < w; ++i) {
				for (int j = 0; j < h; ++j) {
					System.out.print(i == 0 || i == w - 1 || j == 0 || j == h - 1 ? '#' : '.');
				}
				System.out.print('\n');
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 37736
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b; cin >> a >> b;
	for (int i = 1; i <= 10000; i++) {
		int x = i * 0.08;
		int y = i * 0.1;
		if (x == a && y == b) {
			cout << i << '\n'; return 0;
		}
	}
	cout << -1 << '\n';
}




Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
    

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
	array<int,100> score{};
	int roop;
	cin >> roop;
	for(int i=0;i<roop;i++){
		cin >> score[i];
	}
	sort(score.begin(),score.end());
	int total = accumulate(score.begin(),score.end(),0);
	int stack=-1;
	if(total%10 == 0){
		for(int A:score){
			if(A%10 != 0){
				stack = A;
				break;
			}
		}
		if(stack == -1){
			total = 0;
		}else{
			total-=stack;
		}
	}
	cout << total;
	return 0;
}

Measured memory_bytes: 256
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define int ll
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=2000010;
int w,h,n;
struct node{
	int x,y;
	bool operator<(const node &b)const{return x<b.x || (x==b.x && y<b.y);}
}p[N];
typedef pair<int,int> pii;
#define mp make_pair
pii a[N],b[N];//stack
int mx[N],tag[N],ans;
void pushup(int o){mx[o]=max(mx[o<<1],mx[o<<1|1]);}
void pushdown(int o){
	if(!tag[o])return;
	tag[o<<1]+=tag[o];tag[o<<1|1]+=tag[o];
	mx[o<<1]+=tag[o];mx[o<<1|1]+=tag[o];
	tag[o]=0;
}
void modify(int o,int l,int r,int posl,int posr,int v){
	if(posl<=l && r<=posr){tag[o]+=v;mx[o]+=v;return;}
	pushdown(o);int mid=(l+r)>>1;
	if(posl<=mid)modify(o<<1,l,mid,posl,posr,v);
	if(mid<posr)modify(o<<1|1,mid+1,r,posl,posr,v);
	pushup(o);
}
void work(){
	memset(mx,0,sizeof(mx));memset(tag,0,sizeof(tag));
	sort(p+1,p+n+1);int l=0,r=0;
	for(int i=1;i<n;i++){
		if(p[i].y<=h/2){
			int lst=i-1;
			while(l && p[i].y>a[l].second){
				modify(1,1,n,a[l].first,lst,a[l].second-p[i].y);
				lst=a[l--].first-1;
			}
			if(lst!=i-1)a[++l]=mp(lst+1,p[i].y);
		}
		else{
			int lst=i-1;
			while(l && p[i].y<b[r].second){
				modify(1,1,n,b[r].first,lst,p[i].y-b[r].second);
				lst=b[r--].first-1;
			}
			if(lst!=i-1)b[++r]=mp(lst+1,p[i].y);
		}
		a[++l]=mp(i,0);b[++r]=mp(i,h);modify(1,1,n,i,i,h-p[i].x);
		ans=max(ans,mx[1]+p[i+1].x);
	}
}
signed main(){
	w=gi();h=gi();n=gi();
	for(int i=1;i<=n;i++)p[i].x=gi(),p[i].y=gi();
	p[++n]=(node){0,0};p[++n]=(node){w,h};
	work();
	for(int i=1;i<=n;i++)swap(p[i].x,p[i].y);swap(h,w);
	work();
	printf("%lld\n",ans*2);
	return 0;
}


Measured memory_bytes: 47360
#include <stdio.h>

int main(){
    char s[5];



    scanf("%s",s);

    if((s[0]=='A') && (s[1]=='B') && (s[2]=='A'))
        printf("Yes\n");
    else if((s[0]=='B') && (s[1]=='A') && (s[2]=='A'))
        printf("Yes\n");
    else if((s[0]=='A') && (s[1]=='A') && (s[2]=='B'))
        printf("Yes\n");
    else if((s[0]=='B') && (s[1]=='A') && (s[2]=='B'))
        printf("Yes\n");
    else if((s[0]=='A') && (s[1]=='B') && (s[2]=='B'))
        printf("Yes\n");
    else if((s[0]=='B') && (s[1]=='B') && (s[2]=='A'))
        printf("Yes\n");



    else if(((s[0]=='B')&& (s[1]=='B') && (s[2]=='B'))||((s[0]=='A') && (s[1]=='A') && (s[2]=='A')))
            printf("No\n");

    return 0;
}



Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long A, B, V, W, T, d, u;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    d = abs(B-A);
    u = V-W;
    if(u*T >= d)    cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

int main() {
	ll n, m;
	cin >> n >> m;
	ll res = 0;
	res += min(n, m / 2);
	if (n < m / 2) {
		res += (m - 2 * n) / 4;
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int ans = 0;
	string s;
	cin >> s;
	int l = 0,r = s.length() - 1;
	while(l < r){
		if(s[l] == s[r]){
			l++;
			r--;
		}else if(s[l] == 'x'){
			ans++;
			l++;
		}else if(s[r] == 'x'){
			ans++;
			r--;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
   string s;
   cin >> s;
   set<char> st;
   for(auto it: s) st.insert(it);
   st.size() > 1 ? cout << "Yes" : cout << "No";
  return 0;
} //good night.

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

int main() {
  int H, W;
  int h, w;
  int ans;

  cin >> H >> W >> h >> w;

  ans = (H * W) - (W*h + H*w - h*w);

  cout << ans << endl;
}


Measured memory_bytes: 256
import string
number   = int(input())
name_tag = []

while number > 0:
  q, a = divmod(number-1, 26)
  name_tag.append(a)
  number = q
  
reverse_name_tag = reversed(name_tag)
for i in reverse_name_tag:
  print(string.ascii_lowercase[i], end="")

Measured memory_bytes: 9844
#include <iostream>
#include <string>
#include <string.h>
#include <strings.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int v;
    cin>>v;
    int a[v];
    int a2[v];
    int a3[v];
for(int y=0;y<v;y++){
    cin>>a[y];
    cin>>a2[y];
    a3[y]=(a2[y]-a[y])+1;
}
int s=0;
for(int t=0;t<v;t++){
    s=s+a3[t];
}
cout<<s;
    return 0;
}


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

using namespace std;

string word;
string par;

int cnt;

void inp(){
	cin >> word;
	transform(word.begin(),word.end(),word.begin(),::toupper);
	string line;
	while(true){
		cin >> line;
		if(!line.compare("END_OF_TEXT")) break;
		transform(line.begin(),line.end(),line.begin(),::toupper);
		cnt += !line.compare(word);
	}
}

int main(){
	inp();
	printf("%d\n",cnt);
	return 0;
}

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

int main() {
	int ans = 0, tmp = 1;
	size_t N;
	cin >> N;
	vector<int> a(N);
	for (auto &x : a) cin >> x;
	sort(a.begin(), a.end());
	for (size_t i = 1; i < N; ++i) {
		if (a[i - 1] == a[i]) ++tmp;
		else {
			if (tmp >= a[i - 1]) ans += tmp - a[i - 1];
			else ans += tmp;
			tmp = 1;
		}
	}
	if (tmp >= a[N - 1]) ans += tmp - a[N - 1];
	else ans += tmp;
	cout << ans;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);

  int count[MAX] = {0};
  rep(i, 1, n+1) {
    rep(j ,i, n+1) {
      int l = min(j-i, abs(x-i)+abs(y-j)+1);
      count[l]++;
    }
  }
  rep(i, 1, n) {
    printf("%d\n", count[i]);
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;

const int inf = (int)1e9; 

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}


int main(void){
	int X;
	cin>>X;
	X = X/200;
	cout<<10-X<<endl;
	return 0;
}

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

int main(){
  int N, M; cin >> N >> M;
  vector< pair<int, int> > stu(N), chk(M);
  for(int i = 0; i < N; i++){
    int x, y; cin >> x >> y;
    stu[i] = make_pair(x, y);
  }
  for(int i = 0; i < M; i++){
    int x, y; cin >> x >> y;
    chk[i] = make_pair(x, y);
  }
  
  for(int i = 0; i < N; i++){
    int idx = -1, dst = (int)1e9;
    for(int j = 0; j < M; j++){
      int tdst = abs(stu[i].first - chk[j].first) + abs(stu[i].second - chk[j].second);
      if(tdst < dst) {
        idx = j + 1; dst = tdst;
      }
    }
    cout << idx << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#ABC124-C
s = input()
cnt1 = 0
cnt2 = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == '1':
            cnt1 += 1
        else:
            cnt2 += 1
            
print(min(cnt1,cnt2))


Measured memory_bytes: 3188
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
    if( m == 0 ) return 1;
    if( i >= n ) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m- A[i]);
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for( i = 0; i < q; i++ ) {
      scanf("%d", &M);
      if ( solve(0, M) )printf("yes\n");
      else printf("no\n");
  }
  
  return 0;
}


Measured memory_bytes: 2096
#include <stdio.h>

struct dice {
	int area[6];
};

void diceroll(const char order, struct dice *dice)
{
	int temp;

	if (order == 'N') {
		temp = dice->area[0];
		dice->area[0] = dice->area[1];
		dice->area[1] = dice->area[5];
		dice->area[5] = dice->area[4];
		dice->area[4] = temp;
	}
	else if (order == 'W') {
		temp = dice->area[0];
		dice->area[0] = dice->area[2];
		dice->area[2] = dice->area[5];
		dice->area[5] = dice->area[3];
		dice->area[3] = temp;
	}
	else if (order == 'E') {
		temp = dice->area[0];
		dice->area[0] = dice->area[3];
		dice->area[3] = dice->area[5];
		dice->area[5] = dice->area[2];
		dice->area[2] = temp;
	}
	else if (order == 'S') {
		temp = dice->area[0];
		dice->area[0] = dice->area[4];
		dice->area[4] = dice->area[5];
		dice->area[5] = dice->area[1];
		dice->area[1] = temp;
	}
}

int main() {
	struct dice dice1;
	int q;
	int qon, qfront;
	char order;
	int i, j, k, l;

	scanf("%d %d %d %d %d %d", &dice1.area[0], &dice1.area[1], &dice1.area[2], &dice1.area[3], &dice1.area[4], &dice1.area[5]);
	scanf("%d", &q);

	for (i = 0; i < q; i++) {
		scanf("%d %d", &qon, &qfront);

		for (l = 0; l < 2; l++) {
			for (k = 0; k < 4; k++) {
				for (j = 0; j < 4; j++) {
					diceroll(order, &dice1);
					if (dice1.area[0] == qon && dice1.area[1] == qfront) {
						printf("%d\n", dice1.area[2]);
						goto loopend;
					}
					order = 'W';
				}
				order = 'N';
			}

			for (k = 0; k < 4; k++) {
				for (j = 0; j < 4; j++) {
					diceroll(order, &dice1);
					if (dice1.area[0] == qon && dice1.area[1] == qfront) {
						printf("%d\n", dice1.area[2]);
						goto loopend;
					}
					order = 'W';
				}
				order = 'S';
			}
		}

	loopend:;

	}

	return 0;
}


Measured memory_bytes: 2052
N,Y=map(int,input().split())
flag=False
for i in range(0,N+1):
    for j in range(N-i+1):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i,j,k)
            flag=True
            break
    if flag:
        break
else:
    print(-1,-1,-1)


Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 50
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, a[maxn][maxn], Ans, vis[maxn];
il void check() {
	rep(i, 1, n) {
		rep(j, 1, n) {
			if(a[i][j]==-1) continue;
			if(vis[i] == 1 && vis[j] == 1 && a[i][j] == 0) return;
			if(vis[i] == 1 && vis[j] == 0 && a[i][j] == 1) return; 
		}
	}
	int ans = 0;
	rep(i, 1, n) ans += vis[i];
	Ans = max(Ans, ans);
}
il void dfs(int u) {
	if(u == n + 1) return (void)(check());
	vis[u] = 0, dfs(u + 1), vis[u] = 1, dfs(u + 1);
}
int main() {
	n = read(), mem(a, -1);
	rep(i, 1, n) {
		m = read();
		rep(j, 1, m) {
			int x = read(), y = read();
			a[i][x] = y;
		}
	}
	dfs(1), cout << Ans;
	return 0;
}

Measured memory_bytes: 256
N, S = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1,N+1):
    for j in range(S+1):
        if j-A[i-1] >= 0:
            dp[i][j] = (dp[i-1][j]*2 + dp[i-1][j-A[i-1]]) % 998244353
 
        else:
            dp[i][j] = dp[i-1][j]*2 % 998244353
 
print(dp[N][S])

Measured memory_bytes: 132564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+1;
const dd eps = 1e-8;
const ll mod = 1e9+7;

ll fac[N],ans,n,a,b;


inline ll qpow(ll a,ll b){
  ll ans = 1;
  a = (a%mod + mod)%mod;
  for(;b;b>>=1){
    if(b&1) ans = (a*ans%mod)%mod;
    a = (a*a)%mod;
  }
  return ans;
}

ll comb(ll n,ll r){
  ll ans=1;
  for(int i=1;i<=r;i++)
    {
      ans = (ans*(n-i+1)%mod *qpow(i,mod-2)%mod)%mod;
    }
  return ans;
}

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>a>>b;
  ans = qpow(2,n) - 1;
  ans -= comb(n,a)+comb(n,b);
  ans = (ans%mod+mod)%mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d.begin(),d.end());
    int ans=0;
    for(int i=0;i<n;i++){
        if(d[i]==d[i-1]) continue;
        else ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
int g(int x,int y){
	if(y==0)return x;
	return g(y,x%y);
}

int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b))printf("%d %d\n",g(a,b),a/g(a,b)*b);
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    ll ans = 0;
    for (int i = n; i--;) {
        ll cnt = (a[i] + ans) / b[i];
        ll rem = (a[i] + ans) % b[i];
        if (rem) cnt++;
        ans += b[i] * cnt - (a[i] + ans);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val m = scanner.nextInt()
	val arr = Array(m){Pair(scanner.nextInt(), scanner.nextInt())}
	arr.sortBy { it.second }
	var ans = 0
	var last = 0
	arr.forEach {
		if (last<it.first){
			ans++
			last = it.second-1
		}
	}
	println(ans)
}

Measured memory_bytes: 110644
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[101],ans;
long long gcd(long long x,long long y)
{
	if(y==0)
	return x;
	return gcd(y,x%y);
}
long long lcm(long long x,long long y)
{
	return x/gcd(x,y)*y;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%lld",a+i);
	if(n<2)
	{
		cout<<a[1]<<endl;
		return 0;
	}
	ans=lcm(a[1],a[2]);
	for(int i=3;i<=n;i++)
	ans=lcm(a[i],ans);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりの計算方法で実装
 */
public class Main {

	/** 平均気温の係数 */
	private static final int D = 6;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), t = scanner.nextInt() * 1000, a = scanner.nextInt() * 1000;
			Queue<Data> queue = new PriorityQueue<>();
			IntStream.range(0, n).forEach(i -> {
				int h = scanner.nextInt();
				queue.add(new Data(i + 1, Math.abs(t - h * D - a)));
			});
			System.out.println(queue.peek().index);
		}
	}

	/**
	 * 番号と平均気温を表すクラス
	 */
	private static class Data implements Comparable<Data> {
		/** 番号 */
		int index;
		/** 平均気温 */
		double t;

		Data(int index, double t) {
			super();
			this.index = index;
			this.t = t;
		}

		@Override
		public int compareTo(Data data) {
			return Double.compare(t, data.t);
		}
	}
}


Measured memory_bytes: 39140
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int n,m,X,Y;
bool work(){
    cin>>n>>m>>X>>Y;
    int mxx = -INF;
    for (int i=1,x;i<=n;i++){
        cin>>x;
        mxx = max(mxx, x);
    }
    int mxy = INF;
    for (int i=1,y;i<=m;i++){
        cin>>y;
        mxy = min(mxy, y);
    }
    mxx++;
    if (mxx>mxy) return false;
    if (mxy <= X ) return false;
    if (mxx > Y) return false;
    return true;
}
int main(){
    if (work()) puts("No War");else puts("War");
    return 0;
}



Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()

ans = ((1900 * m) + (n - m) * 100) * (2 ** m)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    if((a==1&&b==2)||(a==2&&b==1))
    {
        printf("3\n");
    }
    else if((a==1&&b==3)||(a==3&&b==1))
    {
        printf("2\n");
    }
    else if((a==3&&b==2)||(a==2&&b==3))
    {
        printf("1\n");
    }

    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(unsigned int i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define sum(a) accumulate(begin(a), end(a), 0)


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

int gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int gcd(ll a, ll b, ll c) {
	return gcd(a, gcd(b, c));
}


int main() {
	ll N, R;

	cin >> N >> R;

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + (100 * (10 - N)) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*
    ||S|A|M|R|A|T||
    Author:codingsamrat
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long 
#define ld long double
#define INF LONG_MAX
#define pb push_back
#define gcd __gcd
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define vii vector<int>
#define vll vector<long long>
typedef long long  ll;

ll bpow(ll a, ll b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
	int n,k;
	cin>>n>>k;
	int a[n];
	f(i,0,n)
	cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	f(i,0,k)
	sum+=a[i];
    cout<<sum; 
return 0;

}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i, N) cin >> a[i];

  int max_abs = 0;
  rep(i, N) if (abs(a[max_abs]) < abs(a[i])) max_abs = i;

  cout << 2*N-1 << endl;
  rep(i, N) cout << max_abs+1 << " " << i+1 << endl;
  if (a[max_abs] < 0) for(int i=N; i>1; i--) cout << i << " " << i-1 << endl;
  else for(int i=1; i<N; i++) cout << i << " " << i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b=0;
  cin>>a;
  if(a>=105)b++;
  if(a>=135)b++;
  if(a>=165)b++;
  if(a>=189)b++;
  if(a>=195)b++;
  cout<<b;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n;

int f(){
    int aux = n;
    int sum = 0;
    while(aux){
        sum += aux%10;
        aux /= 10;
    }
    return sum;
}

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    int temp = f();
    if(n % temp == 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct _hoge {
    long long int value;
    int num;
} hoge;

long long int cmp( const void *p, const void *q ) {
    return ((hoge*)p)->value - ((hoge*)q)->value;
}

int main(void) {
    int n, m;
    int i;
    hoge t[100000];
    long long int money = 0;
    scanf("%d %d", &n, &m);
    for (i=0; i<n; i++) {
        scanf("%lld %d", &t[i].value, &t[i].num);
    }
    qsort(t, n, sizeof(hoge), cmp);
    i =0;
    while(m>0) {
        if(t[i].num <= m) {
            money += t[i].num * t[i].value;
        } else {
            money += m * t[i].value;
        }
        m -= t[i].num;
        i += 1;
    }
    printf("%lld\n", money);
    return 0;
}


Measured memory_bytes: 3324