akhauriyash/Code-Regression huggingface dataset:
from collections import deque
H, W = map(int, input().split())
S = list(input() for _ in range(H))
dist = [[-1]*W for _ in range(H)]
dist[0][0] = 1

d = deque([[0, 0, 1]])
while d:
    x, y, c = deque.popleft(d)
    if x > 0:
        if dist[x-1][y] == -1 and S[x-1][y] == ".":
            dist[x-1][y] = c+1
            deque.append(d, [x-1, y, c+1])
    if y > 0:
        if dist[x][y-1] == -1 and S[x][y-1] == ".":
            dist[x][y-1] = c+1
            deque.append(d, [x, y-1, c+1])
    if x < H-1:
        if dist[x+1][y] == -1 and S[x+1][y] == ".":
            dist[x+1][y] = c+1
            deque.append(d, [x+1, y, c+1])
    if y < W-1:
        if dist[x][y+1] == -1 and S[x][y+1] == ".":
            dist[x][y+1] = c+1
            deque.append(d, [x, y+1, c+1])

road = 0
for ss in S:
    for s in ss:
        if s == ".":
            road += 1
if dist[H-1][W-1] == -1:
    print(-1)
else:
    print(road-dist[H-1][W-1])


Measured memory_bytes: 74152
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	int a, b;
	char op;

	while (1) {
		cin >> a >> op >> b;
		if (op == '?')break;

		if (op == '+')cout << a + b << endl;
		else if (op == '-')cout << a - b << endl;
		else if (op == '*')cout << a*b << endl;
		else if (op == '/')cout << a / b << endl;

	}
	return 0;
}

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N+1)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i+1])
	}
	on := make([]int, N+1)
	n := a[1]
	cnt := 1
	for {
		if n == 2 {
			fmt.Println(cnt)
			break
		}
		if on[n] > 1 {
			fmt.Println("-1")
			break
		}
		// log.Println(n)
		cnt++
		on[n] += 1
		// log.Println(on)
		n = a[n]

	}
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n,y,z;

	cin>>n>>y>>z;

	n -= z;

	cout<<n/(y+z)<<endl;

}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 200000;

char S[MAXN + 2];

