akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)
long long INF = 1LL<<60;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main( ){
    ll N;
    cin>>N;
    ll K;
    cin>>K;
    ll mod=1e9+7;
    vll sum(N+2,0);
    rep(i,0,N+2){
        sum[i]=sum[i-1]+(i-1);
    };
    ll res=0;
    rep(cntc,K,N+2){
        ll small=sum[cntc]-sum[0];
        ll big=sum[N+1]-sum[N+1-cntc];
        res+=big-small+1;
        res%=mod;
        if(res<0)res+=mod;
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 4764
import java.util.*;

public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, m = 0;
    public static char grid[][] = null;
    public static long[][] dp = new long[1050][1050];
    public static long mod = 1000000007;

    public static long solve(int i, int j) {
        if (i == n - 1 && j == m - 1) {
            return 1;
        } else {
            if (dp[i][j] == -1) {
                long c1 = 0;
                long c2 = 0;
                if (j < m - 1 && grid[i][j + 1] == '.') {
                    c1 = solve(i, j + 1);
                }
                if (i < n - 1 && grid[i + 1][j] == '.') {
                    c2 = solve(i + 1, j);
                }
                long ans = c1 % mod + c2 % mod;
                ans = ans % mod;
                dp[i][j] = ans;
                return ans;
            } else {
                return dp[i][j];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 1050; i++) {
            for (int j = 0; j < 1050; j++) {
                dp[i][j] = -1;
            }
        }
        n = in.nextInt();
        m = in.nextInt();
        grid = new char[n][m];
        for (int i = 0; i < n; i++) {
            String line = in.next();
            for (int j = 0; j < m; j++) {
                grid[i][j] = line.charAt(j);
            }
        }
        System.out.println(solve(0, 0) % mod);
    }

}


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

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

    string s, p;
    cin >> s >> p;
    s += s;
    if (s.find(p) != -1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3228
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n,a[13],ans=0;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	sort (a,a+n);
	for (int i=0;i<n-1;i++) ans+=a[i];
	ans+=a[n-1]/2;
	cout<<ans;
	return 0;
}

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

ans=0
for i in range(n):
  if b[i]<=a[i]:
    a[i]-=b[i]
    ans+=b[i]
  elif b[i]<=(a[i]+a[i+1]):
    a[i+1]-=(b[i]-a[i])
    a[i]=0
    ans+=b[i]
  else:
    ans+=(a[i]+a[i+1])
    a[i]=0
    a[i+1]=0

print(ans)

Measured memory_bytes: 82020
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl

int getLen(int *hash, vector<vector<int>> &rev, int vertex) {
    if (rev[vertex].size() == 0) {
        return 0;
    }
    if (hash[vertex]) {
        return hash[vertex];
    }
    int maxLen = 0;
    for (auto r : rev[vertex]) {
        maxLen = max(maxLen, getLen(hash, rev, r) + 1);
    }
    hash[vertex] = maxLen;
    return maxLen;
}

int main() {
    
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    int *hash = new int[n];
    memset(hash, false, sizeof false);

    vector<vector<int>> adj(n);
    vector<vector<int>> rev(n);

    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        rev[b].push_back(a);
    }

    int maxLen = 0;
    for (int i = 0; i < n; i++) {
        if (adj[i].size() == 0) {
            maxLen = max(maxLen, getLen(hash, rev, i));
        }
    }
    cout << maxLen << endl;

    return 0;
}

Measured memory_bytes: 17792
#include "bits/stdc++.h"
using namespace std;
int x[100], y[100], h[100];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	for (int cx = 0; cx <= 100; cx++) {
		for (int cy = 0; cy <= 100; cy++) {
			int H;
			for (int i = 0; i < N; i++) {
				if (h[i] > 0) {
					H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					break;
				}
			}
			bool ok = 1;
			for (int i = 0; i < N; i++) {
				if (max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
					ok = 0;
					break;
				}
			}
			if (ok) {
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

dp = [False] * (K + 1)

for i in range(1, K + 1):
    for a in a_list:
        if i - a < 0:
            continue
        if not dp[i - a]:
            dp[i] = True
            break

if dp[-1]:
    print("First")

else:
    print("Second")


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

m = 0
ab = []
for i in a:
    if i < 0:
        m+=1
        i = i*-1
    ab.append(i)

if m%2 == 0:
    print(sum(ab))
else:
    ab.sort()
    print(sum(ab[1:])-ab[0] )

Measured memory_bytes: 65680
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1
    max_val = 0
    results = []
    for i in words.keys():
        if words[i] > max_val:
            max_val = words[i]
            results = []
            results.append(i)
        elif words[i] == max_val:
            results.append(i)

            # results = [key
            #            for key in words.keys() if words[key] == max(words.values())]
            # results.sort()
    results.sort()
    print('\n'.join(map(str, results)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 34140
import numpy as np
n,k = map(int,input().split())
num_list = list(map(int,input().split()))
ans = 0
num_list = np.sort(num_list)[::-1]
num_list = np.array(num_list)

if k > len(num_list):
    ans = 0
    
else:
    for i in range(n-k):
        ans += num_list[i+k]
print(ans)

Measured memory_bytes: 42504
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M,x,y;cin>>N>>M;
  vector<int> arr(N,1),ans_arr(N,0);
  ans_arr[0]=1;
  REP(i,0,M){
    cin>>x>>y;
    x--;y--;
    if(arr[x]){
      arr[y]++;
      if(ans_arr[x]){
        ans_arr[y]=1;
      }
      arr[x]--;
      if(arr[x]==0){
        ans_arr[x]=0;
      }
    }
  }
  int ans=sum(ans_arr);
  print(ans);

}


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

int main(){
  int N; cin >> N;
  string s;
  vector<int> c(4,0);
  for(int i=0; i<N; ++i){
    cin >> s;
    if(s=="AC")
      ++c[0];
    else if(s=="WA")
      ++c[1];
    else if(s=="TLE")
      ++c[2];
    else if(s=="RE")
      ++c[3];
  }
  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair 
using namespace std;
const int N=1005;
queue<int>q;
int n,m,dist[N][N],ans;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char c[N][N];
inline bool ok(int x,int y){return (x>=0&&y>=0&&x<n&&y<m);}
int main()
{
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			dist[i][j]=1e9;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(c[i][j]=='#')
			{
				q.push(i);
				q.push(j);
				q.push(0);
				dist[i][j]=0;
			}
		}
	}
	while(!q.empty())
	{
		int x=q.front();q.pop();
		int y=q.front();q.pop();
		int z=q.front();q.pop();
		for(int i=0;i<4;i++)
		{
			int x2=x+dx[i];
			int y2=y+dy[i];
			if(!ok(x2,y2)||dist[x2][y2]!=1e9)continue;
			q.push(x2);
			q.push(y2);
			q.push(z+1);
			dist[x2][y2]=z+1;
		}
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			ans=max(ans,dist[i][j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    int divisible_by_four = 0, divisible_by_two = 0;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(a % 4 == 0)  ++divisible_by_four;
        else if(a % 2 == 0) ++divisible_by_two;
    }
    int cnt = divisible_by_four * 2 + 1;
    if(cnt >= n){
        cout << "Yes\n";
        return 0;
    }
    n -= cnt;
    if(divisible_by_two >= n + 1){
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s,ans="None";
	vector<pair<char,int>>vec;
	cin >> s;
	for(int i=0;i<26;i++){
		pair<char,int>p;
		p=make_pair(i+97,0);
		vec.push_back(p);
	}
	for(int i=0;i<s.size();i++){
		for(int j=0;j<vec.size();j++){
			if(s[i]==vec[j].first){
				vec[j].second=1;
			}
		}
	}
	for(int i=0;i<vec.size();i++){
		if(vec[i].second==0){
			ans=vec[i].first;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  
  vector<map<int,int>> mp(2);
  rep(i,n){
    int x; cin >> x;
    mp[i%2][x]++;
  }
  
  vector<P> a,b;
  for(auto it:mp[0]){ a.emplace_back(it.S,it.F); } sort(a.rbegin(),a.rend());
  for(auto it:mp[1]){ b.emplace_back(it.S,it.F); } sort(b.rbegin(),b.rend());
  
  if(a[0].S!=b[0].S){ cout << n-a[0].F-b[0].F << endl; return 0; }
  
  cout << min(n-a[1].F-b[0].F,n-a[0].F-b[1].F) << endl;
  return 0;
}


Measured memory_bytes: 6136
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

struct Point{
    double x;
    double y;
    Point (double x, double y) : x(x), y(y){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
double abs_(Vector v){
    return sqrt(dot(v, v));
}
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2){}
};
bool is_inSegment(Point p, Segment s){
    double max_x = s.p1.x;
    double min_x = s.p2.x;
    if (min_x > max_x) swap(min_x, max_x);
    if (p.x < min_x || p.x > max_x) return false;
    double max_y = s.p1.y;
    double min_y = s.p2.y;
    if (min_y > max_y) swap(min_y, max_y);
// cout << min_y << " " << max_y << " " << p.y << endl;
    if (p.y < min_y || p.y > max_y) return false;
    return true;
}
bool is_intersect(Segment s1, Segment s2){
    double alpha = cross(s2.p1 - s2.p2, s1.p1 - s1.p2);
    if (fabs(alpha) < 1e-10) return false;
    double beta  = cross(s2.p1, s2.p2);
    double gamma = cross(s1.p1, s1.p2);
    double x_is = ((s1.p1.x - s1.p2.x) * beta -
                   (s2.p1.x - s2.p2.x) * gamma) / alpha;
    double y_is = ((s1.p1.y - s1.p2.y) * beta -
                   (s2.p1.y - s2.p2.y) * gamma) / alpha;
    Point p_is(x_is, y_is);
    if (!is_inSegment(p_is, s1)) return false;
    if (!is_inSegment(p_is, s2)) return false;
    return true;
}
double get_distanceSP(Segment s, Point p){
// cout << "(" << s.p1.x << "," << s.p1.y << ")";
// cout << "(" << s.p2.x << "," << s.p2.y << ")   :    ";
// cout << "(" << p.x << "," << p.y << ")" << endl;
    Vector a1 = s.p2 - s.p1;
    Vector b1 = p    - s.p1;
    if (dot(a1, b1) <= 0) return abs_(b1);
    Vector a2 = s.p1 - s.p2;
    Vector b2 = p    - s.p2;
    if (dot(a2, b2) <= 0) return abs_(b2);
    return fabs(cross(a1, b1)) / abs_(a1);
}
double get_distanceSS(Segment s1, Segment s2){
    if (is_intersect(s1, s2)) return 0;
    // cout << get_distanceSP(s1, s2.p1) << " ";
    // cout << get_distanceSP(s1, s2.p2) << " ";
    // cout << get_distanceSP(s2, s1.p1) << " ";
    // cout << get_distanceSP(s2, s1.p2) << endl;
    return min(min(get_distanceSP(s1, s2.p1), get_distanceSP(s1, s2.p2)),
               min(get_distanceSP(s2, s1.p1), get_distanceSP(s2, s1.p2)));
}
int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3;
        cin >> x_p0 >> y_p0 >> x_p1 >> y_p1;
        cin >> x_p2 >> y_p2 >> x_p3 >> y_p3;
        Segment s1(Point(x_p0, y_p0), Point(x_p1, y_p1));
        Segment s2(Point(x_p2, y_p2), Point(x_p3, y_p3));
        double distance = get_distanceSS(s1, s2);
        cout << fixed << setprecision(10);
        cout << distance << endl;
    }
    return 0;
}



Measured memory_bytes: 3292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static final String OVER_FLOW = "overflow";
    private static final String STRING_ZERO = "0";
    private static final int MAX_NUM = 100000000;

    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;

        try {
            count = Integer.valueOf(in.readLine());

            for (int i = 0; i < count; i++) {

                int[] budget = new int[10];
                String input1 = in.readLine();
                String input2 = in.readLine();

                if(input1.length() > 80 || input2.length() > 80) {
                    System.out.println(OVER_FLOW);
                    continue;
                }

                int idx = 0;
                for (int j = input1.length(); j > 0; j -= 8) {

                    budget[idx] = Integer.valueOf(input1.substring(
                            j - 8 > 0 ? j - 8 : 0, j));
                    idx++;
                }

                idx = 0;

                for (int k = input2.length(); k > 0; k -= 8) {

                    budget[idx] += Integer.valueOf(input2.substring(
                            k - 8 > 0 ? k - 8 : 0, k));
                    idx++;
                }

                for (int l = 0; l < 9; l++) {
                    if (budget[l] >= MAX_NUM) {
                        budget[l + 1] += 1;
                        budget[l] -= MAX_NUM;
                    }
                }

                if (budget[9] >= MAX_NUM) {
                    System.out.println(OVER_FLOW);
                } else {

                    boolean startFlg = false;

                    StringBuilder result = new StringBuilder();

                    for (int m = 9; m >= 0; m--) {

                        if (startFlg) {

                            String tmp = String.valueOf(budget[m]);

                            for (int n = 8 - tmp.length(); n > 0; n--) {
                                result.append(STRING_ZERO);
                            }
                            result.append(tmp);
                        } else if (budget[m] > 0 || m == 0) {
                            result.append(budget[m]);
                            startFlg = true;
                        }
                    }

                    System.out.println(result.toString());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Measured memory_bytes: 16888
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int f=1,n=4,a[5],b[]={1,4,7,9};
	for(int i=0;i<n;i++){
		cin>>a[i];
	} 
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			f=0;break;
		}
	}
	if(f==1)cout<<"YES\n";
	else cout<<"NO\n"; 
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<pii> pa(n);
    for (int i = 0; i < n; ++i) {
        cin >> pa[i].first >> pa[i].second;
    }
    sort(pa.begin(), pa.end());
    int idx = 0;
    while (k > 0) {
        k -= pa[idx].second;
        ++idx;
    }
    cout << pa[idx - 1].first << "\n";
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a>b) {
    cout << 2*a -1 << endl;
  } else if (a<b) {
    cout << 2*b -1 << endl;
  } else {
    cout << 2*a << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
int main(){
  int a,b;
  cin>>a>>b;
  cout<<lcm(a,b)<<endl;
}
  

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
    	int n, k;
    	cin >> n >> k;

    	if(500 * n >= k)
    		cout << "Yes\n";
    	else
    		cout << "No\n";
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int n; cin >> n;
    
    vector< vector< vector<int> > > T(4, vector< vector<int> >(3, vector<int>(10, 0)));

    for (int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        b--; f--; r--;
        T[b][f][r] += v;
    }

    for (int i = 0; i < 4; i++) {
        vector< vector<int> > building = T[i];

        for (auto floar : building) {

            for (auto room : floar) {

                cout << ' ' << room;
            } cout << '\n';
        } 
        if (i != 3)
            cout << "####################" << '\n';
    }


}



Measured memory_bytes: 3068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		int sLen = s.length();
		int numVictory = 0;
		
		for(int i = 0; i < sLen; i++) {
			char charAt = s.charAt(i);
			if(charAt == 'o'){	
				numVictory++;
			}
		}
		
		if(numVictory + (15-sLen) >= 8) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21460
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    for (int i = 0; i < s.length(); i += 2) {
      System.out.print(s.charAt(i));
    }
    System.out.println();
    
    sc.close(); 
  }
}


Measured memory_bytes: 31200
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;

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

  if(S<="2019/04/30") cout<<"Heisei"<<endl;

  else cout<<"TBD"<<endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    static long gcd(long a,long b){
        if(b==0) return a;
        return gcd(b,a%b);
    }
    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner input = new Scanner(System.in);
		long k = input.nextLong();
		long sum = 0;
		
		for(long i=1;i<=k;i++){
		    for(long j=1;j<=k;j++){
		        for(long l=1;l<=k;l++){
		            long g1 = gcd(i,j);
		            long g2 = gcd(g1,l);
		            sum+=g2;
		        }
		    }
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 35788
N = int(input())
nums = list(map(int,input().split()))
flag = True
count = 0

while(True):
    for num in nums:
        flag = flag and (num%2==0)
    if flag:
        count += 1
        nums = list(map(lambda x:x//2, nums))
    else:
        break

print(count)

Measured memory_bytes: 38896
#include <stdio.h>
int n;
int a[10];
int b[10];
int fact[10];
int aa,bb;
int visita[10];
int visitb[10];
int abs(int x){
	return x>0?x:-x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	fact[0] = 1;
	for(int i=1;i<=n;i++){
		fact[i] = fact[i-1]*i;
	}
	for(int i=1;i<=n;i++){
		int cnta = 0;
		int cntb = 0;
		for(int j=1;j<=n;j++){
			if(j==a[i]) break;
			if(visita[j]==0) cnta++;
		}
		for(int j=1;j<=n;j++){
			if(j==b[i]) break;
			if(visitb[j]==0) cntb++;
		}
		visita[a[i]] = visitb[b[i]] = 1;
		aa+=cnta*fact[n-i];
		bb+=cntb*fact[n-i];
	}
	printf("%d\n",abs(aa-bb));
}

Measured memory_bytes: 1688
#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 1100
#define ac 5500
#define inf 2139062143

int n;
int Head[AC], Next[ac], date[ac], tot;
int f[AC], g[3][ac], v[AC];
//还需要g数组来辅助转移是为了保证当前点颜色的子树权值之和不超过它自己的权值,直接转移就无法限制了，应该在这个基础上再使另外一种颜色权值尽可能小

inline int read()
{
	int x = 0;char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

inline void add(int f, int w){
	date[++ tot] = w, Next[tot] = Head[f], Head[f] = tot;
}

inline void upmin(int &a, int b){
	if(b < a) a = b;
}

void pre()
{
	n = read();
	for(R i = 2; i <= n; i ++) add(read(), i); 
	for(R i = 1; i <= n; i ++) v[i] = read();
	memset(f, 127, sizeof(f));
}

void dfs(int x)
{
	int sta = 0, now;
	if(!Head[x]) {f[x] = 0; return ;}//叶子节点的另一种颜色自然是0
	for(R i = Head[x]; i; i = Next[i]) dfs(date[i]);//要先遍历一遍，否则g数组会使用混乱，，，，
	memset(g[sta], 127, sizeof(g[sta]));
	g[sta][0] = 0;
	for(R i = Head[x]; i; i = Next[i]) 
	{
		sta ^= 1, now = date[i];//先滚动一下，相当于复制一个数组出来，树形背包常见写法？
		memset(g[sta], 127, sizeof(g[sta]));
		for(R j = v[x]; j >= 0; j --)
		{
			if(j - v[now] >= 0 && g[sta ^ 1][j - v[now]] != inf) 
				upmin(g[sta][j] ,g[sta ^ 1][j - v[now]] + f[now]);//与这个节点同色
			if(j - f[now] >= 0 && g[sta ^ 1][j - f[now]] != inf) 
				upmin(g[sta][j], g[sta ^ 1][j - f[now]] + v[now]);//与这个节点异色
		}
	}
	for(R i = 0; i <= v[x]; i ++) upmin(f[x], g[sta][i]);//只要权值之和比它小就可以了
}

int main()
{
	//freopen("in.in", "r", stdin);
	pre();
	dfs(1);
	if(f[1] != inf) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	//fclose(stdin);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define mk make_pair
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
char s[N];
int main()
{
    cin >> s + 1;
    if (s[3] == s[4] && s[5]==s[6])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

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

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

int x, y, c[50][50], dp[50][50];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y-1) rep(j,x) {
    if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (tj < 0 || tj >= x) continue;
        if (c[ti][tj] == 1) continue;
        if (c[ti][tj] == 2 && z != 1) continue;
        dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2 && c[i+2][j] != 1) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  rep(j,x) res += dp[y][j] + dp[y-1][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> ruiseki(n+1);
  ruiseki.at(0)=0;
  for(int i=1; i<=n; i++){
    ruiseki.at(i)=ruiseki.at(i-1)+i;
  }

  auto itr=lower_bound(ruiseki.begin(),ruiseki.end(),n);
  vector<int> ans;
  for(int i=1; i<=itr-ruiseki.begin(); i++){
    ans.push_back(i);
  }
  if(*itr>n){
    int sa=*itr-n;
    ans.erase(ans.begin()+sa-1);
  }
  for(int i=0; i<ans.size(); i++){
    cout<<ans.at(i)<<endl;
  }
}

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

typedef long long ll;
const ll MOD = 1000000007;

int main(){
  static ll n;
  static ll a[100010];
  cin >> n;
  for(int i = 0 ; i < n ; i ++){
    cin >> a[i];
    a[i] ++;
  }
  static ll dp[100010];
  static ll cnt[100010] ={};
  ll ret = 1;
  cnt[0] = 3;
  for(int i = 0 ; i < n ; i ++){
    ret *= cnt[a[i]-1]; ret %= MOD;
    cnt[a[i]-1] --;
    cnt[a[i]] ++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = unsigned long long;
typedef pair<int,int> P;
typedef priority_queue<int> Pr;
typedef vector<int> Vi;
typedef vector<P> Vp;
int const MOD = 1000000007;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n; cin>>n;
    cout<<n*n*n<<'\n';
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <utility>
using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

int W,H,tmpAns;
vector <vector <int> > cels;
vector<int> ans;
vector<Pii> candidate;//未探索候補

// タイルの種類　黒＝1，赤＝2，探索済み＝3

bool isCan(int h,int w){
    // 範囲チェック
    if(h<0||h>H-1)return false;
    if(w<0||w>W-1)return false;

    // チェック
    if(cels[h][w]==1)return true;
    return false;
}

void searchCel(int h,int w){
Pii tmpPair;

tmpAns++;
cels[h][w]=3;
if(isCan(h,w+1)==true){
    tmpPair.first = h;tmpPair.second = w+1;
    candidate.push_back(tmpPair);
}
if(isCan(h,w-1)==true){
    tmpPair.first = h;tmpPair.second = w-1;
    candidate.push_back(tmpPair);
}
if(isCan(h+1,w)==true){
    tmpPair.first = h+1;tmpPair.second = w;
    candidate.push_back(tmpPair);
}
if(isCan(h-1,w)==true){
    tmpPair.first = h-1;tmpPair.second = w;
    candidate.push_back(tmpPair);
}

while(1){
    if(candidate.empty())return;
    pair<int,int> tmpPair=candidate.back();
    candidate.pop_back();
    if(cels[tmpPair.first][tmpPair.second]==1){
        searchCel(tmpPair.first,tmpPair.second);
        break;
    }
}

return;
}

int main(){
    char tmp;
    int now_w,now_h;
    while(1){
        cin>>W>>H;
        if(W==0&&H==0)break;
        cels.clear();
        cels.assign(H,vector<int>(W,0));
        tmpAns=0; 
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin>>tmp;
                switch (tmp){
                case '.':
                    cels[i][j]=1;
                    break;
                case '#':
                    cels[i][j]=2;
                    break;
                case '@':
                    cels[i][j]=3;
                    now_h=i;now_w=j;
                    break;
                default:
                    return -1;
                }
            }
        }
        searchCel(now_h,now_w);
        ans.push_back(tmpAns);
        
    }

    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3116
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(K,N): #105-A
    if K%N==0:
        return  0
    else:
        return  1

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

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

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;

class BResistorsInParallel {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        double sum = 0;
        for (int i = 0; i < n; ++i) {
            double x;
            in >> x;
            x = (1 / x);
            sum += x;
        }
        sum = (1 / sum);
        out << fixed << setprecision(9);
        out << sum;
    }
};


int32_t main() {
    BResistorsInParallel solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    vector<string> t;
    rep(mask, 0, (1LL<<4)) {
        string u = "";
        if (mask & (1LL<<0)) u += "A";
        u += "KIH";
        if (mask & (1LL<<1)) u += "A";
        u += "B";
        if (mask & (1LL<<2)) u += "A";
        u += "R";
        if (mask & (1LL<<3)) u += "A";
        t.emplace_back(u);
    }
    for(auto v : t) {
        if (s == v) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,a,b,i=2;
    cin>>k>>a>>b;
    long long temp=k;
    while(true)
    {
        if(temp>=a && temp<=b)
        {
        cout<<"OK";
        return 0;
        }
        else if(temp>b)
        break;
        temp=k*i;
        i++;

    }
    cout<<"NG";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  int i=n/111;
  cout << (n%111!=0?i++,i*111:i*111) << endl;
}


Measured memory_bytes: 256
s = int(input())
list_a = [None]
list_a.append(s)
ans = 0
for i in range(1, 10 ** 6 + 1):
    if list_a[i] % 2 == 0:
        list_a.append(list_a[i] // 2)
    else:
        list_a.append(3 * list_a[i] + 1)
    if list_a[i] in list_a[:i]:
        ans = i
        break
print(ans)

Measured memory_bytes: 9056
/*
Author- Aasav Badera
Time- Sun Apr 26 17:29:10 2020
*/
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
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);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                9223372036854775807
#define endl               '\n' 
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        string s[n];
        map<string, ll> m;
        rep(i, 0, n)
        {
        	cin >> s[i];
        	m[s[i]]++;
        }
        ll ans = sz(m);
        cout << ans;
    }
    return 0;
}

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

int main()
{
int a, b, c;
cin >>a >> b>> c;
if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)) 
	{
    	cout << "YES" << endl;
    }
else cout << "NO" << endl;
}


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

#include <iostream>

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#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, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  int a;
  int sum = 0;
  REP(i,3){
  	cin >> a;
    sum += a;
  }
  if (sum > 21) cout << "bust";
  else cout << "win";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 3e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int psumw[MAXN];
int psume[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n;
    cin>>S;

    for(int i=1;i<=n;i++){
        psumw[i] = psumw[i-1];
        if(S[i-1]=='W')psumw[i]++;
    }

    for(int i=n;i>=1;i--){
        psume[i] = psume[i+1];
        if(S[i-1]=='E')psume[i]++;
    }

    for(int i=1;i<=n;i++){
        mn = min(mn,psumw[i-1]+psume[i+1]);
    }

    cout<<mn<<"\n";

    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<tuple>

using namespace std;

typedef long long ll;
typedef tuple<int, int, int> T3;

int H, W;
int Ch, Cw, Dh, Dw;
bool field[1000 + 10][1000 + 10];
int ans[1000 + 10][1000 + 10];

int vx[4] = { 0, 1, 0, -1 }, vy[4] = {1, 0, -1, 0};

void djk() {
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)ans[i][j] = 100000000;
	priority_queue<T3, vector<T3>, greater<T3>> pq;
	pq.push(make_tuple(0, Ch, Cw));
	ans[Ch][Cw] = 0;
	
	while (pq.size()) {
		auto tmp = pq.top();
		pq.pop();
		int Tcost = get<0>(tmp), h = get<1>(tmp), w = get<2>(tmp);
		if (ans[h][w] < Tcost)continue;
		
		//ノーコスト
		for (int i = 0; i < 4; i++) {
			int nh = h + vx[i], nw = w + vy[i];
			if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
			if (!field[nh][nw])continue;
			if (ans[nh][nw] > ans[h][w]) {
				ans[nh][nw] = ans[h][w];
				pq.push(make_tuple(ans[nh][nw], nh, nw));
			}
		}

		//コスト1で5*5県内へ飛ぶ
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int nh = h + i, nw = w + j;
				if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
				if (!field[nh][nw])continue;
				if (ans[nh][nw] > ans[h][w] + 1) {
					ans[nh][nw] = ans[h][w] + 1;
					pq.push(make_tuple(ans[nh][nw], nh, nw));
				}
			}
		}
	}
	
}

int main() {
	cin >> H >> W;
	cin >> Ch >> Cw >> Dh >> Dw;
	Ch--, Cw--, Dh--, Dw--;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c;
			cin >> c;
			if (c == '#') {
				field[i][j] = false;
			}
			else field[i][j] = true;
		}
	}

	djk();

	if (ans[Dh][Dw] == 100000000) {
		cout << -1 << endl;
	}
	else cout << ans[Dh][Dw] << endl;

	return 0;
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

void Change(string& T)
{
    for(auto& x : T)
    {
        if(x=='?') x='D';
    }
}

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

    Change(T);

    OUT0(T);

    return 0;
}

Measured memory_bytes: 3924
from heapq import *
from collections import Counter
H, W = map( int, input().split())
C = [ list( map( int, input().split())) for _ in range(10)]
A = [ list( map( int, input().split())) for _ in range(H)]
N = [0]*10
for i in range(H):
    CA = Counter(A[i])
    for j in range(10):
        N[j] += CA[j]
L = [(0,1)]
V = [-1]*10
while L:
    d, v = heappop(L)
    if not V[v] == -1:
        continue
    V[v] = d
    for i in range(10):
        if V[i] == -1:
            heappush(L, (d+C[i][v], i))
ans = 0
for i in range(10):
    ans += V[i]*N[i]
print(ans)


Measured memory_bytes: 3828