akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  string ans = "YES";
  for(int i=1; i<n; i++) {
    if(a[i] == a[i - 1]) {
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int n, m;
  cin >> n >> m;
  
  int l = 0, r = INF;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    l = max(l, a);
    r = min(r, b);
  }

  cout << max(0, r-l+1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    char turn = 'a';
    int a = 0, b = 0, c = 0;
    int na = sa.size(), nb = sb.size(), nc = sc.size();
    char winner;
    while (a <= na and b <= nb and c <= nc) {
        if (a == na and turn == 'a') winner = 'A';
        if (b == nb and turn == 'b') winner = 'B';
        if (c == nc and turn == 'c') winner = 'C';
        if (turn == 'a') {
            turn = sa[a];
            ++a;
        } else if (turn == 'b') {
            turn = sb[b];
            ++b;
        } else if (turn == 'c') {
            turn = sc[c];
            ++c;
        }
    }
    cout << winner << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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(){
  string a,b;
  cin>>a>>b;
  string n=a+b;
  int num=atoi(n.c_str());
  int dou=sqrt(num)/1;
  if(dou*dou==num)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;   
    
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i+2<n;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M, *HAB = map(int, open(0).read().split())
H, AB = [0] + HAB[:N], HAB[N:]
good = [False] + [True] * N
for a, b in zip(*[iter(AB)] * 2):
  if H[a] >= H[b]:
    good[b] = False
  if H[b] >= H[a]:
    good[a] = False
print(sum(good))

Measured memory_bytes: 44064
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll K, T;
    cin >> K >> T;
    vector<ll> a(T);
    ll ma = 0;
    rep(i, T) {
        cin >> a[i];
        ma = max(ma, a[i]);
    }
    print(max(ma - 1 - (K-ma),(ll)0));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

int main(){
  long long int A,V, B,W, T;
  std::cin >> A >> V >> B >> W >> T;

  if(A == B){
  	std::cout << "YES" << std::endl;
    return 0;
  }

  if(W >= V){
  	std::cout << "NO" << std::endl;
    return 0;
  }
  
  std::size_t diff;
  if(A > B){
  	diff = A-B;
  }else{
   	diff = B-A; 
  }
  
  if((V-W)*T >= diff){
    std::cout << "YES" << std::endl;
    return 0;
  }else{
    std::cout << "NO" << std::endl;
    return 0;
  }
  
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int n,m;
  cin>>n>>m;
  vi to[m+3];
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].pb(b);
    to[b].pb(a);
  }
  queue<int> q;
  q.push(0);

  vi mark(n,-1);

  while(!q.empty()){
    int p=q.front();
    q.pop();
    for(auto v:to[p]){
      if(mark[v]>-1) continue;
      mark[v]=p+1;
      q.push(v);
    }
  }
  bool ok=1;
  rep(i,n){
    if(mark[i]<0)ok=0;
  }
  if(ok){
    cout<<"Yes"<<endl;
  FOR(i,1,n-1){
    cout<<mark[i]<<endl;
  }
    
  }else{
    cout<<"No"<<endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 15028
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)
    
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了
"""
K=int(input())
S=input()
if K>=len(S):
    print(S)
else:
    print(S[0:K]+"...")

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



int main(){
 int N,A,c=0;
 cin >> N;
 for(int i=0;i<N;i++){
   cin >> A;
   if(A%2==0){
     if(A%3==0||A%5==0)
        continue;
     else{
       c=1;
       break;
     }
   }
   else
    continue;
 }

 if(c==0)
  cout <<"APPROVED" <<endl;
 else
  cout <<"DENIED" <<endl;
}


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

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)
#define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

const long long INF = 1LL << 60;

// ここから開始だよ！
ll mtrix[4][4], tmp1, tmp2;
bool a[4], b[4];

int main() {
	repi(i, 1, 4) {
		repi(j, 1, 4) {
			cin >> mtrix[i][j];
		}
	}
	
	repi(a, 1, 4) {
		if (a == 1) {
			tmp1 = mtrix[a][1] - mtrix[a][2];
			tmp2 = mtrix[a][2] - mtrix[a][3];
		} else {
			if(!(mtrix[a][1] - mtrix[a][2] == tmp1 && mtrix[a][2] - mtrix[a][3] == tmp2)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	repi(b, 1, 4) {
		if (b == 1) {
			tmp1 = mtrix[1][b] - mtrix[2][b];
			tmp2 = mtrix[2][b] - mtrix[3][b];
		} else {
			if(!(mtrix[1][b] - mtrix[2][b] == tmp1 && mtrix[2][b] - mtrix[3][b] == tmp2)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main()
{
    double f, s;
    
    while (cin >> f >> s) {
        if (f < 35.5 && s < 71)
            cout << "AAA";
        else if (f < 37.5 && s < 77.0)
            cout << "AA";
        else if (f < 40.0 && s < 83.0)
            cout << "A";
        else if (f < 43.0 && s < 89.0)
            cout << "B";
        else if (f < 50.0 && s < 105.0)
            cout << "C";
        else if (f < 55.0 && s < 116.0)
            cout << "D";
        else if (f < 70.0 && s < 148.0)
            cout << "E";
        else
            cout << "NA";
        
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque

def main():
    n,m = map(int,input().split())
    G = [[] for _ in range(3*n)]
    for _ in range(m):
        u,v = map(int,input().split())
        u -= 1
        v -= 1
        for i in range(3):
            G[u*3 + i].append(v*3 + (i + 1)%3)
    
    s,g = map(int,input().split())
    s -= 1
    g -= 1

    q = deque([3*s])
    dist = [-1] * (3*n)
    dist[3*s] = 0
    while q:
        p = q.popleft()
        for e in G[p]:
            if dist[e] < 0:
                dist[e] = dist[p] + 1
                q.append(e)
                
    print(dist[3*g]//3 if dist[3*g] >= 0 else -1)
if __name__ == '__main__':
    main()

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

int main() {
	int a, b;
	cin >> a >> b;
	string mark;
	if (a < b) {
		mark = "<";
	}
	else if (a > b) {
		mark = ">";
	}
	else {
		mark = "==";
	}
	cout << "a " + mark + " b" << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

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



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


int main() {

	int i, j, k;
	//ll N, M, K;
	int N, M, K;

	queue<string> Q;
	int time = 1;
	cin >> K;
	if (K <= 9) {
		cout << K;
		return 0;
	}
	rep(i, 1, 10) {
		string a;
		a.push_back('0' + i);
		Q.push(a);
	}
	while (time < K) {
		time++;
		string S = Q.front();
		Q.pop();
		int a = S.back() - '0';
		string T = S;
		if (a == 0) {
			T.push_back('0');
			Q.push(T);
			T = S;
			T.push_back('1');
			Q.push(T);
		}
		else if (a > 0 && a < 9) {
			T.push_back('0' + a - 1);
			Q.push(T);
			T = S;
			T.push_back('0' + a);
			Q.push(T);
			T = S;
			T.push_back('0' + a + 1);
			Q.push(T);
		}
		else {
			T.push_back('8');
			Q.push(T);
			T = S;
			T.push_back('9');
			Q.push(T);
		}


	}
	cout << Q.front();
	return 0;
	
}

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

int main()
{
    ll n, total;
    cin >> n >> total;

    for (int i = 0; i <= n; i++) {
        ll x = 10000 * i;
        for (int j = 0; j <= n-i; j++) {
            ll y = 5000 * j;
            ll z = 1000 * (n - i - j);

            if (x + y + z == total) {
                cout << i << ' ' << j << ' ' << n-i-j << "\n";
                return 0;
            }
        }
    }

    puts("-1 -1 -1");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,T;
  int ans;
  int count;
  cin >> A >> B >> T;
  count = T / A;
  for(int i=0;i<count;i++){
    ans += B;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(a, k);
    k = max(0ll, k - a - b);
    ans -= min(c, k);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define int ll
vector<P> node[100005];
ll num[100005]={0},two_j[100005]={0};
bool used[100005]={false};
void dfs(ll pos,ll k){
  two_j[pos]=k;
  k%=2; k++;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i].first;
    if(two_j[to]==0){
      two_j[to]=k;
      dfs(to,k);
    }
  }
}
void set_val(ll pos,ll val){
  used[pos]=true;
  num[pos]=val;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i].first,cos=node[pos][i].second;
    if(!used[to]){
      used[to]=true;
      set_val(to,cos-val);
    }
  }
}
signed main(){
  ll n,m; cin>>n>>m;
  for(int i=0;i<m;i++){
    ll a,b,c; cin>>a>>b>>c;
    node[a].push_back(P(b,c));
    node[b].push_back(P(a,c));
  }
  dfs(1,1);
  for(int i=1;i<=n;i++) used[i]=false;
  used[1]=true;
  set_val(1,0);
  //for(int p=1;p<=n;p++) cout<<num[p]<<" ";
  //cout<<endl;
  bool f=false;
  for(int i=1;i<=n;i++){
    for(int j=0;j<node[i].size();j++){
      ll to=node[i][j].first;
      if(two_j[i]==two_j[to]) f=true;
    }
  }
  //for(int p=1;p<=n;p++) cout<<num[p]<<" ";
  //cout<<endl;
  if(f){
    for(int i=1;i<=n;i++){
      for(int j=0;j<node[i].size();j++){
        ll to=node[i][j].first,cos=node[i][j].second;
        if(num[i]+num[to]!=cos){
          ll sa=cos-num[i]-num[to];
          if(sa%2!=0){
            cout<<0<<endl;
            return 0;
          }
          sa/=2;
          for(int l=1;l<=n;l++){
            if(two_j[l]==two_j[i]) num[l]+=sa;
            else num[l]-=sa;
            if(num[l]<=0){
              cout<<0<<endl;
              return 0;
            }
          }
        }
      }
    }
    for(int i=1;i<=n;i++){
      if(num[i]<=0){
        cout<<0<<endl;
        return 0;
      }
      for(int j=0;j<node[i].size();j++){
        ll to=node[i][j].first;
        if(num[to]+num[i]!=node[i][j].second){
          cout<<0<<endl;
          return 0;
        }
      }
    }
    cout<<1<<endl;
    return 0;
  }
  else{
    for(int i=1;i<=n;i++){
      for(int j=0;j<node[i].size();j++){
        ll to=node[i][j].first;
        if(num[to]+num[i]!=node[i][j].second){
          cout<<0<<endl;
          return 0;
        }
      }
    }
    ll one_m=1744174417441744,two_m=1744174417441744;
    for(int i=1;i<=n;i++){
      if(two_j[i]==1) one_m=min(one_m,num[i]);
      else two_m=min(two_m,num[i]);
    }
    cout<<max((ll)0,(one_m+two_m-1))<<endl;
  }
}


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

int main(){
    string n;
    cin >> n;
    int k;
    cin >> k;
    long long ans = 0;
    for (int i = 1; i < n.size(); i++)
    {
        if (i < k) continue;
        if (k == 1) ans += 9;
        else if (k == 2) ans += 9 * 9 * (i - 1);
        else ans += 9 * 9 * 9 * (i - 1) * (i - 2) / 2;
    }
    string tmp = n;
    for (int i = 0; i < tmp.size(); i++) tmp[i] = '0';
    for (int i = 1; i < 10; i++)
    {
        tmp[0] = i + '0';
        if (k > 1)
        {
            for (int x2 = 1; x2 < tmp.size(); x2++)
            {
                for (int j = 1; j < 10; j++)
                {
                    tmp[x2] = j + '0';
                    if (k > 2)
                    {
                        for (int x3 = x2 + 1; x3 < tmp.size(); x3++)
                        {
                            for (int z = 1; z < 10; z++)
                            {
                                tmp[x3] = z + '0';
                                if (tmp <= n) ans++;
                                tmp[x3] = '0';
                            }
                        }
                    }
                    else
                        if (tmp <= n) ans++;
                    tmp[x2] = '0';
                }
            }
        }
        else
            if (tmp <= n) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
string s;
void solve(){
	if(s == "Sunny") cout << "Cloudy" << endl;
	else if(s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


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

using namespace std;

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

  int keta = 0;
  int count = 0;
  for(int i = 0; i < N; i++){
    int a = i + 1;
    keta = 0;
    while(a != 0){
      a /= 10;
      keta++;
    }

    if(keta % 2 == 1) count++;
  }

  cout << count << endl;
 return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Class_
{
	void Test()
	{
		var NM = A_Long_();
		var N = NM[0];
		var M = NM[1];

		//Console.WriteLine( (N * 2 + M)/4);
		//return;

		if (N>=M/2) {
			Console.WriteLine(M/2);
		} else {
			var a = N;
			var b = (M-2*N)/ 4;
			Console.WriteLine(a+b);
		}
		


	}

	static void Main(string[] args)
  {
    new Class_().Test();
  }

  #region

  string S_String_()
  {
    return Console.ReadLine();
  }

	//
	string[] A_String_()
  {
    return Console.ReadLine().Split();
  }

  int[] A_Int_(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

	//
	int[] A_Int_()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }

	long[] A_Long_()
	{
		var ss = Console.ReadLine().Split();

		var x = new long[ss.Length];
		for (var i = 0; i < ss.Length; i++)
			x[i] = long.Parse(ss[i]);

		return x;
	}

	#endregion
}


Measured memory_bytes: 13140
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(list):
    return reduce(lcm_base, list, 1)

N = int(input())
T = [int(input()) for i in range(N)]

print(lcm_list(T))


Measured memory_bytes: 9476
mod = 998244353
n,k = map(int,input().split())
s = [list(map(int,input().split())) for i in range(k)]
c = [0]*(n+1)
c[0] = 1
for i in range(n):
    for j,k in s:
        if i+j<n+1:
            c[i+j] += c[i]
        if i+k<n:
            c[i+k+1] -= c[i]
    if i>0:
        c[i+1] += c[i] 
        c[i+1] %= mod

print(c[n-1])

Measured memory_bytes: 16800
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for ( int i = 0; cin >> ch; i++ ) {
    if ( ch == '\\' ) S1.push(i);
    else if ( ch == '/' && S1.size() > 0 ) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while ( S2.size() > 0 && S2.top().first > j ) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while ( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;

    int num = 100*r + 10*g + b;

    if (num % 4 == 0) {
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#16:15
n = int(input())
can = []
for _ in range(n):
  raw = input()
  made = []
  for k in range(10):
    made.append(raw[k])
  made.sort()
  can.append(made)
can.sort()
ans = 0
combo = 0
for i in range(1,n):
  if can[i] == can[i-1]:
    combo += 1
  else:
    combo = 0
  ans += combo
print(ans)

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2,vector<int>(n));
	vector<vector<int>> total(2,vector<int>(n));
	rep(i,2) rep(j,n) cin >> a[i][j];
	total[0][0] = a[0][0], total[1][0] = a[1][0];
	rep(i,2) rep(j,n-1) total[i][j+1] = total[i][j] + a[i][j+1];
	/*rep(i,2) {
		rep(j,n) printf("%d ",total[i][j]);
		printf("\n");
	}*/
	int ans = total[0][0] + total[1][n-1];
	for (int i=1;i<n;i++) ans = max(ans, total[0][i] + total[1][n-1] - total[1][i-1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

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

	READV(N);
	READV(L);
	ll sum=N*L+(N*(N+1))/2-N;
	ll x=1;
	FORI(i,1,N+1)
	{
		if (abs(L+i-1)<=abs(L+x-1))
		{
			x=i;
		}
	}
	sum=sum-(L+x-1);
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

signed main()
{
   string A; cin >> A;

   const int CHAR_SIZE = 26;
   int N = A.size();

   set<char> s;
   stack<int> idx;
   idx.push(N);
   RFOR(i, 0, N) {
      s.insert(A[i]);
      if (s.size() == CHAR_SIZE) {
         idx.push(i); s.clear();
      }
   }
   s.clear();

   int prev = 0;
   string ans;
   while (!idx.empty()) {
      int j = idx.top(); idx.pop();

      FOR(i, prev, j) {
         s.insert(A[i]);
      }
      char next;
      FOR(i, 0, CHAR_SIZE) {
         if (!EXIST(s, 'a'+i)) {
            next = 'a'+i;
            break;
         }
      }
      s.clear();
      ans += next;

      FOR(i, j, N) {
         if (A[i] == next) {
            prev = i+1;
            break;
         }
      }
   }
   cout << ans << endl;


   return 0;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int x; cin >> x;
	if (x < 1200)puts("ABC");
	else puts("ARC");

	return 0;
}

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

N,A,B,C,D = map(int,readline().split())

X = abs(B - A)
n = N - 1

# n回で絶対値Xを作れるか

if n * C <= X <= n * D:
  print("YES")
  exit(0)

# n * Cより小さい数を作る必要があるため、Cを何回使うかを基準に考える
for i in range(1, n):
  rest_1 = abs(C * i - X)
  rest_2 = X + C * i
  # 絶対値restを残り使える数で作れるか
  useful_num = n - i # 残り使える数
  # 残りの数を割って、C <= 商 <= Dに収まるなら作れる
  if (C <= (rest_1 / useful_num) <= D) or (C <= (rest_2 / useful_num) <= D):
    print("YES")
    break
else:
  print("NO")


Measured memory_bytes: 9112
N = int(input())
A = list(map(int,input().split()))

count = 0
Sum = 0
r = 0

for l in range(0, N):
    #Sum = A[l]
    while r < N and Sum + A[r] == Sum ^ A[r]:
            Sum += A[r]
            r += 1
    count += r-l
    if(l==r):
        r+=1
    else:
        Sum -= A[l]
    
    
print(count)

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

void solve()
{
  string s;
  cin>>s;
  int i=0;
  int sum=0;
 while(s[i]!='\0')
  {
    sum+=s[i]-'0';
   
   i++;
  }
  if(sum%9==0)
    cout<<"Yes";
  else
    cout<<"No";
  return;
  
  
}
int main()

{
   solve();
}


Measured memory_bytes: 3712
fun main() {
    val n = readInt()
    val a = readInts().map { it.toLong() }
    val mod = 1000000007L

    var total = a.reduce { acc, l -> (acc + l) % mod }
    var ans = 0L
    for (i in 0 until n) {
        total = (mod + total - a[i]) % mod
        ans = (ans + a[i] * total) % mod
    }

    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 72872
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <sstream>
#include <utility>
#include <bitset>
#include <stack>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-9
#define MOD (998244353) 
#define IOS ios::sync_with_stdio(false)

typedef pair<int,int> pii ;
typedef pair<double,double> pdd ;
typedef long long ll ;

ll n,a,b,k;
ll inv[300005],fooq[300005];

ll Pow(int x,int p)
{
	if(p==1) return x;
	if(p==0) return 1;
	ll ret=Pow(x,p>>1);
	if(p&1) return ((ret*ret%MOD)*(ll)x)%MOD;
	return (ret*ret)%MOD;
}

inline ll C(int x,int y)
{
	if(y==0) return 1;
	if(y>x) return 0;
	return ((fooq[x]*inv[y]%MOD)*inv[x-y])%MOD;
}

int main()
{
	cin>>n>>a>>b>>k;
	fooq[1]=1;
	fooq[0]=inv[0]=1;
	for(int i=2;i<=300000;i++) fooq[i]=(fooq[i-1]*i)%MOD;
	inv[300000]=Pow(fooq[300000],MOD-2);
	for(int i=299999;i>=1;i--) inv[i]=(inv[i+1]*(i+1))%MOD;
	ll ans=0ll;
	for(int i=0;i<=n;i++)
	{
		ll sa=a*(ll)i;
		if((k-sa)%b || sa>k) continue;
		ll B=(k-sa)/b;
		ans+=(C(n,i)*C(n,B))%MOD;
		if(ans>=MOD) ans-=MOD;
	}
	cout<<ans;
	return 0;
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 10;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
//const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
 
string a[N];
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m, k;
    cin >> n >> m >> k;
    rep(i, 0, n) {
        cin >> a[i];
    }
    int ans = inf;
    rep(mask, 0, (1 << (n - 1))) {
        int cnt = __builtin_popcount(mask);
        int tot = cnt;
        vector<int> cur(cnt + 1, 0);
        rep(j, 0, m) {
            int p = 0;
            rep(i, 0, n) {
                cur[p] += (a[i][j] == '1');
                if ((mask >> i) & 1) {
                    p++;
                }
            }
            bool bad = false;
            rep(i, 0, sz(cur)) {
                if (cur[i] > k) {
                    bad = true;
                }
            }
            if (bad) {
                tot++;
                fill(cur.begin(), cur.end(), 0);
                int p = 0;
                rep(i, 0, n) {
                    cur[p] += (a[i][j] == '1');
                    if ((mask >> i) & 1) {
                        p++;
                    }
                }
                bool bad = false;
                rep(i, 0, sz(cur)) {
                    if (cur[i] > k) {
                        bad = true;
                    }
                }
                if (bad) {
                    tot = inf;
                }
            }
        }
        setmin(ans, tot);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
 
 
for i in range(2,n):
    for j in range(1,i):
        for k in range(j):
            if l[k]==l[j] or l[i]==l[j] or l[i]==l[k]:
                continue
            x=l[k]+l[j]
 
            if x > l[i]:
                ans+=1
 
print(ans)

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

int main() {
  int n,d;cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n)rep(j,d)cin>>x[i][j];
  int cnt=0;
  rep(i,n)for(int j=i+1;j<n;j++){
      int ans=0;
      rep(k,d){
      ans+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    }
    for(int k=1;k<=ans;k++){
      if(k*k==ans)cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int A, B, M;
  cin >> A >> B >> M;
  int a[A], b[B];
  for(int i = 0; i < A; i++)cin >> a[i];
  for(int i = 0; i < B; i++)cin >> b[i];
  int x[M], y[M], c[M];
  for(int i = 0; i < M; i++)cin >> x[i] >> y[i] >> c[i];
  int Min = 1000000;
  for(int i = 0; i < M; i++){
    Min = min(Min, a[x[i]-1]+b[y[i]-1]-c[i]);
  }
  sort(a, a+A);
  sort(b, b+B);
  Min = min(Min, a[0]+b[0]);
  cout << Min << endl;
  return 0;
}



Measured memory_bytes: 2176
import sys
import os
import itertools
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    X=list(map(int, input().split()))

    for i,x in enumerate(X):
        if x==0:
            print(i+1)
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 9464
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int mod = 1e9 + 7;
int N, M, Q, K;
map<int, int> cnt;
int A[MAX];
int main()
{
    int i, j, k, num;
    scanf("%d", &N);

    for(i = 1; i<=N; ++i){
        scanf("%d", &A[i]);
        cnt[A[i]]++;
    }
    int sum = 0;
    auto it = cnt.begin();
    for(;it!=cnt.end(); ++it){
        if(it->second > it->first){
            sum += it->second - it->first;
        }
        else if(it->second < it->first){
            sum += it->second;
        }
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 5120
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
money = 0
drink = 0
for a,b in ab:
    if drink+b <= m:
        drink += b
        money += a*b
    else:
        money += (m-drink) * a
        drink = m
    if drink == m: break
print(money)

Measured memory_bytes: 27344
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define MX 100000
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int tp1,tp2;
	tp1=abs(a-b);tp2=abs(a-c);
	if(tp1>tp2)
		printf("B");
	else printf("A");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Long> A = new ArrayList();
        for (int i = 0; i < N; i++) {
            A.add(scan.nextLong());
        }
        A.sort(Comparator.reverseOrder());
        PriorityQueue<Candidate> queue = new PriorityQueue<>(new CandidateComparator());
        long ans = 0;
        ans += A.get(0);
        if (N == 2) {
            System.out.println(ans);
            return;
        }
        queue.add(new Candidate(A.get(0), A.get(1)));
        boolean first = true;
        for (int i = 2; i < N; i++) {
            long current = A.get(i);
            Candidate c = queue.poll();
            ans += c.value();
            if (first) {
                queue.add(c);
                first = false;
            }
            queue.add(new Candidate(c.left, current));
            queue.add(new Candidate(current, c.right));
        }
        System.out.println(ans);
    }
    class Candidate {
        long left = 0;
        long right = 0;
        Candidate(long left, long right) {
            this.left = left;
            this.right = right;
        }
        long value() {
            return Math.min(left, right);
        }
    }
    class CandidateComparator implements Comparator<Candidate> {
        @Override
        public int compare(Candidate o1, Candidate o2) {
            long v1 = o1.value();
            long v2 = o2.value();
            if (v1 != v2) {
                return -Long.compare(v1, v2);
            }
            if (o1.left != o2.left) {
                return Long.compare(o1.left, o2.left);
            }
            return Long.compare(o2.left, o2.left);
        }
    }
}


Measured memory_bytes: 71016
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int h,w;
int main() {
	fast;
	cin>>h>>w;
	char grid[h][w];
	int dp[h][w];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<h;i++)
	   for(int j=0;j<w;j++)
	       cin>>grid[i][j]; 
	for(int i=h-1;i>=0;i--){
	   for(int j=w-1;j>=0;j--){
		   if(i==h-1 and j==w-1){
			   dp[i][j]=1;
			   continue;
		   }
	   	   if(grid[i][j]=='.')
	   	      dp[i][j]=(((i<h-1)?dp[i+1][j]:0)+((j<w-1)?dp[i][j+1]:0))%mod;
	   }
	}
	cout<<dp[0][0]<<"\n";
	return 0;
}


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

long long n,ans=1e16,a[10],sum[1000000],x;

int main()
{
	cin>>n;
	for (int i=1; i<=n; ++i)
		cin>>x,sum[i]=sum[i-1]+x;
	int p=1,q=3;
	for (int i=3; i<=n; ++i)
	{
		while (p<=i-3 && abs(sum[p]-(sum[i-1]-sum[p])) >= abs(sum[p+1]-(sum[i-1]-sum[p+1]))) p++;
		while (q<=n-2 && abs(sum[q]-sum[i-1]-(sum[n]-sum[q])) >= abs(sum[q+1]-sum[i-1]-(sum[n]-sum[q+1]))) q++;
		a[1]=sum[p];
		a[2]=sum[i-1]-sum[p];
		a[3]=sum[q]-sum[i-1];
		a[4]=sum[n]-sum[q];
		sort(a+1,a+4+1);
		ans=min(ans,a[4]-a[1]);
	}
	cout<<ans;
} 

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l.at(i);
  sort(l.begin(), l.end());
  long long cnt = 0;
  int kmax, kmin;
  for (int i = n - 1; i >= 2; i--) {
    for (int j = i - 1; j >= 1; j--) {
      kmax = n;
      kmin = n;
      for (int k = 0; k < j; k++) {
        if (l.at(k) > l.at(i) - l.at(j)) {
          kmin = k;
          break;
        }
      }
      if (kmin == n) break;
      for (int k = j - 1; j >= 0; j--) {
        if (l.at(k) < l.at(i) + l.at(j)) {
          kmax = k;
          break;
        }
      }
      if (kmax == n) break;
      cnt += kmax - kmin + 1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        initialize();
    }

    void initialize(){
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = modpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int nCr(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        if(n > MAX_N){
            MAX_N = n;
            initialize();
        }
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

signed main(){

    int H, W, K;
    cin >> H >> W >> K;
    int mod = 1000000007;
    Combination comb(H + W, mod);

    int ans = K;
    ans *= (comb.nCr(H + W, K) * comb.fact[K]) % mod;
    if(K >= 2){
        int a0 = 0;
        int c0 = (comb.nCr(H + W - 2, K - 2) * comb.fact[K - 2]) % mod;
        FOR(k, 2, K + 1){
            int c = c0;
            c *= 2 * (k - 1);
            c %= mod;
            a0 = (a0 + c * (K - k + 1)) % mod;
        }
        a0 *= (H * W) % mod;
        ans = (ans + a0) % mod;
    }

    int a0 = 0;
    int c0 = (comb.nCr(H + W - 1, K - 1) * comb.fact[K - 1]) % mod;
    FOR(k, 1, K + 1){
        int c = c0;
        a0 = (a0 + c * (K - k + 1)) % mod;
    }
    a0 *= (H + W) % mod;
    ans = (ans + a0) % mod;

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 312704
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n;
map<int, int> mp;

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  mp.clear();
  for (int i = 0; i < n; i++) {
    int d;
    scanf("%d", &d);
    mp[d]++;
  }
  return true;
}

void solve() {
  int m;
  scanf("%d", &m);
  bool bad = false;
  for (int i = 0; i < m; i++) {
    int t;
    scanf("%d", &t);
    if (!mp.count(t)) {
      bad = true;
      continue;
    }
    if (!mp[t]) {
      bad = true;
      continue;
    }
    mp[t]--;
  }
  if (bad) {
    printf("NO\n");
    return;
  }
  printf("YES\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 int W,H,x,y,r;
 cin>> W >> H >> x >> y >> r;
 if (x-r>=0&&y-r>=0&&y+r<=H&&x+r<=W){
     cout<<"Yes"<<endl;
           }
else       {
     cout<<"No"<<endl;
           }

           }



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

struct UnionFind {
  vi par;

  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; i++) par.at(i) = i;
  }

  int root(int x){
    if(par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }

  int unite(int x, int y){
    if(root(x) == root(y)) return 0;
    par.at(root(x)) = root(y);
    return 1;
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }

};

int main(){
  ll n, q;
  cin >> n >> q;
  vll com(q), x(q), y(q);
  for(int i = 0; i < q; i++){
    cin >> com.at(i) >> x.at(i) >> y.at(i);
  }
  UnionFind tree(n);
  for(int i = 0; i < q; i++){
    if(com.at(i) == 0) tree.unite(x.at(i), y.at(i));
    else cout << (tree.same(x.at(i), y.at(i)) ? 1 : 0) << endl;
  }
}


Measured memory_bytes: 5096