akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

//===== グラフ受け取り =====//
/*
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);

        // 無向グラフの場合は以下を追加
        // G[b].push_back(a);
    }
    
    // == 重み付きグラフ == //
    
    struct Edge {
        int to; 
        int weight; 
        Edge(int t, int w) : to(t), weight(w) { }
    };
    using Graph = vector<vector<Edge>>;
    int main() {
        int N, M; cin >> N >> M;
        Graph G(N);
        for (int i = 0; i < M; ++i) {
            int from, to, weight;
            cin >> from >> to >> weight;
            G[from].push_back(Edge(to, weight));
        }
    }
*/    

using namespace std;
// using Edge = pair<int, int>;
// using Graph = vector<vector<Edge>>;
// using pll = pair<long long, long long>;

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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { 
    return (a.second < b.second); 
} 


int main() {
    double W,H,x,y; cin >> W >> H >> x >> y;
    int cnt = 0;
    if(W / 2 == x && H / 2 == y) cnt = 1;
    cout << W * H / 2 << " " << cnt << endl;
}






Measured memory_bytes: 256
// 26
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e) cerr << "\033[48;5;196m\033[38;5;15m" << e << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> &p) {
  return os << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  rep(i, (int)v.size()) os << setw(7) << left << v[i];
  return os << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &os, map<A, B> &m) {
  for (auto &kv : m) os << kv;
  return os;
}
// 3
void _main(int tc) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> isWinning(k + 1);
  rep(stones, k + 1) {
    for (int &x : a) {
      if (stones - x >= 0 && !isWinning[stones - x]) isWinning[stones] = true;
    }
  }
  cout << (isWinning[k] ? "First" : "Second") << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 640
import sys

N = int(input())
A = list(input().split())
A = list(sorted([int(A[i]) for i in range(N)], reverse=True))
ans = 1

if 0 in A:
    print(0)
    sys.exit()
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10 ** 18:
            print(-1)
            sys.exit()

print(ans)

