akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;
int w, h, n;
char map[1024][1024];
// 各点到当前工厂的距离
int d[1024][1024];
const int direction[4][2] = {
    { -1, 0 },
    { 1, 0 },
    { 0, -1 },
    { 0, 1 },
};
 
int factory[16][2];
typedef pair<int, int> P;
 
 
 
//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const int & sx 起点x
// Parameter: const int & sy 起点y
// Parameter: const int & gx 终点x
// Parameter: const int & gy 终点y
//************************************
int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
{
    //memset(d, -1, sizeof(d));
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            d[j][i] = -1;
        }
    }
    queue<P> que;
    que.push(P(sx, sy));
    d[sx][sy] = 0;
    while (que.size())
    {
        const P p = que.front(); que.pop();
        // 如果是终点就结束
        if (p.first == gx && p.second == gy)
        {
            break;
        }
 
        // 四方向漫游
        for (int i = 0; i < 4; ++i)
        {
            int nx = p.first + direction[i][0];
            int ny = p.second + direction[i][1];
            // 是否可以移动，并且该点没有访问过
            if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
            {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
 
    return d[gx][gy];
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
    cin >> h >> w >> n;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cin >> map[j][i];
        }
    }
 
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (map[j][i] == 'S')
            {
                factory[0][0] = j;
                factory[0][1] = i;
                map[j][i] = '.';
            }
            else if (isdigit(map[j][i]))
            {
                int index = map[j][i] - '0';
                factory[index][0] = j;
                factory[index][1] = i;
            }
        }
    }
 
    int step = 0;
    for (int i = 0; i < n; ++i)
    {
        // 按顺序吃遍中华
        step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
    }
     
    cout << step << endl;
 
    return 0;
}


Measured memory_bytes: 8108
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    umap<lli, lli, custom_hash> mp;
    lli limit = sqrt(n) + 2;
    loop(i, 1, limit){
        loop(j, 1, limit){
            loop(k, 1, limit){
                lli temp = i*i + j*j + k*k + i*j + j*k + i*k;
                mp[temp]++;
            }
        }
    }
    vll ans(n+1, 0);
    loop(i, 1, n+1)
        if(mp.find(i) != mp.end())
            ans[i] = mp[i];
    loop(i, 1, n+1)
        cout<<ans[i]<<" ";
    cout<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int pop_count(int bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(){
    int N;
    cin >> N;
    const int M = 1<<20;
    static int num[M];
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        num[a]++;
    }
    for(int k=0; k<20; k++) for(int i=M-1; i>=0; i--) if(!nth_bit(i, k)) num[i] += num[i+(1<<k)];

    vector<int64_t> pw2(N+1, 1);
    for(int i=1; i<=N; i++) pw2[i] = pw2[i-1] * 2 % MOD;


    int64_t ans = 0;
    for(int i=0; i<M; i++){
        int64_t res = pw2[num[i]] - 1;
        if(pop_count(i)%2) res *= -1;
        add(ans, MOD+res);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}
 
template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int n, x;
set<int> S;

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		cin>>x;
		S.insert(x);
	}
	if (S.size() == n)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    int res = 0;
    rep(i, 0, N) {
        int a;
        cin >> a;
        if(a >= K) {
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
//無向グラフを隣接行列を用いて受け取る

#include<iostream>
using namespace std;

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]){
    bool all_visited = true;
    for(int i = 0; i < n; i++){
        if(visited[i] == false){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }

    int ret = 0;
    for(int i = 0; i < n; i++){
        if(graph[v][i] == false){
            continue;
        }
        if(visited[i]){
            continue;
        }
        visited[i] = true;
        ret += dfs(i, n, visited);
        visited[i] = false;
    }

    return ret;
}

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }

    bool visited[nmax];
    for(int i = 0; i < n; i++){
        visited[i] = false;
    }

    //頂点1を訪問済みとする
    visited[0] = true;
    //再帰関数呼び出し
    cout << dfs(0, n, visited) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  int n;cin>>n;int fac[100];fill(fac,fac+100,0);vector<int> pri;bool pp[100];fill(pp,pp+100,true);pp[0] = pp[1] = false;
  repd(i,2,100){
    if(!pp[i])continue;
    repd(j,2,100){
      if(i*j >= 100)break;
      pp[i*j] = false;
    }
  }
  rep(i,100)if(pp[i])pri.push_back(i);
  repd(i,2,n+1){
    int t = i;
    rep(j,pri.size()){
      while(!(t%pri[j])){
        t /= pri[j];
        fac[pri[j]]++;
      }
    }
  }
  sort(fac,fac+100,greater<int>());
  ll c74 = 0, c24 = 0, c14 = 0, c4 = 0, c2 = 0;
  rep(i,100){
    if(fac[i] >= 74){
      c74++;c24++;c14++;c4++;c2++;
    }else if(fac[i] >= 24){
      c24++;c14++;c4++;c2++;
    }else if(fac[i] >= 14){
      c14++;c4++;c2++;
    }else if(fac[i] >= 4){
      c4++;c2++;
    }else if(fac[i] >= 2){
      c2++;
    }
  }
  cout << c74 + (c14 * (c4-1)) + (c24 * (c2-1)) + (c4 * (c4-1) * (c2 - 2) / 2) << endl;
}


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

