akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n), f(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> f[i];
    }
    sort(all(a));
    sort(rall(f));

    ll left = -1, right = INF;
    while(right - left > 1) {

        ll mid = (left + right)/2;

        bool ok = [&]{

            ll cnt = 0;
            rep(i, n) {
                cnt += max(0LL, a[i] - mid/f[i]);
            }

            return cnt <= k;
        }();

        if(ok) {
            right = mid;
        }
        else {
            left = mid;
        }

    }
    
    out(right);
    re0;
}

Measured memory_bytes: 3456
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

/*
ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}*/

int h, w, pcnt;
char grid[52][52];
int cntgrid[52][52];

int main(){
	cin >> h >> w;
	pcnt = 0;
	lp(w+2) {
		grid[0][i] = '#';
		grid[h + 1][i] = '#';
	}
	lp(h) {
		grid[i + 1][0] = '#';
		grid[i + 1][w + 1] = '#';
	}
	lp(h) {
		LP(w, j) {
			cin >> grid[i + 1][j + 1];
			if (grid[i + 1][j + 1] == '.') {
				pcnt++;
			}
		}
	}
	lp(h + 2) {
		LP(w + 2, j) {
			cntgrid[i][j] = 1000000;
		}
	}
	cntgrid[1][1] = 1;
	lp(pcnt) {
		LP(h, j) {
			LP(w, k) {
				if (grid[j + 1][k + 1] == '.') {
					if (grid[j][k + 1] == '.') {
						cntgrid[j][k + 1] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j][k + 1]);
					}
					if (grid[j + 1][k] == '.') {
						cntgrid[j + 1][k] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j + 1][k]);
					}
					if (grid[j + 2][k + 1] == '.') {
						cntgrid[j + 2][k + 1] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j + 2][k + 1]);
					}
					if (grid[j + 1][k + 2] == '.') {
						cntgrid[j + 1][k + 2] = min(cntgrid[j + 1][k + 1] + 1, cntgrid[j + 1][k + 2]);
					}
				}
			}
		}
	}
	if(cntgrid[h][w]==1000000)
		cout << -1 << endl;
	else cout << pcnt - cntgrid[h][w] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	
	cin >> n;
	int x , g = 0;

	for(int i  = 0; i < n; i++){
		cin >> x;
		g = __gcd(g,x);
	}
	cout << g << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
  int x, y;
  while(1){
    scanf("%d %d",&x, &y);
    if( x==0 && y ==0)break;
    if(x>=y)
      printf("%d %d\n", y, x);
    else if(y>=x)
      printf("%d %d\n",x, y);
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void) {
	int m,f,r;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1){
			break;
		}
		if(m==-1 || f==-1){
			printf("F");
		}else if(m+f>=80){
			printf("A");
		}else if(m+f>=65){
			printf("B");
		}else if(m+f>=50){
			printf("C");
		}else if(m+f>=30 && r>=50){
			printf("C");
		}else if(m+f>=30){
			printf("D");
		}else{
			printf("F");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
import java.io.*;
import java.util.*;


class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            int count = 0;
            int n = 0,q = 0;
            String line;
            Deque<String> name = new ArrayDeque<>();
            Deque<Integer> time = new ArrayDeque<>();
            String[] tmp;
            int spentTime = 0;
            while((line = br.readLine()) != null){
                // System.out.println(line);
                if(Objects.equals(line,"")){
                    break;
                }
                tmp = line.split(" ");
                if(count == 0){
                    n = Integer.parseInt(tmp[0]);
                    q = Integer.parseInt(tmp[1]);
                    count++;
                }
                else{
                    name.addLast(tmp[0]);
                    time.addLast(Integer.parseInt(tmp[1]));
                }
            }

            String temp_name;
            int temp_time;
            while(name.size() != 0){
                temp_name = name.removeFirst();
                temp_time = time.removeFirst();

                if(temp_time > q){
                    temp_time -= q;
                    name.addLast(temp_name);
                    time.addLast(temp_time);
                    spentTime += q;
                }else{
                    System.out.println(temp_name + " " + (spentTime + temp_time));
                    spentTime += temp_time;
                }
            }
        }catch(Exception e){
            System.out.println(e);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 62624
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    m = sum(s)/n
    numerator = sum([(float(s[i])-m)**2 for i in range(n)])
    alphalpha = numerator / n
    print("{0:.8f}".format(math.sqrt(alphalpha)))

Measured memory_bytes: 7736
import collections

N = int(input())

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

mod = 10**9+7

# 各数字の出現回数を調べる
c = collections.Counter(A)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print(2**(len(c.values()))%mod)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print((2**(len(c.values())-1))%mod)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数




Measured memory_bytes: 14812
#include<stdio.h>
#include<stdlib.h>
 
#define NIL -1
#define MAX 500001
 
typedef struct{
  int right;
  int left;
  int key;
} Node;
 
void Insert(Node*,int,int);
void PreOrder(Node*,int);
void InOrder(Node*,int);
void Find(Node*,int, int);
 
int main(void){
  int i, n, k, f, count=0;
  char state[8];
  Node T[MAX];
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", state);
 
    if(state[0] == 'i'){
 
      scanf("%d",&k);
      Insert(T, count, k);
      count++;
 
    } else if(state[0] == 'p'){
 
      if(count > 0){
        InOrder(T, 0);
        printf("\n");
        PreOrder(T, 0);
        printf("\n");
      }
 
    } else if(state[0] == 'f'){
 
      scanf("%d", &f);
      Find(T, f, 0);
 
    }
  }
  return 0;
}
 
