akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];
    sort(all(p),greater<ll>());
    sort(all(q),greater<ll>());
    sort(all(r),greater<ll>());
    ll cntp=x-1,cntq=y-1,cntr=0;
    while(1){
        if(cntr>=c||r[cntr]<=p[cntp]&&r[cntr]<=q[cntq]) break;
        if(p[cntp]<=q[cntq]){
            p[cntp]=r[cntr];
            cntp--;
            if(cntp<0) cntp=0;
        }else{
            q[cntq]=r[cntr];
            cntq--;
            if(cntq<0) cntq=0;
        }
        cntr++;
    }
    ll sum=0;
    rep(i,x) sum+=p[i];
    rep(i,y) sum+=q[i];
    cout<<sum<<endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair

const int MAXN = 2e5+5;
const int SIZE = 1<<18;

ll h[MAXN], a[MAXN], dp[MAXN];
ll tree[2*SIZE];

void update(int index, ll val) {
	index+=SIZE;
	tree[index] = max(tree[index], val);
	while(index)	
		index>>=1, tree[index] = max(tree[2*index], tree[2*index+1]);

}

ll query(int left, int right) {
	left += SIZE, right += SIZE;	
	ll R = max(tree[left], tree[right]);	
	while(left>>1 != right>>1) {
		if (left%2==0)
			R = max(R, tree[left+1]);
		if (right%2==1)
			R = max(R, tree[right-1]);
	left>>=1, right>>=1;
	}
	return R; 
}

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

	int n;	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> h[i];	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++) {
		ll x = query(0, h[i]-1);
		dp[h[i]] = x + a[i];
		update(h[i], dp[h[i]]);
	}

	ll R = 0;
	for(int i = 0; i <= n; i++) {
		R = max(R, dp[i]);
	}
	cout << R;
}	


Measured memory_bytes: 8576
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;
int h[100000];

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i = 0;i<n;i++){
		scanf("%d",&h[i]);
	}
	k--;
	sort(h,h+n);
	int min = h[k] - h[0];
	for(int i = 1;i<n-k;i++){
		int t = h[k+i] - h[i];
		if(t<min)min = t;
	}
	printf("%d\n",min);
	
}


