akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  int m,d; cin>>m>>d;
  if(m<=3) cout<<0<<endl;
  else{
    int sum=0;
    for(int i=4;i<=m;i++){
      for(int j=2;j<=9;j++){
        for(int k=2;k<=9;k++){
          if(j*10+k<=d && j*k==i) sum++;
        }
      }
    }
    cout<<sum<<endl;
  }
  
}



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


using namespace std;
const int N = 2e5 + 10;

struct Edge{
	int to , nex;
}e[N << 1];int head[N] , ecnt;

void adde(int fr,int to){
	e[++ecnt] = (Edge){to , head[fr]};
	head[fr] = ecnt;
}

void addedge(int fr,int to){
	adde(to , fr);
	adde(fr , to);
}

int n , par[N] , c[N] , mx[N];
map<int,int> exi[N];

void dfs(int x,int fa)
{
	par[x] = fa;
	for (int j = head[x];j;j = e[j].nex)
	if (e[j].to != fa){
		mx[e[j].to] = max(mx[x] , x);
		dfs(e[j].to , x);
	}
}
int Q(int x,int v){
	if (exi[x].count(v)) return exi[x][v];
	int res = 0;
	for (int j = head[x];j;j = e[j].nex){
		if (e[j].to <= v && e[j].to != par[x]){
			res += Q(e[j].to , v) + 1;
		}
	}
	return exi[x][v] = res;
}

void dfs2(int x){
	for (int j = head[x];j;j = e[j].nex){
		if (e[j].to != par[x]){
			
			if (e[j].to > mx[x]){
				c[e[j].to] = c[x] + Q(e[j].to , mx[e[j].to]) + 1;
			}else{
				c[e[j].to] = c[x] + Q(e[j].to , mx[e[j].to]) - Q(e[j].to , mx[x]);
			}
			dfs2(e[j].to);
		}
	}
}
int main(){
	scanf("%d",&n);
	for (int i = 1;i < n;i++){
		int u , v;scanf("%d%d",&u,&v);
		addedge(u , v);
	}
	mx[1] = -1;
	dfs(1 , 0);
	dfs2(1);
	
	for (int i = 2;i <= n;i++) printf("%d ",c[i]);
	return 0;
}

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

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string str;
    cin >> str;
    int ans = 0;
    int point = str.size() / 2;
    for(int i=0;i<point;i++){
        if(str[i] != str[str.size()-i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int n;
	cin >> n;
	while (n > 0) {
		if (n%10==7) {
			cey;
			return 0;
		}
		n /= 10;
	}
	cen;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){

  int n,s,m[50],bun[50][50],r,p,q,result=0,count[50]={0},i,j,k,l;

  cin>>n>>s;

  for(i=0;i<s;i++){

    cin>>m[i];
    for(j=0;j<m[i];j++) cin>>bun[i][j];

  }

  cin>>r;

  for(i=0;i<r;i++){

    cin>>p>>q;
    for(j=0;j<s;j++){

      for(k=0;k<m[j]-1;k++){
        for(l=k+1;l<m[j];l++){

          if(bun[j][k] == p && bun[j][l] == q){
            count[p-1]++;
            count[q-1]++;
          }
          if(bun[j][k] == q && bun[j][l] == p){
            count[p-1]++;
            count[q-1]++;
          }

        }
      }

    }

  }
  

  for(i=0;i<n;i++) if(count[i] != 0) result++;
  
    
  cout<<result<<endl;

  return 0;

}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();

		if(a+W<b) {
			System.out.println(b-a-W);
		}else if(a>b+W){
			System.out.println(a-b-W);
		}else {
			System.out.println(0);
		}




	}
	public static int sample(int N,int M,char[][] arrayA,char[][] arrayB,int k) {
		int res=0;
		for(int i=0;i<N-M+1;i++) {
			for(int j=0;j<M;j++) {
				for(int l=0;l<M;l++) {
					if(arrayA[j+k][l+i]!=arrayB[j][l]) {
						res = 1;
						break;
					}
				}
			}
			if(res == 0) {
				return 0;
			}
			res = 0;
		}
		return 1;
	}

}