void Insert(Node *T,int count, int k){
  int x, y;
 
  T[count].key = k;
  T[count].left = NIL;
  T[count].right = NIL;
 
  if(count == 0) return;
 
  x = 0;
  while(x!=NIL){
    y = x;
 
    if(k < T[x].key) x = T[x].left;
    else x = T[x].right;
 
  }
 
  if(k < T[y].key) T[y].left = count;
  else T[y].right = count;
 
  return;
}
 
void PreOrder(Node *T, int u){
 
  if(u == NIL) return;
 
  printf(" %d", T[u].key);
  PreOrder(T, T[u].left);
  PreOrder(T, T[u].right);
 
  return;
}
 
void InOrder(Node *T, int u){
 
  if(u == NIL) return;
 
  InOrder(T, T[u].left);
  printf(" %d", T[u].key);
  InOrder(T, T[u].right);
 
  return;
}
 
void Find(Node *T, int f, int u){
 
  if(u == NIL) printf("no\n");
  else if(T[u].key == f) printf("yes\n");
  else if(T[u].key > f && T[u].left != NIL) Find(T, f, T[u].left);
  else Find(T, f, T[u].right);
 
  return;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


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

int main() {
  
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;

//-----------------   
  cout << 'U';
  
  REP(i, ty-sy-1 ){
    cout << 'U';
  }
  REP(i, tx-sx-1 ){
    cout << 'R';
  }
  
  cout << 'R';
//-----------------  
  cout << 'D';
  
  REP(i, ty-sy-1 ){
    cout << 'D';
  }
  REP(i, tx-sx-1 ){
    cout << 'L';
  }
  
  cout << 'L';
//-----------------  
  cout << 'L';
  
  REP(i, ty-sy+1 ){
    cout << 'U';
  }
  REP(i, tx-sx+1 ){
    cout << 'R';
  }
  
  cout << 'D';
//-----------------    
  cout << 'R';
  
  REP(i, ty-sy+1 ){
    cout << 'D';
  }
  REP(i, tx-sx+1 ){
    cout << 'L';
  }
  
  cout << 'U';
//----------------- 
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import bisect

def main():
    d = dict()
    for _ in range(int(input())):
        s = ''.join(sorted(input()))
        if s not in d:
            d[s] = 0
        d[s] += 1
    ans = 0
    A = list(d.values())
    for a in A:
        val = a * (a - 1) // 2
        ans += val
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 17844
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  
  if(a == 1){
    if(b == 1) cout << "Draw";
    else cout << "Alice";
  }
  else if(b == 1) cout << "Bob";
  else if(a < b) cout << "Bob";
  else if(a == b) cout << "Draw";
  else if(a > b) cout << "Alice";
  
  cout << endl;
  return 0;
}

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

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

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

  int r = 0, g = 0, b = 0;
  for (char c : s) {
    if (c == 'R') {
      r++;
    } else if (c == 'G') {
      g++;
    } else if (c == 'B') {
      b++;
    }
  }

  long long answer = (long long)r * g * b;

  Rep(i, n - 2) {
    for (int d = 1; i + d * 2 < n; d++) {
      int j = i + d;
      int k = i + d * 2;
      if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
        answer--;
      }
    }
  }

  cout << answer << endl;

  return 0;
}


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

