akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a == b)&&(b == c)){
			System.out.println("No");
		}else if((a != b) && (b != c) && (a != c)){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	string s,t;
	cin >> n >> s >> t ;
	for0(i,n){
		cout << s[i] << t[i] ; 
	} 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<ll> a;
  ll x;
  for(int i=0;i<n;i++){
    cin>>x;
    a.push_back(x);
  }
  vector<ll> b;
  if(n%2==0){
    for(int i=n-1;i>=0;i--){
      b.push_back(a[i]);
      i--;
    }
    for(int i=0;i<n;i++){
      b.push_back(a[i]);
      i++;
    }
  }else{
    for(int i=n-1;i>=0;i--){
      b.push_back(a[i]);
      i--;
    }
    for(int i=1;i<n;i++){
      b.push_back(a[i]);
      i++;
    }
  }
  for(int i=0;i<n-1;i++){
    cout<<b[i]<<" ";
  }
  cout<<b[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 5488
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
L=[[] for i in range(M)]
for i in range(N):
  L[X[i]%M].append(X[i])
for i in range(1,(M+1)//2):
  if len(L[i])<len(L[M-i]):
    L[i],L[M-i]=L[M-i],L[i]
P=0
X=0
B=0
for i in range(1,(M+1)//2):
  X=len(L[i])
  B=True
  for j in range(X-1):
    if B:
      if L[i][j]==L[i][j+1] and X-2>=len(L[M-i]):
        X-=2
        P+=1
        B=False
    else:
      B=True
  P+=min(X,len(L[M-i]))
P+=len(L[0])//2
if M&1==0:
  P+=len(L[M//2])//2
print(P)

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

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

#define fr first
#define sc second

int n,m;
int a[200010],b[200010];
vector<P> G[1002];

int ok[1002][1002];
void solve(int s){
	queue<P> que;
	int id[1002] = {};
	bool used[1002];
	for(int i = 0 ; i < 1002 ; i ++){
		used[i] = false;
	}
	id[s] = n+1;
	used[s] = true;
	for(int i = 0 ; i < G[s].size() ; i ++){
		int v = G[s][i].fr;
		id[v] = v;
		que.push(P(v,id[v]));
	}
	while(!que.empty()){
		P p = que.front(); que.pop();
		if(used[p.fr])continue;
		for(int i = 0 ; i < G[p.fr].size() ; i ++){
			P ed = G[p.fr][i];
			if(id[ed.fr] != n+1 && id[ed.fr] != p.sc){
				if(id[ed.fr] == 0){
					id[ed.fr] = p.sc;
					used[ed.fr] = false;
					que.push(P(ed.fr,id[ed.fr]));
				}
				else {
					id[ed.fr] = n+1;
					used[ed.fr] = false;
					que.push(P(ed.fr,id[ed.fr]));
				}
			}
		}
	}
	for(int i = 1 ; i <= n ; i ++){
		if(id[i] == 0)ok[s][i] = 0;
		else if(id[i] <= n)ok[s][i] = 1;
		else ok[s][i] = 2;
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i = 0 ; i < m ; i ++){
		scanf("%d%d",&a[i],&b[i]);
		G[a[i]].push_back(P(b[i],i));
	}
	for(int i = 1 ; i <= n ; i ++){
		solve(i);
	}
	for(int i = 0 ; i < m ; i ++){
		int cnt = 0;
		if(ok[a[i]][b[i]] == 2)cnt ++;
		if(ok[b[i]][a[i]] >= 1)cnt ++;
		if(cnt == 1)puts("diff");
		else puts("same");
	}
}



Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int dp[100001][2];
vector<int> v;
int find(int k, int turn, int n) {
  if(k < 0) {
    return 1;
  }
  if(k == 0) {
  	return dp[k][turn] = 0; 
  }
  if(dp[k][turn] != -1) {
    return dp[k][turn];
  }
  dp[k][turn] = 0;
  for(int u: v) {
  	if(find(k - u, turn ^ 1, n) == 0) {
    	dp[k][turn] = 1;
      	break;
    }
  }
  return dp[k][turn];
}
int main(void) {
  int n, k;
  cin>>n>>k;
  v.resize(n);
  for(int i = 0; i <= k; i++) {
  	dp[i][0] = dp[i][1] = -1;
  }
  for(int& i: v) {
    cin>>i;
  }
  int result = find(k, 0, n);
  if(result) {
  	cout<<"First\n";
  } else {
  	cout<<"Second\n";
  }
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int num[2][2019];
string s;
ll ans;
int main(){
	cin>>s;
	int now=0;
	for (int i=0;i<s.size();i++){
		s[i]-='0';
		now^=1;
		memset (num[now],0,sizeof(num[now]));
		for (int j=0;j<2019;j++) num[now][(j*10+s[i])%2019]+=num[now^1][j];
		num[now][s[i]]++;
		ans+=num[now][0];
	}
	cout<<ans;
}

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

using namespace std;

#define ll long long
#define ar array

int n,m,k,tmp;
int a[200000];
int b[200000];



void solve(){
    
    cin >> n >> m >> k;

    int last = 0;
    int maxn = n-1;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        a[i] = last+tmp;
        last = a[i];
        if(last > k && maxn == n-1) maxn = i-1;
    }
    int maxm = m-1;
    last = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> tmp;
        b[i] = last+tmp;
        last = b[i];
        if(last > k && maxm == m-1) maxm = i-1;
    }

    int ans = max(maxn+1,max(maxm+1,0));
    int sum = 0;
    int curm = 0;
    for (int i = maxn; i >=0; i--)
    {
        sum = a[i] + b[curm];
        while(sum < k && curm < (m-1)){
            curm++;
            sum = a[i] + b[curm];
        }

        if(curm == m-1 && sum <= k){
            ans = max(curm+i+2,ans);
        }
        else{
            ans = max(curm-1+i+2,ans);
        }
    }
    
    cout << ans << endl;

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Measured memory_bytes: 5076
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n) <- in if n != 0) {
        var x, y = 0
        for (Array(a, b) <- in.take(n)) {
            if(a > b) x += a+b
            else if(a < b) y += a+b
            else {x += a; y+= b}
        }
        println(x + " " + y)
    }
}

Measured memory_bytes: 70552
N = int(input())
A = input().split()

ans = 0
kisu = 0
gusu = 0
for i in range(N):
    if int(A[i]) % 2 == 0:
        ans += 3**(N-i-1) * 2**(gusu)
        gusu += 1
    else:
        ans += 3**(N-i-1) * 2 * 2**(gusu)

print(ans)

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    int h, w;
    in >> h >> w;
    vector<string> strs(h);
    for (auto&& i : strs) {
      in >> i;
    }
    int dx[] = { 0, 0, 1, 1, 1, -1, -1, -1 };
    int dy[] = { 1, -1, -1, 1, 0, -1, 1, 0 };
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (strs[i][j] == '.') {
          strs[i][j] = '0';
          for (int k = 0; k < 8; k++) {
            if (i + dx[k] < 0 || i + dx[k] == h) {
              continue;
            }
            if (j + dy[k] < 0 || j + dy[k] == w) {
              continue;
            }
            strs[i][j] += strs[i + dx[k]][j + dy[k]] == '#';
          }
        }
      }
    }
    for (auto&& i : strs) {
      out << i << "\n";
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 256
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if(i * i != n):
                divisors.append(n // i)
    return divisors


def smallDivisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors

x = int(input())

fact_x = smallDivisors(x)

for f in fact_x:
    fact_const = divisors(abs((f ** 4) - (x // f)))
    fact_const.append(0)
    for a in fact_const:
        b = a - f
        if (a**4 + (a**3) * b + (a**2) * (b**2) + a * (b**3) + b**4) == x // f:
            print("{} {}".format(a, b))
            break
    else:
        continue
    break

Measured memory_bytes: 9372
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
const int oo = 0x3f3f3f3f;
int a , b , c , x , y;
int main(){
	cin >> a >> b >> c >> x >> y;
	int ans = 2 * oo;
	for(int i = 0 ; i <= max(2 * x , 2 * y) ; i += 2){
		int la = max(0 , x - i / 2);
		int lb = max(0 , y - i / 2);
		ans = min(ans , la * a + lb * b + i * c);
	} 
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
# your code goes here
def my_index(l, x, default=False):
    if x in l:
        return int(l.index(x))+1
    else:
        return default

ans = []

num = int(input())

for i in range(1,50001):
    ans.append(int(i*1.08))

print(my_index(ans,num,":("))

Measured memory_bytes: 5016
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

A,B,C,D = LI()

'''
cでもdでも割り切れない
逆に割り切れる数を計算する
Bまでで割り切れる個数
Aまでで割り切れる個数
B'-A'でA-Bまでの割り切れる個数が出せる
'''
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

BC = B//C
BD = B//D
BCD = B//lcm(C,D)

#  print('BC, BD, BCD', BC, BD, BCD)
B_count = B - (BC + BD - BCD)

A = A - 1
AC = A//C
AD = A//D
ACD = A//lcm(C,D)
#  print('AC, AD, ACD', AC, AD, ACD)

A_count = A - (AC + AD - ACD)

#  print(B_count, A_count)
print(B_count - A_count)


Measured memory_bytes: 65516
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n];
	vector<int> ans(n,0);
	rep(i,n) cin >> a[i];
	rep(i,n) ans[a[i] - 1] = i + 1;
	rep(i,n) cout << ans.at(i) << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int l=1;
  int N;
 int K;
 cin>>N;
 cin>>K;
 for(int i=0;i<N;i++)
 {
   if(l<K)l*=2;else l+=K;
 }
 cout<<l<<endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };

int H, W;
vector<string> S;

vv<bool> visited;
vv<ll> cnt;
ll ans;

pair<ll, ll> dfs(int y, int x) {
    visited[y][x] = true;
    pair<ll, ll> bw = { 0, 0 };

    if (S[y][x] == '#') {
        for (int d = 0; d < 4; ++d) {
            int ny = y + dy[d], nx = x + dx[d];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;

            if (!visited[ny][nx] && S[ny][nx] == '.') {
                auto ret = dfs(ny, nx);
                
                ans += bw.first * ret.second + bw.second * ret.first;

                bw.first += ret.first;
                bw.second += ret.second;
            }
        }

        ans += bw.second;

        bw.first++;
        return bw;
    }
    else {
        for (int d = 0; d < 4; ++d) {
            int ny = y + dy[d], nx = x + dx[d];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;

            if (!visited[ny][nx] && S[ny][nx] == '#') {
                auto ret = dfs(ny, nx);

                ans += bw.first * ret.second + bw.second * ret.first;

                bw.first += ret.first;
                bw.second += ret.second;
            }
        }

        ans += bw.first;

        bw.second++;
        return bw;
    }
}

int main() {
    cin >> H >> W;
    S.resize(H);
    rep(i, H) cin >> S[i];

    visited = vvec(H, W, false);
    cnt = vvec(H, W, 0LL);

    rep(i, H) rep(j, W) {
        if (!visited[i][j]) dfs(i, j);
    }

    write(ans);
}

Measured memory_bytes: 19200
#include <iostream>
using namespace std;
int main() {
	int k, a, b;
	bool isOK = false;
	cin >> k;
	cin >> a >> b;

	if (k == 1) {
		cout << "OK" << endl;
	}
	else {
		for (int i = a; i <= b; i++)
		{
			if (i % k == 0) {
				isOK = true;
				break;
			}
		}

		if (isOK) {
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    if(s=="SUN")cout<<7;
    else if(s=="MON")cout<<6;
    else if(s=="TUE")cout<<5;
    else if(s=="WED")cout<<4;
    else if(s=="THU")cout<<3;
    else if(s=="FRI")cout<<2;
    else cout<<1;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> b[i];
  vector<vector<int>> g(n);
  while (m--) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<pair<int, int>> vertex(n);
  for (int i = 0; i < n; ++i)
    vertex[i] = make_pair(a[i] - b[i], i);
  sort(vertex.begin(), vertex.end());
  vector<int> f(n, -1), dp(n);
  vector<ll> s(n);
  function<int(int)> find = [&](int x) { return f[x] == x ? x : f[x] = find(f[x]); };
  for (int i = 0; i < n; ++i) {
    int u = vertex[i].second;
    dp[u] = max(a[u] - b[u], 0);
    f[u] = u;
    s[u] = b[u];
    for (int v : g[u]) {
      if (f[v] == -1) continue;
      int x = find(v);
      if (x == u) continue;
      f[x] = u;
      s[u] += s[x];
      dp[u] = min((ll)dp[u], max((ll)dp[x], a[u] - b[u] - s[x]));
    }
    if (i == n - 1) {
      cerr << s[u] << '\n';
      cout << (dp[u] + s[u]);
    }
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    int a, b;
    cin >> a >> b;

    if (b >= a) cout << a << endl;
    else cout << a - 1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define MAX 100

using namespace std;
 
struct Card { char suit, value; };
 
void bubbleSort(struct Card C[], int N) {
  REP(i, N) {
    for (int j = N - 1; j >= i + 1; j--) {
      if (C[j].value < C[j - 1].value) {
        Card temp = C[j];
        C[j] = C[j - 1];
        C[j - 1] = temp;
      }
    }
  }
}
 
void selectionSort(struct Card C[], int N) {
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (C[j].value < C[minj].value) {
        minj = j;
      }
    }
    Card temp = C[i];
    C[i] = C[minj];
    C[minj] = temp;
  }
}
 
void print(struct Card C[], int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << C[i].suit << C[i].value;
  }
  cout << endl;
}
 
bool isStable (struct Card C1[], struct Card C2[], int N) {
  for (int i = 0; i < N; i++) {
    if (C1[i].suit != C2[i].suit) {
      return false;
    }
  }
  return true;
}
   
   
int main() {
  Card C1[MAX], C2[MAX];
  int N;
   
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> C1[i].suit >> C1[i].value;
    C2[i] = C1[i];
  }
 
  bubbleSort(C1, N);
  selectionSort(C2, N);
 
  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if (isStable(C1, C2, N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define MP make_pair

typedef double db;

const db EPS = 1e-8;

inline int sign(db a) {
	return a < -EPS ? -1 : a > EPS;
}

struct P {
	db x, y;
	P() {
	}
	P(db _x, db _y) :
			x(_x), y(_y) {
	}
	P operator+(P p) {
		return P(x + p.x, y + p.y);
	}
	P operator-(P p)  {
		return P(x - p.x, y - p.y);
	}
	P operator*(db d) {
		return P(x * d, y * d);
	}
	P operator/(db d) {
		return P(x / d, y / d);
	}
	bool operator<(P p) const {
		int c = sign(x - p.x);
		if (c)
			return c == -1;
		return sign(y - p.y) == -1;
	}
	db dot(P p) {
		return x * p.x + y * p.y;
	}
	db det(P p) {
		return x * p.y - y * p.x;
	}
	db distTo(P p) { return (*this-p).abs(); }

	db alpha() {
		return atan2(y, x);
	}
	void read() {
		cin>>x>>y;
	}
	db abs() {
		return sqrt(abs());
	}
	db abs2() {
		return x * x + y * y;
	}
	P rot90(){
		return P(-y,x);
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

P isSS(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool isMiddle(db a, db m, db b) {
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
 
bool isMiddle(P a, P m, P b) {
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

P proj(P p1, P p2, P me) {
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(me - p1) / dir.abs2());
}

db nearest(P p1,P p2,P me){
	P h = proj(p1,p2,me);
	if(isMiddle(p1,h,p2))
		return me.distTo(h);
	return min(p1.distTo(me),p2.distTo(me));
}

db getrad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}

db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}

int main(){
	P p1, p2;
	p1.read(),p2.read();
	int n;cin>>n;
	rep(i,0,n){
		P q; q.read();
		P ret = proj(p1,p2,q);
		printf("%0.10f %0.10f\n",ret.x,ret.y);
	}

	return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, ma=0, con;
	vector<string> v, ans;
	vector<int> d;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	sort(v.begin(), v.end());
	v.emplace_back("1");

	con = 1;
	for (int i = 0;i < n;i++) {
		if (v[i] == v[i + 1]) {
			con++;
		}
		else {
			ans.emplace_back(v[i]);
			d.emplace_back(con);
			con = 1;
		}
		ma = max(ma, con);
	}

	for (int i = 0;i < ans.size();i++) {
		if (d[i] == ma) cout << ans[i] << endl;
	}

}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	if (N >= 100) 	cout << "ABC" << N << "\n";
	else if (N >= 10)cout << "ABC0" << N << "\n";
	else cout << "ABC00" << N << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(V) V.begin(), V.end()
#define PB push_back
using namespace std;
typedef long long ll;

int main() {
    int n,m;
    cin >> n >>m;
    vector<int>wa(n);
    vector<bool>flag(n);
    int pena = 0;
    int cnt = 0;

    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA" && flag[p] == false) {
            wa[p]++;
        }
        if(s == "AC" && flag[p] == false){
            cnt++;
            pena += wa[p];
            flag[p] = true;
        } 
    }
    cout << cnt << " "<< pena <<endl;
}

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

int main() {
  int n, S[100001], cnt = 0;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> S[i];

  int q, v;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> v;
    if (*lower_bound(S, S+n, v) == v) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1548
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<string> s(n + 1);
	vector<vector<int>> same(n + 1, vector<int>(30, 0));

	for (int i = 1; i <= n; i++) {
		cin >> s[i];

		for (char j = 'a'; j <= 'z'; j++) {
			for (int k = 0; k < s[i].size(); k++) {
				if (s[i][k] == j) same[i][j-'a'+1] += 1;
			}
		}
	}

	string ans;
	for (char i = 'a'; i <= 'z'; i++) {
		int MIN = INF;

		for (int j = 1; j <= n; j++) {
			MIN = min(MIN, same[j][i-'a'+1]);
		}

		for (int j = 1; j <= MIN; j++) {
			ans.push_back(i);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

vector<int> gr[100500];
int dp[1050][1050];

string s[1050];

const int mod = 1000000007;

int add(int a, int b) {
    int result = a + b;
    if (result >= mod)
        result -= mod;
    return result;
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int h, w;
    cin >> h >> w;
    forn(i, h)
        cin >> s[i];

    dp[0][0] = 1;

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if ((i || j) && s[i][j] == '.') {
                if (i)
                    dp[i][j] = dp[i - 1][j];

                if (j)
                    dp[i][j] = add(dp[i][j], dp[i][j - 1]);
            }

    cout << dp[h - 1][w - 1];

    return 0;
}

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

int main() {
    long long x, y;
    cin >> x >> y;

    long long a = x;
    long long cnt = 1;
    while (1) {
        a *= 2;
        if (a > y) break;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	cout << (n - k + 1) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz 100005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
int a[100][100];

int main()
{
    faster_io
    int n,t,cnt=0;
    cin>>t>>n;

    for(int i=0;i<t;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<t;i++){
        for(int k=i+1;k<t;k++){
            int x = 0,xx;
            for(int j=0;j<n;j++){
                xx =(a[i][j] - a[k][j]);
                x+=(xx*xx);
            }
            int sq = sqrt(x+.0);
            if(sq*sq == x) cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}





Measured memory_bytes: 256
#include <valarray>
#include <vector>
#include <cstdio>
using namespace std;
typedef valarray<__int128_t>V;
int n,m=1000000007;
V z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V &Mx(const V &_x){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
int main(){
	int N,K,C,T;
	scanf("%d%d%d%d",&N,&K,&C,&T);C--;
	vector<int>a(K),b(K),t(K);
	for(int i=0;i<K;i++)scanf("%d%d%d",&a[i],&b[i],&t[i]),a[i]--;
	n=N*5;
	V x(n*n);
	V e(n*n);
	z.resize(n*n);
	for(int i=0;i<n;i++)e[i*n+i]=1;
	for(int i=0;i<K;i++)for(int j=0;j<N;j++){
		int nj=j<a[i]?j+b[i]:j<a[i]+b[i]?j-a[i]:j;
		x[j*5*n+nj*5+t[i]-1]++;
	}
	for(int i=0;i<N;i++)for(int j=1;j<5;j++)x[(i*5+j)*n+i*5+j-1]++;
	for(;T;T>>=1){
		if(T&1)e=Me(e,x);
		x=Mx(x);
	}
	printf("%lld\n",(long long)e[C*5*n]);
}

Measured memory_bytes: 4236
H,W = [int(x) for x in input().split()]
li = []
op = []
def get_wh(index):
    h = index//W
    if(h%2==0):
        w = index%W +1
    else:
        w = W - index%W
    return h+1,w

for i in range(H):
    if(i%2 == 0):
        li+=[int(x)%2 for x in input().split()]
    else:
        li+=[int(x)%2 for x in input().split()][::-1]

for index in range(len(li[:-1])):
    if(li[index]==1):
        li[index]=0
        li[index+1]=1-li[index+1]
        op.append(get_wh(index)+get_wh(index+1))

print(len(op))
for i in op:
    print(i[0],i[1],i[2],i[3])


Measured memory_bytes: 26236
W = []
K = []
SW=0
SK = 0
for i in range(10):
    w = int(input())
    W.append(w)
    W.sort(reverse=True)
for i in range(10):
    k = int(input())
    K.append(k)
    K.sort(reverse=True)
for i in range(3):
    SW = SW + W[i]
for i in range(3):
    SK = SK + K[i] 
print(SW,SK)  


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 1000 + 5;
const ll INF = 1e17 + 7 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);


int n , m;

char a[N][N];

ll add(ll a , ll b){
    a += b;
    if(a >= mod)a -= mod;
    return a;
}

void solve(int testCase){

    scanf("%d %d" , &n , &m);

    for(int i = 0 ; i < n ; i ++){
            scanf("%s" , a[i]);
    }

    vector < vl > dp(n+1 , vl(m+1 , 0));
    dp[1][1] = 1;

    for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= m ; j ++){
                    if(a[i-1][j-1] == '#')continue;

                    dp[i][j] = add(dp[i][j] , add(dp[i-1][j] , dp[i][j-1]));
            }
    }

    printf("%lld\n" , dp[n][m]);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

using namespace std;

int d[100004];

int main() {
    int n, k; scanf("%d%d",&n,&k);
    for (int i=0; i<k; i++) {
        scanf("%d",&d[i]);
        n-=d[i]; if (n<=0) {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
}

Measured memory_bytes: 640
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// template<class... Args>
// auto create(size_t n, Args&&... args) {
// 	if constexpr(sizeof...(args) == 1)
// 		return vector(n, args...);
// 	else
// 		return vector(n, create(args...));
// }

// template<typename... T>
// void read(T&... args) {
// 	((cin >> args), ...);
// }

// template<typename... T>
// void write(T&&... args) {
// 	((cout << args), ...);
// }

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr.begin(), arr.end());
	int ans = 0;
	for(int i = 0; i < k; i++)
		ans += arr[i];
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	solve();
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
    int n,m,l,r;
    cin>>n>>m;
    long tree[n+1],lr[n+1],dp[n+1];
    tree[0]=0;
    for(int i=0;i<n;i++)cin>>tree[i+1];
    for(int i=0;i<=n;i++)lr[i]=i;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        if(lr[r]>l)lr[r]=l;
    }
    for(int i=n-1;i>=0;i--)lr[i]=lr[i+1]<lr[i]?lr[i+1]:lr[i];
    dp[0]=0;
    for(int i=1;i<=n;i++)dp[i]=dp[i-1]>dp[lr[i]-1]+tree[i]?dp[i-1]:dp[lr[i]-1]+tree[i];
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 7696
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

for count in range(N):
    b = int(input())

    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = -1

ans = 'No'
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == -1:
        ans = 'Yes'
    if A[0][i] == A[1][i] == A[2][i] == -1:
        ans = 'Yes'
if A[0][0] == A[1][1] == A[2][2] == -1:
    ans = 'Yes'
if A[2][0] == A[1][1] == A[0][2] == -1:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 38384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//Random sc =new Random();
		int N=sc.nextInt();
		int K=sc.nextInt();
		int S=sc.nextInt();
		
		
		int b[]=new int[N];
		
		for(int i=0;i<N;i++) {
			
			if(i<K)b[i]=S;
			else if(S>2)b[i]=S-1;
			else b[i]=S+1;
		}
		
		for(int i:b) {
			System.out.print(i+" ");
			
			
		}
		
		
		
		
		
		
		
		
		
		
		
		
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 40728
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	vector<int> prime;
	int i,j;
	
	for(i=0;i<1000001;i++)
		prime.push_back(1);
	
	prime[0]=prime[1]=0;
	
	for(i=2;i<1000001;i++)
	{
		if(prime[i]==1)
		{
			for(j=2;j*i<1000001;j++)
				prime[j*i]=0;
		}
	}
	
	int n,x,ans;
	
	for(;;)
	{
		cin >> n >> x ;
		if(n==0 && x==0)
			break;
		
		vector<int> price;
		ans=0;
		
		for(i=0;i<n;i++)
		{
			int a;
			cin >> a;
			price.push_back(a);
		}
		
		vector<int> sans;
		
		for(i=0;i<1000001;i++)
			sans.push_back(0);
		
		for(i=0;i<price.size();i++)
			sans[price[i]]=1;
		
		for(i=0;i<=x;i++)
		{
			if(sans[i]==1)
			{
				if(prime[i]==1)
					ans=i;
				for(j=0;j<price.size();j++)
				{
					if(i+price[j]<=x)
					{
						sans[i+price[j]]=1;
					}
				}
			}
		}
		
		if(ans==0)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}
}

Measured memory_bytes: 8848
/*
author : seryu
title : contest
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

bool compare_by_second(pair<P, P> a, pair<P, P> b)
{
	if (a.second.second != b.second.second)return a.second > b.second;
	else if(a.first.first != b.first.first) return a.first.first < b.first.first;
	else return a.first.second < b.first.second;
}

void solve()
{
	ll a, b, n; cin >> a >> b >> n;
	ll ans;
	if(n < b -1)
	{
		ans = (a*n/b)-a*(n/b);
	}
	else
	{
		ans = a - (a+b-1)/b;
	}
	cout << ans << endl;
	return;
}

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


Measured memory_bytes: 3596
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    h: usize,
    ab: [(usize, usize); n],
    }
    let ma = ab.iter().map(|x| x.0).max().unwrap();
    let mut b = ab.iter().map(|x| x.1).collect::<Vec<usize>>();
    b.sort();
    b.reverse();
    let mut p:usize = 0;
    let mut ans:usize = 0;
    for &i in &b {
        if ma < i {
            p += i;
            ans += 1;
        }
        if p >= h {
            println!("{}", ans);
            return;
        }
    }
    let h = h - p;
    ans += h / ma + if h % ma == 0 { 0 } else { 1 };
    println!("{}", ans);
}


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

const int  MAXINT = 32767;
const int MAXNUM = 10;

int A[MAXNUM][MAXNUM];
int num[10];

int main()
{
    int h,w,t,total=0;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<10;i++)
    for(int j=0;j<10;j++){
        cin>>t;
        A[i][j]=t;
    }
    for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
        if(A[i][j]>A[i][k]+A[k][j] )
            A[i][j]=A[i][k]+A[k][j];
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
        cin>>t;
        num[t]++;
    }
    for(int i=0;i<10;i++)
        total+=A[i][1]*num[i];

    cout<<total;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <climits>
#include <cstring>
#include <string>
#include <ctype.h>
#include <sstream>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define FOR(i,a,b) for (int i=a;i<b;i++)
#define fi first
#define se second

int main(){
    string S;
    cin>>S;
    LL K;
    cin>>K;
    LL now = 0;
    int x = S.length();
    FOR(i,0,x){
        if (S[i] == '1'){
            if (K == i+1){
                cout<<'1'<<endl;
                return 0;
            }
        } else {
            cout<<S[i]<<endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << endl; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n; read(n);
    vi a(n); rep(i, n) read(a[i]);
    ll cash = 1000;
    repa(i, 1, n) if(a[i] > a[i-1]) {
        ll v = cash / a[i-1];
        ll r = cash % a[i-1];
        cash = v * a[i] + r;
    }
    println(cash);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
 int n;
 cin >> n;
 vector<ll> a(n); 
 for(int i = 0; i < n; i++) cin >> a[i];
 mint sum = 0;
 mint sq = 0;
 for(int i = 0; i < n; i++){
   sum += a[i];
 }
  for(int i = 0; i < n; i++){
   sq += a[i]*a[i];
 }
  
  mint ans;
  ans = (sum*sum - sq)/2;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD ((long) 1e9 + 7)
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (i, 0, v.size()) cout << v[i] << " "; cout << "\n";

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

  long n;
  cin >> n;

  vector<long> a(n);
  double soma = 0;
  for (auto &x : a) {
    cin >> x;
    soma += x;
  }
  long y = round(soma / n);
  long total = 0;
  for (auto &x : a) {
    total += abs(x - y) * abs(x - y);
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7

S = input()[:-1]
N = len(S)

dp = [[0]*4 for _ in range(N+1)]

for i in reversed(range(N+1)):
    for j in reversed(range(4)):
        if i == N:
            dp[i][j] = 1 if j == 3 else 0
        else:
            if j == 3:
                m1 = 3 if S[i] == "?" else 1
                dp[i][j] = m1*dp[i+1][j]
            else:
                m2 = 1 if S[i] == "?" or S[i] == "ABC"[j] else 0
                m1 = 3 if S[i] == "?" else 1
                dp[i][j] = m1*dp[i+1][j]+m2*dp[i+1][j+1]
        dp[i][j] %= MOD
print(dp[0][0])


Measured memory_bytes: 27596