int main() {
	cin >> S;
	int N = strlen(S);
	ll ans = 0;
	for(int l = 0, r = 0; r < N; r++) {
		if(S[r] == 'W') {
			ans += r - l;
			l++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<int> G[2];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int x;
    cin >> x;
    G[x%2].pb(x);
  }
  if (G[1].size() > 2) {
    cout << "Impossible\n";
    return 0;
  }
  vector<int> a, ans;
  if (G[1].size() == 2 && M == 2) {
    a.pb(G[1][0]); a.pb(G[1][1]);
    rep(_, N/2) ans.pb(2);
  }
  else {
    // left
    if (G[1].size() >= 1) {
      int len = G[1][0];
      a.pb(len);
      rep(_, (len-1)/2) ans.pb(2);
    }
    else {
      assert(!G[0].empty());
      int len = G[0].back();
      G[0].pop_back();
      a.pb(len);
      ans.pb(len-1);
    }

    for (int x : G[0]) {
      a.pb(x);
      ans.pb(x);
    }

    // right
    if (G[1].size() >= 2) {
      int len = G[1][1];
      a.pb(len);
      ans.pb(len+1);
    }
    else ans.pb(1);
  }
  for (int x : a) cout << x << " "; cout << "\n";
  cout << ans.size() << "\n";
  for (int x : ans) cout << x << " "; cout << "\n";

  assert(a.size() == M);
  int sum = 0; for (int x : ans) sum += x;
  assert(sum == N);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<vint> vvint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

vint score(200005, 0);
vint to[200005];

void dfs(int v, int p) {
    int next_p = p + score[v];
    score[v] += p;
    for (int u : to[v]) {
        dfs(u, next_p);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    int a, b;
    rep(i, n-1) {
        //cin >> a >> b;
        scanf("%d%d", &a, &b);
        to[a-1].push_back(b-1);
    }
    int p, x;
    rep(i, q) {
        //cin >> p >> x;
        scanf("%d%d", &p, &x);
        score[p-1] += x;
    }
    dfs(0, 0);
    rep(i, n) printf("%d%s", score[i], i!=n-1 ? " " : "\n");
    return 0;
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    vll d(26,1e9);
    rep(i,n){
        string s;
        cin>>s;
        vll d2(26,0);
        rep(j,s.size()){
            d2[s[j]-'a']++;
        }
        rep(j,26){
            d[j]=min(d[j],d2[j]);
        }
    }
    rep(i,26){
        rep(j,d[i]){
            cout << (char)(i+'a');
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b;
    cin >> a >> b;
    if ( a <= b ) cout << a << endl;
    else          cout << a - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include<bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class a {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    in >> n;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

	    map<int, int> mp;
	    for(int bit=1; bit<(1<<n); bit++){
            ll sum = 0;
            for(int i=0; i<n; i++){
                if(bit & (1<<i)) sum += a[i];
            }
            mp[sum]++;
	    }

	    int q;
	    in >> q;
	    int m;
	    for(int qi=0; qi<q; qi++){
	        in >> m;
	        if(mp.count(m)) out << "yes" << enl;
	        else out << "no" << enl;
	    }
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 3260
n = int(input())
ps = map(int, input().split())

swap = 0
done = False
ok = True
for i in range(n):
    p = next(ps)
    if p != i+1:
        if done:
            ok = False
            break
        elif swap != 0:
            if swap == i+1:
                done = True
                swap = 0
            else:
                ok = False
                break
        else:
            swap = p

if ok:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
import math
mod = 10**9+7

# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m=mod):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

import sys
input = sys.stdin.readline


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

dic = {}
for a in A:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

lcm = 1
for num, count in dic.items():
    lcm *= pow(num, count, mod)
    lcm %= mod

ans = 0
for a in A:
    ans += mod_inv(a)*lcm
    ans %= mod

print(ans)

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

int main(){
  int N; cin>>N;
  vector<int>a(N);
  long long S;
  int x;
  for(int i=0;i<N;i++){ 
    cin>>a.at(i);
    S+=a.at(i);
  }
  x=S/2;
  for(int i=1;i<N;i+=2){
    x-=a.at(i);
  }
  cout<<2*x<<endl;
  
  for(int i=0;i<N-1;i++){
    cout<<2*(a.at(i)-x)<<endl;
    x=a.at(i)-x;
  }
}

Measured memory_bytes: 1664
import * as fs from 'fs'
import {type} from "os";

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const k = parseInt(args[0][0]);

let sum = 0;
for (let i = 1; i <= k; i++) {
  for (let j = 1; j <= k; j++) {
    for (let l = 1; l <= k; l++) {
      sum += [i, j, l].reduce((x, y) => gcd(x, y));
    }
  }
}

console.log(sum);

function gcd(n: number, m: number): number {
  if (n < m) return gcd(m, n)

  if (m === 0) return n

  return gcd(m, n % m)
}

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

using namespace std;

int main(){
    int N, K;
    long long total;
    total = 0;
    
    cin >> N >> K;
    vector<int> H(N);
    
    if(K >= N){
        cout << 0 << endl;
    }else{
        for(int i=0;i<N;++i){
            cin >> H[i];
        }
        sort(H.begin(), H.end());
        for(int i=0;i<N-K;++i){
            total += H[i];
        }
        cout << total << endl;
    }
    
    return 0;
}


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

int abs(int a){
  return ((a > 0) ? (a) : (-a));
}

int main(){
  int L;
  int N;
  int sum=0;
  cin>>L>>N;
  for(int i=0;i<N;i++){
    int x,w;
    cin>>x>>w;
    sum += x*w;
  }
  int sign=((sum > 0)?(-1):(1));
  cout<<abs(sum)<<endl;
  for(int i=0,size=abs(sum);i<size;i++){
    cout<<sign<<' '<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
X, K, D = map(int, input().split())

if X < 0:
    X = -1 * X

x = X % D
N = X // D

if N > K:
    print(X - D * K)
else:
    judge = (K - N) % 2
    if judge == 0:
        print(x)
    else:
        print((x-D)*-1)


Measured memory_bytes: 61800
#include <bits/stdc++.h>
using namespace std;
int a[11],n,m;
string str;
long long mem[100001][10];

long long saiki(int idx,int sum){
  sum%=10;
  if(idx==n)return mem[idx][sum]=(sum==0);
  if(mem[idx][sum]!=-1) return mem[idx][sum];
  mem[idx][sum]=0;
  if(str[idx]!='*'){
    int num=str[idx]-'0';
    if(idx%2) num*=2;
    mem[idx][sum]+=saiki(idx+1,sum+num%10+num/10%10);
  }
  else 
    for(int i=0;i<m;i++){
      int num=a[i];
      if(idx%2) num*=2;
      mem[idx][sum]+=saiki(idx+1,sum+num%10+num/10%10);
    }
  return mem[idx][sum];
}

int main(){

  cin>>n;
  cin>>str;
  
  cin>>m;
  for(int i=0;i<m;i++)cin>>a[i];
  reverse(str.begin(),str.end()); 
  memset(mem,-1,sizeof(mem));
  cout<<saiki(0,0)<<endl; 

  return 0;
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> w(1 << (n - 1));
  for (int i = 0; i < n - 2; ++i) {
    for (int j = 0; j < 1 << i; ++j) {
      int l = 1, r = 1;
      for (int k = i - 1; ~k; --k) {
        if (j >> k & 1) {
          l += r;
        } else {
          r += l;
        }
      }
      w[(1 << i) + j] = l + r;
    }
  }
  vector<vector<vector<long long>>> dp(n, vector<vector<long long>>(n, vector<long long>(1 << (n - 1), -1)));
  function<long long(int, int, int)> solve = [&](int l, int r, int s) {
    if (l > r) {
      return 0ll;
    }
    if (dp[l][r][s] != -1) {
      return dp[l][r][s];
    }
    dp[l][r][s] = LLONG_MAX;
    for (int i = l; i <= r; ++i) {
      dp[l][r][s] = min(dp[l][r][s], solve(l, i - 1, s * 2 + 0) + solve(i + 1, r, s * 2 + 1) + w[s] * a[i]);
    }
    return dp[l][r][s];
  };
  cout << a[0] + a[n - 1] + solve(1, n - 2, 1) << "\n";
  return 0;
}


Measured memory_bytes: 354048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	Yn(!(s[0]==s[1]&&s[1]==s[2]));
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] t = {1, 2, 4, 8, 16, 32, 64, 101};
		for(int i = 0; i < t.length; i++){
			if(t[i] > N){
				System.out.println(t[i-1]);
				break;
			}
		}
	}
}

Measured memory_bytes: 23636
fun main(args: Array<String>) {
    val (n, k) = readInputLine().split(" ").map { it.toInt() }
    val aList = readInputLine().split(" ").map { it.toLong() }
    
    var sumList = mutableListOf<Long>()
    
    for (i in 0 until n) {
        var sum = aList[i]
        sumList.add(sum)
        for (j in i + 1 until n) {
            sum += aList[j]
            sumList.add(sum)
        }
    }
    
    sumList.sortDescending()
    
    var bitFlag = 1L.shl(50)
    
    while (bitFlag != 0L) {
        val filtered = sumList.filter { it and bitFlag != 0L}
        if (filtered.size >= k) {
            sumList = filtered.toMutableList()
        }
        bitFlag = bitFlag.shr(1)
    }
    
    var ans = sumList[0]
    for (i in sumList) {
        ans = ans and i
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 58432
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A,B=map(int,input().split())
    print(min(A*N,B))

if __name__ == '__main__':
    main()


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i=0;i<M;i++){
    cin >> X.at(i);
  }
  
  sort(X.begin(),X.end());
  
  vector<int> sa(M-1);
  for(int i=0;i<M-1;i++){
    sa.at(i)=X.at(i+1)-X.at(i);
  }
  
  sort(sa.begin(),sa.end());
  
  int aida = 0;
  
  if(N>=M){
    cout << 0 << endl;
  }
  else if(N == 1){
    cout << X.at(M-1)-X.at(0) << endl;
  }
  else{
    for(int i=1;i<N;i++){
      aida  = aida + sa.at(M-i-1);
    }
    cout << X.at(M-1)-X.at(0)-aida << endl;
  }
  
}

Measured memory_bytes: 1024
from collections import Counter

def solve():
    MOD = 10**9 + 7
    maxA = 10**6

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

    isPrimes = [False]*2 + [True]*(maxA-1)
    minFs = [1] * (maxA+1)
    for i in range(2, int(maxA**0.5) + 1):
        if isPrimes[i]:
            for x in range(i*i, maxA+1, i):
                isPrimes[x] = False
                minFs[x] = i

    def getPrimeFactors(x):
        anss = []
        while minFs[x] > 1:
            anss.append(minFs[x])
            x //= minFs[x]
        if x != 1:
            anss.append(x)
        return anss

    PFss = []
    Primes = set()
    for A in As:
        PFs = getPrimeFactors(A)
        cnt = Counter(PFs)
        PFss.append(cnt)
        Primes |= cnt.keys()

    cntP = Counter()
    for PFs in PFss:
        for key, num in PFs.items():
            cntP[key] = max(cntP[key], num)

    lcmA = 1
    for key, num in cntP.items():
        lcmA *= pow(key, num, MOD)
        lcmA %= MOD

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs

    invs = getInvs(10**6, MOD)

    ans = 0
    for A in As:
        ans += lcmA * invs[A]
        ans %= MOD

    print(ans)

solve()


Measured memory_bytes: 154256
N,Z,W = map(int,input().split(' '))
a=list(map(int,input().split(' ')))

# Xが全部とる
t1=abs(a[N-1]-W)
# Xが1個残しでとる
if N>1:
    t2=abs(a[N-1-1]-a[N-1])
else:
    t2=0
# Xが2個残しで取る場合、Yの都合に従う
if N>2:
    t3=min( abs(a[N-2-1]-a[N-1]),abs(a[N-1]-a[N-1-1]) )
else:
    t3=0

print(max(t1,t2,t3))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		String res = "YES";
		int[] nums = new int[n];
		int[] sortedNums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			nums[i] = p;
			sortedNums[i] = p;
		}
		
		Arrays.sort(sortedNums);
		
		int cnt = 0;
		
		for (int i = 0; i < n; i++) {
			if (nums[i] != sortedNums[i]) {
				cnt++;
			}
		}
		
		if (cnt > 2) { res = "NO"; };
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#include <utility>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
int cnt[100000];
int main(){
 	int n; cin >>n;
 	vector<int> p(n);
 	int Max=0;
 	map<int,int> mp;
 	for(int i=0;i<n;i++){
 		cin >>p[i];
 		Max=max(Max,p[i]);
 		mp[p[i]]++;
 	}
 	cout << Max << " ";
 	if(Max%2==0){
 		int dif=1e9;
 		int ans=-1;
 		for(auto p:mp){
 			if(dif>abs(Max/2-p.first)){
 				ans=p.first;
 				dif=Max/2-p.first;
 			}
 		}
 		cout << ans << endl;
 	}
 	else if(Max%2==1){
 		int dif=1e9;
 		int ans=-1;
 		for(auto p:mp){
 			if(dif>abs(Max/2-p.first)){
 				ans=p.first;
 				dif=Max/2-p.first;
 			}
 			if(dif>abs(Max/2+1-p.first)){
 				ans=p.first;
 				dif=Max/2+1-p.first;
 			}
 		}
        cout << ans << endl;
 	}
 }

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

int main() {
    int n; cin >> n;
    vector<string> w(n);
    rep(i,n) cin >> w[i];

    rep(i,n-1) {
        for (int j = i+1; j < n; j++)
        {
            if (w[i] == w[j])
            {
                cout << "No\n";
                return 0;
            }
        }
    }

    rep(i,n-1) {
        if (w[i][w[i].size()-1] != w[i+1][0])
        {
                cout << "No\n";
                return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p = 0;
    for(int k = 1;k<=n;k++){
      if(k*(k+1)/2>=n){
        p=k;
        break;
      }
    }
    int[] res = new int[p+1];
    for(int i = 1;i <= p;i++)res[i]=i;
    if(n!=p*(p+1)/2)res[p*(p+1)/2-n]=0;
    for(int i = 1;i <= p;i++)
      if(res[i]!=0)System.out.println(res[i]);
  }
}

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

int main() {
  string s;
  cin >> s;
  bool even = true;

  for(char c = 'a'; c <= 'z'; c++) {
    int count = 0;
    for(int i=0; i < s.size(); i++) {
      if(s[i] == c) {
        count++;
      }
    }
    if(count % 2 == 1) even = false;
  }
  cout << (even ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3536
import math
a, b, hour, minute = list(map(int, input().split()))

x_hour = a * math.cos((hour + minute/ 60)*30/180 * math.pi)
x_min = b * math.cos(minute*6 / 180 * math.pi)
y_hour = a * math.sin((hour + minute/ 60)*30/180 * math.pi)
y_min = b * math.sin(minute*6 / 180 * math.pi)

print(math.sqrt((x_hour - x_min) ** 2 + (y_hour - y_min) ** 2))


Measured memory_bytes: 9508
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 2e5+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll l = 1,r = 1e10;
    while(l<r)
    {
        ll mid = (l+r)/2;
        ll sum=0;
        for(int i=0;i<n;i++)
            sum+= max((ll)(arr[i]-b*mid+a-b-1)/(a-b),(ll)0);
        if(sum<=mid)
            r =mid;
        else
            l = mid+1;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 4016
#include<stdio.h>
#include<iostream>
#include <iomanip>
#include<vector>

using namespace std;

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

  int ans=0;
  ans+=x/500*1000;
  int y=x%500;
  ans+=y/5*5;
  
  cout<<ans;
  return 0;
}

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

/* constant */

#define MAX_INT (100000000000000000LL)
#define MAX_N   (100000)

/* typedef */

typedef long long ll;

/* global variables */

static ll hxs[MAX_N], hys[MAX_N], hsxs[MAX_N], hsys[MAX_N];

/* subroutines */

ll distxy(ll x0, ll y0, ll x1, ll y1) {
  ll dx, dy;

  dx = x1 - x0;
  if (dx < 0) dx = -dx;
  dy = y1 - y0;
  if (dy < 0) dy = -dy;

  return (dx + dy);
}

int compll(const void *a, const void *b) {
  ll diff = *((ll *)a) - *((ll *)b);
  return (diff == 0) ? 0 : (diff < 0) ? -1 : 1;
}

/* main */

int main(int argc, char **argv) {
  int h, i, k, n, w;
  ll d, max_dist, min_sx, min_sy, min_sumd;
  ll sxs[2], sys[2];

  scanf("%d %d", &w, &h);
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    ll xi, yi;

    scanf("%lld %lld", &xi, &yi);
    hxs[i] = hsxs[i] = xi;
    hys[i] = hsys[i] = yi;
  }

  qsort(hsxs, n, sizeof(ll), compll);
  qsort(hsys, n, sizeof(ll), compll);

  sxs[0] = hsxs[(n - 1) / 2];
  sys[0] = hsys[(n - 1) / 2];
  sxs[1] = hsxs[(n + 1) / 2];
  sys[1] = hsys[(n + 1) / 2];

  min_sumd = MAX_INT;
  min_sx = min_sy = -1;

  for (k = 0; k < 4; k++) {
    ll sumd = 0;
    ll max_dist = 0;
    ll sx = sxs[k / 2];
    ll sy = sys[k % 2];
    /*printf("sx=%lld, sy=%lld\n", sx, sy);*/

    for (i = 0; i < n; i++) {
      d = distxy(hxs[i], hys[i], sx, sy);
      sumd += d;
      if (max_dist < d) max_dist = d;
    }

    sumd = sumd * 2 - max_dist;

    if (min_sumd > sumd) {
      min_sumd = sumd;
      min_sx = sx;
      min_sy = sy;
    }
  }

  printf("%lld\n", min_sumd);
  printf("%lld %lld\n", min_sx, min_sy);

  return 0;
}

Measured memory_bytes: 4548
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int N;
    cin >> N;

    vector < pair<pair<int, string>, int>> rest;
    string shop;
    int score;
    REPinit(i, 0, N) {
        cin >> shop >> score;
        pair<int, string> tmp(static_cast<int>(i + 1), shop);
        pair< pair<int, string>, int> tmp2(tmp, score);
        rest.push_back(tmp2);
    }


    sort(ALL(rest), [](pair<pair<int, string>, int> i, pair<pair<int, string>, int> j) -> bool {
        //cout << "Compare : " << i.first.second << " & " << j.first.second << endl;
        if (i.first.second == j.first.second) {
            return i.second > j.second;
        }
        else {
            return i.first.second < j.first.second;
        }
    });

    

    REPinit(i, 0, N) {
        cout << rest.at(i).first.first << endl;
    }


    return 0;
}


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

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

    map<int, int> A;

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

    for(int i=0; i<K; ++i) {
        int d;
        cin >> d;
        for (int j=0; j<d; ++j) {
            int s;
            cin >> s;
            A[s] += 1;
        }
    }

    int itazura = 0;
    for (int i=1; i<=N; ++i) {
        // cout << "A" << i << ": "<< A[i] << endl;
        if (A[i] == 0) itazura++;
    }
    cout << itazura << endl;
}

Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=1;_i<=_N;_i++)
typedef long long int lli;
using namespace std;

int main() {
	L(i,9)
		L(j,9)
			cout << i << "x" << j << "=" << i*j << endl;
	return 0;
}

Measured memory_bytes: 3036
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

MOD = 10 ** 9 + 7

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

# (1/2)^n
x = (MOD + 1) // 2
power = [1] * (N+100)
power_inv = [1] * (N+100)
for i in range(1,N+100):
    power[i] = power[i-1] * 2 % MOD
    power_inv[i] = power_inv[i-1] * x % MOD

# 部分木の大きさ
answer = 0
size = [1] * (N+1)
for v in order[::-1]:
    p = parent[v]
    size[p] += size[v]
    A = [size[w] for w in graph[v] if w != p] # 部分木のサイズ集合
    if v != root:
        A.append(N - 1 - sum(A))
    if len(A) == 1:
        continue
    prod = 1
    coef = 1
    for x in A:
        prod *= power_inv[x]
        prod %= MOD
        coef += (power[x] - 1)
    E = 1 - prod * coef % MOD
    answer += E

answer *= power_inv[1]
answer %= MOD
print(answer)


Measured memory_bytes: 69932
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;


signed main(){
	
	int a;
	cin>>a;
	string s;
	if(a/100==a%10)s="Yes";
	else s="No";
	cout<<s<<endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(100000)

N=int(input())
AB=[list(map(int,input().split())) for _ in range(N-1)]
C=deque(sorted(map(int,input().split())))
edges=[[] for _ in range(N)]
for a,b in AB:
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

ps=[0]*N

def dfs(prev, curr):
    ps[curr]=C.pop()
    for dst in edges[curr]:
        if prev==dst:
            continue
        dfs(curr,dst)
dfs(-1,0)

ans=0
for a,b in AB:
    ans += min(ps[a-1],ps[b-1])

print(ans)
print(" ".join([str(p) for p in ps]))


Measured memory_bytes: 55640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = (1..3).map { sc.next() }
    val c = Array(3) { Array(3) { HashSet<Int>()} }
    for (i in 0 until 3) {
        for (j in 0 until 3) {
            if (i == j) continue
            for (start in s[i].indices) {
                if (check(s[i], s[j], start)) {
                    c[i][j].add(start)
                }
            }
            c[i][j].add(s[i].length)
        }
    }

    var ans = s.map { it.length }.sum()
    for (i in 0 until 3) {
        for (j in 0 until 3) {
            if (i == j) continue
            for (k in 0 until 3) {
                if (i == k || j == k) continue
                ans = Math.min(ans, solve(s, c, listOf(i, j, k)))
            }
        }
    }
    println(ans)
}

fun solve(s: List<String>, c: Array<Array<HashSet<Int>>>, order: List<Int>): Int {
    val s0 = order[0]
    val s1 = order[1]
    val s2 = order[2]

    var ans = s.map { it.length }.sum()
    for (i in c[s0][s1]) {
        for (j in c[s1][s2]) {
            val idx = i + j
            if (idx >= s[s0].length || c[s0][s2].contains(idx)) {
                var len = s[s0].length
                len = Math.max(len, i + s[s1].length)
                len = Math.max(len, idx + s[s2].length)
                ans = Math.min(ans, len)
            }
        }
        for (j in c[s0][s2]) {
            if (j <= i + s[s1].length) continue
            var len = s[s0].length
            len = Math.max(len, j + s[s2].length)
            ans = Math.min(ans, len)
        }
    }
    return ans
}

fun check(a: String, b: String, start: Int): Boolean {
    for (i in b.indices) {
        if (start + i >= a.length) {
            return true
        }
        val ach = a[start + i]
        val bch = b[i]
        if (!(ach == '?' || bch == '?' || ach == bch)) {
            return false
        }
    }
    return true
}


Measured memory_bytes: 43728
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(h);lin(N);
  ll A;
  rep(i,N){
    lin(a);
    A+=a;
  }
  
  if(A>=h) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int mod = n % 10;
    cout << (mod == 3 ? "bon" : (mod == 0 || mod == 1 || mod == 6 || mod == 8) ? "pon" : "hon") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void) {

  int N, K, d;
  int i = 0, time = 0, temp;
  int flag = 0;
  int Sunuke[100];
  
  for(i = 0; i < 100; i++){
    Sunuke[i] = 0;
  }

  scanf("%d", &N);
  scanf("%d", &K);

  while (time < K) {
    scanf("%d", &d);
    for (i = 0; i < d; i++) {
      scanf("%d", &temp);
      Sunuke[(temp - 1)] = 1;
    }
    time++;
  }

  for (i = 0; i < N; i++) {
    if (Sunuke[i] != 1) {
      flag++;
    }
  }
  printf("%d\n", flag);

  return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e4+5;

int main() {
    int t,n,m;
    scanf("%d",&n);
    string s;
    map<string,int>p;
    for(int i = 0;i < n;i++){
        cin>>s;
        p[s]++;
    }
    map<string,int>::iterator it=p.begin();
    int mx=it->second;
    for(it++;it!=p.end();it++){
        if(it->second>mx) mx=it->second;
    }
    for(it=p.begin();it!=p.end();it++){
        if(it->second==mx)
            cout<<it->first<<'\n';
    }
    return 0;
}


Measured memory_bytes: 25216
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}


int G[310][310];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n,m,l;
    cin>>n>>m>>l;
    rep(i,310)rep(j,310)if(i-j)
        G[i][j]=inf;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a][b]=G[b][a]=c;
    }
    rep(k,n)rep(i,n)rep(j,n)cmin(G[i][j],G[i][k]+G[k][j]);
    rep(i,n)rep(j,n)if(G[i][j]>l)G[i][j]=inf;
    else G[i][j]=1;
    rep(k,n)rep(i,n)rep(j,n)cmin(G[i][j],G[i][k]+G[k][j]);
    int q;
    cin>>q;
    while(q--){
        int a,b;cin>>a>>b;
        a--;b--;
        if(G[a][b]==inf)cout<<-1<<endl;
        else cout<<G[a][b]-1<<endl;
    }
}


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