struct grid{
	int x,y;
	bool operator<(const grid& another) const {
		return x < another.x;
	}
};

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

	vector<grid> r,b;
	int n;
	cin >> n;

	for (int i = 0;i < n;i++){
		grid a; cin >> a.x >> a.y;
		r.push_back(a);
	}
	sort(r.begin(),r.end());

	for (int i = 0;i < n;i++){
		grid c;cin >> c.x >> c.y;
		b.push_back(c);
	}
	sort(b.begin(),b.end());

	int p = 0;
	int size = 0;
	int cn = -1;
	int ma = -1;
	int ans = 0;

	for (int i = 0;i < n;i++){
		for (int j = 0;j < r.size();j++){
				if (r[j].y < b[i].y && r[j].x < b[i].x) {
					if (ma < r[j].y){ma = r[j].y; cn = j;}	 
			}
		}
		if (ma != -1) {
			r.erase(r.begin() + cn);
			ans++;
		}
		ma = -1;cn = -1;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// 文字列の入力
		// 出力
		if (a % 2 == 0 || b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}

	}

}


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

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int a, b;
	
	cin >> a >> b;
	
	int sum = (3*a) + b;
	
	cout << sum/2 << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S, T; 
    cin >> S >> T;
    bool ans = false;
    for (int i= 0; i < S.size(); ++i){
        if( S==T){
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size()-1);
    }
    if (ans) {
    cout << "Yes" << endl;
    }
    else {
    cout << "No" << endl;
    }   
}



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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<vector<ll>> V(N);
    REP(i, N) {
        ll x, y, z;
        cin >> x >> y >> z;
        V[i] = {x, y, z};
    }
    vector<VI> S{{0, 0, 0}, {0, 0, 1} , {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}};
    ll ans = 0;
    for (auto v : S) {
        sort(all(V), [v](auto a, auto b) {
            ll sumA = 0;
            ll sumB = 0;
            REP(i, 3) {
                if (v[i] == 0) {
                    sumA += a[i];
                    sumB += b[i];
                } else {
                    sumA += -a[i];
                    sumB += -b[i];
                }
            }
            return sumA > sumB;
        });
        vector<ll> sum{0, 0, 0};
        REP(i, M) {
            sum[0] += V[i][0];
            sum[1] += V[i][1];
            sum[2] += V[i][2];
        }
        ans = max(ans, abs(sum[0]) + abs(sum[1]) + abs(sum[2]));
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll n;
    cin >> n;
    ll h, w, r;
    srepn(i,1,3500)srepn(j,1,3500){
        ll k = 4*i*j-n*i-n*j;
        if(k>0 && (n*i*j)%k==0){
            h = i;
            w = j;
            r = (n*i*j)/k;
            break;
        }
    }
    cout << h << " " << w << " " << r << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
	string s;
	cin>>s;
	int a=0,b=0;
	int n=s.size();
for(int i=0;i<n;i++){
 if(i%2==0){
     if(s[i]!='0')b++;
	 if(s[i]!='1')a++;
 }else{
	 if(s[i]!='0')a++;
	 if(s[i]!='1')b++;
 }
}
cout<<min(a,b)<<endl;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<P> items(N);
    rep(i, N) cin >> items[i].second >> items[i].first;

    sort(items.rbegin(), items.rend());

    ll now = 0;
    set<ll> eat;
    vector<ll> eat2;
    rep(i, K) {
        P p = items[i];
        now += p.first;
        if (eat.count(p.second)) {
            eat2.push_back(p.first);
        } else {
            eat.insert(p.second);
        }
    }

    ll ans = now + eat.size() * eat.size();
    sort(eat2.begin(), eat2.end());

    int j = 0;
    rep2(i, K - 1, N) {
        P p = items[i];
        if (eat.count(p.second)) {
            continue;
        } else {
            now += p.first;
            if (eat2.size() <= j) {
                break;
            }
            now -= eat2[j];
            j++;
            eat.insert(p.second);
            ans = max(ans, (ll) (now + eat.size() * eat.size()));
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 5244
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<int> hs(n);
	for (int i = 0; i < n; i++)
	{
		cin >> hs[i];
	}
	int ans = 1;
	for (int i = 1; i < n; i++)
	{
		bool ok = 1;
		for (int j = 0; j < i; j++)
		{
			ok &= hs[j] <= hs[i];
		}
		ans += ok;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli dp[5100][5100];
 
int main(){

	lli n,k;
	cin>>n>>k;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

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

	lli ans = n;

	dp[0][0]=1;

	REP(i,0,n){
		REP(j,0,k){
			dp[i+1][j] += dp[i][j];
			if(j+a[i] < k){
				dp[i+1][j+a[i]] += dp[i][j];
			}
		}
	}

	REP(i,0,n){
		lli dplast[5100];
		REP(j,0,5100)dplast[j] = dp[n][j];
		//戻すDP
		REP(j,0,k){
			if(j+a[i] < k){
				dplast[j+a[i]] -= dplast[j];
			}
			if(j >= k-a[i] && dplast[j]){
				ans--;
				break;
			}
		}
	}

	cout<<ans<<endl;




    return 0;
}

Measured memory_bytes: 202856
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
int n;
int x[102],cnt=0;

int main(){

int n,m;cin>>n>>m;

vector<int>x(m),dis(m-1);

rep(i,m)cin>>x[i];
sort(x.begin(),x.end());
rep(i,m-1)dis[i] = x[i+1]-x[i];

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

ll ans=0;
if(m-n<=0)ans =0;
else rep(i,m-n)ans+=dis[i];
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    if(b > x) cout << x % MOD << endl;
    else cout << (x % MOD + (((x-b)/(a-b)%MOD)*(b%MOD)) % MOD) % MOD << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;//AmShZ
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b, ll md = mod) {
    ll res = 1;while(b){if(b&1){res=(a*res)%mod;}a=(a*a)%mod;b>>=1;}return(res);
}

int main(){
    migmig
    ld l;
  	cin >> l;
  	cout << fixed << setprecision(10) << (l/(ld)3)*(l/(ld)3)*(l/(ld)3);
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


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

using namespace std;

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

    if ((a == b && a != c)  || (b == c && b != a) || (c == a && c != b)) {
        cout << "Yes" << endl; 
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
const int N = 2e5 + 1;

vector<int>g[N];
int ans[N],a[N];
int n;
vector<int>ve;

void dfs(int u,int p){
	int del = -1;
	int pos = lower_bound(ve.begin(),ve.end(),a[u]) - ve.begin();
	if(pos != ve.size()){
		del = ve[pos];
		ve[pos] = a[u];
	}
	else
		ve.push_back(a[u]);
	ans[u] = ve.size();
	for(int v:g[u]){
		if(v==p)
			continue;
		dfs(v,u);
	}
	if(del == -1)
		ve.pop_back();
	else{
		pos = lower_bound(ve.begin(),ve.end(),a[u]) - ve.begin();
		ve[pos] = del;
	}
}

int32_t main(){ 
    boost;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    for(int i=1,u,v;i<n;i++){
    	cin>>u>>v;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
    	cout<<ans[i]<<endl;
}


Measured memory_bytes: 30552
MOD = 10**9+7
x, y = map(int, input().split())
n, r1 = divmod(2*y-x, 3)
m, r2 = divmod(2*x-y, 3)


def com(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
    Y = pow(Y, MOD-2, MOD)
    return X*Y


if r1 or r2:
    print(0)
else:
    print(com(n+m, n) % MOD)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

#define YES() cout << "YES" << endl;
#define Yes() cout << "yes" << endl;
#define NO() cout << "NO" << endl;
#define No() cout << "No" << endl;
#define POSSIBLE() cout << "POSSIBLE" << endl;
#define Possible() cout << "Possible" << endl;
#define IMPOSSIBLE() cout << "IMPOSSIBLE" << endl;
#define Impossible() cout << "Impossible" << endl;

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

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

string s;
int k;
vector< int > idx[26];

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

	cin >> s >> k;
	int sz = (int)s.size();
	set< string > st;
	REP(i, sz) {
		REP(j, 6) {
			if (i + j > sz) break;
			string t = s.substr(i, j);
			st.insert(t);
		}
	}
	auto itr = st.begin();
	REP(i, k) itr++;
	cout << *itr << endl;

    return 0;
}


Measured memory_bytes: 1664
listA=[]
listB=[]
n,m,l=map(int,input().split())
result_vec=[[0]*l for n in range(n)]
for i in range(n):
    listA.append(list(map(int,input().split())))
for i in range(m):
    listB.append(list(map(int,input().split())))
for i in range(n):
    for j in range(l):
        number=0
        for k in range(m):
            number+=listA[i][k]*listB[k][j]
        result_vec[i][j]=number
for n in range(n):
    print(' '.join(map(str,result_vec[n])))


Measured memory_bytes: 6912
import Control.Monad
import Text.Printf
import Data.List
import Data.Ratio

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO()
main = do
  _ <- getLine
  v <- getInts
  let vs = sort v
  printf "%f" $ slv (drop 2 vs) ((vs !! 0 + vs !! 1) % 2)

slv :: [Int] -> Ratio Int -> Double
slv [] rat = (fromIntegral n) / (fromIntegral d)
  where d = denominator rat
        n = numerator rat
slv (s:sn) rat = slv sn $ (rat + (s % 1)) * (1 % 2)

Measured memory_bytes: 1020
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    X = int(input())
    res = 0
    res += X // 500 * 1000
    X = X % 500
    res += X // 5 * 5
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
from collections import Counter

N = int(input())
*a, = map(int, input().split())
c = Counter(a)
b = len(c.keys())

def check():
    if 0 in c.keys():
        if b==1 or (b==2 and c[0]==N//3):
            return True
    elif b==3:
        s, t, u = c.keys()
        if s^t^u==0 and c[s]==c[t]==c[u]:
            return True
    return False

print("Yes" if check() else "No")

Measured memory_bytes: 14468
import copy
import collections

n = int(input())
k = list(input())
t = collections.Counter(k)
d = {i:t[i] for i in t.keys()}

for _ in range(n - 1):
    k = list(input())
    t = collections.Counter(k)
    for key, value in t.items():
        if key in d.keys():
            d[key] = min(value, d[key])
    j = copy.deepcopy(list(d.keys()))
    for key in j:
        if key not in t.keys():
            del d[key]
ans = ""
for k in sorted(list(d.keys())):
    ans = ans + k * d[k]
print(ans)

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
a=(a+11)%13;
b=(b+11)%13;
if (a>b)
    cout <<"Alice"<<endl;
if (a==b)
    cout <<"Draw"<<endl;
if (a<b)
    cout <<"Bob"<<endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> G;
typedef pair<int, int> P;

int i,j,N;
bool F[100][10];
int Q[100][11];
int pmax = -1000000000;

int main() {
	cin >> N;
	
	REPI(0,N) REPJ(0,10) cin >> F[i][j];
	REPI(0,N) REPJ(0,11) cin >> Q[i][j];
	
	REPI(1,1024) {
		int x = 0;
		REPJ(0,N) {
			int cnt = 0;
			for (int k=0; k<10;k++) if (i&(1<<k)) cnt += F[j][k];
			x += Q[j][cnt];
		}
		pmax = MAX(x, pmax);
	}
	
	cout << pmax;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
    int64_t X;
    cin >> X;
    int64_t sum = 0;
    int n = 0;
    while (sum < X) {
        n++;
        sum += n;
    }
    cout << n << endl;
}


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

flag = 1
for a in A:
  if a % 2 == 0:
    if a % 3 == 0 or a % 5 == 0:
      continue
    else:
      flag = 0
print('APPROVED' if flag else 'DENIED')

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int H, W, N; cin >> H >> W >> N;
  cout << min((N - 1) / W, (N - 1) / H) + 1 << endl;
}


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

void dfs(int u, bool c[], int adj[51][51]){
  for ( int i = 1; i <= n ; i++){
    if(!c[i] && adj[u][i]){
      c[i] = true;
      dfs(i, c, adj);
    }
  }
  return;
}

bool check(bool c[]){
  for ( int i = 1; i <= n; i++){
    if(!c[i]){
      return false;
    }
  }
  return true;
}

int main(){
  cin >> n >> m;
  pair<int,int> p[m];
  int adj[n+1][n+1];
  for ( int i = 1; i <= n; i++){
    for ( int j = 1; j <= n; j++){
      adj[i][j] = 0;
    }
  }
  int a, b;
  for ( int i = 0; i < m; i++){
    cin >> a >> b;
    p[i] = make_pair(a, b);
    adj[a][b] = 1;
    adj[b][a] = 1;
  }

  int ans = 0;
  for (int i = 0; i < m; i++){
    int a = p[i].first;
    int b = p[i].second;
    int ad[51][51];
    bool c[n+1];
    for ( int i = 1; i <= n; i++)c[i] = false;
    for ( int i = 1; i <= n; i++){
      for ( int j = 1; j <= n; j++){
        ad[i][j] = adj[i][j];
      }
    }
    ad[a][b] = 0;
    ad[b][a] = 0;
    dfs(1, c, ad);
    if(!check(c)){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

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

using ll = long long;
using lb = long double;
using P = pair<string,string>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N;
  cin>>N;
  vector<ll> v(5,0);
  rep(i,N){
    string S;
    cin>>S;
    if(S[0]=='M') v[0]++;
    if(S[0]=='A') v[1]++;
    if(S[0]=='R') v[2]++;
    if(S[0]=='C') v[3]++;
    if(S[0]=='H') v[4]++;
  }
  ll ans = 0;
  rep(i,3){
    for(int j = i+1;j < 4; j++){
      for(int k = j+1; k<5; k++){
        ans += v[i]*v[j]*v[k];
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#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 pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

ll N, tmp, pre, prepre, s, sq;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  if (N == 1){
    cout << 1 << endl;
    return 0;
  }
  if (N == 2){
    cout << 4 << endl;
    return 0;
  }
  pre = N * N % mod;
  prepre = N;
  sq = (N - 1) * (N - 1);
  FOR(i, 3, N + 1){
    tmp = pre + s + sq + N - i + 2;
    tmp %= mod;
    s += prepre;
    s %= mod;
    prepre = pre;
    pre = tmp;
  }
  cout << pre << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int k = 2;
	int n;
	cin >> n;
	
	vector<int> vals(n);
	for(int i=0; i < n; i++) cin >> vals[i];
	
	vector<int> dp(n, numeric_limits<int>::max());
	dp[0] = 0;
	
	for(int i=0; i < n-1; i++) {
		for(int j=1; j <= k; j++) {
			if(i+j < n) {
				dp[i+j] = min(dp[i+j], dp[i] + abs(vals[i] - vals[i+j]));
			}
		}
	}
	
	cout << dp[n-1];

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int k, n;
    string s;

    cin >> n >> k >> s;

    s[k - 1] = char(s[k - 1] + ('a' - 'A'));

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let big_int = 1000000007i64;
    let mut counts = vec![0; 3];
    let mut ans = 1;
    for num in a {
        let mut same_num = 0;
        for i in 0..3 {
            if counts[i] == num {
                same_num += 1;
            }
        }
        ans *= same_num;
        ans %= big_int;
        for i in 0..3 {
            if counts[i] == num {
                counts[i] += 1;
                break;
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

struct Idx {
    int idx;
    ll val;
};

// 値が大きい順にソート。
// 値が同じ場合は、indexが大きい順にソート
bool SortbyVal(const Idx &a, const Idx &b) {
    if (a.val == b.val) return a.idx > b.idx;
    return a.val > b.val;
}

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

    int n;
    cin >> n;

    vector <Idx> vec(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        vec[i] = (Idx){i, a};
    }

    vec.push_back((Idx){-1, 0LL});
    sort(vec.begin(), vec.end(), SortbyVal);

    vector <ll> ans(n, 0);
    int id = n;
    ll pc = 0, cur = vec[0].val;
    while (pc <= n) {
        if (vec[pc].val == cur) {
            pc++;
            continue;
        }

        id = min(id, vec[pc - 1].idx);
        ans[id] += (cur - vec[pc].val) * pc;
        cur = vec[pc++].val;
    }

    for (ll ret : ans) cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 4736
n = int(input())

prime = []
for i in range(2,1001):
	f = True
	for j in range(2,i):
		if i % j == 0:
			f = False
			break
	if f == True:
		prime.append(i)


c,total = 1,1

for p in prime:
	if p > n:
		continue
	for i in range(1,100):
		if p**i <= n:
			c += n // p**i
		else:
			total *= c
			c = 1
			break
		
print(total % (10**9+7))


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (auto &c : s) {
        if (c == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
struct info
{
    int l,r,d;
}s[400005];
int n,m;
int flag = 1;
int dis[100005],visited[100005];
int first[400005],nexti[400005];
void dfs(int t)
{
    if(!flag)return;
    int k = first[t];
    while(k != -1)
    {
        if(!flag)return;
        if(!visited[s[k].r])
        {
            dis[s[k].r] = dis[s[k].l] + s[k].d;
            visited[s[k].r] = 1;
            dfs(s[k].r);
        }
        else if(s[k].d + dis[s[k].l] != dis[s[k].r])
        {
            flag = 0;
            return;
        }
        k = nexti[k];
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 0;i < m;i ++)
    {
        scanf("%d%d%d",&s[i].l,&s[i].r,&s[i].d);
        nexti[i] = first[s[i].l];
        first[s[i].l] = i;
        s[i + m].r = s[i].l;
        s[i + m].l = s[i].r;
        s[i + m].d = -s[i].d;
        nexti[i + m] = first[s[i + m].l];
        first[s[i + m].l] = i + m;
    }
    for(int i = 1;i <= n;i ++)
    {
        if(!visited[i])
        {
            visited[i] = 1;
            dfs(i);
        }
    }
    if(flag)printf("Yes");
    else printf("No");
}


Measured memory_bytes: 9728
s = list(input())
lenS = len(s)
sumS = 0

patterns = []
for i in range(2 ** (lenS - 1)):
    tmp = [False] * (lenS - 1)
    for j in range(lenS - 1):
        if i >> j & 1:
            tmp[j] = True
    patterns.append(tmp)

for pattern in patterns:
    a = s[0]
    for i in range(len(pattern)):
        if pattern[i] == True:
            pass
        else:
            sumS += int(a)
            a = "0"
        a += s[i+1]
    sumS += int(a)

print(sumS)


Measured memory_bytes: 3316
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))
L, R = [0] * (n + 1), [0] * (n + 1)

for i in range(1, n + 1):
    L[i] = gcd(L[i - 1], A[i - 1])

for i in range(n - 1, -1, -1):
    R[i] = gcd(R[i + 1], A[i])

ans = 0
#print(L, R)
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))
print(ans)

Measured memory_bytes: 16120
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 200005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,head[MAX],cnt=0;
struct edge{
	int next,to;
}a[MAX<<1];
void add(int x,int y)
{
	a[++cnt].next=head[x];
	a[cnt].to=y;
	head[x]=cnt;
}
int calc(int x,int f,int v)
{
	if(x>v) return 0;
	int re=1;
	for(int i=head[x];i;i=a[i].next)
	{
		int t=a[i].to;
		if(t==f) continue;
		re+=calc(t,x,v);
	}
	return re;
}
int mx[MAX],f[MAX],g[MAX],h[MAX],ans[MAX];
void dfs(int x,int fa)
{
	if(x>mx[fa])
	{
		mx[x]=x;
		h[x]=1;
		for(int i=head[x];i;i=a[i].next)
		{
			int t=a[i].to;
			if(t==fa) continue;
			f[t]=calc(t,x,x);
			g[t]=calc(t,x,mx[fa]);
			h[x]+=g[t];
		}
		ans[x]+=h[x];
	}
	else mx[x]=mx[fa];
	for(int i=head[x];i;i=a[i].next)
	{
		int t=a[i].to;
		if(t==fa) continue;
		ans[t]=ans[x];
		if(x>mx[fa]) ans[t]+=f[t]-g[t];
		dfs(t,x);
	}
}
int main()
{
	n=read();
	int x,y;
	for(int i=1;i<n;i++)
		x=read(),y=read(),add(x,y),add(y,x);
	dfs(1,0);
	for(int i=2;i<=n;i++)
		printf("%d ",ans[i]-1);
	return 0;
}


Measured memory_bytes: 27796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	vector<int> dp_a(n + 1), dp_b(n + 1), dp_c(n + 1);
	cin >> dp_a[0] >> dp_b[0] >> dp_c[0];
	rep2(i, 1, n) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		dp_a[i] = max(dp_b[i-1], dp_c[i-1]) + a;
		dp_b[i] = max(dp_a[i-1], dp_c[i-1]) + b;
		dp_c[i] = max(dp_a[i - 1], dp_b[i - 1]) + c;
	}
	cout << max(max(dp_a[n - 1], dp_b[n - 1]), dp_c[n - 1]);
}



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

int main() {
 int a , b , c;
  cin >> a >> b >> c ;
  if(a == b && a != c) cout<< "Yes" <<endl;
  else if(a == c && a != b) cout << "Yes" << endl;
  else if(b == c && a != b) cout << "Yes" <<endl;
  else {cout << "No" << endl;}
  
}

Measured memory_bytes: 256
K = int(input())

a = list(range(1, 10))
i = 0
while len(a) < K:
  A = []
  for j in range(3):
    n = str(a[i])
    if j == 0 and int(n[-1]) - 1 >= 0:
      A.append(int(n + str(int(n[-1]) - 1)))
    elif j == 1:
      A.append(int(n + n[-1]))
    elif j == 2 and int(n[-1]) + 1 < 10:
      A.append(int(n + str(int(n[-1]) + 1)))
  a += A
  i += 1
print(a[K-1])

Measured memory_bytes: 7044
n, k = map(int, input().split())
num_dict = {}
for i in range(n):
    a, b = map(int, input().split())
    if a in num_dict:
        num_dict[a] += b
    else:
        num_dict[a] = b

count = 0
for key, value in sorted(num_dict.items()):
    count += value
    if count >= k:
        print(key)
        break


Measured memory_bytes: 14564