Measured memory_bytes: 512
/*
 *created by Kraken on 26-04-2020 at 16:47
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    FastReader sc = new FastReader();
    Set<String> set = new HashSet<>();
    int n = sc.nextInt();
    for (int i = 0; i < n; i++) set.add(sc.next());
    System.out.println(set.size());
  }

  static class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
        cout << "Possible";
    }else{
        cout << "Impossible";
    }
}

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

int main()
{
  int l,r,d = 0;
  int count = 0;
  cin >> l >> r >> d;
 
  for(int i=l; i<=r; i++)
  {
    if(i % d == 0)
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main()
{
    string s ,h,u;
    int k,m,n,v;
    cin>>s>>h;
    cin>>k>>m;
    cin>>u;
    if (u==s){
        n=k-1;
        cout<<n<<" "<<m;
    }
    if (u==h){
        v=m-1;
        cout<<k<<" "<<v;
    }
    return 0;
}

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

#define ll long long

typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0)

double n, l;

int main(){
	fast;
	
	cin>>n>>l;
	vector< string > v(n);
	for(auto &i : v) cin>>i;

	sort(v.begin(), v.end());

	for(auto i : v) cout<<i;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N, x=0; cin >> N;
  for(ll i=2; i<=sqrt(N); i++){
    ll e=0, p=0;
    while(N%i==0) {
      e++;
      if(e>p){
        x++;
        p=e;
        e=0;
      }
      N/=i;
    }
  }
  if(N!=1) x++;
  cout << x;
  return 0;
}

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

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

    if (r < 1200)
        cout << "ABC" << endl;
    else if (r < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;

    return 0;
}


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

int main(){
  int a,b,c=-1,d=-1,e[]={2,3,4,5,6,7,8,9,10,11,12,13,1};
  cin>>a>>b;
  for(int i=0;i<=12;i++){
    c=(a==e[i]?i:c);
    d=(b==e[i]?i:d);
  }
  if(c>d)cout<<"Alice";
  else if(c<d)cout<<"Bob";
  else if(c==d)cout<<"Draw";
  return 0;
}


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

int main(){
  
  string S;
  cin>>S;
  int first,second;
  first=(int)((S[0]-'0')*10+S[1]-'0');
  second=(int)((S[2]-'0')*10+S[3]-'0');
  if(first>0&&first<13&&second>0&&second<13){
    cout<<"AMBIGUOUS"<<endl;;
  }else if((first==0||first>12)&&(second==0||second>12)){
    cout<<"NA"<<endl;
  }else if((first>0&&first<13)&&(second==0||second>12)){
    cout<<"MMYY"<<endl;
  }else{
    cout<<"YYMM"<<endl;
  }
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < 19; i++){
    if(i==5||i==13)cout<< ' ';
    else cout << s.at(i);
  }
  cout<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define N 100
int pop(void);
void push(int);
int top=0,S[N];
int main(){
    
    char s[N];
    int a,b;
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            push(pop() + pop());
        }
        else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }
        else if(s[0] == '*'){
            push(pop() * pop());
        }
        else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
}

int pop(){
    top--;
    return S[top+1];
}

void push(int num){
    S[++top] = num;
}



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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	
	int zi=c-a;
	int hu=d-b;
	
	int tt=zi*60+hu;
	tt-=e;
	cout << max(0,tt) << "\n";
	return 0;
}

Measured memory_bytes: 3612
n,a,b = map(int, input().split())
min_num = 0
max_num = 0

if a == n or b == n:
    min_num = min(a,b)
    max_num = min(a,b)
elif a == b and a == n:
    min_num = n
    max_num = n
elif a == 0 or b == 0:
    pass
elif n >= a + b:
    max_num = min(a,b)
elif n < a + b:
    min_num = abs(n-a-b)
    max_num = min(a,b)

print(max_num, min_num)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  int h1,m1,h2,m2;cin>>h1>>m1>>h2>>m2;
  int k;cin>>k;
  int time = h2*60 + m2 - h1*60 - m1;
  print(time - k);
  return 0;
}


Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>

int main(void){
int i,j,n,x=0,y=0;
scanf("%d",&n);
for(i=0;i<n;i++){
	char a[101],b[101];
	scanf("%s%s",a,b);
	
	for(j=0;1;j++){
		if ((a[j]=='\0')&&(b[j]!='\0')){
			y=y+3;
		}else if ((b[j]=='\0')&&(a[j]!='\0')){
			x=x+3;	
		}else if((a[j]=='\0')&&(b[j]=='\0')){
			y++;
			x++;
		}else if (a[j]-b[j]>0){
			x=x+3;
		}else if (b[j]-a[j]>0){
			y=y+3;
		};
														
		if((a[j]=='\0')||(b[j]=='\0')) break;

		if((a[j]!='\0')&&(b[j]!='\0')&&(a[j]-b[j]!=0)) break;
	};

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

Measured memory_bytes: 2728
#B
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()

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

int main(){
  ll N;
  cin >> N;

  vector<ll> A(N, 0);
  for(ll i = 0; i < N; i++){
    cin >> A[i];
    A[i] -= i+1;
  }

  sort(A.begin(), A.end());

  ll b = A[N/2];
  ll ans = 0;
  for(ll i = 0; i < N; i++){
    ans += abs(b - A[i]);
  }
  
  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
  int N,K;
  long long int ans=0;
  scanf("%d %d",&N,&K);
  if(K==0){
    ans = (long long int)N*N;
    printf("%lld\n",ans);
    return 0;
  }
  for(int b=K+1;b<=N;b++){
    ans += (N/b)*(b-K);
    if(N%b>=K) ans += N%b-K+1;
  }
  
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
#A = [int(input()) for i in range(n)]
L = [int(i) for i in input().split()]


def bubbleSort(A,N):
	i = 0
	cnt = 0
	flag = 1
	while flag:
		flag = 0
		for j in reversed(range(i+1,N)):
			if A[j] < A[j-1]:
				key = A[j-1]
				A[j-1] = A[j]
				A[j] = key
				flag = 1
				cnt += 1
		i += 1
	return cnt

cnt = bubbleSort(L,n)

for item in range(len(L)):
	if item == len(L)-1:
		print(L[item])
	else:
		print(L[item],end=" ")

print(cnt)


Measured memory_bytes: 5612
# ある時点の重複番組数を前からカウントして、最大値が答え
# s順に並べて、ループごとに重複数を増やしつつ、
# 終了キューにtを追加
# 番組追加するごとに終了キューの中身をチェック
# 同じチャンネルだったら、終了キューt <= 現在時刻 のときに終了キューから外せる
# 違うチャンネルだったら、終了キューt < 現在時刻となる
# チャンネルごとにheapqを持つ

N,C = map(int,input().split())
import heapq
endq = [[] for i in range(C)]
for i in range(C):
  heapq.heapify(endq[i])
progs = [None] * N
for i in range(N):
  s,t,c = map(int,input().split())
  progs[i] = [s,t,c-1]

progs = sorted(progs,key = lambda x:x[0])

ans = 0
cur = 0

for i in range(N):
  s,t,c = progs[i]
  # 時刻sに終了する番組をチェックする
  # まず同チャンネルのものが時刻sに終了していたら、それを外すことが出来る
  while endq[c]:
    endt = heapq.heappop(endq[c])
    if endt <= s:
      cur -= 1
    else:
      heapq.heappush(endq[c],endt)
      break
  
  # 他のチャンネルをチェックする
  for endc in range(C):
    if endc == c:
      continue # 同じチャンネルはチェック済み
    while endq[endc]:
      endt = heapq.heappop(endq[endc]) # 各チャンネルのキューから取り出す
      if endt < s:
        cur -= 1
      else:
        heapq.heappush(endq[endc],endt)
        break
  # 今回の番組を格納する
  cur += 1
  heapq.heappush(endq[c],t)
  if cur > ans:
    ans = cur

print(ans)

Measured memory_bytes: 63320
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int h[]=new int[n];
    int count=0;
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      if(h[i]>=k){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 49752
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
using namespace std;



int main()
{
	long long int i, j, k, l, m, n, sum, flag, N, M,cnt;
	sum = 0;
	flag = 0;
	cnt = 1;
	cin >> N >> M;
	vector<long long int>A(N);
	vector<long long int>B(N);
	for (i = 0; i < N; i++) {
		B[i] = 0;
	}
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	B[0] = A[0]%M;
	for (i = 1; i < N; i++) {
		B[i] += B[i - 1] + A[i];
		B[i] = B[i] % M;
	}
	sort(B.begin(), B.end());

	j = B[0];
	i = 1;
	while (i < N) {
		if (B[i] == j) {
			cnt++;
			i++;
		}
		else {
			j = B[i];
			i++;
			sum += (cnt - 1)*cnt / 2;
			cnt = 1;
		}
	}
	sum+= (cnt - 1)*cnt / 2;
	for (i = 0; i < N; i++) {
		if (B[i] == 0) {
			sum++;
		}
	}
	cout << sum << endl;

		


    return 0;
}



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

int main(){
	int a[1145][2],n,s,i,j,cnt,num,total;
	for(i=0;i<1024;i++){
		for(j=1,cnt=0,num=0,total=0;cnt<10;j*=2,cnt++){
			if(i&j){
				total+=cnt;num++;
			}
		}
		a[i][0]=total;
		a[i][1]=num;
	}
	//for(i=0;i<1024;i++) printf("i=%d,total=%d,num=%d     ",i,a[i][0],a[i][1]);
	while(1){
		scanf("%d %d",&n,&s);
		if(n==0&&s==0) break;
		cnt=0;
		for(i=0;i<1024;i++){
			if(a[i][1]==n){
				if(a[i][0]==s)cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mod 1000000007
#define inf 10000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
set<int> g[26],rg[26];
int freq[26][26];
int vis[26];
int cache[26];
int main()
{
    IOS
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        g[s[i]-'a'].insert(t[i]-'a');
        rg[t[i]-'a'].insert(s[i]-'a');
        freq[s[i]-'a'][t[i]-'a']++;
        vis[s[i]-'a'] = -1;
    }
    for(int i=0;i<26;i++)
        cache[i] = -1;
    for(int i=0;i<26;i++)
    {
        if(g[i].size() > 1 || rg[i].size()>1)
        {
            cout<<"No";
            return 0;
        }
        else if(g[i].size() == 1)
            cache[i] = *(g[i].begin());
    }
    for(int i=0;i<26;i++)
    {
        if(vis[i] == -1)
        {
            int start = i,cur = i;
            int to = cache[start];
            int val = freq[start][to];
            int count = 0;
            while(to!=start)
            {
                count++;
                cur = to;
                to = cache[cur];
                if(to == -1)
                    break;
                vis[cur] = vis[to] = 1;
                /*if(val != freq[cur][to])
                {
                    //cout<<"No"<<to<<start;
                    cout<<"No";
                    return 0;
                }*/
                if(count > 50)
                {
                    cout<<"No";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes";
    return 0;

}