using namespace std;

long long int binpow(long long int a, long long int p, long long int D){
  long long int res = 1LL;
  while(p > 0){
    if(p & 1) res = (res * a) % D;
    a = (a * a) % D;
    p >>= 1;
  }
  return res;
}

//long long int fac(long long int a, long long int D){
//  long long int res = 1LL;
//  while(a > 0){
//    res *= a;
//    a--;
//  }
//  return res;
//}

int main(){
  long long int D = 1000000007LL;
  long long int W, H, A, B;
  cin >> H >> W >> A >> B;
  vector<long long int> V(H+W+1);
  V[0] = 1LL;
  for(long long int i = 1; i < V.size(); i++){
    V[i] = (V[i-1]*i) % D;
  }
  vector<long long int> I(H+W+1);
  I[0] = 1LL;
  for(long long int i = 1; i < I.size(); i++){
    I[i] = binpow(V[i], 1000000005LL, D);
  }
  long long int ans = 0LL;
  for(long long int i = B+1; i <= W; i++){
    long long int in = V[i-1+H-A-1] * I[H-A-1] % D * I[i-1] %D;
    long long int out = V[W-i+A-1] * I[A-1] % D * I[W-i] %D;
    long long int tmp = (in * out) % D;
    ans = (ans + tmp) % D;
  }
  //cout << ans << endl;
  //for(long long int i = B+1; i <= W; i++){
  //  long long tmp = (V[W-i+1 + A] * (I[W-i+1] * I[A]) % D)%D;
  //  ans = (ans + tmp)%D;
  //}
  
  cout << ans << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, M, C, sum = 0, ans = 0;
  cin >> N >> M >> C;
  
  vector<int> vecA(M), vecB(M);
  
  for(int i = 0; i < M; i++){
    cin >> vecB.at(i);
  }
  for(int j = 0; j < N; j++){
    for(int k = 0; k < M; k++){
      cin >> vecA.at(k);
      sum += vecB.at(k) * vecA.at(k);
    }
    if(sum + C > 0){
      ans += 1;
      sum = 0;
    }
    else{
      sum = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
    public class Main {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(Math.min(A*N, B));
      }
    }

Measured memory_bytes: 23764
def f(n):
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int, raw_input().split())
    if a in D: D[a]+=b*c
    else:
      D[a]=b*c
      A.append(a)
  B=[i for i in A if D[i]>=1e6]
  if B==[]: B=["NA"]
  return B

while 1:
  n=input()
  if n==0: break
  for e in f(n): print e

Measured memory_bytes: 4356
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();

            input1 += input1.Substring(0, input2.Length - 1);

            string judge = "No";
            for (int i = 0; i < input1.Length - input2.Length + 1; i++)
            {
                if (input2 == input1.Substring(i, input2.Length))
                {
                    judge = "Yes";
                    break;
                }
            }

            Console.WriteLine(judge);
        }
    }
}