Measured memory_bytes: 23764
def myAnswer(S:str) -> int:
   ans = 0
   a=[chr(i) for i in range(65, 65+26)]
   a.remove("A")
   a.remove("T")
   a.remove("C")
   a.remove("G")
   counter = 0
   for s in S:
      if((s in a) == False):
         counter +=1
      else:
         ans=max(counter,ans)
         counter=0
   return max(ans,counter)


def modelAnswer():
   tmp=1
def main():
   S = input()
   print(myAnswer(S))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
from itertools import accumulate

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    max_sum = 0
    index = -1
    sum_P = [0] + list(accumulate(P))
    for i in range(N + 1 - K):
        tmp = sum_P[i+K] - sum_P[i]
        if tmp > max_sum:
            max_sum = tmp
            index = i
        
    ans = 0
    for i in range(index,index + K):
        tmp = P[i] * (P[i] + 1) // 2
        ans += tmp / P[i]
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 77576
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"):
    pars = list(range(N))

    def getpar(n: int):
        if pars[n] == n:
            return n
        pars[n] = getpar(pars[n])
        return pars[n]

    def union(a: int, b: int):
        pars[getpar(a)] = getpar(b)

    for xi, yi in zip(x, y):
        union(xi - 1, yi - 1)
    print(sum(
        1
        for i in range(N)
        if getpar(p[i] - 1) == getpar(i)
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, p, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19364
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
class Trois{
    public:
        int a, c;
        string b;
        Trois(){
            a = 0;
            b = "";
            c = 0;
        }
        Trois(int _a, string _b, int _c){
            a = _a;
            b = _b;
            c = _c;
        }
};
bool cmp(const Trois &_a, const Trois &_b) {
    if (_a.b == _b.b) return _a.c > _b.c;
    return _a.b < _b.b;
}
void Main(){
    int N = read();
    vector<Trois> V(N);
    for (int i = 0; i < N; i++) {
        V[i].a = i+1;
        V[i].b = read_s();
        V[i].c = read();
    }
    sort(V.begin(), V.end(), cmp);
    for (auto v:V) printf("%d\n", v.a);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200000 + 5;

int n;
int a[N];
pair<int, int> str[N];

bool check(int sigma) {
    int top = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] > a[i - 1]) {
            continue;
        } else {
            for ( ; top; ) {
                if (str[top].first > a[i]) {
                    top--;
                } else {
                    break;
                }
            }
            int ptr = a[i];
            for ( ; ptr > 0; ptr--) {
                if (top && str[top].first == ptr) {
                } else {
                    str[++top] = make_pair(ptr, 0);
                }
                str[top].second++;
                if (str[top].second == sigma) {
                    top--;
                } else {
                    break;
                }
            }
            if (ptr == 0) {
                return false;
            } else {
            }
        }
    }
    return true;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }
    int l = 0, r = n;
    while (l + 1 < r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << endl;
}

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


Measured memory_bytes: 1656
#include <stdio.h>
#include <string.h>

int main(void)
{
	char tarou[101],hanako[101];
	int n = 1000, i, k, T = 0, H = 0;;
	scanf("%d", &n);
	getchar();
	for (i = 0; i < n; i++)
	{
		scanf("%s %s", tarou, hanako);
		if (strcmp(tarou, hanako) == 0)
		{
			T++; H++;
		}else if (strcmp(tarou, hanako) < 0)
		H += 3;
		else
		T += 3;
	}
	printf("%d %d\n", T, H);
	return 0;
}

Measured memory_bytes: 608
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = y-x
        sm += tmp
        if tmp > 0:
            tmp //= 2
        s += tmp
    if s >= 0 and sm >= 0:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 10404
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    System.out.println(solve(A) ? "First" : "Second");
  }

  static boolean solve(long[] A) {
    int N = A.length;
    long sum = 0;
    ArrayList<Integer> oddIdx = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      sum += A[i];
      if (A[i] % 2 == 1) {
        oddIdx.add(i);
      }
    }
    sum -= N;
    if (sum % 2 == 1) {
      return true;
    }
    if (oddIdx.size() != 1) {
      return false;
    }
    if (A[oddIdx.get(0)] == 1) {
      return false;
    }
    A[oddIdx.get(0)]--;
    long gcd = A[0];
    for (int i = 1; i < N; i++) {
      gcd = gcd(gcd, A[i]);
    }
    for (int i = 0; i < N; i++) {
      A[i] /= gcd;
    }
    return !solve(A);
  }

  static long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
  }

}