Measured memory_bytes: 916
#include<stdio.h>
int main(void){
    int N,K;
    scanf("%d %d",&N,&K);

    if(N%2==0){
        if(N/2>=K){
            printf("YES");
        }else{
            printf("NO");
        }
    }else{
        if((N+1)/2>=K){
         printf("YES");
        }else{
            printf("NO");
        }   
    }
    return 0;
}

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

int main(void) {
	int x, y, z;
	cin >> x;
	y = x / 500;
	y *= 1000;
	z = x % 500;
	z /= 5;
	z *= 5;
	cout << y + z << endl;
	 return 0;
	
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    if(N >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7732
#include<stdio.h>
int main(void){
int A,B;
scanf("%d%d", &A, &B);
if(A+B>=A-B && A+B>=A*B) printf("%d\n", A+B);
else if (A-B>=A+B && A-B>=A*B) printf("%d\n", A-B);
else printf("%d\n", A*B);
return 0;
}

Measured memory_bytes: 128
class Dice:
    def __init__(self):
        self.total = 1
        self.up = 1
        self.s = 2
        self.e = 3

    def north(self):
        self.up, self.s = self.s, 7 - self.up
        self.total += self.up

    def south(self):
        self.up, self.s = 7 - self.s, self.up
        self.total += self.up

    def east(self):
        self.up, self.e = 7 - self.e, self.up
        self.total += self.up

    def west(self):
        self.up, self.e = self.e, 7 - self.up
        self.total += self.up

    def right(self):
        self.s, self.e = self.e, 7 - self.s
        self.total += self.up

    def left(self):
        self.s, self.e = 7 - self.e, self.s
        self.total += self.up

    def exe(self, cmd):
        if 'N' in cmd:
            self.north()
        elif 'S' in cmd:
            self.south()
        elif 'E' in cmd:
            self.east()
        elif 'W' in cmd:
            self.west()
        elif 'R' in cmd:
            self.right()
        elif 'L' in cmd:
            self.left()

def solve(N):
    dice = Dice()
    for i in range(N):
        cmd = input()
        dice.exe(cmd)

    print(dice.total)

while True:
    N = int(input())
    if N == 0:
        break
    solve(N)

Measured memory_bytes: 7732
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    if wv[i][0]==w0:
        k=wv[i][1]+x[0][-1]
        l=len(x[0])
        if l*w0<=w:x[0].append(k)
    elif wv[i][0]==w0+1:
        k=wv[i][1]+x[1][-1]
        l=len(x[1])
        if l*(w0+1)<=w:x[1].append(k)
    elif wv[i][0]==w0+2:
        k=wv[i][1]+x[2][-1]
        l=len(x[2])
        if l*(w0+2)<=w:x[2].append(k)
    else:
        k=wv[i][1]+x[3][-1]
        l=len(x[3])
        if l*(w0+3)<=w:x[3].append(k)

ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
for i in range(l3):
    for j in range(l2):
        for k in range(l1):
            d=w-(i*(w0+3)+j*(w0+2)+k*(w0+1))
            if d>=0:
                ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,len(x[0])-1)]
            ma=max(ma,ma_sub)