Measured memory_bytes: 8920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s, t;
  cin >> s >> t;
  int x = stoi(s+t);
  for (int i = 1; i*i <= 100100; i++) {
    if (x == i * i) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

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

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 19:25:17 2020

@author: Kanaru Sato
"""

def parin(s):
    l = list(s)
    flag = 0
    for i in range(len(l)//2):
        if l[i] != l[len(s)-i-1]:
            flag = 1
    if flag == 0:
        return True
    else:
        return False


s = list(input())

if parin(s) == True:
    if parin(s[0:len(s)//2]) == True and parin(s[len(s)//2+1:len(s)]) == True:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int g[15][15],cr[15][32768],ins[32768],dp[32768][15];
int main (){
	int i,j,k,t,u,v,c,l,n,m,s=0;
	scanf ("%d%d",&n,&m);
	for (i=1;i<=m;i++)
	{scanf ("%d%d%d",&u,&v,&c);
	u--;v--;g[u][v]=g[v][u]=c;s+=c;
	}
	for (i=0;i<n;i++)
	{for (k=0;k<n;k++)
	{for (j=0;j<(1<<n);j++)
	{if ((1<<k)&j) 
	{cr[i][j]+=g[i][k];}
	}
	}
	}
	for (i=0;i<(1<<n);i++)
	{for (j=0;j<n;j++)
	{for (k=0;k<n;k++)
	{if ((1<<j)&i)
	{if ((1<<k)&i)
	{ins[i]+=g[j][k];}
	}
	}
	}
	ins[i]/=2;
	}
	memset(dp,-1,sizeof(dp));
	dp[1][0]=0;
	for (i=1;i<(1<<n);i++)
	{for (j=0;j<n;j++)
	{if (dp[i][j]<0) {continue;}
	int tar=i-(1<<j),b=(1<<n)-1-i;
	for (k=0;k<n;k++)
	{if (i&(1<<k)) {continue;}
	if (g[j][k]<=0) {continue;}
	dp[i+(1<<k)][k]=max(dp[i+(1<<k)][k],dp[i][j]+g[j][k]);
	}
	for (t=b;t;t=(t-1)&b)
	{dp[t|i][j]=max(dp[t|i][j],dp[i][j]+cr[j][t]+ins[t]);}
	}
	}
	int ans=0;
	for (i=0;i<(1<<n);i++)
	{ans=max(ans,dp[i][n-1]);}
	printf ("%d",s-ans);
	return 0;
}
	
	
	
	

Measured memory_bytes: 4224
from math import sqrt
n = int(input())
a = list()
sum = 0
for i in range(n):
    x, y = map(int, input().split())
    a.append((x, y))
for i in range(n):
    for j in range(i + 1, n):
        v1, v2 = a[i], a[j]
        sum += sqrt((v1[0] - v2[0]) ** 2 + (v1[1] - v2[1]) ** 2)
print(sum*2/n)


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

int main(){
	int A, B, X;
	cin >> A >> B >> X;
	if(X<A){
		cout << "NO" << endl;
	}else if((A+B)>X){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define int long long
#define ll unsigned long long
#define ld long double
#define mx 100005
#define mod 1000000007
#define fr first
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{
     string s1;
     cin >> s1;
     for(int i=0; s1[i]; i++){
        if(s1[i] == '7'){
            puts("Yes");
            return;
        }
     }


     puts("No");
}

signed main()
{
   //freopen("text.txt", "r", stdin);
   //freopen("text2.txt", "w", stdout);
   fast;
   int kk=0;
   //cin >> tc;
   //scanf("%d", &tc);
   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 3640
n=int(input())
s=input()
a=0
b=0
p=0
for i in range(len(s)):
  if s[i]=="(":
     a+=1
  if s[i]==")":
     b+=1
     a-=1
     if a<0:
       p+=1
       a=0
print("("*p+s+")"*a)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int int_compare(const void*a,const void*b){return *(int*)a-*(int*)b;}
int main(void)
{
  int n;
  int a[100000];
  int num[1000000]={0};
  int sum,max;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),int_compare);
  for(int i=0;i<n;i++){
    num[a[i]]++;
  }
  max=0;
  for(int i=0;i<=100000;i++){
    sum=0;
    if(i>0)sum+=num[i-1];
    sum+=num[i];
    if(i<100000)sum+=num[i+1];
    if(sum>max)max=sum;
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 4860
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<string>
#include<iomanip>

//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n;
long double dp[3000];

void marota(){
    std::cin>>n;
    dp[0]=1;
    for (int i=1;i<=n;i++){
        long double a;
        std::cin>>a;
        for (int j=i;j>=1;j--){
            dp[j]=dp[j-1]*a+dp[j]*(1-a);
        }
        dp[0]*=(1-a);
    }   
    long double ans=0L;
    for (int i=n;i>n/2;i--){
        ans+=dp[i];
    }
    std::cout<<std::setprecision(10)<<std::fixed<<ans;
}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}

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

void pok() {
  cout << "Yes" << endl;
}
void png() {
  cout << "No" << endl;
}

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

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

int main() {
	int i;
	int w, n;
	int table[30];
	scanf("%d %d", &w, &n);

	/* init table */
	for (i = 0; i < w; i++) {
		table[i] = i + 1;
	}

	/* apply swap */
	for (i = 0; i < n; i++) {
		int a, b, x;
		scanf("%d,%d", &a, &b);
		x = table[a-1];
		table[a-1] = table[b-1];
		table[b-1] = x;
	}

	/* output */
	for (i = 0; i < w; i++) {
		printf("%d\n", table[i]);
	}

	return 0;
};

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  vector<int> cost;
  for(int i=0;i<N;i++){cin>>a[i];}
  for(int i=-100;i<=100;i++){
    int temp=0;
    for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
    cost.push_back(temp);
  }
  int ans=*min_element(cost.begin(),cost.end());
  cout<<ans<<endl;
}

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

int main() {
    int a, b, x;
    cin >> a >> b >> x;

    if (x >= a && x <= a + b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


void solve(){
    ll N; cin  >> N;
    vector<ll> X(N); for(auto& in:X) cin >> in;
    vector<ll> T = X;
    sort(X.begin(),X.end());
    ll M = X[N/2 - 1];
    vector<ll> ans(N);
    for(int i = 0; i < N;i++){
        if(T[i] <= M){
            cout << X[N/2] << endl;
        }else{
            cout << X[N/2 - 1] << endl;
        }
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 6912
import java.util.*;
import java.io.*;

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();
        if(A==B && B==C) System.out.println("Yes");
        else System.out.println("No");


    }
}


Measured memory_bytes: 22996
def readinput():
    n=int(input())
    d=[]
    for i in range(n):
        d.append(int(input()))
    return (n,d)

def main(n,d):
    d.sort(reverse=True)
    npre=d[0]
    ndan=1
    for i in range(1,n):
        if(d[i]<npre):
            npre=d[i]
            ndan+=1
    
    return ndan

if __name__=='__main__':
    n,d=readinput()
    ans=main(n,d)
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = (int)1e5;
int dp[MAX_N + 1];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for (int i = 0; i <= MAX_N; ++i){
		dp[i] = MAX_N;
	} // end for

	dp[0] = 0;
	// 1 円
	for (int i = 1; i <= MAX_N; ++i){
		dp[i] = min(dp[i], dp[i-1] + 1);
	} // end for

	int curr = 6;
	int add = 6;
	while(true){
		bool update = false;
		for (int i = curr; i <= MAX_N; ++i){
			dp[i] = min(dp[i], dp[i-curr] + 1);
			update |= true;
		} // end for
		if (!update) break;
		curr *= add;
	} // end while

	curr = 9;
	add = 9;
 	while(true){
		bool update = false;
		for (int i = curr; i <= MAX_N; ++i){
			dp[i] = min(dp[i], dp[i-curr] + 1);
			update |= true;
		} // end for
		if (!update) break;
		curr *= add;
	} // end while

	int N; cin >> N;

	cout << dp[N] << endl;
 	
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>

int a, b;

int GCD(int n1, int n2){
	if(n2 == 0) return n1;
	return GCD(n2, n1 % n2);
}

int main(){
	scanf("%d %d", &a, &b);
	int ans = GCD(a, b);
	printf("%d\n", ans);
	return 0;
}

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


def solve(N: int, A: int, B: int, X: "List[int]"):
    Sum = 0
    for n in range(1, N):
        walk_cost = (X[n] - X[n-1]) * A
        if walk_cost > B:
            Sum += B
        else:
            Sum += walk_cost
    print(Sum)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15148
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a = deque(a)
d = 0
i = 1
for _ in range(n):
    b = a.popleft()
    if i == b:
        d +=1
        i += 1
        
print(n-d if d !=0 else -1)

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

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000;

int main() {
	int n;
	int s[100];
	cin >> n;
	int count = 0;
	REP(i, n) {
		cin >> s[i]; count += s[i];
	}
	if (count % 10 != 0) { print(count); return 0; }
	sort(s, s + n);
	REP(i,n)if((count-s[i])%10!=0) { print(count-s[i]); return 0; }
	print(0);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int a, b;
  cin >> a >> b;

  int _a=0, _b=0;
  rep(i, a) _b += pow(10, i) * b;
  rep(i, b) _a += pow(10, i) * a;

  cout << max(_a, _b) << endl;
  return 0;
}

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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int tb=0;
  int tw=0;
  for(int i=0;i<N;i++){
    if(s.at(i)=='#'){
      tb++;
    }else{
      tw++;
    }
  }
  int64_t ans;
  int cb=0;
  int cw=0;
  ans=tw;
  if(s.at(0)=='#'){
    cb++;
  }else{
    cw++;
  }
  for(int i=1;i<N;i++){
    if(s.at(i)!=s.at(i-1)){
      int sum=cb+(tw-cw);
      if(ans>sum){
        ans=sum;
      }
    }
    if(s.at(i)=='#'){
      cb++;
    }else{
      cw++;
    }
  }
  if(ans>tb){
    ans=tb;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
S = input()
P = 2019
N = len(S)

T = [0] * (N + 1)
T[0] = 0
e = 1
for i in range(N):
  T[i + 1] = T[i] + int(S[N - i - 1]) * e
  T[i + 1] %= P
  e *= 10
  e %= P

a = {}
for i in range(N + 1):
  if T[i] in a:
    a[T[i]] += 1
  else:
    a[T[i]] = 1

num = 0
if P % 2 == 0 or P % 5 == 0:
  for i in range(N):
    if int(S[i]) % P == 0:
      num += 1 + i
else:
  for k in a:
    num += a[k] * (a[k] - 1) // 2

print(num)


Measured memory_bytes: 16340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a;
  cin>>a;
  long double b;
  cin>>b;
  long long c=round(b*100);
  long long kotae=a*c/100;
  cout<<kotae<<endl;
  return 0;
}

    


Measured memory_bytes: 3796
def func(x):
  if x%2==0:
    return x//2
  else:
    return 3*x + 1
A = [True for i in range(1000001)]
N = int(input())
count = 1
while A[N]:
  A[N] = False
  N = func(N)
  count += 1
print(count)

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

int main()
{
    int n, k, q;
    std::cin >> n >> k >> q;

    std::vector<long long> points(n, k);
    std::vector<int> a(q);
    for (int i = 0; i < q; i++) {
        std::cin >> a[i];
        a[i]--;
    }

    for (int i = 0; i < q; i++) {
        points[a[i]]++;
    }

    for (int i = 0; i < n; i++) {
        std::cout << (points[i] > q ? "Yes" : "No") << std::endl;
    }
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	k := K
	ans := 1
	for N >= K {
		K *= k
		ans++
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

string s;

int hsh(int pw) {
    char x[4];
    if (pw < 10) {
        x[0] = x[1] = x[2] = '0';  x[3] = char(pw + '0');
    }
    else if (pw < 100){
        x[0] = x[1] = '0'; x[2] = char(pw/10 + '0');  x[3] = char(pw%10 + '0');
    }
    else if (pw < 1000){
        int ic = pw;
        x[0] = '0'; 
        x[1] = char(ic/100 + '0');
        ic %= 100;
        x[2] = char(ic/10 + '0');  
        x[3] = char(ic%10 + '0');
    }
    else {
        int ic = pw;
        x[0] = char(ic/1000 + '0'); 
        ic %= 1000;
        x[1] = char(ic/100 + '0');
        ic %= 100;
        x[2] = char(ic/10 + '0');  
        x[3] = char(ic%10 + '0');
    }
    
    int depth = 0;
    vector<int> ope, value[30];
    for (int i = 0; i < s.size(); i++) {
        if (char(s[i]) == '[') depth++;
        else if (char(s[i]) == ']') {
            if (ope[ope.size() - 1] == 1) 
            value[depth - 1].push_back(value[depth][0] | value[depth][1]);
            if (ope[ope.size() - 1] == 2) 
            value[depth - 1].push_back(value[depth][0] & value[depth][1]);
            if (ope[ope.size() - 1] == 3) 
            value[depth - 1].push_back(value[depth][0] ^ value[depth][1]);
            
            //cout << ope[ope.size() - 1] << endl;
            ope.pop_back();
            value[depth].pop_back();
            value[depth].pop_back();
            
            depth--;
        }
        else if (char(s[i]) == '+') ope.push_back(1);
        else if (char(s[i]) == '*') ope.push_back(2);
        else if (char(s[i]) == '^') ope.push_back(3);
        else {
            if (char(s[i]) == 'a') value[depth].push_back(int(x[0] - '0'));
            if (char(s[i]) == 'b') value[depth].push_back(int(x[1] - '0'));
            if (char(s[i]) == 'c') value[depth].push_back(int(x[2] - '0'));
            if (char(s[i]) == 'd') value[depth].push_back(int(x[3] - '0'));
        }
    }
    
    return value[0][0];
}

int main(void){
    while (1) {
        cin >> s;
        if (s == ".") return 0;
        
        int p;
        cin >> p;
        
        int check = hsh(p);
        
        int ans = 0;
        for (int i = 0; i < 10000; i++) {
            if (hsh(i) == check) ans++;
        }
        
        cout << check << " " << ans << endl;
    }
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	V a(n + 1);
	int i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	V L(n + 2);
	L[1] = a[1];
	V R(n + 2);
	R[n] = a[n];
	for (i = 2; i <= n; i++) {
		L[i] = gcd(L[i - 1], a[i]);
		R[n + 1 - i] = gcd(R[n + 2 - i], a[n + 1 - i]);
	}
	L[0] = R[2];
	R[n + 1] = L[n - 1];
	ll ans = 0;
	for (i = 1; i <= n; i++) {
		chmax(ans, gcd(L[i - 1], R[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define llinf LLONG_MAX/3
#define LLINF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PLL pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VLL vector<long long>
#define VULL vector<unsigned long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SCD second

using namespace std;

const LL ANS_MAX = 1000000007;

LL calc(LL s0, LL s1, LL s2)
{
	return MAX(s0, MAX(s1, s2)) - MIN(s0, MIN(s1, s2));
}

// ARC074C
int main()
{
	LL ret;

	LL H;
	LL W;
	cin >> H >> W;

	if (H % 3 == 0 || W % 3 == 0) {
		ret = 0;
	}
	else {
		{
			LL h0 = ceil((double)H / 3);
			LL w0 = W;
			LL h1 = H - h0;
			LL w1 = W / 2;
			LL h2 = H - h0;
			LL w2 = W - w1;
			ret = calc(h0 * w0, h1*w1, h2* w2);
		}
		{
			LL h0 = floor((double)H / 3);
			LL w0 = W;
			LL h1 = H - h0;
			LL w1 = W / 2;
			LL h2 = H - h0;
			LL w2 = W - w1;
			ret = MIN(ret, calc(h0 * w0, h1 * w1, h2 * w2));
		}
		{
			LL h0 = H;
			LL w0 = ceil((double)W / 3);
			LL h1 = H / 2;
			LL w1 = W - w0;
			LL h2 = H - h1;
			LL w2 = W - w0;
			ret = MIN(ret, calc(h0 * w0, h1 * w1, h2 * w2));
		}
		{
			LL h0 = H;
			LL w0 = floor((double)W / 3);
			LL h1 = H / 2;
			LL w1 = W - w0;
			LL h2 = H - h1;
			LL w2 = W - w0;
			ret = MIN(ret, calc(h0 * w0, h1 * w1, h2 * w2));
		}
		{
			LL h = (H < W) ? H : W;
			LL w = (H > W) ? H : W;
			LL h0 = h;
			LL w0 = w / 3;
			LL h1 = h;
			LL w1 = (w - w0) / 2;
			LL h2 = h;
			LL w2 = w - w0 - w1;
			ret = MIN(ret, calc(h0 * w0, h1 * w1, h2 * w2));
		}
	}

	cout << ret << endl;

#if _DEBUG
	cin >> ret;
#endif

	return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
 
#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	ll n;
	cin>> n;
	ll ans = 10000000000000;
	for(ll i = 1; i <= (ll)sqrt(n); i++)
	{
		if(n%i == 0)
			ans = min(ans, (i - 1 + n/i - 1));
	}
	cout<< ans;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
x=1
for t in a:
    x=lcm(x,t)
x-=1
ans=0
for t in a:
    ans+=x%t
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
string o,e;
cin>>o>>e;

if(o.size()-e.size() == 0){
for(int i =0;i<o.size();i++){
	cout<<o[i]<<e[i];
}
cout<<endl;
}
else if(o.size()-e.size() == 1){
	for(int i=0;i<e.size();i++){
		cout<<o[i]<<e[i];
	}
	cout<<o[o.size()-1]<<endl;
}

}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int main()
{
	string s;
	cin >> s;

	if( s[0] != s[1] || s[0] != s[2] || s[1] != s[2] ) printf("Yes\n");
	else printf("No\n");
}

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

int main(){
  
  int N;
  int d[100] = {};
  int cnt=1;

  cin >> N;
  for(int i = 0; i<N; i++)
    cin >> d[i];
  
  sort(d,d+N);

  for(int i = 0; i<N-1; i++)
    if(d[i] != d[i+1])
      cnt++;

  cout << cnt << endl;

  return 0;
}


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

int main(){
   vector<string> week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
   string s;
   cin >> s;
   for(int i=0;i<7;i++){
      if(s==week[i]){
         cout <<abs(i-7) << endl;
      }
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int> > > shi_by_p(N);
  int kami[M], shimo[M];
  for(int i=0; i<M; i++){
    int p, y;
    cin >> p >> y;
    kami[i] = p;
    p--;
    shi_by_p[p].push_back(make_pair(y, i));
  }
//  for(int i=0; i<shi_by_p.size(); i++) for(auto j: shi_by_p[i]) sort(j.begin(), j.end());
//  for(auto j: shi_by_p) for(auto i: j) cout << i.first << endl;
//  for(auto j: shi_by_p) sort(j.begin(), j.end(), greater<pair<int, int> >());  
  for(int i=0; i<shi_by_p.size(); i++) {
    if(shi_by_p[i].size() == 0) continue;
    sort(shi_by_p[i].begin(), shi_by_p[i].end()); 
  }
//  for(auto j: shi_by_p) for(auto i: j) cout << i.first << endl;
  for(int i=0; i<N; i++){
//    if(shi_by_p[i].size() == 0) continue;
    for(int j=0; j<shi_by_p[i].size(); j++){
      auto tmp = shi_by_p[i][j];
      shimo[tmp.second] = j+1;
    }
  }
  for(int i=0; i<M; i++) cout << setfill('0') << right << setw(6) << kami[i] << setfill('0') << right << setw(6) << shimo[i] << endl;
  
  return 0;
}

Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int N;
	int A;
	int B;
	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		int ans = 0;
		for(int i=1; i<=N; i++) {
			int sum=0;
			int v = i;
			while(v != 0) {
				sum += v % 10;
				v = v/10;
			}
			if(A <= sum && sum <= B) {
				ans += i;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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

const int md = (int)1e9 + 7;
inline void add(int &a, int b) {
	a += b;
	if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
	a -= b;
	if (a < 0) a += md;
}
inline int mul(int a, int b) {
	return (int) ((long long) a * b % md);
}
int main() {
#ifdef LOCAL_DEFINE
	// freopen("data.in", "rt", stdin);
	// freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	string s;
	int d;
	cin >> s >> d;
	int n = s.length();
	vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(d, vector<int>(2)));
	dp[0][0][1] = 1;
	for (int i = 0; i < n; i++) {
		int cdig = s[i] - '0';
		for (int j = 0; j < d; j++) {
			for(int dig = 0; dig <= 9; dig++) {
				add(dp[i + 1][(j + dig) % d][0], dp[i][j][0]);
			}
			for(int dig = 0; dig <= cdig; dig++) {
				add(dp[i + 1][(j + dig) % d][dig == cdig], dp[i][j][1]);
			}
		}
	}
	int ans = md - 1;
	add(ans, dp[n][0][0]);
	add(ans, dp[n][0][1]);
	cout << ans << '\n';

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 55424
#define rep(i,n) for(int i=0;i<(n);++i)

#include<iostream>
#include<fstream>
#include<iomanip>

#include<vector>
#include<array>
#include<string>
#include<bitset>
#include<queue>
#include<list>

#include<utility>

#include<algorithm>
#include<cmath>
using ll = long long;
using namespace std;

int src(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> point(n,0);
    rep(i,q) {
        int a;
        cin>>a;
        point[a-1]++;
    }
    rep(i,n){
        if(q-point[i]<k){
            cout<<"Yes"<<"\n";
        }else{
            cout<<"No"<<"\n";
        }
    }
    return 0;
}


int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 1024
import heapq
import sys
sys.setrecursionlimit(10**7)
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
c = [-i for i in list(map(int,input().split()))]
heapq.heapify(c)
print(-sum(c)+min(c))

for i in range(n):
    if len(g[i]) == 1:
        start = i
        break

ans = [-1]*n
ans[start] = -heapq.heappop(c)
q = [start]

while q:
    now = q.pop(-1)
    for i in g[now]:
        if ans[i] == -1:
            ans[i] = -heapq.heappop(c)
            q.append(i)

for i in ans:
    print(i)

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

using namespace std;

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main(){
	double x1,y1;
	double x2,y2;
	double xq,yq;
	double x,y;
	double v1x,v1y;
	double v2x,v2y;
	double vx,vy;
	double inner;
	double d,l;
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF){
		v1x = x2-x1;
		v1y = y2-y1;
		
		v2x = xq-x1;
		v2y = yq-y1;
		
		inner = v1x*v2x + v1y*v2y; 
		l = v1x*v1x + v1y*v1y;
		
		vx = (inner/l)*v1x;
		vy = (inner/l)*v1y;
		
		x = x1+2*vx-v2x;
		y = y1+2*vy-v2y;
		
		printf("%f %f\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
}

Measured memory_bytes: 3504
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 202


ll dp1[NUM][NUM];
ll dp2[NUM][NUM][NUM];
ll dp3[NUM][NUM];
ll num_nodes[NUM];
ll in_num[NUM];
int N;
vector<int> G[NUM];


ll dfs(int node_id){

	if(G[node_id].size() == 0){
		dp1[node_id][1] = 1;
		return num_nodes[node_id] = 1;
	}

	num_nodes[node_id] = 1;

	for(int i = 0; i < G[node_id].size(); i++){
		num_nodes[node_id] += dfs(G[node_id][i]);
	}

	int num_children = (int)G[node_id].size();

	for(int i = 0; i <= num_children; i++){
		for(int k = 0; k <= num_nodes[node_id]; k++)dp3[i][k] = 0;
	}

	dp3[0][0] = 1;

	int child_node;
	for(int i = 0; i < num_children; i++){
		child_node = G[node_id][i];

		for(int c = 0; c < num_nodes[node_id]; c++){
			for(int a = 0; a <= c; a++){
				for(int b = 0; b <= num_nodes[child_node]; b++){
					dp3[i+1][c] += (dp3[i][a]*dp1[child_node][b]%MOD)*dp2[a][b][c]%MOD;
					dp3[i+1][c] %= MOD;
				}
			}
		}
	}

	for(int num = 0; num < num_nodes[node_id]; num++){
		dp1[node_id][num+1] = dp3[num_children][num];
	}

	return num_nodes[node_id];
}


int main(){

	for(int a = 0; a < NUM; a++){
		for(int b = 0; b < NUM; b++){
			dp1[a][b] = 0;
			for(int c = 0; c < NUM; c++)dp2[a][b][c] = 0;
		}
	}

	for(int i = 0; i < NUM; i++){
		dp2[i][0][i] = 1;
		dp2[0][i][i] = 1;
	}

	for(int c = 1; c < NUM; c++){
		for(int a = 1; a < NUM; a++){
			for(int b = 1; b < NUM; b++){
				dp2[a][b][c] = (dp2[a-1][b-1][c-1]+dp2[a-1][b][c-1]+dp2[a][b-1][c-1])%MOD;
			}
		}
	}

	for(int i = 0; i < N; i++)in_num[i] = 0;

	scanf("%d",&N);
	int from,to;

	for(int loop = 0; loop < N-1; loop++){
		scanf("%d %d",&from,&to);
		G[from].push_back(to);
		in_num[to]++;
	}

	int root;

	for(int i = 0; i < N; i++){
		if(in_num[i] == 0){
			root = i;
			dfs(i);
			break;
		}
	}

	ll ans = 0;
	for(int i = 1; i <= N; i++){
		ans += dp1[root][i];
		ans %= MOD;
	}

	printf("%lld\n",ans%MOD);

	return 0;
}



Measured memory_bytes: 67984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string S;
    cin >> S;
    int ans = 0;
    int N = S.length();
    for (int i = 0; i < N; i++) {
        ans += S[i] - '0';
        ans = ans % 9;
    }

    if(ans == 0){
        Yes();
    }
    else
    {
        No();
    }
    

}

Measured memory_bytes: 3720