Measured memory_bytes: 22892
def main():
    import collections
    s=list(map(int,input()))
    modpow=[1]*len(s)
    for i in range(1,len(s)):
        modpow[i]=(modpow[i-1]*10)%2019
    ans=0
    res=[0]*len(s)
    res[0]=s[-1]%2019
    for i in range(1,len(s)):
        res[i]=(modpow[i]*s[len(s)-1-i]+res[i-1])%2019
    res.append(0)
    c=collections.Counter(res).most_common()
    for i in range(len(c)):
        ans+=(c[i][1]*(c[i][1]-1)//2)
    print(ans)
if __name__=="__main__":
    main()

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n;
  cin >> n;
  map<int,int> ma;
  rep(i,n){
    int d;
    cin >> d;
    ma[d]++;
  }

  int m;
  cin >> m;
  rep(i,m){
    int t;
    cin >> t;
    ma[t]--;
    if(ma[t]<0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if (a==1) {
    if (b==2){
      cout<<3<<endl;
    }
    else cout<<2<<endl;
  }
  if (a==2) {
    if (b==1){
      cout<<3<<endl;
    }
    else cout<<1<<endl;
  }
  if (a==3) {
    if (b==2){
      cout<<1<<endl;
    }
    else cout<<2<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#define bye return 0
#define speedOne ios::sync_with_stdio(false)
#define speedtwo cin.tie(0)
typedef long long int lli;
typedef long long ll;
using namespace std;
int main()
{   
    speedOne;
    speedtwo;
	int cnt=0, t, m, n, x, y, a, b;
	cin >> m >> n >> x >> y;
	//set<int> s;
	//map<int, int> m;
	vector<int> xn;
	vector<int> yn;
	while(m--){
	    cin >> a;
	    xn.push_back(a);
	}
	while(n--){
	    cin >> b;
	    yn.push_back(b);
	}
	
	int max = *max_element(xn.begin(), xn.end());
	int min = *min_element(yn.begin(), yn.end());
	
	if(min>max && min>x && min<=y) cout << "No War" << "\n";
	else cout << "War" << "\n";
	
	bye;
}

Measured memory_bytes: 380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll h[100000];
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	ll l = 0, r = 1 << 30;
	while ((r - l) > 1) {
		ll m = (l + r) / 2;
		ll cnt = 0;
		for (int i = 0; i < N; i++) {
			if (m*B < h[i]) {
				cnt += (h[i] - m * B + (A - B) - 1) / (A - B);
			}
		}
		if (cnt <= m) r = m;
		else l = m;
	}
	cout << r << endl;
 }

Measured memory_bytes: 1024
a,b=map(int,input().split())
if b%4==1:
  B=1
elif b%4==3:
  B=0
elif b%4==0:
  B=b
else:
  B=b+1
if a%4==2:
  A=1
elif a%4==0:
  A=0
elif a%4==1:
  A=a-1
else:
  A=a
print(A^B)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	fmt.Println(a[N-1] - a[0])
}


Measured memory_bytes: 512
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

fun search(lowerBound: Long, upperBound: Long, ab: Long): Long {
    if (upperBound == lowerBound) return lowerBound
    if (upperBound == lowerBound + 1) {
        return if (upperBound * upperBound < ab) upperBound else lowerBound
    }
    val pivot = (lowerBound + upperBound) / 2

    return if (pivot * pivot < ab) search(pivot, upperBound, ab)
    else search(lowerBound, pivot - 1, ab)
}

fun query(a: Long, b: Long): Long {
    val ab = a * b
    val f = (a - 1) * 2
    return f + if ((a + 1) * (a + 1) < ab) {
        val m = search(a + 1, b - 1, ab)
        val alpha = m - a
        if (m * (m + 1) < ab) {
            2 * alpha + (if (a + alpha * 2 + 1 < b) 1 else 0)
        } else {
            (alpha - 1) * 2 + 1 + + (if (a + alpha * 2 < b) 1 else 0)
        }
    } else {
        if (a + 1 < b) 1L else 0L
    }
}

fun main(args: Array<String>) {
    val Q = readInts()[0]
    (0 until Q).forEach {
        val (a, b) = readInts().sorted()
        println(query(a.toLong(), b.toLong()))
    }
}

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

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


Measured memory_bytes: 3656
import java.util.Scanner;

class Main {
    private static int R;
    private static int C;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        R = sc.nextInt();
        C = sc.nextInt();

        char[][] arr = new char[R][C];
        for (int i = 0; i < R; i++) {
            String s = sc.next();
            for (int j = 0; j < C; j++) {
                arr[i][j] = s.charAt(j);
            }
        }

        int[][] dp = new int[R][C];

        for (int i = 0; i < R; i++) {
            for (int j = 0; j < C; j++) {
                if (i == 0 && j == 0) {
                    dp[i][j] = 1;
                } else if (i == 0) {
                    if (arr[i][j] == '.') {
                        dp[i][j] = dp[i][j - 1];
                    } else if (arr[i][j] == '#') {
                        dp[i][j] = 0;
                    }
                } else if (j == 0) {
                    if (arr[i][j] == '.') {
                        dp[i][j] = dp[i - 1][j];
                    } else if (arr[i][j] == '#') {
                        dp[i][j] = 0;
                    }
                } else {
                    if (arr[i][j] == '.') {
                        dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
                    } else {
                        dp[i][j] = 0;
                    }
                }

                dp[i][j] = dp[i][j] % 1000000007;
            }
        }

        System.out.println(dp[R - 1][C - 1]);
        sc.close();
    }
}

Measured memory_bytes: 35548
N, M = map(int, input().split())
ES = []
D = [{} for i in range(N)]

*parent, = range(M)
def root(x):
    if x == parent[x]:
        return x
    parent[x] = y = root(parent[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px < py:
        parent[py] = px
    else:
        parent[px] = py

E = {}
for i in range(M):
    p, q, c = map(int, input().split()); p -= 1; q -= 1
    ES.append((p, q, c))
    if c in D[p]:
        unite(D[p][c], i)
    else:
        D[p][c] = i
    E.setdefault(p, set()).add(c)
    if c in D[q]:
        unite(D[q][c], i)
    else:
        D[q][c] = i
    E.setdefault(q, set()).add(c)
P = {}
for i in range(M):
    p, q, c = ES[i]
    s = P.setdefault(root(i), set())
    s.add(p); s.add(q)

from collections import deque
que = deque([(0, 0, 0)])
INF = 10**18
dist = [INF]*N
dist[0] = 0
gdist = [INF]*M

while que:
    cost, v, t = que.popleft()
    if t:
        # edge
        if gdist[v] < cost or v not in P:
            continue
        for w in P[v]:
            if cost + 1 < dist[w]:
                dist[w] = cost + 1
                que.append((cost + 1, w, 0))
    else:
        # node
        if dist[v] < cost or v not in E:
            continue
        for w in D[v].values():
            w = root(w)
            if cost < gdist[w]:
                gdist[w] = cost
                que.appendleft((cost, w, 1))

print(dist[N-1] if dist[N-1] < INF else -1)


Measured memory_bytes: 203028
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<ll> answers(N+1);
    for(int i=1; i*i<=N; i++){
        for (int j=1; j*j <= N; j++){
            for (int k=1; k*k<=N; k++){
                ll ans = i*i + j*j + k*k + i*j + j*k + i*k;
                if (ans <= N and ans >= 1){
                    answers[ans]++;
                    //cout << "ans: " <<  ans << endl;
                }
            }
        }
    }
    for (int i=1; i<=N; i++){
        cout << answers[i] << endl;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long A[300300],B[300300],X[300300];
priority_queue<int,vector<int>,greater<int> > PQ1;
priority_queue<int,vector<int>,less<int> >    PQ2;
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N*3;i++)
		cin>>X[i];
	long long Sum=0;
	for(int i=0;i<N;i++)
	{
		PQ1.push(X[i]);
		Sum+=X[i];
	}
	A[N-1]=Sum;
	for(int i=N;i<N*3;i++)
	{
		Sum+=X[i];
		PQ1.push(X[i]);
		Sum-=PQ1.top();
		PQ1.pop();
		A[i]=Sum;
	}
	Sum=0;
	for(int i=N*3-1;i>=N*2;i--)
	{
		PQ2.push(X[i]);
		Sum+=X[i];
	}
	B[N*2-1]=Sum;
	for(int i=N*2-1;i>=0;i--)
	{
		Sum+=X[i];
		PQ2.push(X[i]);
		Sum-=PQ2.top();
		PQ2.pop();
		B[i-1]=Sum;
	}
	long long Ans=-9099999999999999999;
	for(int i=N-1;i<N*2;i++)
		Ans=max(Ans,A[i]-B[i]);
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 8440
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
  int n, c;
  cin >> n >> c;
  int d[c + 1][c + 1];
  vector<int> grid[3];
  for (int i = 1; i <= c; i++)
    for (int j = 1; j <= c; j++)
      cin >> d[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++){
      int tmp;
      cin >> tmp;
      grid[(i + j) % 3].push_back(tmp);
    }
  int gaps[3][c + 1];
  for (int i = 0; i < 3; i++)
    for (int j = 1; j <= c; j++){
      gaps[i][j] = 0;
      for (int k = 0; k < grid[i].size(); k++)
        gaps[i][j] += d[grid[i][k]][j];
    }

  int strange = 1000 * n * n;
  for (int i = 1; i <= c; i++){
    for (int j = 1; j <= c; j++){
      if (i == j)
        continue;
      for (int k = 1; k <= c; k++){
        if (j == k || k == i)
          continue;
        strange = min(strange, gaps[0][i] + gaps[1][j] + gaps[2][k]);
      }
    }
  }
  cout << strange << endl;
  return 0;
}


Measured memory_bytes: 1520
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,x,l;
long long lef;
pair<long long,long long> sg[100100];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x>>l;
		sg[i]=make_pair(x+l,x-l);
	}
	sort(sg+1,sg+n+1);
	lef=-1e18;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(lef<=sg[i].second){
			lef=sg[i].first;
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int x,y; cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
    {
  
   ll int x;
   cin>>x;
   if(x==5||x==7||x==3)
   cout<<"YES"<<endl;
   else
   cout<<"NO"<<endl;
  
  
  
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







Measured memory_bytes: 10632
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int h[100100];
int dp[100100];

int solve() {
    fill_n(dp, n, inf);
    dp[0] = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = 1; j <= k; j++) {
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
    return dp[n-1];
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> h[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1024
get_str(String) :-
 current_input(Input),
 read_string(Input,"\n","",_,String).

tap_even([])    :- writeln("Yes").
tap_even([X|R]) :- (X='L' -> tap_odd(R); (X='U' -> tap_odd(R); (X='D' -> tap_odd(R); writeln("No")))).
tap_odd([])     :- writeln("Yes").
tap_odd([X|R])  :- (X='R' -> tap_even(R); (X='U' -> tap_even(R); (X='D' -> tap_even(R); writeln("No")))).

main :-
 get_str(N),atom_codes(A,N), atom_chars(A,C),tap_odd(C).

Measured memory_bytes: 8016
#include<stdio.h>

int main(){
  int a, b, c;
  int i;
  int count = 0;
  
  scanf("%d %d %d", &a, &b, &c);

  for(i = a; i <= b; i++){
    if(c % i == 0) count++;
  }

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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
int t1,t2,a1,a2,b1,b2,ans;
cin>>t1>>t2>>a1>>a2>>b1>>b2;
if(a1<b1){
    a1*=-1;
    b1*=-1;
    a2*=-1;
    b2*=-1;
}

if((a1-b1)*t1+(a2-b2)*t2>0){
    cout<<0;
    return 0;
}
if((a1-b1)*t1+(a2-b2)*t2==0){
    cout<<"infinity";
    return 0;
}
int x=(a1-b1)*t1,y=(a1-b1)*t1+(a2-b2)*t2;y*=-1;
 ans=2*(x/y);
if(x%y==0){
  cout<<ans;
}else {
    //cerr<<(abs(a1-b1)*t1)%abs(abs(a1-b1)*t1-abs(a2-b2)*t2)<<endl;
    cout<<1+ans;
}


return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A;
	while(cin>>A) {
		VI T(5);
		T[0]=A;
		RANGE(i, 1, 5) cin>>T[i];
		sort(ALL(T));
		ll ans = INF;
		do {
			ll t = 0;
			REP(i, T.size()) {
				t = (t+10-1)/10*10;
				t += T[i];
			}
			minUpdate(ans, t);
		} while(next_permutation(ALL(T)));
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N, K, x[112345];
	scanf("%d %d", &N, &K);
	rep(i, N) scanf("%d", &x[i]);

	int ans = 2123456789;
	if (x[0] > 0) {
		printf("%d\n", x[K - 1]);
		return 0;
	}
	if (x[N - 1] < 0) {
		printf("%d\n", -x[N - K]);
		return 0;
	}
	rep(i, N - K + 1) {
		if (x[i] <= 0 && x[i + K - 1] >= 0) {
			ans = min(ans, x[i + K - 1] - x[i] * 2);
			ans = min(ans, x[i + K - 1] * 2 - x[i]);
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
using ll=long long;

int main(){
    ll L,R;
    cin>>L>>R;
    int a[2019];
    for(ll i=0;i<2019;i++){
        a[i]=0;
    }
    for(ll i=L;i<=R;i++){
        ll temp=i%2019;
        if(temp==0){
            cout<<0<<endl;
            return 0;
        }
        a[temp]++;
    }
    ll min_value=2020;
    for(ll i=0;i<2019;i++){
        for(ll j=0;j<2019;j++){
            if(i==j){
                if(a[i]>=2){
                    min_value=min(min_value,i*j%2019);
                }
            }else if(a[i]>=1&&a[j]>=1){
                min_value=min(min_value,i*j%2019);
            }
        }
    }
    cout<<min_value<<endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[] l = new int[M];
        int[] r = new int[M];
        int[][] lr = new int[N + 1][N + 1];
        for (int i = 0; i < M; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
            lr[l[i]][r[i]]++;
        }
        int[] p = new int[Q];
        int[] q = new int[Q];
        for (int i = 0; i < Q; i++) {
            p[i] = sc.nextInt();
            q[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                lr[i][j] += lr[i][j - 1];
            }
        }
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                lr[i][j] += lr[i - 1][j];
            }
        }
        for (int i = 0; i < Q; i++) {
            System.out.println(lr[q[i]][q[i]] + lr[p[i] - 1][p[i] - 1] - lr[p[i] - 1][q[i]] - lr[q[i]][p[i] - 1]);
        }
    }

}


Measured memory_bytes: 64268
X,N = map(int,input().split())
if(N == 0):
    print(str(X))
    exit()
p = list(map(int,input().split()))
p = sorted(p)
tmp = 200
for i in range(102):
    if(i in p):
        pass
    else:
        tmp2 = abs(X-i)
        if(tmp2 < tmp):
            tmp = tmp2
            ans = i
        elif(tmp2 == tmp):
            pass
print(str(ans))

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

using namespace std;

const int MAXN = 100005;

int n, naso;
string s;

int main () {
    cin >> s;
    n = s.size();
    for (int i=1; !naso && i<n; i++) {
        if (s[i] == s[i-1]) {
            cout << i << " " << i+1;
            naso = 1;
        } else if (i > 1 && s[i] == s[i-2]) {
            cout << i-1 << " " << i+1;
            naso = 1;
        }
    }
    if (!naso) cout << -1 << " " << -1;
    return 0;
}


Measured memory_bytes: 512
A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])
max=[]
k=0
while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    ma=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if ma<x and x<=m:
                ma=x
    max.append(ma)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")



Measured memory_bytes: 5720
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


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

	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0 << endl;
	else
		cout << min({a * b, b * c, c * a}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

	string str;
	str.push_back(s[0]);
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] == s[i]) continue;
		else str.push_back(s[i]);
	}
	cout << str.size() - 1 << endl;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define ll long long
#define clr(a, b) memset(a, b, sizeof(a))

using namespace std;

struct in{
    char data[10],s[10];
    int minu,num;
    void input(){
        int h,m;
        scanf("%s%d:%d%s%d",data,&h,&m,s,&num);
        minu=h*60+m;
//        printf("%d\n",minu);
    }
}p[10001];

int n;
bool vis[20000];
int ans[10020];
int str[20000];

int main(){
    while(scanf("%d",&n)&&n){
        for(int i=0;i<n;i++){
            p[i].input();
        }
        memset(ans,0,sizeof(ans));
        char s1[10];
        strcpy(s1,p[0].data);
        memset(vis,0,sizeof(vis));
        bool now =false;

        for(int i=0;i<n;i++){
            if(strcmp(s1,p[i].data)==0){
                if(p[i].s[0]=='I'){
                    if(p[i].num==0){
                        now =true;
                        str[p[i].num]=p[i].minu;
                    }else{
                        vis[p[i].num]=true;
                        str[p[i].num]=p[i].minu;
                    }
                }else{
                    if(p[i].num==0){
                        now =false;
                        for(int j=1;j<=1000;j++){
                            if(vis[j]==false)continue;
                            ans[j]+=p[i].minu-max(str[0],str[j]);
                        }
                    }else{
                        vis[p[i].num]=false;
                        if(now == false)continue;
                        ans[p[i].num]+=p[i].minu-max(str[0],str[p[i].num]);
                    }
                }
            }else{
                if(now ==1){
                    for(int j=1;j<=1000;j++){
                        if(vis[j]==false)continue;
                        ans[j]+=24*60-max(str[0],str[j]);
                    }
                }
                now =false;
                memset(s1,0,sizeof s1);
                memset(vis,0,sizeof vis);
                strcpy(s1,p[i].data);
                if(p[i].num==0){
                    now =true;
                    str[p[i].num]=p[i].minu;
                }else{
                    vis[p[i].num]=true;
                    str[p[i].num]=p[i].minu;
                }
            }
        }
        if(now ==1){
            for(int j=1;j<=1000;j++){
                if(vis[j]==false)continue;
                ans[j]+=24*60-max(str[0],str[j]);
            }
        }
        int ans1 = 0;
        for(int i=1;i<1000;i++){
            ans1 =max(ans1,ans[i]);
        }
        printf("%d\n",ans1);
    }
    return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,L; cin >> N >> L;
    int base = (L + N+L-1) * N / 2;
    dump(base)
    int ans;
    if(L >= 0) {
        ans = base - L;
    }
    else if(N+L-1 < 0){
        ans = base - (N+L-1);
    }
    else{
        ans = base;
    }
    cout << ans << endl;

}

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

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

    int N;
    // 引数の受け取り
    cin >> N;

    // 出力
    cout << (N < 1200 ? "ABC" : "ARC") << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(100000)

def dfs(graph, color, visit, idx):
    visit[idx] = True
    if len(graph[idx]) == 0:
        return
    for i, w in graph[idx]:
        if visit[i] is True:
            continue
        if w%2 == 0:    # 同色で塗る
            color[i] = color[idx]
        else:   # 異色で塗る
            color[i] = 1 - color[idx]   # 1-cで異色になる
        dfs(graph, color, visit, i)


N = int(input())
L = N-1
graph = [[] for _ in range(N)]
color = [-1 for _ in range(N)]
visit = [False for _ in range(N)]

for i in range(L):
    u,v,w = map(int, input().split())
    u-=1
    v-=1
    graph[u].append((v,w))
    graph[v].append((u,w))

color[0] = 0    # 添え字0をcolor0と置く
dfs(graph, color, visit, 0)

for c in color:
    print(c)


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

int main(){
    ll N;
    cin >> N;
    vector<vector<pair<ll, ll>>> tree(N);
    ll a, b, c;
    rep(i,N-1){
        cin >> a >> b >> c;
        a--;b--;
        tree[a].push_back(make_pair(b,c));
        tree[b].push_back(make_pair(a,c));
    }
    ll Q, K;
    cin >> Q >> K;
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>> > que;
    que.push(make_pair(K-1,0));
    vector<ll> dist(N,1e15);
    //dist[K-1] = 0;
    while(!que.empty()){
        ll v = que.top().first;
        ll cost = que.top().second;
        que.pop();
        if(dist[v] != 1e15)continue;
        dist[v] = cost;
        for(auto& u:tree[v]){
            que.push(make_pair(u.first,cost+u.second));
        }
    }
    vector<ll> x(Q), y(Q);
    rep(i,Q){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
    }
    rep(i,Q){
        cout << dist[x[i]] + dist[y[i]] << endl;
    }

}


Measured memory_bytes: 13940
# coding: utf-8
# Your code here!

import re

s=input()
#print(s)


s_t=input()
sl=[]
sl.extend(s)
#print(sl)
hl=re.compile(r'\?+').findall(s)
cl=re.compile(r'\w+').findall(s)
#print(hl)
#print(cl)
hf = False
f = True
tl=[]

if sl[0] == '?':
    for i in range(len(hl)-1):
        tl.append(hl[i])
        tl.append(cl[i])
    if len(hl) != len(cl):
        tl.append(hl[len(cl)])
else:
    for i in range(len(cl)-1):
        tl.append(cl[i])
        tl.append(hl[i])
    if len(hl) != len(cl):
        tl.append(cl[len(hl)])
        
        
#print(tl)

#まず上から
for t in tl:
    if t.find(s_t) != -1:
        s = s.replace('?','a')
        print(s)
        exit()

def fin(s,i):
    
    t=0
    for c in s:
        if c == i[t] or c == '?':
            t+=1
            continue
        
        else:
            #print (':'+c+':'+i[t]+':')
            return False
    
    return True
    
for w in range(len(s)-len(s_t)+1):
    #print(s[len(s)-w-len(s_t):len(s)-w]+':',end='')
    #print(s_t+':',end='')
    if True:
        
        if fin(s[len(s)-w-len(s_t):len(s)-w],s_t):
            s = s[0:len(s)-w-len(s_t)] + s_t +s[len(s)-w:len(s)]
            s = s.replace('?','a')
        
            print(s)
            exit()
    else:
        continue

for t in tl:
    if t[0]!='?':
        continue
    if len(s_t)<= len(t):
        ind=tl.index(t)
        tl[ind]=(len(t)-len(s_t))*'?'+s_t
        ans=''
        for t in tl:
            ans=ans+t
        
        ans = ans.replace('?','a')
        print(ans)
        exit()

print('UNRESTORABLE')



Measured memory_bytes: 3188
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int dp[100];
int fib(int n) {
	if (dp[n] >= 0) return dp[n];
	if (n == 0 || n == 1) return 1;
	return dp[n] = (fib(n - 1) + fib(n - 2));
}

int main() {
	int n; cin >> n;
	memset(dp, -1, sizeof(dp));
	cout << fib(n) << endl;
	return 0;
}


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

struct Card {char suit,value;};

void bubble(struct Card A[],int N){
    for(int i = 0;i<N;i++){
        for(int j = N-1;j >=i+1;j--){
            if(A[j].value < A[j-1].value){
                Card t = A[j];A[j] = A[j-1];A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[],int N){
    for(int i = 0;i<N;i++){
        int minj = i;
        for(int j = i;j<N;j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i];A[i] = A[minj];A[minj] = t;
    }
}

void print(struct Card A[],int N){
    for(int i = 0;i<N;i++){
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i = 0;i<N;i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    char ch;
    
    cin >> N;
    for(int i = 0;i<N;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0;i<N;i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout << "Stable" << endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

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

    int l = S.length();
    vector <string> dic;
    map <string, int> D;

    int count = 0;
    for (int i = 0; i < l; i++){
        for (int j = 1; i + j <= l && j <= 5; j++){
            string a = S.substr(i, j);
            if (D[a] == 0){
                dic.push_back(a);
                count ++;
            }
            D[a] ++;
        }
    }

    sort(dic.begin(), dic.end());
    
    cout << dic[K - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 2048
s = gets.to_s.chomp
k = gets.to_s.to_i

b = s.bytes
# p "az".bytes #=> [97, 122]
ans = s.dup
b.each_with_index do |c, i|
  
  if c == 97
    next
  else
    d = 123 - c
    if d <= k
      k -= d
      ans[i] = 'a'
    end
  end
end

ans[-1] = (97 + (ans[-1].ord + k - 97) % 26).chr

puts ans

Measured memory_bytes: 4988
// parameter "input" gets all data
function Main(input) {
 // the first line is assigned to input[0], the second line is assigned to input[1] similarly.
 input = input.split("\n");
 tmp = input[1].split(" ");
 // convert string from integer using "parseInt"
 var a = parseInt(input[0], 10);
 var s = ''
 a= a % 10
  switch(a){
    case 2:
            case 4:
            case 5:
            case 7:
            case 9:
          s = 'hon'
       break; // 可选的
      case 0:
            case 1:
            case 6:
            case 8:
       s ='pon'
       break; // 可选的
    case 3:
        s='bon'
       break; // 可选的
 
}
 //output
 console.log(s)
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

  if (n % 500 <= a) {
          cout << "Yes" << endl;
    }
    
  else if ( n % 500 > a) {
          cout << "No" << endl;
    }
 }
  


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int h, n;
  cin >> h >> n;

  int a[100009];
  rep(i, n) cin >> a[i];

  int ans = 0;
  rep(i, n) ans += a[i];

  if(ans >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}


/*





















*/


Measured memory_bytes: 640
# coding: utf-8
# Here your code !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
N = int(input())
K = int(input())

a = 1
for i in range(N) : 
    if a > K : a = a + K
    else : a = 2*a
print(a)

Measured memory_bytes: 15528
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  while(cin>>n>>m&&n&&m){
    bool f[n],d[n][n];
    memset(f,false,sizeof(f));
    memset(d,false,sizeof(d));
    int ans=0;
    vector<int> c;
    for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;a--;b--;
      d[a][b]=d[b][a]=true;
      if(a==0&&!f[b]){
        ans++;
        f[b]=true;
        c.PB(b);
      }
    }
    for(int i=0;i<c.size();i++){
      for(int j=1;j<n;j++){
        if(c[i]==j)continue;
        if(d[c[i]][j]&&!f[j]){
          ans++;
          f[j]=true;
        }
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1468
import sys
from collections import deque

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

# グリッドBFS
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#': continue
        dis = [[-1 for k in range(w)] for k in range(h)]
        dis[i][j] = 0
        d = deque()
        d.append([i, j])
        while len(d):
            now = d.popleft()
            y = now[0]
            x = now[1]
            for k in range(4):
                ny = y + dy_dx[k][0]
                nx = x + dy_dx[k][1]
                if 0 <= ny < h and 0 <= nx < w:
                    if s[ny][nx] != '#' and dis[ny][nx] == -1:
                        dis[ny][nx] = dis[y][x] + 1
                        ans = max([ans, dis[ny][nx]])
                        d.append([ny, nx])

print(ans)


Measured memory_bytes: 75344
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i=0; i < n; i++){
    if(s[i] != s[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int number_of_partitions(int n,int m,int mod){
	int dp[m+1][n+1]={};
	dp[0][0] = 1;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(j-i >= 0){
				dp[i][j] = (dp[i-1][j]+dp[i][j-i]) % mod;
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	return dp[m][n];
}


int main(){
	int n,m;
	cin >> n >> m;
	cout << number_of_partitions(n,m,int(1e9+7)) << endl;
}


Measured memory_bytes: 7044
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    ll data[n]; rep(i,n) cin >> data[i];
    ll ans[n];

    sort(data,data+n);

    int count = n-1;
    for(int i = 2; i < n; i += 2){
        ans[i] = data[count]; count--;
    }
    ans[0] = data[count]; count = 0;
    for(int i = 1; i < n; i += 2){
        ans[i] = data[count]; count++;
    }
    ll num1= 0;
    rep(i,n-1) num1 += abs(ans[i+1]-ans[i]);

    count = 0;
    for(int i = 2; i < n; i += 2){
        ans[i] = data[count]; count++;
    }
    ans[0] = data[count]; count = n-1;
    for(int i = 1; i < n; i += 2){
        ans[i] = data[count]; count--;
    }
    ll num2= 0;
    rep(i,n-1) num2 += abs(ans[i+1]-ans[i]);

    cout << max(num1,num2) << endl;
}



Measured memory_bytes: 5168
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, i, k = 0;
	long long int j = 0, ans = 0;
	cin >> n;
	vector<int>a(n), b(n), c(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	for (i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(c.begin(), c.end());
	for (i = 0; i < n; i++) {
		while (a[j] < b[i] && j < n)j++;
		while (c[k] <= b[i] && k < n)k++;
		ans += j * (n - k);
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 1536
from itertools import combinations

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)

fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1].issubset(x) for i in x)

while all(map(fail, combinations(r, n))):
  n -= 1
print(n)


Measured memory_bytes: 3188
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline()
    result = 0
    for i in range(1, N):
        s1 = S[:i]
        s2 = S[i:]
        result = max(result, len(set(s1) & set(s2)))
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940