print(ma)


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 2e5+5;
int pre[maxn], pst[maxn];
VI G[maxn];
int tree[4*maxn];

void update(int i, int j, const int value, const int n)
{
    for (i += n, j += n; i < j; i >>= 1, j >>= 1) {
        if (i&1) { tree[i++] += value; }
        if (j&1) { tree[--j] += value; }
    }
}

void pushdown(const int n)
{
    for (int i = 1; i < n; i++) {
        tree[i<<1] += tree[i]; tree[i<<1|1] += tree[i]; tree[i] = 0;
    }
}

void dfs(const int u, const int p, int& label)
{
    pre[u] = label++;
    FOR_ALL(v,G[u]) if (*v != p)
        dfs(*v,u,label);
    pst[u] = label++;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,q;
    while (cin >> n >> q) {
        memset(tree,0,sizeof(tree));
        FOR(i,1,n+1)
            G[i].clear();
        FOR(i,0,n-1) {
            int u,v; cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        int label = 1;
        dfs(1,0,label);
        /* FOR(i,1,n+1) { */
        /*     cout << pre[i] << ' ' << pst[i] << endl; */
        /* } */
        FOR(i,0,q) {
            int p,x; cin >> p >> x;
            const int L = pre[p];
            const int R = pst[p]+1;
            update(L,R,x,label);
        }
        pushdown(label);
        FOR(i,1,n+1) {
            const int x = pre[i]+label;
            cout << tree[x] << ' ';
        }
        cout << endl;
    }
    return 0;
}


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

n, m = map(int, readline().split())
ipy = [[i] + list(map(int, readline().split())) for i in range(m)]

ipy.sort(key=lambda x: x[2])

c = [0] * n
l = []
for i, p, y in ipy:
    c[p - 1] += 1
    x = str(format(p, '06') + format(c[p - 1], '06'))
    l.append([i, x])

l.sort()
for i, v in l:
    print(v)

Measured memory_bytes: 45320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗(i <= 20 まで)
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    string s;
    cin >> s;
    int count = 0;
    int ans = -1;
    rep(i, s.size()) {
        if(s[i] == 'A'||s[i]=='T'||s[i]=='C'||s[i]=='G') count++;
        else {
            ans=max(ans,count);
            count = 0;
        }
    }
    ans = max(ans,count);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  double x,d,y,c,t;
  cin >> x >> d >> y >> c >> t;
  double z=abs(x-y);
  if(d-c>=0&&z/(d-c)<=t) pr("YES");
  else pr("NO");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main(){
    string S,T,res="No";
    cin >> S >> T;
    if (S==T){
        res = "Yes";
    }
    for (int i=0;i<S.length();i++){
        S=S.substr(1)+S[0];
        if (S==T){
        res = "Yes";
    }
    
}cout << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


N=int(input())
A = [[] for _ in range(N)]
a = list(map(int, input().split()))
for i in range(1,N+1):
    A[i-1].append(i)
    A[i-1].append(a[i-1])

A.sort(key=lambda x: x[1])
for i in range(N):
    print(A[i][0], end=" ")

Measured memory_bytes: 69424
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n;string a,b;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);cin>>a>>b;
	for(int i=1;i<=n;i++){
		cout<<a[i-1]<<b[i-1];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
struct P{
	long long x,h;
	bool operator <(const P yy) const {
		return x<yy.x;
	}
}a[600005];
long long n,d,A,c[200005],ans=0,to[200005];
signed main(){
	scanf("%lld%lld%lld",&n,&d,&A);
	for(long long i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].h);
	sort(a+1,a+n+1);
	for(long long i=1,j=1;i<=n;i++){
		//cout<<i<<endl;
		while(j<=n&&a[j].x<=a[i].x+2*d)j++;
		to[i]=j;
	}
	for(long long i=1;i<=n;i++){
		//cout<<i<<' '<<c[i]<<endl;
		c[i]+=c[i-1];
		a[i].h-=c[i];
		if(a[i].h<=0)continue;
		long long t;
		if(a[i].h%A)t=a[i].h/A*A+A;
		else t=a[i].h;
		ans+=t/A;
		if(to[i]-1>i)c[i+1]+=t,c[to[i]]-=t;
	}
	cout<<ans;
}

Measured memory_bytes: 8448
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())