using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))

typedef long long ll;


int main(){
	int n;
	cin>>n;
	if(!n) cout<<1<<endl;
	else if(n==1) cout<<2<<endl;
	else if(n==2) cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 123456*2+1

int main(void) {
	bool isprime[MAX] = {false};
	int n;
	for(int i = 1; i < MAX; i++) {
		if(i % 2) isprime[i] = true;
	}
	isprime[1] = false;  isprime[2] = true;

	for(int i = 3; i * i <= MAX; i += 2) {
		if(isprime[i]) {
			for(int j = i * i; j < MAX; j += i) {
				isprime[j] = false;
			}
		}
	}

	while(1) {
		scanf("%d", &n);
		if(!n) break;
		printf("%d\n", count(&isprime[n + 1], &isprime[2 * n + 1], true));
	}

	return 0;
}

Measured memory_bytes: 1276
#include<iostream>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 1; i < n-1; i++) {
    if(a[i-1] < a[i] && a[i] < a[i+1]) {
      ans++;
    } else if(a[i+1] < a[i] && a[i] < a[i-1]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int mx=300001;
vector<int> edj[mx];
bool visited[mx];
int am=0;
void dfs(int u)
{
    am++;
    //cout<<u<<" "<<m<<endl;
    visited[u]=1;
    for(int v:edj[u])
    {
        if(!visited[v])
        dfs(v);
    }

}

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {edj[i].clear(); 
     visited[i]=0;
    }
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        u--,v--;
        edj[u].push_back(v);
        edj[v].push_back(u);
    }
    int ans=1;
    for(int i=0;i<n;i++)
    {
        if(!visited[i])
        {   am=0;
            dfs(i);
            ans=max(ans,am);
            
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> mirror(N);
  
  for (int i = 0; i < N; i++) cin >> mirror.at(i);
  
  for (int i = 0; i < N; i++) {
    
    for (int j = 0; j < N; j++) {
      if (mirror.at(i) == mirror.at(j) && i != j) mirror.at(i) = 0;
    }
    
  }
  
    int count = 0;
  for (int i = 0; i < N; i++) {
    if (mirror.at(i) == 0) count++;
  }
  
  cout << N - count << endl;
}


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

/**
AOJ ITP1_7_D Matrix Multiplication.
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_D
行列の積.
*/
int main() {
    int n,m,l,i,j,k;
    cin >> n >> m >> l;
    long long a[n][m], b[m][l], c[n][l] = {};
    for (i=0;i<n;i++) for (j=0;j<m;j++) cin >> a[i][j];
    for (i=0;i<m;i++) for (j=0;j<l;j++) cin >> b[i][j];
    for (i=0;i<n;i++) {
        for (j=0;j<l;j++) {
            for (k=0;k<m;k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
            cout << c[i][j] << (j==l-1?"\n":" ");
        }
    }
    return 0;
}


Measured memory_bytes: 3312