Measured memory_bytes: 46492
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const long long int MOD = 1000003;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;




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

	cin >>N>> L >> R >> H >> W;
	string s;
	cin >> s;
	s = 'o' + s;
	if (L > R) {
		swap(L, R);
		swap(H, W);
	}
	if (H < W) {
		while (R != W) {
			if (s[R + 2]=='.')R += 2;
			else if (s[R + 1] == '.')R++;
			else break;
		}
		if (R != W) {
			cout << "No\n";
			return 0;
		}
		while (L != H) {
			if (s[L + 2] == '.')L += 2;
			else if (s[L + 1] == '.')L++;
			else break;
		}
		if (L != H) {
			cout << "No\n";
			return 0;
		}
		cout << "Yes\n";
		return 0;
	}
	bool flag = false;
	for (int i = R; i <= W; i++) {
		if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.')flag = true;
	}
	for (int i = R; i < W; i++) {
		if (s[i] == s[i + 1] && s[i] == '#') {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = L; i < H; i++) {
		if (s[i] == s[i + 1] && s[i] == '#') {
			cout << "No\n";
			return 0;
		}
	}
	if (flag)cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
int main(){
    CIN(A);CIN(B);CIN(C);
    REP(a,B+1){
        if(A*a%B==C){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


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

int main(){
  char b;
  cin >> b;
  if (b == 'A') cout << 'T';
  else if (b == 'T') cout << 'A';
  else if (b == 'C') cout << 'G';
  else if (b == 'G') cout << 'C';
  }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else if(s == "Rainy"){
    cout << "Sunny" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

int n;
string s1,s2;
int mod = 1e9+7;

int oblicz(int cur)
{
   if(cur == n-1) return 3;
   if(cur == n-2 and s1[n-2] == s1[n-1]) return 6;
   if(cur == n-2) return 6;
   if(s1[cur] == s1[cur+1])
   {
        if(cur == n-3)
        {
            return 2*oblicz(cur+2) % mod;
        }
        if(s1[cur+2] == s1[cur+3])
        {
            return 3 * oblicz(cur+2) % mod;
        }
        else
        {
            return 2*oblicz(cur+2) % mod;
        }
   }
   else
   {
        if(s1[cur+1] == s1[cur+2])
        {
            return oblicz(cur+1);
        }
        else
        {
            return 2*oblicz(cur+1) % mod;
        }
   }
}

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> s1 >> s2;
    int pod = 0;
    ///cout << oblicz(47) << endl;
    cout << oblicz(0) << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n) {
  int ret = 1;
  for (int i = 1; i < n + 1; ++i) {
    ret = ret * i;
  }
  return ret;
}

/* 最大公約数 */
template <typename T>
T gcd(T x, T y) { return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>
T lcm_n(vector<T> &numbers) {
  T l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); ++i) {
    l = lcm(l, numbers[i]);
  }
  return l;
}

/*
 * DP向け
 */
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}



int main() {
  ll N;
  mpint ans = 1;
  cin >> N;
  vector<ll> A(N);

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (int i = 0; i < N; ++i) {
    ans *= A[i];
    if (1'000'000'000'000'000'000 < ans) {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4084
n = int(input())
kk_list = []
# 九九の答えをリストに入れる
for i in range(1,10):
    for j in range(1,10):
        kk_list.append(i * j)
# 九九の答えリストにｎがあればYes
if n in kk_list:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9152
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <climits>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include<ctime>
#include<set>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
set<int> s;
while(n--)
{
    int t;
    cin>>t;
    auto it=s.find(t);
    if(it!=s.end())
        s.erase(t);
    else
        s.insert(t);
}
cout<<s.size()<<endl;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int i,j,k,n;
  int res[7],tmp,maxi,f;
  vector<int> in(5);
  set<int> s;
  string data[7] = {"four card","full house","straight","three card","two pair","one pair","null"};

  while(scanf("%d,%d,%d,%d,%d",&in[0],&in[1],&in[2],&in[3],&in[4],&in[5]) != EOF){
    rep(i,7) res[i] = 0;
    s.clear();
    rep(i,5) s.insert(in[i]);
    f = 1;
    sort(in.begin(),in.end());

    maxi = 0;
    rep(i,5){
      tmp = 0;
      rep(j,5) if(in[i] == in[j]) tmp++;
      if(maxi < tmp) maxi = tmp;
    }

    if((int)s.size() == 2){
      if(maxi == 4) res[0] = 1;
      if(maxi == 3) res[1] = 1;
    }
    if((int)s.size() == 3){
      if(maxi == 3) res[3] = 1;
      if(maxi == 2) res[4] = 1;
    }
    if((int)s.size() == 4) res[5] = 1;

    REP(i,1,5) if(in[i-1] + 1 != in[i]) f = 0;
    if(f && (int)s.size() == 5) res[2] = 1;
    f = 1;
    if(in[0] = 1 && in[1] == 10 && in[2] == 11 && in[3] == 12 && in[4] == 13) res[2] = 1;

    res[6] = 1;

    rep(i,7) if(res[i]){
      cout << data[i] << endl;
      break;
    }
  }


  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define inf 1e9
#define mod 1000000007

void solve()
{
    string s1, s2;
    cin >> s1 >> s2;

    int ans = 1;
    for (int i = 0; i < s1.length(); i++)
    {
        if (s1[i] != s2[i])
        {
            ans = 0;
            break;
        }
    }
    if (ans) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


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

typedef long long ll;
#define mem(x,y) memset(x,y,sizeof(x))
#define PI   3.1415926
#define INF  0x3f3f3f3f//(1061109567)
int main()
{
	int n,k,s;
	cin >> n >> k >> s;
	int q;
	if(s!=1e9) q=s+1;
	else q=s-1;
	if(n>k)
	{
		for(int j=0;j<k;j++)
		{
			cout << s << " "; 
		}
		for(int j=0;j<n-k;j++)
		{
			if(j!=n-k-1) cout << q << " ";
			else cout << q;
		}
	}
	else
	{
		for(int j=0;j<k;j++)
		{
			if(j==k-1) cout << s;
			else cout << s << " "; 
		}
	}
	return 0;
}

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

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

    int K;
    string S;
    cin >> K >> S;

    if(S.length() <= K) cout << S << endl;
    else {
        for(int i = 0; i < K; i++) {
            cout << S[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    char c; cin >> c;
    string s = "aeiou";
    cout << (s.find(c) != string::npos ? "vowel" : "consonant") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int bubbleSort(int a[],int n){
    int flag =1,i,tmp,ct =0;
    while(flag ==1){
        flag = 0;
        for(i = n-1;i>0;i--){
            if(a[i] < a[i-1]){
                tmp = a[i];
                a[i] = a[i-1];
                a[i-1] = tmp;
                flag = 1;
                ct++;
            }
        }
    }
    return ct;
}
int main(){
    int a[100];
    int n,i,ct;
    scanf("%d",&n);
    for(i = 0;i<n;i++){
        scanf("%d",&a[i]);
    }
    ct = bubbleSort(a,n);
    for(i =0;i<n-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n%d\n",a[n-1],ct);
    return 0;
}


Measured memory_bytes: 2076
local mce, mma, mmi = math.ceil, math.max, math.min
local h, n = io.read("*n", "*n")
local inf = 1000000007
local z = {}
for i = 1, 10000 do
  z[i] = inf
end
for i = 1, n do
  local a, b = io.read("*n", "*n")
  z[a] = mmi(z[a], b)
end
local t = {}
for i = 1, h do
  t[i] = inf
end
for a = 1, 10000 do
  local b = z[a]
  if b < inf then
    for src = h - 1, 1, -1 do
      local lim = mce((h - src) / a)
      for j = 1, lim do
        local dst = mmi(h, src + a * j)
        t[dst] = mmi(t[dst], t[src] + b * j)
      end
    end
    do -- src = 0
      local lim = mce(h / a)
      for j = 1, lim do
        local dst = mmi(h, a * j)
        t[dst] = mmi(t[dst], b * j)
      end
    end
  end
end
print(t[h])


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count=1;
    for(int i=1; i<N; i++){
        if(S.at(i)!=S.at(i-1)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define X first
#define Y second
typedef long long LL;
typedef pair<int, int> pii;
const int N = 1e5 + 100;

int a[N], b[N], c[N];

int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) scanf("%d", a + i);
    for(int i = 1; i <= n; i ++) scanf("%d", b + i);
    for(int i = 1; i <= n; i ++) scanf("%d", c + i);

    sort(a + 1, a + 1 + n);
    sort(c + 1, c + 1 + n);
    LL ans = 0;
    for(int i = 1; i <= n; i ++) {
        ans += (lower_bound(a + 1, a + 1 + n, b[i]) - (a + 1)) * 1LL *
            (c + 1 + n - (upper_bound(c + 1, c + 1 + n, b[i])));
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
	int a, b;

	scanf("%d %d", &a, &b);

	if ((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) {
		printf("Possible\n");
	}
	else printf("Impossible\n");

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int S = N * 800;
  
  if (N >= 15) {
    cout << S - ((N / 15) * 200) << endl;
  } else {
    cout << S << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int n,m,i,j,a[3],s,c,ans;
 
   scanf("%d %d",&n,&m);
   a[0]=a[1]=a[2]=-1;
   for (i=0;i<m;i++) {
      scanf("%d %d",&s,&c);
      if (s==1 && c==0 && n>1) {
         puts("-1");
         return 0;
      }
      if (a[s-1]==-1) a[s-1]=c;
      else if (a[s-1]!=c) {
         puts("-1");
         return 0;
      }
   }
   if (n==1 && (m==0 || a[0]==0)) {
      puts("0");
      return 0;
   }
   ans=1;
   for (i=1;i<n;i++) ans*=10;
   for (;;ans++) {
      j=ans;
      for (i=n-1;i>=0;i--,j/=10)
         if (a[i]>=0 && a[i]!=j%10) break;
      if (i<0) break;
   }
   printf("%d\n",ans);
   return 0;
}


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

int main(){

	float l;
	float x,res;
	cin>> l;
	x = ((float)l)/3;
	if((3 * x) != l)
		res = x*x*(l - (2*x));
	else
		res = x*x*x;
	printf("%.6f\n",res );
}

/*

xyz

(x+y+z) = L
x + y = (L - z)

f = (L -(x + y))*x*y

f = L



*/

Measured memory_bytes: 384
from collections import Counter as cs

S = input()
T = input()

cS = cs(S)
cT = cs(T)

lS = [0] * 26
lT = [0] * 26

az = "abcdefghijklmnopqrstuvwxyz"

for i in range(26):
    lS[i] = cS[az[i]]
    lT[i] = cT[az[i]]

lS.sort()
lT.sort()

if lS==lT:
    print("Yes")
else:
    print("No")


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

int main() {
    int n = 0, k = 0;
    int p[1000];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> p[i];

    sort(p, p + n);

    int ans = 0;
    for (int i = 0; i < k; i++) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,t,sum,f=0,d,b;
    cin>>n;
        cin>>t;
        sum=0;
    while(n--)
    {

        cin>>a;

        if(f==0){b=a;f=1;}
        else{
                d=a-b;
        b=a;
        if(d<=t)
        {
            sum+=d;
        }
        else{sum+=t;}

        }
    }
    sum+=t;
    cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  long sum = 0;
  int maxi = 0;
  rep(i,n){
    int p;
    cin >> p;
    maxi = max(maxi,p);
    sum += p;
  }
  cout << sum - maxi/2 << 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 For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int x, y;
	cin >> x >> y;
	int res = 0;
	if (x * y == 1) {
		res+=400000;
	}
	if (x <= 3) {
		res += 100000 * (4 - x);
	}
	if (y <= 3) {
		res += 100000 * (4 - y);
	}
	put(res);
	return 0;
}


Measured memory_bytes: 256
//00
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    int c[2][9];
    for(int i=0;i<2;i++){
      for(int j=0;j<9;j++){
	cin>>c[i][j];
      }
      sort(c[i],c[i+1]);
    }
    int gw=0,jw=0,np=0;
    do{
      int g=0,j=0;
      np++;
      for(int i=0;i<9;i++){
	((c[0][i]>c[1][i])?g:j)+=c[0][i]+c[1][i];
      }
      gw+=g>j;
      jw+=j>g;
    }while(next_permutation(c[0],c[1]));
    cout<<fixed<<setprecision(5)<<gw*1./np<<' '<<jw*1./np<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int ans = 0;
    for (int i = 0; i < 10; ++i) {
        int x; cin >> x;
        ans += x;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL C[2020][2020];
const LL MOD = 1000000007;

void makepas(){
  MSET(C, 0);
  REP(i, 2020){
    C[i][0] = C[i][i] = 1;
    for(int j = 1; j < i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
  }
}

int n, k;

void solve() {
  makepas();
  cin >> n  >> k;
  FOR(i, 1, k+1) {
    int a = n-k-(i-1);
    if (a < 0) {
      cout << 0 << endl;
      continue;
    }
    LL res = C[k-1][i-1];
    res = res * C[a+i][i] % MOD;
    cout << res << endl;
  }
}

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


Measured memory_bytes: 32128
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
d = a-b
l = 0
r = 10**10+1
ans = r


def check(num):
    global h
    global d
    global b
    cnt = 0
    for i in h:
        if i>b*num:
            cnt+= (i-b*num+d-1)//d
    return cnt<=num


while r>=l:
    mid = (r+l)//2
    if check(mid):
        r = mid-1
        ans = min(ans,mid)
    else:
        l = mid+1
print(ans)

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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  long long N;
  cin >> N;

  const long long k = N / 2;
  const long long total = (N % 2) ? (2 * k + 2) * k + k + 1 : (2 * k + 1) * k;
  cout << total - N << endl;
  return 0;
}


Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll a,b;
cin>>a>>b;
string x1="";
string x2="";
for(ll i=0;i<a;i++)
{
    x1+=(char)(b+48);
}
for(ll i=0;i<b;i++)
{
    x2+=(char)(a+48);
}
string ans=min(x1,x2);
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
lld mk[N];
int main()
{
    //sync;
    string s;
    lld k;
    cin>>s>>k;
    lld n = sz(s);
    vector<string> v;
    rep(i,0,n) {
        string curr = "";
        rep(j,i,n) {
            if(sz(curr) >= k) break;
            curr += s[j];
            v.pb(curr);
        }
    }
    sort(all(v));
    lld tot = 1;
    if(k==1) {
        cout<<v[0]<<endl;
        return 0;
    }
    rep(i,1,sz(v)) if(v[i] != v[i-1]) {
        tot++;
        if(tot==k) {
            cout<<v[i]<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1660
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll ans = 0;
    priority_queue<int> pq;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        pq.push(x);
    }
    while (m--)
    {
        int x = pq.top();
        pq.pop();
        x = x / 2;
        pq.push(x);
    }
    while (!pq.empty())
    {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 892
A,B,M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

m = 10000000

for i in range(M):
  x,y,c = map(int, input().split())
  m= min(m, a[x-1]+b[y-1]-c)
  
m = min(m, min(a)+min(b))
  
print(m)

Measured memory_bytes: 24708
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		char[] C = S.toCharArray();
		int N = C.length;
		// < = 60 , > = 62 ASCII
		List<Integer> zeros = new ArrayList<>();
		int[]a = new int[N+1];
		Arrays.fill(a,-1);
		if(C[0] == '<') {
			a[0] = 0;
			zeros.add(0);
		}
		for(int i=1;i<N;i++) {
			if(C[i-1] == '>' && C[i] == '<') {
				a[i] = 0;
				zeros.add(i);
			}
		}
		if(C[N-1] == '>') {
			a[N] = 0;
			zeros.add(N);
		}

		for(Integer zero:zeros) {

			for(int i=zero;i>0;i--) {
				if(a[i-1]==0)continue;
				if(C[i-1] == '>') {
					a[i-1] = a[i]+1;
				}else {
					break;
				}
			}
		}
		for(Integer zero:zeros) {
			for(int i=zero;i<N;i++) {
				if(a[i+1]==0)continue;
				if(C[i] == '<') {
					a[i+1] = a[i]+1;
				}else {
					break;
				}
			}
		}
		for(int i=1;i<N;i++) {
			if(C[i-1] == '<'&&C[i] == '>') {
				a[i] = Math.max(a[i-1], a[i+1])+1;
			}
		}

		long sum = 0;
		for(int num:a) {
			//out.print(num);
			sum += num;
		}
		out.println(sum);

	}
	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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


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

    bool n = false;
    bool s = false;
    bool e = false;
    bool w = false;

    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'N') n = true;
        else if (S[i] == 'S') s = true;
        else if (S[i] == 'E') e = true;
        else if (S[i] == 'W') w = true;
    }

    if (n == s && e == w) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    char upper_a = toupper(a[0]);
    char upper_b = toupper(b[0]);
    char upper_c = toupper(c[0]);
    cout << upper_a << upper_b << upper_c << "\n";
}

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

#define ll long long
int main() {
  ll N, K;
  cin >> N >> K;
  
  vector<pair<ll, ll>> vec(N);
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    
    vec[i] = {a, b};
  }
    
  sort(vec.begin(), vec.end());
  
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum += vec[i].second;
    
    if (sum >= K) {
      cout << vec[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4812
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

type Job struct {
	A, B int
}

func main() {
	defer stdout.Flush()
	N := readInt()
	J := make([]Job, N)
	for i := range J {
		J[i].A = readInt()
		J[i].B = readInt()
	}

	pq := new(PriorityQueue)
	push := func(x Job) {
		heap.Push(pq, x)
	}
	pop := func() Job {
		x := heap.Pop(pq)
		return x.(Job)
	}
	empty := func() bool {
		return pq.Len() == 0
	}

	for _, x := range J {
		push(x)
	}
	t := 0
	for !empty() {
		j := pop()
		if j.B < t+j.A {
			println("No")
			return
		}
		t = t + j.A
	}
	println("Yes")

}

// -----------------------------------------------------------------------------

type PriorityQueue []Job

func (pq PriorityQueue) Len() int {
	return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].B < pq[j].B {
		return true
	} else if pq[j].B < pq[i].B {
		return false
	}
	return pq[i].A < pq[j].A
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	old := *pq
	*pq = append(old, x.(Job))
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old) - 1
	x := old[n]
	*pq = old[:n]
	return x
}


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

void sharp() {
	for (int i = 0; i < 100; i++) {
		cout << "#";
	}
	cout << endl;
}
void dots() {
	for (int i = 0; i < 100; i++) {
		cout << ".";
	}
	cout << endl;
}
void just50() {
	for (int i = 0; i < 50; i++) {
		cout << ".#";
	}
	cout << endl;
}
void f(int a) {
	for (int i = 0; i < a; i++) {
		cout << ".#";
	}
	for (int i = 0; i < 50 - a; i++) {
		cout << "##";
	}
	cout << endl;
}
void g(int b) {
	for (int i = 0; i < b; i++) {
		cout << "#.";
	}
	for (int i = 0; i < 50 - b; i++) {
		cout << "..";
	}
	cout << endl;
}
int main() {
	int a, b;
	cin >> a >> b;
	a--;
	b--;
	int cnt = 1;
	cout << 100 << " " << 100 << endl;
	sharp();
	while (a > 50) {
		just50();
		sharp();
		cnt += 2;
		a -= 50;
	}
	if (a > 0) {
		f(a);
		sharp();
		cnt += 2;
	}
	cnt++;
	dots();
	while (b > 50) {
		just50();
		dots();
		cnt += 2;
		b -= 50;
	}
	if (b > 0) {
		g(b);
		dots();
		cnt += 2;
	}
	for (int i = 0; i < 100 - cnt; i++) {
		dots();
	}
}

Measured memory_bytes: 256
/*
现在你有一棵树, 节点已经被染上颜色, 非黑(B)即白(W)
你可以从任意一个节点出发, 并执行操作: 

将所在节点的颜色反转 or 
走到下一个节点, 并反转它的颜色

问最少操作多少次, 能使得树是黑涩的(即无白色节点)
*/
#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5;

long long ans,cost[N];

int root,n,cnt,to[N<<1],nxt[N<<1],head[N],du[N];

bool Del[N],vis[N],val[N];

char c[N];

queue<int>que;

void add(int x,int y){
	to[++cnt]=y;nxt[cnt]=head[x];head[x]=cnt;
}

void sol(int x,int f){
	for(int i=head[x];i;i=nxt[i])
		if(to[i]!=f&&!Del[to[i]]){
			sol(to[i],x);
			if(val[x]==1) ans=min(ans,cost[x]+cost[to[i]]-3);
			else ans=min(ans,cost[x]+cost[to[i]]-1);
			cost[x]=min(cost[to[i]]-1,cost[x]);
		}
	if(val[x]) cost[x]--;
	else cost[x]++;
}


int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
		du[x]++;du[y]++;
	}
	scanf("%s",c+1);
	for(int i=1;i<=n;i++){
		if(du[i]==1&&c[i]=='B') que.push(i);
	}
	while(!que.empty()){
		int x=que.front();que.pop();
		Del[x]=1;
		for(int i=head[x];i;i=nxt[i]){
			du[to[i]]--;
			if(c[to[i]]=='B'&&du[to[i]]==1&&!Del[to[i]]) que.push(to[i]);
		}
	}
	for(int i=1;i<=n;i++)
		if(!Del[i]) {root=i;break;}
	if(!root) printf("0\n");
	else {
		for(int i=1;i<=n;i++)
			if(!Del[i]){
				val[i]=((du[i]%2)&&c[i]=='B')|(!(du[i]%2)&&c[i]=='W');
			}
		sol(root,0);
		for(int i=1;i<=n;i++)
			if(!Del[i]){
				ans+=val[i]+2;
			}
		ans-=2;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7808
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++) {
            list.add(scan.nextInt());
        }
        Collections.sort(list);
        Collections.reverse(list);

        for (int i = 0; i < 3; i++) {
            System.out.println(list.get(i));
        }
    }

}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
ll a, b, c, d;
map<ll, ll> memo;

ll solve(ll n) {
  if (n == 0) return 0;
  if (n == 1) return d;
  if (memo.count(n)) return memo[n];
  
  ll res = 1e18;
  if (res/d > n) res = d*n;
  ll l2 = n/2*2;
  ll r2 = (n+1)/2*2;
  
  ll l3 = n/3*3;
  ll r3 = (n+2)/3*3;
  
  ll l5 = n/5*5;
  ll r5 = (n+4)/5*5;
  
  res = min(res, llabs(n-l2)*d + a + solve(l2/2));
  res = min(res, llabs(n-r2)*d + a + solve(r2/2));
  res = min(res, llabs(n-l3)*d + b + solve(l3/3));
  res = min(res, llabs(n-r3)*d + b + solve(r3/3));
  res = min(res, llabs(n-l5)*d + c + solve(l5/5));
  res = min(res, llabs(n-r5)*d + c + solve(r5/5));
  
  return memo[n] = res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    ll n;
    memo.clear();
    cin >> n >> a >> b >> c >> d;
    cout << solve(n) << endl;
  }
}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 1;

Graph G;
vector<int> dist;

int dfs(int cur){
    int m = G[cur].size();
    if(m==0) return dist[cur] = 0;

    vector<int> vec;
    for(int i = 0; i < m; ++i){
        int e = G[cur][i];
        vec.push_back(dfs(e));
    }
    sort(vec.begin(), vec.end(), greater<int>());
    int tmp = 0;
    for(int i = 0; i < m; ++i){
        tmp = max(tmp, i + 1 + vec[i]);
    }
    return dist[cur] = tmp;
}

void solve() {
    int n;cin >> n;
    G.resize(n);
    dist.resize(n);
    for(int i = 0; i < n-1; ++i){
        int a;cin >> a;
        --a;
        G[a].push_back(i+1);
    }
    dfs(0);
    int ans= 0;
    for(int i = 0; i < n; ++i){
        ans = max(ans, dist[i]);
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 15488
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<string> s;
    for(int i=0;i<n;i++){
        string t;
        cin >> t;
        s.push_back(t);
    }

    
    for(int i=0;i<s.size();i++) sort(s.at(i).begin(),s.at(i).end());
    sort(s.begin(),s.end());
    //for(int i=0;i<n;i++) cout << s.at(i) << endl;
    
    ll ans=0,counter=1;
    for(int i=1;i<n;i++){
        if(s.at(i-1)==s.at(i)) {
            counter++;
        }else{
            ans+= counter*(counter-1)/2;
            counter=1;
        } 
    }
    ans+= counter*(counter-1)/2;

    cout << ans << endl;
}


Measured memory_bytes: 7476