for i in range(1,k+1):
    if n-k+1<i:
        print(0)
    else:
        ans = combinations_count(k-1,i-1)*combinations_count(n-k+1, i)
        print(int(ans%(10**9+7)))


Measured memory_bytes: 67160
N = int(input())
A = list(map(int, input().split(' ')))
rod = {}
for i in A:
    if i in rod:
        rod[i] += 1
    else:
        rod[i] = 1
if len([i for i in rod.values() if i >= 2]) < 2:
    print(0)
else:
    length4 = [k for k, v in rod.items() if v >= 4]
    length4.sort()
    length2 = [k for k, v in rod.items() if v >= 2]
    length2.sort()
    if len(length4) > 0 and length4[-1] == length2[-1]:
        print(length4[-1]**2)
    else:
        print(length2[-2] * length2[-1])

Measured memory_bytes: 18064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
using ii = pair<int,int>;
ii mods = {1'000'000'007, 1'000'000'009};
ii base = {313, 419};
int add(int a, int b, int mod){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}
int mul(long long a, long long b, int mod){
	return a * b % mod;
}
ii operator + (ii a, ii b){
	return make_pair(add(a.first, b.first, mods.first), add(a.second, b.second, mods.second));
}
ii operator - (ii a, ii b){
	return make_pair(add(a.first, mods.first - b.first, mods.first), add(a.second, mods.first - b.second, mods.second));
}
ii operator * (ii a, ii b){
	return make_pair(mul(a.first, b.first, mods.first), add(a.second, b.second, mods.second));
}
ii text[maxn], pattern[maxn], pwrs[maxn];
ii get_text(int l, int r){
	return text[r + 1] - pwrs[r - l + 1] * text[l];
}
ii get_pattern(int l, int r){
	return pattern[r + 1] - pwrs[r - l + 1] * pattern[l];
}
int main(){
	pwrs[0] = {1, 1};
	for(int i = 1; i < maxn; i++) pwrs[i] = pwrs[i - 1] * base;
	text[0] = {0, 0};
	pattern[0] = {0, 0};
	int k; string s; cin >> k >> s;
	int n = s.length(); k++;
	for(int i = 0; i < n; i++){
		text[i + 1] = text[i] * base + make_pair(s[i], s[i]);
	}
	int rn = (n + k - 1) / k;
	string ans(rn, '9');
	for(int i = 0; i < rn; i++){
		for(int v = '1'; v <= '9'; v++){
			ans[i] = v;
			pattern[i + 1] = pattern[i] * base + make_pair(v, v);
			int blocks = 0;
			bool bad = false;
			for(int j = 0; j < n; ){
				int lo = 0, hi = min(i, n - j - 1), pos = -1;
				while(lo <= hi){
					int mid = (lo+hi)>>1;
					if(get_text(j, j + mid) == get_pattern(0, mid)){
						pos = mid;
						lo = mid + 1;
					} else {
						hi = mid - 1;
					}
				}
				if(pos == min(i, n - j - 1) || s[j + pos + 1] < ans[pos + 1]) j += rn;
				else {
					if(rn == 1){
						bad = true;
						break;
					}
					j += rn - 1;
				}
				blocks++;
			}
			if(!bad && blocks <= k) break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2944
def isok(m):
    p0 = 0
    p1 = 1
    p2 = 1
    while p0 < N:
        # l0>=m ??¨???????????????p1????±???????
        if p1 <= p0: p1 = p0 + 1
        while d[p1] - d[p0] < m and p1 - p0 < N:
            p1 += 1
        if d[p1] - d[p0] < m:
            p0 += 1
            continue
        l0 = d[p1] - d[p0]
        # l1>=l0??¨???????????????p2????±???????
        if p2 <= p1: p2 = p1 + 1
        while d[p2] - d[p1] < m and p2 - p0 < N:
            p2 += 1
        if d[p2] - d[p1] < m:
            p0 += 1
            continue
        l1 = d[p2] - d[p1]
        if L - l0 - l1 >= l1:
            return True
        p0 += 1
    return False

N = int(input())
A = [0] * N
L = 0
for i in range(N):
    A[i] = int(input())
    L += A[i]
d = [0] * (2*N)
for i in range(1, 2*N):
    d[i] = d[i-1] + A[(i-1)%N]

left = 1
right = L // 3
ans = 0
while left <= right:
    m = (left + right) // 2
    if isok(m):
        ans = m
        left = m + 1
    else:
        right = m - 1
print(ans)

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

using namespace std;

int main() {
	int x;
	cin >> x;
	switch (x % 7) {
	case 1:
		cout << "fri" << endl;
		break;
	case 2:
	    cout << "sat" << endl;
	    break;
	case 3:
	    cout << "sun" << endl;
	    break;
	case 4:
	    cout << "mon" << endl;
	    break;
	case 5:
	    cout << "tue" << endl;
	    break;
	case 6:
	    cout << "wed" << endl;
	    break;
	case 0:
	    cout << "thu" << endl;
	    break;
	}
	return 0;
}


Measured memory_bytes: 3084
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = raw_input()
flag = True
for i in range(len(S)):
    if i % 2 == 0:
        if not S[i] in "RUD":
            flag = False
    else:
        if not S[i] in "LUD":
            flag = False
print "Yes" if flag else "No"

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long H, W;
  cin >> H >> W;
 

  if (H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }


  if (H * W % 2 == 1){
    cout << (H * W + 1) / 2 << endl;
  } else {
    cout << H * W /2 << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
typedef long long ll;
ll n,a,b,ans;
int main()
{
    scanf("%lld",&n);
    ff(i,1,n)
    {
        scanf("%lld%lld",&a,&b);
        int flag=0;
        if((ll)sqrt(a*b)*(ll)sqrt(a*b)==a*b)flag=1;
        if(flag)
        {
            if(a==b)
            printf("%lld\n",2*((ll)sqrt(a*b)-1));
            else
                printf("%lld\n",2*((ll)sqrt(a*b)-1)-1);
        }
        else
        {
            if((ll)sqrt(a*b)*(ll)(sqrt(a*b)+1)<a*b)
            printf("%lld\n",2*((ll)sqrt(a*b)-1)+1);
            else
                printf("%lld\n",2*((ll)sqrt(a*b)-1));
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, k;

int main() {
    cin >> n >> k;
    ll ans = (n/k) * (n/k) * (n/k);
    if (k%2 == 0) {
        if (n >= k/2) {
            ll m = (n+k/2) / k;
            ans += m * m * m;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		double L = fs.nextInt();
//		double t = 0;
//
//		for(double x = 1; x < L; x+=0.01 ) {
//			for(double y = 1; y < L; y+=0.01 ) {
//
//				if(x + y > L) continue;
//
//
//				double m = x * y * (L - ( x + y ));
//				if(m > t) {
//					t = m;
//				}
//
//			}
//		}

		double t = (L*L*L) / 27.0;
		System.out.println(String.format("%.12f", t));
	}

}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	vector<int> a(7), b(7); rep(i, 0, 7) { cin >> a[i] >> b[i]; cout << a[i] - b[i] << endl; }
	return 0;
}

Measured memory_bytes: 3076
// ===================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}
 
const int N=50+10;
 
struct edge { int v,nxt; } e[N];
int head[N];
void addEdge(int u,int v) {
    static int cnt=0;
    e[++cnt]=(edge){v,head[u]},head[u]=cnt;
}
 
int n,X,d;
struct node { ll v; int w,id; } a[N];
int operator <(node a,node b) { return a.w*b.v>b.w*a.v; }
ll dp[N*N*N];
 
void dfs(int u) {
    a[u].w=1,a[u].id=u;
    for (int i=head[u];i;i=e[i].nxt)
        dfs(e[i].v),a[u].v+=a[e[i].v].v,a[u].w+=a[e[i].v].w;
}
 
int main() {
    n=read(),X=read(),d=read();
    a[1].v=read();
    for (int i=2;i<=n;++i)
        a[i].v=read(),addEdge(read(),i);
    dfs(1); int mx=n*n*n,L=min(n,d);
    memset(dp,0x3f,sizeof(dp)),dp[0]=0;
    for (int i=1;i<=n;++i) {
        int x=L;
        for (int j=0;1<<j<=x;++j) {
            int w=a[i].w*(1<<j); ll v=a[i].v*(1<<j);
            for (int k=mx;k>=w;--k) dp[k]=min(dp[k],dp[k-w]+v);
            x-=1<<j;
        }
        if (x) {
            int w=a[i].w*x; ll v=a[i].v*x;
            for (int j=mx;j>=w;--j) dp[j]=min(dp[j],dp[j-w]+v);
        }
    }
    sort(a+1,a+n+1);
    while (a[n].id!=1) --n;
    ll ans=0;
    for (int i=0;i<=mx;++i) {
        if (dp[i]>X) continue;
        ll w=i,v=dp[i];
        for (int j=1;j<n;++j) {
            ll c=min((ll)d-L,(X-v)/a[j].v);
            w+=c*a[j].w,v+=c*a[j].v;
        }
        ll c=(X-v)/a[n].v;
        w+=c*a[n].w,v+=c*a[n].v;
        ans=max(ans,w);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{
	public static void main(String args[]) throws IOException {
		int Ans = 0;
		int ans = 0;

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s1 = new String(in.readLine());

		int N = Integer.parseInt(s1);

		String s2 = new String(in.readLine());
		String[] a = s2.split(" +");

		List<Integer> A = new ArrayList<Integer>();

		A.add(0);
		for(int i = 0;i < N;i++) {
			if( i == 0 || A.get(A.size() - 1) != Integer.parseInt(a[i])) {
				A.add(Integer.parseInt(a[i]));
			}
		}
		A.add(0);

		List<St> li = new ArrayList<St>();

		for(int i = 0;i < A.size() ;i++) {
			li.add(new Main().new St(A.get(i),i));
		}

		li.sort((e1,e2)-> e1.getNum() - e2.getNum()	);

		//初期状態での島の数の確認
		//マイナスからプラスへの境目を見る
		for (int j = 0; j < A.size() - 1 ; j++) {
			if (A.get(j) == 0 && A.get(j + 1) > 0) {
				ans++;
			}
		}
		Ans = ans;

		int countNum = 0;
		int incNum = 0;
		int decNum = 0;
		//System.out.println("初期島数 = " + Ans);
		
		//島の最大数を確認する
		//見る数値がリストの数値の中で最大値になった場合、終了する。
		for (int i = 0; li.get(i).getNum() != li.get(li.size() - 1).getNum();i++) {
			St st = li.get(i);
			St nextst = li.get(i + 1);

			//初期状態は確認しているのでスキップ
			if (st.getNum() <= 0 ) {
				continue;
			}

			countNum++;

			//沈む陸地に対しその左右の陸地をみて
			//ansを操作する。
			int nl_num = A.get(st.getIndex() - 1) ;
			int nr_num = A.get(st.getIndex() + 1) ;


			if (nl_num - st.getNum() > 0 && nr_num - st.getNum() > 0) {
				ans++;
				incNum++;
				//System.out.print("[in]:");
			}
			if (nl_num - st.getNum() <= 0 && nr_num - st.getNum() <= 0) {
				ans--;
				decNum++;
				//System.out.print("[de]:");
			}
		

			//System.out.println("getNum = " + String.format("%2d",st.getNum()) +",i = " + String.format("%4d",i) + ",index = " + String.format("%4d",st.getIndex()) + ",left = " + String.format("%2d",(rnum + st.getNum())) + ",right = " + String.format("%2d",(nnum + st.getNum())) + ",ans = " + String.format("%3d",ans));

			//海面の高さが変化するタイミングで
			//ansの判定を行う。
			if (st.getNum() != nextst.getNum() ) {
				if (ans > Ans) {
					Ans = ans;
				}
				//System.out.println("浸水 = " +  String.format("%2d",st.getNum()) + ",対象 = " + String.format("%4d",countNum) + ",inc = " + String.format("%4d",incNum) + ",dec = " + String.format("%4d",decNum) + ",ans = " + String.format("%4d",ans) + ",Ans = " + String.format("%4d",Ans));
				countNum = 0;
			}
			//if(i > 1000) {
			//	break;
			//}
		}

		System.out.println(Ans);
	}
	public class St{
		private int num;
		private int index;

		public St(int num , int index) {
			this.num = num;
			this.index = index;
		}

		public int getNum() {
			return num;
		}

		public int getIndex() {
			return index;
		}
	}

}


Measured memory_bytes: 57828
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n, x; cin >> n >> x;

  vector<int> co(n+1);
  rep(i,n) {
    int y; cin >> y;
    co[i] = abs(x-y);
  }
  co[n] = co[n-1];
  int ans;
  if (co[0] == 0) ans = co[1];
  else ans = co[0];
  rep(i,n) {
    if (co[i] == 0) continue;
    ans = __gcd(ans,co[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3704
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	slice := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&slice[i])
	}

	m := make(map[int]bool)
	uniq := []int{}

	for _, v := range slice {
		num, _ := strconv.Atoi(fmt.Sprintf("%d", v))
		if !m[num] {
			m[num] = true
			uniq = append(uniq, num)
		}
	}

	fmt.Println(len(uniq))
}


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

using namespace std;

using ll = long long;

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

    // const ll n = 2 * 1e5, X = 1e9;
    // cout << n << ' ' << X << '\n';
    // for (int i = n - 1; 0 <= i; --i) {
    //     cout << X - i << (i == 0 ? '\n' : ' ');
    // }

    ll n, X;

    cin >> n >> X;
    vector<ll> x(n + 1);
    for (int i = 1; i <= n; ++i) cin >> x[i];
    for (int i = 1; i <= n; ++i) x[i] += x[i - 1];

    ll min_e = numeric_limits<ll>::max();
    for (ll k = 1; k <= n; ++k) {
        ll sum = 0, id = (n + k - 1) / k;
        ll l = 1, r = (n % k == 0 ? k : n % k);
        while (l <= n) {
            ll mul = (id == 1 ? 5 : 2 * id + 1);
            sum += mul * (x[r] - x[l - 1]);
            l = r + 1;
            r += k;
            --id;
        }
        if (0 <= sum + k * X)
            min_e = min(min_e, sum + k * X);
    }

    cout << min_e + n * X << endl;

    return 0;
}


Measured memory_bytes: 1792
n = int(input())
n_list =[0 for i in range(101)]
count = 0
ans = 0
for i in range(1, n+1):
    if i >=10:
        n_list[int(str(i)[0])*10+int(str(i)[len(str(i))-1])] += 1
    elif i < 10:
        n_list[int(str(i)[0])] += 1
for i in range(1,10):
    ans += n_list[i]
for i in range(1,10):
    ans += (n_list[i]*n_list[i*11])*2
for i in range(11, 100):
    if int(str(i)[1]) != 0:
        b = int(str(i)[1])*10+int(str(i)[0])
        ans += n_list[i]*n_list[b]
print(ans)

Measured memory_bytes: 3064
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N):
    k = i
    for j in range(i+1, N):
        while (k < N and L[k] < L[i]+L[j]):
            k += 1
        ans += k - (j+1)

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int black=0,white=0;
    rep(i,n){
        if(s.at(i)=='.') white++;
        else black++;
    }
    int tmp=white,ans=white;
    rep(i,n){
        if(s.at(i)=='#') tmp++;
        else tmp--;
        chmin(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 644